/var/www/vhosts/nabawater/api/modules/v1/models
Edit: /var/www/vhosts/nabawater/api/modules/v1/models/Order.php (6316B)
'#D4A017',
self::ORDER_STATUS_ACCEPTED => '#2554C7',
self::ORDER_STATUS_DELIVERED => '#348017',
self::ORDER_STATUS_REJECTED => '#C11B17',
];
/**
*
* @var string
*/
public $item_total_price, $item_name, $vendor_name, $vendor_image_path, $device_token, $branch_key, $status_color_code, $order_status_label, $branch_order_type, $branch_availability_status, $vendor_payment_option, $branch_name;
/**
*
* @return array
*/
public function fields()
{
return[
'order_key',
'order_number',
'order_date_time' => function(self $model){
$dtHelper = DateTimeHelper::getInstance()->setDate($model->order_date_time);
return $dtHelper->format($dtHelper::CUSTOM_DATE_TIME_FORMAT);
},
'order_status',
'order_status_label' => function(self $model) {
$orderModel = new Order();
return $orderModel->getOrderStatusLabelNew($model->order_status);
},
'status_color_code' => function(self $model) {
if(array_key_exists($model->order_status, self::COLOR_CODE)) {
return self::COLOR_CODE[$model->order_status];
}
return "";
},
'order_total',
'pickup_delivery_date_time' => function (self $model) {
if($model->delivery_option == 2) {
return $model->pickup_delivery_date_time;
}
return $model->pickup_delivery_date_time;
},
'show_reschedule_now' => function (self $model) {
if($model->order_status == Order::ORDER_STATUS_DELIVERED) {
return 0;
}
if($model->is_deliveryboy_request_for_reschdule == 1) {
return 1;
}
if($model->delivery_option != 2){
return 0;
}
if($model->reschedule_status == 2) {
return 0;
}
$t2 = strtotime(date("Y-m-d H:i:s") );
$t1 = strtotime($model->pickup_delivery_date_time);
$diff = $t1 - $t2;
$hours = $diff / ( 60 * 60 );
if($hours < 24 && 0 < $hours){
return 1;
}
return 0;
},
'is_reschedule_order' => function (self $model) {
return $model->is_deliveryboy_request_for_reschdule == null ? 0 : $model->is_deliveryboy_request_for_reschdule;
},
'delivery_option',
//'payment_type',
// 'branch_key',
// 'rejected_reason',
// 'vendor_name',
// 'branch_name',
// 'vendor_image_path' => function(self $model){
// return UploadHelper::getInstance()->get($model->vendor_image_path);
// },
// 'branch_availability_status' => function(self $model) {
// if ((int)$model->branch_order_type === BranchTimeslot::ORDER_TYPE_BOTH) {
// $modelTimeSlotCount = '';
// $modelTimeSlot = BranchTimeslot::find()
// ->where([
// 'day_id' => date('w')+1,
// 'branch_id' => $model->branch_id,
// 'branch_timeslot_status' => Branch::ACTIVE,
// ])
// ->andWhere(['<=','timeslot_start_time', date('H:i', time())])
// ->andWhere(['>','timeslot_end_time', date('H:i', time())])
// ->one();
// if ($modelTimeSlot !== null) {
// $modelTimeSlot = (array)$modelTimeSlot;
// $modelTimeSlotCount = count($modelTimeSlot);
// }
// $modelTimeSlot = $modelTimeSlotCount;
// } else {
// $modelTimeSlot = BranchTimeslot::find()
// ->where([
// 'day_id' => date('w')+1,
// 'branch_id' => $model->branch_id,
// 'branch_timeslot_status' => Branch::ACTIVE,
// ])
// ->andWhere(['<=','timeslot_start_time', date('H:i', time())])
// ->andWhere(['>','timeslot_end_time', date('H:i', time())])
// ->andWhere(['timeslot_type' => $model->branch_order_type])
// ->one();
// }
// if ($model->branch_availability_status == Branch::BRANCH_AVAILABILITY_STATUS_BUSY) {
// $class = Branch::BRANCH_AVAILABILITY_STATUS_BUSY;
// } else if ($model->branch_availability_status == Branch::BRANCH_AVAILABILITY_STATUS_CLOSED || !isset($modelTimeSlot) || empty($modelTimeSlot)){
// $class = Branch::BRANCH_AVAILABILITY_STATUS_CLOSED;
// } else {
// $class = 1;
// }
// return $model->branch_availability_status !== null ? $class : 0 ;
// },
// 'order_type' => function (self $model) {
// return $model->branch_order_type;
// },
// 'payment_option' => function (self $model) {
// return $model->vendor_payment_option;
// }
];
}
}