예제 #1
0
파일: Order.php 프로젝트: riki343/naidusvoe
 /**
  * @param object $form
  * @param Order $order
  * @return array
  */
 public static function CheckForm($form, $order)
 {
     $result = ['correct' => true, 'order' => null];
     $total = 0;
     if ($form->advOnMain['checked'] === true) {
         switch ($form->advOnMain['period']) {
             case '3':
                 $order->setAdvOnMainPeriod(3);
                 $total += 15;
                 break;
             case '7':
                 $order->setAdvOnMainPeriod(7);
                 $total += 30;
                 break;
             case '14':
                 $order->setAdvOnMainPeriod(14);
                 $total += 50;
                 break;
         }
         $order->setAdvOnMain(true);
     } else {
         $order->setAdvOnMain(false);
     }
     if ($form->advOnTop['checked'] === true) {
         switch ($form->advOnTop['period']) {
             case '3':
                 $order->setAdvOnTopPeriod(3);
                 $total += 15;
                 break;
             case '7':
                 $order->setAdvOnTopPeriod(7);
                 $total += 30;
                 break;
             case '14':
                 $order->setAdvOnTopPeriod(14);
                 $total += 50;
                 break;
         }
         $order->setAdvOnTop(true);
     } else {
         $order->setAdvOnTop(false);
     }
     if ($form->advFilled['checked'] === true) {
         switch ($form->advFilled['period']) {
             case '3':
                 $order->setAdvFilledPeriod(3);
                 $total += 15;
                 break;
             case '7':
                 $order->setAdvFilledPeriod(7);
                 $total += 30;
                 break;
             case '14':
                 $order->setAdvFilledPeriod(14);
                 $total += 50;
                 break;
         }
         $order->setAdvFilled(true);
     } else {
         $order->setAdvFilled(false);
     }
     if ($form->advUrgent['checked'] === true) {
         switch ($form->advUrgent['period']) {
             case '3':
                 $order->setAdvUrgentPeriod(3);
                 $total += 15;
                 break;
             case '7':
                 $order->setAdvUrgentPeriod(7);
                 $total += 30;
                 break;
             case '14':
                 $order->setAdvUrgentPeriod(14);
                 $total += 50;
                 break;
         }
         $order->setAdvUrgent(true);
     } else {
         $order->setAdvUrgent(false);
     }
     if ($form->advUpdate['checked'] === true) {
         $order->setAdvUpdate(true);
         $total += 15;
     } else {
         $order->setAdvUpdate(false);
     }
     if ($form->advBlock['checked'] === true) {
         switch ($form->advBlock['period']) {
             case '3':
                 $order->setAdvBlockPeriod(3);
                 $total += 15;
                 break;
             case '7':
                 $order->setAdvBlockPeriod(7);
                 $total += 30;
                 break;
             case '14':
                 $order->setAdvBlockPeriod(14);
                 $total += 50;
                 break;
         }
         $order->setAdvBlock(true);
     } else {
         $order->setAdvBlock(false);
     }
     $order->setAmount($total);
     $order->setPayWay($form->payWay);
     $result['correct'] = $form->total === $total;
     $result['order'] = $order;
     return $result;
 }