| Current Path : /var/www/html/dyna-crm/models/ |
| Current File : /var/www/html/dyna-crm/models/StockDelivery.php |
<?php
namespace app\models;
use Yii;
/**
* This is the model class for table "stock_delivery".
*
* @property int $id
* @property string $customer_name
* @property string $customer_phone
* @property string $customer_email
* @property string $customer_address1
* @property string $customer_address2
* @property string $customer_address3
* @property string $customer_postcode
* @property string $customer_city
* @property string $customer_state
* @property string $stock_details
* @property string $courier
* @property string $tracking_no
* @property string $upload_file
* @property string $delivery_date
* @property string $delivery_status
* @property string $receive_date
* @property string $receive_proof
* @property string $remarks
* @property int $do_id
* @property string $created_dt
* @property int $created_by
* @property string $updated_dt
* @property int $updated_by
*/
class StockDelivery extends \yii\db\ActiveRecord {
public $search_year;
public $keyword;
public $receiver_search;
public $do_search;
/**
* {@inheritdoc}
*/
public static function tableName() {
return 'stock_delivery';
}
/**
* {@inheritdoc}
*/
public function rules() {
return [
[['uuid', 'keyword', 'customer_address2', 'customer_address3', 'courier', 'tracking_no', 'upload_file',
'delivery_status', 'receive_proof', 'do_id', 'created_by', 'updated_by', 'stock_details', 'remarks',
'delivery_date', 'receive_date', 'created_dt', 'updated_dt', 'delivery_proof', 'ref_no', 'industry',
'details_status', 'rider_id', 'rider_remarks', 'rider_wages_status', 'rider_wages_amount', 'receiver_search', 'do_search', 'wages_status', 'wages_rider_id', 'search_year'], 'safe'],
[['customer_name', 'customer_phone', 'customer_address1', 'customer_postcode', 'customer_city', 'customer_state', 'company_name',], 'required', 'on' => 'addUpdate'],
// [['customer_email'], 'email'],
[['receive_proof',], 'required', 'on' => 'riderupdate'],
];
}
/**
* {@inheritdoc}
*/
public function attributeLabels() {
return [
'id' => 'ID',
'company_name' => 'Company',
'customer_name' => 'Receiver Name',
'customer_phone' => 'Phone Number',
'customer_email' => 'Email Address',
'customer_address1' => 'Address',
'customer_address2' => 'Customer Address2',
'customer_address3' => 'Customer Address3',
'customer_postcode' => 'Postcode',
'customer_city' => 'City',
'customer_state' => 'State',
'stock_details' => 'Item',
'courier' => 'Courier',
'tracking_no' => 'Tracking No',
'upload_file' => 'Upload File',
'delivery_date' => 'Delivery Date',
'delivery_status' => 'Delivery Status',
'receive_date' => 'Receive Date',
'receive_proof' => 'Receive Proof',
'remarks' => 'Remarks',
'do_id' => 'DO Number',
'created_dt' => 'Created Dt',
'created_by' => 'Created By',
'updated_dt' => 'Updated Dt',
'updated_by' => 'Updated By',
'delivery_proof' => 'Delivery Proof',
'ref_no' => 'Reference Number',
'industry' => 'Industry',
'details_status' => 'Information Status',
'rider_id' => 'Rider Name',
'rider_remarks' => 'Remarks from rider',
];
}
public function afterSave($insert, $changedAttributes) {
parent::afterSave($insert, $changedAttributes);
if ($this->courier == 'rider' && empty($this->tracking_no)) {
$this->tracking_no = 'PARCEL' . sprintf("%06d", $this->id);
$this->save();
}
}
}