本文整理汇总了PHP中Shipment::model方法的典型用法代码示例。如果您正苦于以下问题:PHP Shipment::model方法的具体用法?PHP Shipment::model怎么用?PHP Shipment::model使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Shipment
的用法示例。
在下文中一共展示了Shipment::model方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionCreate
/**
* Creates a new model.
* If creation is successful, the browser will be redirected to the 'view' page.
*/
public function actionCreate($shipment_id = '')
{
$model = new Booking();
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
$awb = '';
if (is_numeric($shipment_id)) {
$shipment = Shipment::model()->findByPk($shipment_id);
if ($shipment instanceof Shipment) {
$model->address = $shipment->shipper_address;
$model->city = $shipment->shipper_city;
$model->postal = $shipment->shipper_postal;
$model->country = $shipment->shipper_country;
$model->phone = $shipment->shipper_phone;
$model->shipment_id = $shipment->id;
$awb = $shipment->awb;
}
}
if (isset($_POST['Booking'])) {
$model->attributes = $_POST['Booking'];
$model->setAttribute('booking_code', dechex(time()));
if ($model->save()) {
if (!empty($model->shipment_id) || $model->shipment_id != '') {
$shipment->booking_id = $model->id;
$tes = $shipment->update();
}
Yii::app()->user->setFlash('success', 'Success to add new booking, ' . $model->booking_code);
$this->redirect(array('index'));
}
}
$this->render('create', array('model' => $model, 'awb' => $awb));
}
示例2: getAllJneIncompleteOrders
/**
* Return all incomplete JNE orders
*
* @return Shipment[]
*/
private function getAllJneIncompleteOrders()
{
$jne_service_ids = RateCompanyService::getJNEServiceId();
$criteria = new CDbCriteria();
$criteria->params = array(':status_POD' => ShipmentStatus::POD);
$criteria->condition = 'shipping_status != :status_POD AND carrier_awb !=""';
$criteria->addInCondition('service_id', $jne_service_ids);
return Shipment::model()->findAll($criteria);
}
示例3: listPickup
public static function listPickup($shipmentId)
{
$criteria = new CDbCriteria();
$criteria->condition = 'id = :id and shipping_status=11';
$criteria->params[':id'] = $shipmentId;
$model = Shipment::model()->find($criteria);
if ($model == null) {
return false;
}
return $model->awb;
}
示例4: actionUpdate
/**
* Updates a particular model.
* If update is successful, the browser will be redirected to the 'view' page.
* @param integer $id the ID of the model to be updated
*/
public function actionUpdate($shipment_id)
{
$model = Pickup::model()->findByAttributes(array('shipment_id' => $shipment_id));
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
$shipment = Shipment::model()->findByPk($shipment_id);
$criteria = new CDbCriteria();
$criteria->with = array('user', 'pickup');
$driver_list_available = new CActiveDataProvider('Driver', array('criteria' => $criteria));
if (isset($_GET['driver_id'])) {
$model->driver_id = $_GET['driver_id'];
$model->shipment_id = $shipment_id;
$trans = Yii::app()->db->beginTransaction();
try {
if ($model->save()) {
$event = new ShipmentEvent();
$event->shipment_id = $shipment_id;
$event->event_time = time();
$event->with_mde = 0;
$event->user_id = Yii::app()->user->id;
$event->status = 11;
$event->setScenario('order');
if ($event->save()) {
$shipment->shipping_status = 11;
$shipment->setScenario('event');
if ($shipment->save()) {
$trans->commit();
$this->redirect(array('shipment/operation'));
} else {
throw new CException($shipment->getErrors());
}
} else {
throw new CException($event->getErrors());
}
} else {
throw new CException($model->getErrors());
}
} catch (CException $e) {
$trans->rollback();
throw $e;
}
}
$this->render('update', array('model' => $model, 'driver_list_available' => $driver_list_available, 'shipment_id' => $shipment_id));
}
示例5: header
<?php
header('Content-type: text/javascript');
$shipment = Shipment::model();
$customer = Customer::model();
?>
<script type="text/javascript">
Ext.define('Job', {
extend: 'Ext.data.Model',
fields: <?php
echo json_encode(array_keys($shipment->getMetaData()->columns));
?>
,
validations: [
{type: 'presence', field: <?php
echo CHtml::activeId($shipment, 'shipper_name');
?>
}
]
});
</script>
示例6: actionUpdateBulkStatus
public function actionUpdateBulkStatus()
{
$new_event = new ShipmentEvent('bulkinsert');
$failed = array();
$success = array();
if (isset($_POST['ShipmentEvent'])) {
$new_event->setAttributes($_POST['ShipmentEvent']);
if ($new_event->validate()) {
$rawsAwb = nl2br($new_event->shipment_list);
$arrAwb = explode('<br />', $rawsAwb);
foreach ($arrAwb as $awb) {
$awb = trim($awb);
$shipment = Shipment::model()->findByAttributes(array('awb' => $awb));
if ($shipment instanceof Shipment) {
array_push($success, $awb);
// CVarDumper::dump($success,10,true);
$event = new ShipmentEvent();
$event->setAttributes($_POST['ShipmentEvent']);
$event->setAttribute('shipment_id', $shipment->id);
$shipment->shipping_status = $event->status;
$shipment->shipping_remark = $event->remark;
$shipment->recipient_name = $event->recipient_name;
$shipment->recipient_title = $event->recipient_title;
$shipment->event_time = strtotime($event->event_time);
if (isset($event->recipient_date)) {
$shipment->recipient_date = strtotime($event->recipient_date);
}
$shipment->setScenario('event');
$event->save();
$shipment->save();
} else {
array_push($failed, $awb);
}
if (count($success) != 0) {
$list_success = implode(', ', $success);
Yii::app()->user->setFlash('success', 'Success : ' . $list_success);
}
if (count($failed) != 0) {
$list_failed = implode(', ', $failed);
Yii::app()->user->setFlash('error', 'Failed : ' . $list_failed);
}
}
}
}
$this->render('updateBulk', array('new_event' => $new_event));
}
示例7: actionCheckawb
public function actionCheckawb()
{
if (!isset($_GET['awb'])) {
echo CJSON::encode($this->statusError('AWB Number required'));
Yii::app()->end();
}
$shipment = Shipment::model()->findByAttributes(array('awb' => $_GET['awb']));
if (!$shipment instanceof Shipment) {
echo CJSON::encode($this->statusError('AWB Number not found'));
Yii::app()->end();
}
$criteria = new CDbCriteria();
$criteria->select = 't2.status,remark,description,event_time';
$criteria->join = 'JOIN shipment_status t2 ON t2.id = t.status JOIN users t3 ON t3.id = t.user_id';
$criteria->params = array(':shipment_id' => $shipment->id);
$criteria->condition = 't.shipment_id =:shipment_id AND t.with_mde = 0';
$criteria->order = 't.id DESC';
$builder = new CDbCommandBuilder(Yii::app()->db->Schema);
$command = $builder->createFindCommand('shipment_event', $criteria);
$tracking = $command->queryAll();
echo CJSON::encode($this->statusSuccess($tracking));
Yii::app()->end();
}
示例8: getShipmentByAwb
protected function getShipmentByAwb($awb, $field)
{
$model = Shipment::model()->findByAttributes(array('awb' => $awb));
if ($model == null) {
return false;
}
return $model->receiver_address;
}
示例9: actionUpdate
/**
* Updates a particular model.
* If update is successful, the browser will be redirected to the 'view' page.
* @param integer $id the ID of the model to be updated
*/
public function actionUpdate($id)
{
$model = $this->loadModel($id);
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
if (isset($_POST['Customer'])) {
$model->attributes = $_POST['Customer'];
$model->save();
$this->redirect("#info");
// $this->redirect(array('view','id'=>$model->bilkey));
}
if (isset($_GET['Shipment'])) {
$shipment_model->attributes = $_GET['Shipment'];
}
$service_details = Customer::model()->getCustomerServiceDetails($id);
$shipment_details = Customer::model()->getShipmentsByCustomerBilkey($id);
$customer = Customer::model()->findByPk($id);
$commande = Commande::model()->findAllByAttributes(array('bilkey' => $id));
$shipment_model = new Shipment('search');
$shipment_model->unsetAttributes();
// clear any default values
$shipment_model->bilkey = $id;
// DEBUGGING
// print "New total: " + $total_balance . '<br />';
// print "Old total: " + $customer->bilbalance;
// die;
// TODO: We really should link the billing activity with the comkey...
if (isset($_POST['Shipment'])) {
// Check if it's an update
if (isset($_POST['update'])) {
$shipment = Shipment::model()->findByPk($_POST['update']);
$shipment->attributes = $_POST['Shipment'];
// We have to cast these manually. For some reason this fails on the production server...
$shipment->shipdebit = floatval($shipment->shipdebit);
$shipment->shipcredit = floatval($shipment->shipcredit);
// If the user leaves these fields blank, let's assume
// they meant to input a 0.
if (empty($shipment->shipdebit) || $shipment->shipdebit == null) {
$shipment->shipdebit = 0;
}
if (empty($shipment->shipcredit) || $shipment->shipcredit == null) {
$shipment->shipcredit = 0;
}
// TODO: We should prolly check this
$shipment->save();
} else {
$shipment = new Shipment();
$shipment->attributes = $_POST['Shipment'];
// We have to cast these manually. For some reason this fails on the production server...
$shipment->shipdebit = floatval($shipment->shipdebit);
$shipment->shipcredit = floatval($shipment->shipcredit);
// If the user leaves these fields blank, let's assume
// they meant to input a 0.
if (empty($shipment->shipdebit) || $shipment->shipdebit == null) {
$shipment->shipdebit = 0;
}
if (empty($shipment->shipcredit) || $shipment->shipcredit == null) {
$shipment->shipcredit = 0;
}
if ($shipment->validate()) {
$shipment->comkey = $commande[0]->comkey;
$shipment->bilkey = $customer->bilkey;
$shipment->save();
}
}
// $this->redirect("customer/update/id/" + $customer->bilkey);
$this->redirect("#billing");
}
$conn = Yii::app()->db;
// $total_balance = 0;
// Update individual account balances
foreach ($commande as $c) {
$command = $conn->createCommand("SELECT SUM(shipcredit) - SUM(shipdebit) as balance FROM shipment WHERE comkey='" . $c->comkey . "' GROUP BY comkey");
$results = $command->queryRow();
$balance = $results['balance'];
// $total_balance += $balance;
$c->dest_bilbalance = $balance;
$c->save();
}
// Fix for Support Request #430
$command = $conn->createCommand("SELECT SUM(shipcredit) - SUM(shipdebit) as balance FROM shipment WHERE bilkey='" . $customer->bilkey . "'");
$results = $command->queryRow();
$total_balance = $results['balance'];
// Update overall account balance
$customer->bilbalance = $total_balance;
$customer->save();
$this->render('//shared/user-info', array('admin' => 1, 'commande' => $commande, 'customer' => $customer, 'customer_model' => $customer, 'service_details' => $service_details, 'shipment_details' => $shipment_details, 'shipment_model' => $shipment_model));
}
示例10: actionPDFAwb
public function actionPDFAwb($id)
{
if (isset($_GET['id']) && is_numeric($id)) {
$shipment = Shipment::model()->findByPk($id);
if ($shipment instanceof Shipment) {
$customer = Customer::model()->findByPk($shipment->customer_id);
$contact = $customer->getContactData();
$html2pdf = Yii::app()->ePdf->HTML2PDF('P', 'A4', 'en');
$html2pdf->WriteHTML($this->renderPartial('pdfawb', array('shipment' => $shipment, 'customer' => $customer, 'contact' => $contact), true));
$html2pdf->Output(dirname(Yii::app()->basePath) . '/pdf/tes2.pdf', EYiiPdf::OUTPUT_TO_BROWSER);
}
}
}
示例11: getShipmentCharges
public function getShipmentCharges()
{
$charges = Shipment::model()->findByPk($this->shipment_id)->getAllShipmentAdditionalCharges();
$arr_charge = array('name' => 'Shipment Cost', 'cost' => $this->charges);
array_push($charges, $arr_charge);
return $charges;
}
示例12: loadModel
/**
* 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 = Shipment::model()->findByPk((int) $id);
if ($model === null) {
throw new CHttpException(404, 'The requested page does not exist.');
}
return $model;
}