/**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  * @param integer the ID of the model to be loaded
  */
 public function loadModel($id)
 {
     $model = OrderTracking::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
Ejemplo n.º 2
0
    /**
     *
     * @param CActiveRecord $model
     * @param int $id
     * @param array $config 
     */
    public function registerAssignScript($model, $id, array $config = array())
    {
        Yii::app()->controller->beginWidget('zii.widgets.jui.CJuiDialog', array('id' => 'assignDriver', "options" => array('title' => 'Assign Driver', 'autoOpen' => false, 'modal' => true, 'buttons' => array('Close' => 'js:function(){$(this).dialog("close")}', 'Assign' => 'js:function(){' . CHtml::ajax(array('url' => $config['ajaxUrl'], 'type' => 'post', 'dataType' => 'json', 'data' => 'js:$("#assignDriver form").serialize()', 'success' => 'function(r){if(r.success){
					$("#assignDriver").dialog("close");
					$.fn.yiiGridView.update("tracking-grid");
				}; 
				if(!r.success){alert("Gagal assign driver")}}')) . ';}'))), true);
        $driverForm = new CForm(array('elements' => array('driver' => array('type' => 'dropdownlist', 'items' => OrderTracking::getDriverList()), 'id' => array('type' => 'hidden'))), $model);
        echo $driverForm->render();
        Yii::app()->controller->endWidget();
        Yii::app()->clientScript->registerScript($id, "jQuery('body').undelegate('.assignDriver_button','click').delegate('.assignDriver_button','click',function(){\ndriverDialog=jQuery('#assignDriver');\ndriverDialog.dialog('open');\njQuery('#assignDriver input#OrderTracking_id').val(\$(this).attr('rel').replace('grid.',''));\n\treturn false;\n});\t");
    }
 static function createWPInvoice($contactName, $itemNumber)
 {
     $xero = new Xero(Config::XERO_KEY, Config::XERO_SECRET, Config::XERO_PATH_PUBLIC_CERT, Config::XERO_PATH_PRIVATE_KEY);
     $date = strftime('%Y-%m-%d');
     // The input format for creating a new invoice (or credit note) see http://blog.xero.com/developer/api/invoices/
     $new_invoice = array(array("Type" => "ACCREC", "Contact" => array("Name" => $contactName), "Date" => $date, "DueDate" => $date, "Status" => "DRAFT", "Reference" => "ABC Super Fund NSF-ED", "Account" => "Sales", "LineAmountTypes" => "Exclusive", "LineItems" => array("LineItem" => array(array("Description" => "Test Description of transaction", "Quantity" => "1.0000", "ItemCode" => $itemNumber)))));
     // Raise an invoice
     $invoice_result = $xero->Invoices($new_invoice);
     OrderTracking::logToFile(json_encode($new_invoice) . "\r\n");
     OrderTracking::logToFile(json_encode($invoice_result) . "\r\n\r\n");
     $invoiceNumber = $invoice_result['Invoices']['Invoice']['InvoiceNumber'];
     return $invoiceNumber;
 }
Ejemplo n.º 4
0
 public function afterSave()
 {
     if ($this->isNewRecord) {
         //for the tracker
         $tracker = new OrderTracking('OrderCreated');
         $tracker->shipments_id = $this->primaryKey;
         $tracker->save();
         //for shipment event
         $shipment_event = new ShipmentEvent();
         $shipment_event->shipment_id = $this->id;
         $shipment_event->status = $this->shipping_status;
         $shipment_event->event_time = $this->event_time;
         if ($this->getScenario() == 'api-requestpickup') {
             $shipment_event->user_id = 0;
         } else {
             $shipment_event->user_id = Yii::app()->user->id;
         }
         $shipment_event->setScenario('order');
         $shipment_event->save();
         if (!empty($this->customer_id)) {
             $trans = new Transaction();
             $trans->shipment_id = $this->id;
             $trans->customer_id = $this->customer_id;
             $trans->created = $this->created;
             $trans->charges = $this->shipping_charges;
             $trans->total = $this->charges;
             $trans->save();
         }
     } else {
         if ($this->getScenario() != 'event') {
             $shipment_event = new ShipmentEvent();
             $shipment_event->shipment_id = $this->id;
             $shipment_event->status = $this->shipping_status;
             $shipment_event->event_time = time();
             $shipment_event->user_id = Yii::app()->user->id;
             $shipment_event->with_mde = 1;
             $shipment_event->setScenario('order');
             $shipment_event->save();
         }
         if (!empty($this->customer_id)) {
             $trans = Transaction::model()->findByAttributes(array('shipment_id' => $this->id));
             $trans->shipment_id = $this->id;
             $trans->customer_id = $this->customer_id;
             $trans->created = $this->created;
             $trans->charges = $this->shipping_charges;
             $trans->total = $this->charges;
             $trans->save();
         }
     }
 }
Ejemplo n.º 5
0
<?php

error_reporting(-1);
ini_set('display_errors', 'on');
echo 'test';
require_once "ordertracking.php";
require_once "D:\\inetpub\\live\\wwwroot\\wp-blog-header.php";
$data = $_POST;
echo OrderTracking::addToXero($data);