/var/www/vhosts/nabawater/common/models
Edit: /var/www/vhosts/nabawater/common/models/BranchTimeslot.php (22186B)
Yii::t('common', 'SUNDAY', [], $languageCode), 'type'=> self::DAY_SUNDAY],
['label' => Yii::t('common', 'MONDAY', [], $languageCode), 'type'=> self::DAY_MONDAY],
['label' => Yii::t('common', 'TUESDAY', [], $languageCode), 'type'=> self::DAY_TUESDAY],
['label' => Yii::t('common', 'WEDNESDAY', [], $languageCode), 'type'=> self::DAY_WEDNESDAY],
['label' => Yii::t('common', 'THURSDAY', [], $languageCode), 'type'=> self::DAY_THURSDAY],
['label' => Yii::t('common', 'FRIDAY', [], $languageCode), 'type'=> self::DAY_FRIDAY],
['label' => Yii::t('common', 'SATURDAY', [], $languageCode), 'type'=> self::DAY_SATURDAY],
];
}
/**
*
* @param integer $typeId
* @return string
*/
public static function getDayLabel($typeId, $languageCode = null)
{
$list = self::getDayList($languageCode);
foreach ($list as $value) {
if ($value['type'] === (int)$typeId) {
return $value['label'];
}
}
return '(not set)';
}
/**
*
* @return array
*/
public function behaviors()
{
$behaviors = parent::behaviors();
$behaviors[] = [
'class' => AttributeKeyGeneratorBehaviour::class,
'attributes' => [
'branch_timeslot_key'
]
];
return $behaviors;
}
public static function getNextTiming($branch_id,$orderType = '3')
{
if($orderType == 3) {
$timeslot = 1;
} else {
$timeslot = $orderType;
}
$data = [];
if($orderType == 3) {
$modelTimeSlotDelivery = BranchTimeslot::find()
->where([
'day_id' => date('w')+1,
'branch_id' => $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' => 1])
->one();
$modelTimeSlotPickup = BranchTimeslot::find()
->where([
'day_id' => date('w')+1,
'branch_id' => $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' => 2])
->one();
if($modelTimeSlotDelivery != null && $modelTimeSlotPickup != null){
$delivery = $modelTimeSlotDelivery->timeslot_end_time;
$pickup = $modelTimeSlotPickup->timeslot_end_time;
if(strtotime($delivery) > strtotime($pickup)){
$data['time'] = $modelTimeSlotDelivery->timeslot_end_time;
$data['status'] = 1;
return $data;
} else {
$data['time'] = $modelTimeSlotPickup->timeslot_end_time;
$data['status'] = 1;
return $data;
}
} else if($modelTimeSlotDelivery != null && $modelTimeSlotPickup == null){
$data['time'] = $modelTimeSlotDelivery->timeslot_end_time;
$data['status'] = 1;
return $data;
} else if($modelTimeSlotDelivery == null && $modelTimeSlotPickup != null){
$data['time'] = $modelTimeSlotPickup->timeslot_end_time;
$data['status'] = 1;
return $data;
} else {
$modelTimeSlot = null;
$i = date('w') + 1;
$current = $i;
while ($modelTimeSlot != null || $i <= 7) {
$i++;
$modelTimeSlotDelivery = BranchTimeslot::find()
->where([
'day_id' => $i,
'branch_id' => $branch_id,
'branch_timeslot_status' => Branch::ACTIVE,
])
->andWhere(['timeslot_type' => 1])
->andWhere(['!=','timeslot_start_time',""])
->one();
$modelTimeSlotPickup = BranchTimeslot::find()
->where([
'day_id' => $i,
'branch_id' => $branch_id,
'branch_timeslot_status' => Branch::ACTIVE,
])
->andWhere(['timeslot_type' => 2])
->andWhere(['!=','timeslot_start_time',""])
->one();
if($modelTimeSlotDelivery != null && $modelTimeSlotPickup != null) {
$delivery = $modelTimeSlotDelivery->timeslot_start_time;
$pickup = $modelTimeSlotPickup->timeslot_start_time;
if(strtotime($delivery) < strtotime($pickup)){
$modelTimeSlot = $modelTimeSlotDelivery;
} else {
$modelTimeSlot = $modelTimeSlotPickup;
}
} else if($modelTimeSlotDelivery != null && $modelTimeSlotPickup == null) {
$modelTimeSlot = $modelTimeSlotDelivery;
} else if($modelTimeSlotDelivery == null && $modelTimeSlotPickup != null) {
$modelTimeSlot = $modelTimeSlotPickup;
} else {
$modelTimeSlot = null;
}
if($modelTimeSlot != null)
{
break;
}
if($current == $i) {
break;
}
if($i == 8) {
$i =1;
}
}
$data['time'] = (isset($modelTimeSlot->timeslot_start_time) ? $modelTimeSlot->timeslot_start_time : 'Long Days') ;
$data['status'] = 2;
return $data;
}
} else {
$modelTimeSlot = BranchTimeslot::find()
->where([
'day_id' => date('w')+1,
'branch_id' => $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' => $timeslot])
->one();
if($modelTimeSlot !== null){
$data['time'] = $modelTimeSlot->timeslot_end_time;
$data['status'] = 1;
return $data;
} else {
if($orderType == 3) {
$new_time_slot = 2;
$modelTimeSlot = BranchTimeslot::find()
->where([
'day_id' => date('w')+1,
'branch_id' => $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' => $new_time_slot])
->one();
if($modelTimeSlot !== null){
$data['time'] = $modelTimeSlot->timeslot_end_time;
$data['status'] = 1;
return $data;
}
}
}
$modelTimeSlot == null;
$i = date('w') + 1;
$current = $i;
while ($modelTimeSlot != null || $i <= 7) {
$i++;
$modelTimeSlot = BranchTimeslot::find()
->where([
'day_id' => $i,
'branch_id' => $branch_id,
'branch_timeslot_status' => Branch::ACTIVE,
])
->andWhere(['timeslot_type' => $timeslot])
->andWhere(['!=','timeslot_start_time',""])
->one();
if($modelTimeSlot != null)
{
break;
}
if($current == $i) {
break;
}
if($i == 8) {
$i =1;
}
}
$data['time'] = (isset($modelTimeSlot->timeslot_start_time) ? $modelTimeSlot->timeslot_start_time : 'Long Days') ;
$data['status'] = 2;
return $data;
}
}
public static function getNextTimingCustom($branch_id,$orderType = '3')
{
if($orderType == 3) {
$timeslot = 1;
} else {
$timeslot = $orderType;
}
$data = [];
if($orderType == 3) {
$modelTimeSlotDelivery = BranchTimeslot::find()
->where([
'day_id' => date('w')+2,
'branch_id' => $branch_id,
'branch_timeslot_status' => Branch::ACTIVE,
])
->andWhere(['<=','timeslot_start_time', date('H:i', time())])
->andWhere(['timeslot_type' => 1])
->one();
$modelTimeSlotPickup = BranchTimeslot::find()
->where([
'day_id' => date('w')+2,
'branch_id' => $branch_id,
'branch_timeslot_status' => Branch::ACTIVE,
])
->andWhere(['<=','timeslot_start_time', date('H:i', time())])
->andWhere(['timeslot_type' => 2])
->one();
if($modelTimeSlotDelivery != null && $modelTimeSlotPickup != null){
$delivery = $modelTimeSlotDelivery->timeslot_start_time;
$pickup = $modelTimeSlotPickup->timeslot_start_time;
if(strtotime($delivery) < strtotime($pickup)){
$data['time'] = $modelTimeSlotDelivery->timeslot_start_time;
$data['status'] = 1;
return $data;
} else {
$data['time'] = $modelTimeSlotPickup->timeslot_start_time;
$data['status'] = 1;
return $data;
}
} else if($modelTimeSlotDelivery != null && $modelTimeSlotPickup == null){
$data['time'] = $modelTimeSlotDelivery->timeslot_start_time;
$data['status'] = 1;
return $data;
} else if($modelTimeSlotDelivery == null && $modelTimeSlotPickup != null){
$data['time'] = $modelTimeSlotPickup->timeslot_start_time;
$data['status'] = 1;
return $data;
} else {
$modelTimeSlot = null;
$i = date('w') + 2;
$current = $i;
while ($modelTimeSlot != null || $i <= 7) {
$i++;
$modelTimeSlotDelivery = BranchTimeslot::find()
->where([
'day_id' => $i,
'branch_id' => $branch_id,
'branch_timeslot_status' => Branch::ACTIVE,
])
->andWhere(['timeslot_type' => 1])
->andWhere(['!=','timeslot_start_time',""])
->one();
$modelTimeSlotPickup = BranchTimeslot::find()
->where([
'day_id' => $i,
'branch_id' => $branch_id,
'branch_timeslot_status' => Branch::ACTIVE,
])
->andWhere(['timeslot_type' => 2])
->andWhere(['!=','timeslot_start_time',""])
->one();
if($modelTimeSlotDelivery != null && $modelTimeSlotPickup != null) {
$delivery = $modelTimeSlotDelivery->timeslot_start_time;
$pickup = $modelTimeSlotPickup->timeslot_start_time;
if(strtotime($delivery) < strtotime($pickup)){
$modelTimeSlot = $modelTimeSlotDelivery;
} else {
$modelTimeSlot = $modelTimeSlotPickup;
}
} else if($modelTimeSlotDelivery != null && $modelTimeSlotPickup == null) {
$modelTimeSlot = $modelTimeSlotDelivery;
} else if($modelTimeSlotDelivery == null && $modelTimeSlotPickup != null) {
$modelTimeSlot = $modelTimeSlotPickup;
} else {
$modelTimeSlot = null;
}
if($modelTimeSlot != null)
{
break;
}
if($current == $i) {
break;
}
if($i == 8) {
$i =1;
}
}
$data['time'] = (isset($modelTimeSlot->timeslot_start_time) ? $modelTimeSlot->timeslot_start_time : 'Long Days') ;
$data['status'] = 2;
return $data;
}
} else {
$modelTimeSlot = BranchTimeslot::find()
->where([
'day_id' => date('w')+2,
'branch_id' => $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' => $timeslot])
->one();
if($modelTimeSlot !== null){
$data['time'] = $modelTimeSlot->timeslot_start_time;
$data['status'] = 1;
return $data;
} else {
if($orderType == 3) {
$new_time_slot = 2;
$modelTimeSlot = BranchTimeslot::find()
->where([
'day_id' => date('w')+2,
'branch_id' => $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' => $new_time_slot])
->one();
if($modelTimeSlot !== null){
$data['time'] = $modelTimeSlot->timeslot_start_time;
$data['status'] = 1;
return $data;
}
}
}
$modelTimeSlot == null;
$i = date('w') + 1;
$current = $i;
while ($modelTimeSlot != null || $i <= 7) {
$i++;
$modelTimeSlot = BranchTimeslot::find()
->where([
'day_id' => $i,
'branch_id' => $branch_id,
'branch_timeslot_status' => Branch::ACTIVE,
])
->andWhere(['timeslot_type' => $timeslot])
->andWhere(['!=','timeslot_start_time',""])
->one();
if($modelTimeSlot != null)
{
break;
}
if($current == $i) {
break;
}
if($i == 8) {
$i =1;
}
}
$data['time'] = (isset($modelTimeSlot->timeslot_start_time) ? $modelTimeSlot->timeslot_start_time : 'Long Days') ;
$data['status'] = 2;
return $data;
}
}
public static function getNextTimingCustom1($branch_id,$orderType = '3')
{
if($orderType == 3) {
$timeslot = 1;
} else {
$timeslot = $orderType;
}
$data = [];
$modelTimeSlot = BranchTimeslot::find()
->where([
'day_id' => date('w')+2,
'branch_id' => $branch_id,
'branch_timeslot_status' => Branch::ACTIVE,
])
->andWhere(['>=','timeslot_start_time', date('H:i', time())])
->andWhere(['timeslot_type' => $timeslot])
->one();
if($modelTimeSlot !== null){
$data['time'] = $modelTimeSlot->timeslot_start_time;
$data['status'] = 1;
return $data;
} else {
if($orderType == 3) {
$new_time_slot = 2;
$modelTimeSlot = BranchTimeslot::find()
->where([
'day_id' => date('w')+2,
'branch_id' => $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' => $new_time_slot])
->one();
if($modelTimeSlot !== null){
$data['time'] = $modelTimeSlot->timeslot_end_time;
$data['status'] = 1;
return $data;
}
}
}
$modelTimeSlot == null;
$i = date('w') + 1;
$current = $i;
while ($modelTimeSlot != null || $i <= 7) {
$i++;
$modelTimeSlot = BranchTimeslot::find()
->where([
'day_id' => $i,
'branch_id' => $branch_id,
'branch_timeslot_status' => Branch::ACTIVE,
])
->andWhere(['timeslot_type' => $timeslot])
->andWhere(['!=','timeslot_start_time',""])
->one();
if($modelTimeSlot != null)
{
break;
}
if($current == $i) {
break;
}
if($i == 8) {
$i =1;
}
}
$data['time'] = (isset($modelTimeSlot->timeslot_start_time) ? $modelTimeSlot->timeslot_start_time : 'Long Days') ;
$data['status'] = 2;
return $data;
}
}