2011-04-20 00:44:13 -07:00
|
|
|
<?php
|
|
|
|
|
class ShipmentsController extends AppController {
|
|
|
|
|
|
2011-04-21 00:38:01 -07:00
|
|
|
var $name = 'Shipments';
|
|
|
|
|
var $helpers = array('Html', 'Form');
|
2011-04-20 00:44:13 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
var $paginate = array(
|
|
|
|
|
|
|
|
|
|
'contain' => false,
|
2011-05-03 18:49:07 -07:00
|
|
|
'limit' => 300,
|
2011-04-20 00:44:13 -07:00
|
|
|
'recursive' => 1
|
|
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
2011-05-03 18:49:07 -07:00
|
|
|
function index($type = 'all') {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-04-21 00:38:01 -07:00
|
|
|
$this->Shipment->recursive = 0;
|
2011-05-03 18:49:07 -07:00
|
|
|
|
|
|
|
|
switch($type) {
|
|
|
|
|
|
|
|
|
|
case 'all':
|
|
|
|
|
$conditions = array();
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 'import':
|
|
|
|
|
|
|
|
|
|
$conditions = array('Shipment.type'=>1);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
case 'direct':
|
|
|
|
|
$conditions = array('Shipment.type'=>2);
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
case 'export':
|
|
|
|
|
$conditions = array('Shipment.type'=>3);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 'local':
|
|
|
|
|
$conditions = array('Shipment.type'=>4);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
|
2011-05-08 19:31:24 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2011-05-03 18:49:07 -07:00
|
|
|
$this->set('shipments', $this->paginate($conditions));
|
|
|
|
|
$this->set('type', $type);
|
|
|
|
|
|
2011-04-28 00:41:36 -07:00
|
|
|
|
|
|
|
|
$principles = $this->Shipment->Principle->find('list');
|
|
|
|
|
$freightForwarders = $this->Shipment->FreightForwarder->find('list');
|
|
|
|
|
$shipmentType = $this->typeOptions(false);
|
|
|
|
|
$shipmentTypeShort = $this->typeOptions(true);
|
2011-05-08 21:12:00 -07:00
|
|
|
$currencies = $this->Shipment->ShipmentInvoice->Currency->find('list', array('fields'=>array('Currency.id','Currency.iso4217')));
|
|
|
|
|
$principles = $this->Shipment->Principle->find('list');
|
|
|
|
|
$this->set(compact('principles', 'freightForwarders', 'shipmentType', 'shipmentTypeShort', 'currencies', 'principles'));
|
2011-04-28 00:41:36 -07:00
|
|
|
|
2011-04-21 00:38:01 -07:00
|
|
|
}
|
2011-04-20 00:44:13 -07:00
|
|
|
|
2011-04-21 00:38:01 -07:00
|
|
|
function view($id = null) {
|
|
|
|
|
if (!$id) {
|
|
|
|
|
$this->Session->setFlash(__('Invalid Shipment.', true));
|
|
|
|
|
$this->redirect(array('action'=>'index'));
|
2011-04-20 00:44:13 -07:00
|
|
|
}
|
2011-04-21 00:38:01 -07:00
|
|
|
$this->set('shipment', $this->Shipment->read(null, $id));
|
|
|
|
|
}
|
2011-04-20 00:44:13 -07:00
|
|
|
|
2011-05-01 20:11:32 -07:00
|
|
|
|
|
|
|
|
function add() {
|
|
|
|
|
$principles = $this->Shipment->Principle->find('list');
|
|
|
|
|
$freightForwarders = $this->Shipment->FreightForwarder->find('list');
|
|
|
|
|
$shipmentType = $this->typeOptions(false);
|
|
|
|
|
$shipmentTypeShort = $this->typeOptions(true);
|
2011-05-08 18:11:23 -07:00
|
|
|
$currencies = $this->Shipment->ShipmentInvoice->Currency->find('list');
|
|
|
|
|
$invoiceType = $this->invoiceTypeOptions();
|
|
|
|
|
$this->set('yesNo', array(0=>'No', 1=>'Yes'));
|
|
|
|
|
$this->set(compact('principles', 'freightForwarders', 'shipmentType', 'shipmentTypeShort', 'currencies','invoiceType', 'yesNo'));
|
2011-05-03 18:49:07 -07:00
|
|
|
|
2011-05-01 20:11:32 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function edit($id = null) {
|
|
|
|
|
|
|
|
|
|
if(isset($id)) {
|
|
|
|
|
if (empty($this->data)) {
|
|
|
|
|
$this->data = $this->Shipment->read(null, $id);
|
2011-05-10 00:01:17 -07:00
|
|
|
|
|
|
|
|
$address = $this->Shipment->Address->find('first', array('conditions'=>array('Address.id'=>$this->data['Shipment']['address_id']),'recursive'=>0));
|
|
|
|
|
|
2011-05-16 21:30:23 -07:00
|
|
|
|
2011-05-01 20:11:32 -07:00
|
|
|
$principles = $this->Shipment->Principle->find('list');
|
|
|
|
|
$freightForwarders = $this->Shipment->FreightForwarder->find('list');
|
|
|
|
|
$shipmentType = $this->typeOptions(false);
|
|
|
|
|
$shipmentTypeShort = $this->typeOptions(true);
|
2011-05-08 18:11:23 -07:00
|
|
|
$currencies = $this->Shipment->ShipmentInvoice->Currency->find('list');
|
2011-05-08 19:31:24 -07:00
|
|
|
|
|
|
|
|
$invoiceType = $this->invoiceTypeOptions();
|
|
|
|
|
$this->set('yesNo', array(0=>'No', 1=>'Yes'));
|
2011-05-09 21:50:42 -07:00
|
|
|
|
2011-05-10 00:01:17 -07:00
|
|
|
$this->set(compact('principles', 'freightForwarders', 'shipmentType', 'shipmentTypeShort', 'currencies','invoiceType', 'yesNo', 'address'));
|
2011-05-08 19:31:24 -07:00
|
|
|
|
2011-05-01 20:11:32 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2011-04-28 00:41:36 -07:00
|
|
|
function ajax_edit() {
|
|
|
|
|
$this->layout = 'ajax';
|
|
|
|
|
if(!empty($this->data)) {
|
2011-05-01 20:11:32 -07:00
|
|
|
//$this->Shipment->create($this->data);
|
2011-05-01 16:42:35 -07:00
|
|
|
|
2011-05-09 21:50:42 -07:00
|
|
|
$shipment_id = $this->data['Shipment']['id'];
|
|
|
|
|
|
|
|
|
|
$this->Shipment->Box->deleteAll(array('shipment_id'=>$shipment_id));
|
|
|
|
|
$this->Shipment->ShipmentInvoice->deleteAll(array('shipment_id'=>$shipment_id));
|
|
|
|
|
|
|
|
|
|
|
2011-05-01 20:11:32 -07:00
|
|
|
if ($this->Shipment->saveAll($this->data)) {
|
2011-05-24 02:11:07 -07:00
|
|
|
|
2011-05-09 21:50:42 -07:00
|
|
|
$this->Shipment->Box->updateCounterCache(array('shipment_id'=>$shipment_id));
|
|
|
|
|
$this->Shipment->ShipmentInvoice->updateCounterCache(array('shipment_id'=>$shipment_id));
|
|
|
|
|
|
|
|
|
|
/*$boxIDs = array();
|
2011-05-01 23:46:24 -07:00
|
|
|
foreach($this->data['Box'] as $box) {
|
|
|
|
|
$boxIDs[] = $box['id'];
|
2011-05-08 18:11:23 -07:00
|
|
|
|
2011-05-01 23:46:24 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$invoiceIDs = array();
|
|
|
|
|
foreach($this->data['ShipmentInvoice'] as $si) {
|
|
|
|
|
$invoiceIDs[] = $si['id'];
|
|
|
|
|
}
|
2011-05-09 21:50:42 -07:00
|
|
|
print_r($boxIDs);*/
|
2011-05-01 23:46:24 -07:00
|
|
|
|
2011-05-16 21:30:23 -07:00
|
|
|
if($this->data['Shipment']['type'] > 1) {
|
|
|
|
|
$jobIDs = array();
|
|
|
|
|
foreach($this->data['Job'] as $job) {
|
|
|
|
|
foreach($job as $index => $id) {
|
|
|
|
|
$jobIDs[] = $id;
|
|
|
|
|
}
|
2011-05-09 21:50:42 -07:00
|
|
|
}
|
|
|
|
|
|
2011-05-16 21:30:23 -07:00
|
|
|
$this->Shipment->Job->updateAll(array('Job.all_sent' => 1), array('Job.id'=>$jobIDs));
|
|
|
|
|
}
|
2011-05-10 16:44:56 -07:00
|
|
|
//print_r($this->data);
|
2011-05-01 23:46:24 -07:00
|
|
|
|
|
|
|
|
|
2011-04-28 00:41:36 -07:00
|
|
|
echo "SUCCESS";
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
echo "FAILURE";
|
|
|
|
|
}
|
2011-04-20 00:44:13 -07:00
|
|
|
|
|
|
|
|
|
2011-04-28 00:41:36 -07:00
|
|
|
}
|
|
|
|
|
else {
|
2011-05-01 16:13:13 -07:00
|
|
|
echo "NO-DATA";
|
2011-04-28 00:41:36 -07:00
|
|
|
}
|
2011-04-20 00:44:13 -07:00
|
|
|
|
2011-04-28 00:41:36 -07:00
|
|
|
}
|
2011-04-21 00:38:01 -07:00
|
|
|
|
2011-04-20 00:44:13 -07:00
|
|
|
|
2011-05-01 16:42:35 -07:00
|
|
|
function ajax_add() {
|
2011-05-19 00:05:01 -07:00
|
|
|
$this->layout = 'ajax';
|
2011-05-01 20:11:32 -07:00
|
|
|
if(!empty($this->data)) {
|
|
|
|
|
$this->Shipment->create($this->data);
|
2011-05-01 16:42:35 -07:00
|
|
|
|
2011-05-01 20:11:32 -07:00
|
|
|
if ($this->Shipment->saveAll($this->data)) {
|
|
|
|
|
echo "SUCCESS";
|
2011-05-24 02:11:07 -07:00
|
|
|
|
2011-05-01 20:11:32 -07:00
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
echo "FAILURE";
|
|
|
|
|
}
|
2011-05-01 16:42:35 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else {
|
2011-05-01 20:11:32 -07:00
|
|
|
echo "NO-DATA";
|
2011-05-01 16:42:35 -07:00
|
|
|
}
|
2011-05-01 20:11:32 -07:00
|
|
|
|
2011-05-01 16:42:35 -07:00
|
|
|
}
|
|
|
|
|
|
2011-04-20 00:44:13 -07:00
|
|
|
|
2011-09-26 20:47:36 -07:00
|
|
|
|
2011-05-24 02:11:07 -07:00
|
|
|
|
|
|
|
|
|
2011-05-09 21:50:42 -07:00
|
|
|
function markJobsSent() {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2011-04-28 00:41:36 -07:00
|
|
|
/* Moved the Views for Adding/Editing to elements. Called from the Index.
|
|
|
|
|
*
|
|
|
|
|
* function add($action = 'add') {
|
|
|
|
|
|
|
|
|
|
$principles = $this->Shipment->Principle->find('list');
|
|
|
|
|
$freightForwarders = $this->Shipment->FreightForwarder->find('list');
|
|
|
|
|
$shipmentType = $this->typeOptions();
|
|
|
|
|
$this->set(compact('principles', 'freightForwarders', 'shipmentType'));
|
|
|
|
|
}*/
|
2011-04-20 00:44:13 -07:00
|
|
|
|
|
|
|
|
|
2011-05-08 18:11:23 -07:00
|
|
|
|
|
|
|
|
function invoiceTypeOptions() {
|
|
|
|
|
$options = array('', 'Freight','Customs','Principle');
|
|
|
|
|
return $options;
|
|
|
|
|
}
|
|
|
|
|
|
2011-04-28 00:41:36 -07:00
|
|
|
function typeOptions($short = false) {
|
|
|
|
|
if($short == false) {
|
|
|
|
|
$options = array('','Import: Principle to CMC','Direct: Principle to Customer','Export','Local');
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
$options = array('','Import','Direct','Export','Local');
|
|
|
|
|
}
|
2011-04-20 00:44:13 -07:00
|
|
|
|
2011-04-21 00:38:01 -07:00
|
|
|
return $options;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2013-04-29 06:00:24 -07:00
|
|
|
function delete($id = null) {
|
|
|
|
|
$this->layout = 'ajax';
|
|
|
|
|
if ($this->Shipment->del($id)) {
|
|
|
|
|
return "Deleted"; // This should be returning status codes
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
return "Fail"; //All over the app.
|
|
|
|
|
}
|
2011-04-21 00:38:01 -07:00
|
|
|
}
|
2011-04-20 00:44:13 -07:00
|
|
|
|
2011-09-26 20:47:36 -07:00
|
|
|
|
|
|
|
|
function reports() {
|
2011-09-26 23:43:52 -07:00
|
|
|
$invoices = $this->Shipment->ShipmentInvoice->find('all');
|
2011-09-26 20:47:36 -07:00
|
|
|
|
|
|
|
|
/*foreach($shipments as $shipment) {
|
|
|
|
|
foreach($shipment['ShipmentInvoice'] as $si) {
|
|
|
|
|
if($si['deferred_gst'] == 1) {
|
|
|
|
|
echo $si['deferred_gst_amount']."\n";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$Fyears = $this->getFinancialYears($invoices);
|
|
|
|
|
$this->set('Fyears',$Fyears);
|
|
|
|
|
|
|
|
|
|
$this->set('invoices', $invoices);
|
|
|
|
|
|
2011-09-26 23:43:52 -07:00
|
|
|
}
|
2011-09-26 20:47:36 -07:00
|
|
|
|
|
|
|
|
|
2011-09-26 23:43:52 -07:00
|
|
|
function getFinancialYears($shipments) {
|
2011-09-26 20:47:36 -07:00
|
|
|
|
|
|
|
|
$Fyears = array();
|
|
|
|
|
|
|
|
|
|
foreach($shipments as $shipment) {
|
|
|
|
|
|
2011-09-26 23:43:52 -07:00
|
|
|
$time = strtotime($shipment['ShipmentInvoice']['date_issued']);
|
2011-09-26 20:47:36 -07:00
|
|
|
$year = date('Y', $time); //ISO-8601 year number
|
|
|
|
|
|
|
|
|
|
$startFYunix = $this->getFirstDayFY($year); //1 July of $year.
|
|
|
|
|
|
|
|
|
|
if($time < $startFYunix) { //Date is before 1 July $year.
|
|
|
|
|
$lastYear = $year - 1;
|
|
|
|
|
|
|
|
|
|
if(!isset($Fyears[$year])) {
|
|
|
|
|
$Fyears[$year] = 1;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
$Fyears[$year]++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else { //Date is After 1 July $year.
|
|
|
|
|
|
|
|
|
|
$nextYear = $year + 1;
|
|
|
|
|
if(!isset($Fyears[$nextYear])) {
|
|
|
|
|
$Fyears[$nextYear] = 1;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
$Fyears[$nextYear]++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
krsort($Fyears); //Sort the array in reverse order, most recent to oldest.
|
|
|
|
|
return $Fyears;
|
2011-09-26 23:43:52 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function viewReport($year, $month = null) {
|
|
|
|
|
$this->layout = 'ajax';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(isset($month) && isset($year)) { //After a Specific Month for a Year
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$startDate = $year.'-'.$month.'-01';
|
|
|
|
|
|
|
|
|
|
$startDateTime = strtotime($startDate);
|
|
|
|
|
|
|
|
|
|
$numberOfDaysInMonth = date('t', $startDateTime);
|
|
|
|
|
|
|
|
|
|
$endDate = $year.'-'.$month.'-'.$numberOfDaysInMonth;
|
|
|
|
|
|
|
|
|
|
$monthStrings = array(
|
|
|
|
|
'01'=>'January',
|
|
|
|
|
'02'=> 'February',
|
|
|
|
|
'03'=>'March',
|
|
|
|
|
'04'=> 'April',
|
|
|
|
|
'05'=> 'May',
|
|
|
|
|
'06'=> 'June',
|
|
|
|
|
'07'=> 'July',
|
|
|
|
|
'08'=> 'August',
|
|
|
|
|
'09'=> 'September',
|
|
|
|
|
'10'=> 'October',
|
|
|
|
|
'11'=> 'November',
|
|
|
|
|
'12' => 'December');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$jobRangeTitle = $monthStrings[$month]." $year";
|
|
|
|
|
$shipmentInvoices = $this->Shipment->ShipmentInvoice->find('all', array('recursive'=>1, 'conditions'=>
|
|
|
|
|
array('ShipmentInvoice.date_issued BETWEEN ? AND ?'=>array($startDate, $endDate)),
|
|
|
|
|
'order'=>'ShipmentInvoice.date_issued ASC'));
|
|
|
|
|
|
|
|
|
|
$shipments = $this->Shipment->find('all');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$jobList = array();
|
|
|
|
|
foreach($shipments as $shipment) {
|
|
|
|
|
$jobListString = '';
|
|
|
|
|
foreach($shipment['Job'] as $job) {
|
|
|
|
|
$jobListString .= '<a href="/jobs/view/'.$job['id'].'">'.$job['title'].'</a> '; //Goddamn
|
|
|
|
|
//$html->link($job['Job']['title'], '/jobs/view/'.$job['Job']['id']).' ';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
$jobList[$shipment['Shipment']['id']] = $jobListString;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$this->set('jobList', $jobList);
|
|
|
|
|
|
|
|
|
|
/* $dateStringFormat = 'j F Y';
|
|
|
|
|
$dateString['first'] = date($dateStringFormat, $firstDayUnix);
|
|
|
|
|
$dateString['last'] = date($dateStringFormat, $lastDayUnix);
|
|
|
|
|
*/
|
|
|
|
|
$this->set('jobRangeTitle', $jobRangeTitle);
|
|
|
|
|
|
|
|
|
|
$this->set('year', $year);
|
|
|
|
|
$this->set('month', $month);
|
|
|
|
|
$this->set('shipments',$shipmentInvoices); //ugh.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// $this->set('totals', $this->getTotals($jobs));
|
|
|
|
|
|
|
|
|
|
$this->set('principleList',$this->Shipment->Job->Enquiry->Principle->find('list'));
|
|
|
|
|
|
|
|
|
|
$this->set('startDate',$startDate);
|
|
|
|
|
$this->set('endDate',$endDate);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
elseif(isset($year) && !isset($month)) { //Requested a whole Financial Year Jobs
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$this->set('year', $year);
|
|
|
|
|
|
|
|
|
|
$lastDayUnix = $this->getLastDayFY($year);
|
|
|
|
|
$firstDayUnix = $this->getFirstDayFY($year,true);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$lastDayDate = date('Y-m-d', $lastDayUnix);
|
|
|
|
|
$firstDayDate = date('Y-m-d', $firstDayUnix);
|
|
|
|
|
|
|
|
|
|
$dateStringFormat = 'j F Y';
|
|
|
|
|
|
|
|
|
|
$dateString['first'] = date($dateStringFormat, $firstDayUnix);
|
|
|
|
|
$dateString['last'] = date($dateStringFormat, $lastDayUnix);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if($year == 0) { //Jobs with an empty 'date_order_received
|
|
|
|
|
$jobs = $this->Job->find('all', array('conditions'=>array('Job.date_order_received'=>'0000-00-000')));
|
|
|
|
|
$jobRangeTitle = "Jobs without Order Received date";
|
|
|
|
|
}
|
|
|
|
|
else { //We're looking for Jobs that have an 'date_order_received'
|
|
|
|
|
|
|
|
|
|
$jobs = $this->Job->find('all', array('conditions'=>
|
|
|
|
|
array('Job.date_order_received BETWEEN ? AND ?'=>array($firstDayDate, $lastDayDate))
|
|
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
$lastYear = $year - 1;
|
|
|
|
|
$jobRangeTitle = $lastYear.' - '.$year.' ('.$dateString['first']." to ".$dateString['last'].')';
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$this->set('jobRangeTitle', $jobRangeTitle);
|
|
|
|
|
|
|
|
|
|
$this->set('shipments',$shipments);
|
|
|
|
|
$this->set('principleList',$this->Job->Enquiry->Principle->find('list'));
|
|
|
|
|
$this->set('sale_category_options', $this->sale_category_options());
|
|
|
|
|
$this->set('sale_category_array', $this->sale_category_array());
|
|
|
|
|
$this->set('job_type_options', $this->job_type_options());
|
|
|
|
|
$this->set('shipment_category_options', $this->shipment_category_options());
|
|
|
|
|
$this->set('freight_paid_by_options',$this->freight_paid_options());
|
|
|
|
|
$this->set('gst_options', $this->gst_options());
|
|
|
|
|
|
|
|
|
|
$this->set('totals', $this->getTotals($jobs));
|
|
|
|
|
// print_r($totals);
|
|
|
|
|
//print_r($jobs);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
else {
|
|
|
|
|
echo "Failure";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//$this->set('jobs', )
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function setInvoiceDates() {
|
|
|
|
|
|
|
|
|
|
$shipments = $this->Shipment->find('all');
|
|
|
|
|
|
|
|
|
|
foreach($shipments as $shipment) {
|
|
|
|
|
|
|
|
|
|
$created = $shipment['Shipment']['created'];
|
|
|
|
|
|
|
|
|
|
foreach($shipment['ShipmentInvoice'] as $si) {
|
|
|
|
|
|
|
|
|
|
$this->Shipment->ShipmentInvoice->id = $si['id'];
|
|
|
|
|
$this->data = $si;
|
|
|
|
|
$this->data['created'] = $created;
|
|
|
|
|
$this->data['date_issued'] = date('Y-m-d', strtotime($created));
|
|
|
|
|
if($this->Shipment->ShipmentInvoice->save($this->data)) {
|
|
|
|
|
echo 'Updated '.$si['id']."to have {$created} as created and date_issued"."<br>";
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
echo "Unable to save ".$si['id']."<br>";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
2011-09-26 20:47:36 -07:00
|
|
|
|
2011-04-20 00:44:13 -07:00
|
|
|
}
|
2013-04-29 06:00:24 -07:00
|
|
|
?>
|