From 06a483338d05d54db304e149d7d2c4a66c95ab13 Mon Sep 17 00:00:00 2001 From: Karl Cordes Date: Tue, 28 Jun 2011 17:32:26 +1000 Subject: [PATCH] Implemented ex-works Delivery point for principles. Closes #12 --- controllers/quotes_controller.php | 2 ++ models/principle.php | 22 ++++++++++++++++++++++ views/quotes/edit.ctp | 12 +++++++++--- 3 files changed, 33 insertions(+), 3 deletions(-) diff --git a/controllers/quotes_controller.php b/controllers/quotes_controller.php index cf4067b2..43ce9e5b 100755 --- a/controllers/quotes_controller.php +++ b/controllers/quotes_controller.php @@ -121,6 +121,8 @@ class QuotesController extends AppController { $currencies = $this->Quote->Currency->find('list'); $this->set('yesNo', array(0=>'No', 1=>'Yes')); $this->set(compact('enquiry', 'quote', 'currencies')); + + $this->set('cityCountryList', $this->Quote->Enquiry->Principle->getCityCountryList()); } diff --git a/models/principle.php b/models/principle.php index 6d940955..c748bc45 100755 --- a/models/principle.php +++ b/models/principle.php @@ -56,6 +56,28 @@ class Principle extends AppModel { 'foreignKey' => 'principle_id' ), ); + + + function getCityCountryList() { + $principles = $this->find('all', array('recursive'=>1)); + + + $search = array('{company}','{city}','{country}'); + $phrase = "Ex Works Incoterms 2010 ({company}, {city}, {country})"; + + $list = array(); + + foreach($principles as $principle) { + $replace = array($principle['Principle']['name'], $principle['Principle']['city'], $principle['Country']['name']); + + $newPhrase = str_replace($search, $replace, $phrase); + + $list[$newPhrase] = $newPhrase; + } + return $list; + + + } } ?> diff --git a/views/quotes/edit.ctp b/views/quotes/edit.ctp index 38f5ea40..934ff3d9 100755 --- a/views/quotes/edit.ctp +++ b/views/quotes/edit.ctp @@ -25,6 +25,12 @@ 'Ex Works Incoterms 2010 (CMC Technologies, Alexandria, NSW Australia)'); + +$deliveryOptions = array_merge($exworksCMC, $cityCountryList); + + echo $form->create('Quote',array('default'=>false)); echo $form->input('id'); @@ -46,12 +52,12 @@ echo $form->input('date_issued_display', array('id'=>'date_issued_display', 'lab echo $form->input('date_issued', array('type'=>'hidden', 'id'=>'date_issued')); echo $form->input('valid_until_display', array('id'=>'valid_until_display', 'label'=>'Valid Until', 'value'=>$this->element('isEmptyDate', array('date'=>$this->data['Quote']['valid_until'])))); echo $form->input('valid_until', array('type'=>'hidden', 'id'=>'valid_until')); -echo $form->input('delivery_point', array('type'=>'select', 'options'=>array( - 'Ex Works Incoterms 2010 (CMC Technologies, Alexandria, NSW Australia)' => 'Ex Works Incoterms 2010 (CMC Technologies, Alexandria, NSW Australia)' -))); +echo $form->input('delivery_point', array('type'=>'select', 'options'=>$deliveryOptions)); echo $form->input('exchange_rate', array('default'=>'NOT APPLICABLE, FIXED PRICE QUOTED')); echo $form->input('customs_duty'); echo $form->input('document_id',array('type'=>'hidden')); echo $form->input('commercial_comments', array('between'=>'')); echo $form->end(); + + ?> \ No newline at end of file