diff --git a/application/modules/invoices/controllers/Invoices.php b/application/modules/invoices/controllers/Invoices.php index 0861d83..8e9a1f6 100644 --- a/application/modules/invoices/controllers/Invoices.php +++ b/application/modules/invoices/controllers/Invoices.php @@ -169,6 +169,8 @@ class Invoices extends Admin_Controller echo $ClientID; */ $PaymentDays = $this->mdl_invoices->GetPaymentDays($invoice_id,$ClientID,'51'); $GetSecondaryAddress = $this->mdl_invoices->GetSecondaryAddress($ClientID); + + $getSecondayAddressSelected = $this->mdl_invoices->getSecondayAddressSelected($invoice_id,'44'); // print_r($GetSecondaryAddress); $custom_fields = $this->mdl_custom_fields->by_table('ip_invoice_custom')->get()->result(); @@ -184,10 +186,22 @@ class Invoices extends Admin_Controller foreach ($fields as $fvalue) { if ($fvalue->invoice_custom_fieldid == $cfield->custom_field_id) { // TODO: Hackish, may need a better optimization + //echo $fvalue->invoice_custom_fieldid ; + if ($fvalue->invoice_custom_fieldid == "7" && $fvalue->invoice_custom_fieldvalue == '') + { + echo 'Mode'. $fvalue->invoice_custom_fieldvalue; + $this->mdl_invoices->set_form_value( + 'custom[' . $cfield->custom_field_id . ']', + 'By Road' + ); + } + else + { $this->mdl_invoices->set_form_value( 'custom[' . $cfield->custom_field_id . ']', $fvalue->invoice_custom_fieldvalue ); + } break; } } @@ -198,6 +212,7 @@ class Invoices extends Admin_Controller 'invoice' => $invoice, 'Duedate' =>$PaymentDays, 'GetSecondary' =>$GetSecondaryAddress, + 'getSecondaySelected' => $getSecondayAddressSelected, 'items' => $this->mdl_items->where('invoice_id', $invoice_id)->get()->result(), 'invoice_id' => $invoice_id, 'tax_rates' => $this->mdl_tax_rates->get()->result(), @@ -368,4 +383,4 @@ class Invoices extends Admin_Controller } } -} +} \ No newline at end of file diff --git a/application/modules/invoices/models/Mdl_invoices.php b/application/modules/invoices/models/Mdl_invoices.php index 8a184b0..37ad069 100644 --- a/application/modules/invoices/models/Mdl_invoices.php +++ b/application/modules/invoices/models/Mdl_invoices.php @@ -62,13 +62,23 @@ class Mdl_Invoices extends Response_Model { $subQuery = "select group_concat(client_custom_fieldvalue separator '
') as Secondary from ip_client_custom where - client_id =? and client_custom_fieldid in (12,45,46,47)"; + client_id =? and client_custom_fieldid in (12,45,46,47,48,50,49)"; $query = $this->db->query($subQuery,array($ClientID)); return $query->result(); } + + public function getSecondayAddressSelected($InvID,$client_custom_fieldid) + { + $subQuery = "select invoice_custom_fieldvalue as secondary from ip_invoice_custom where invoice_id=? and + invoice_custom_fieldid=?"; + + $query = $this->db->query($subQuery,array($InvID,$client_custom_fieldid)); + + return $query->result(); + } public function default_select() { @@ -561,4 +571,4 @@ class Mdl_Invoices extends Response_Model } } -} +} \ No newline at end of file