Exemplo n.º 1
0
 /**
  * 订单确认页面
  */
 function confirm()
 {
     $bmobObj = new BmobObject('Cart');
     $res = $bmobObj->get('', array('where={"userId":"' . $this->userId . '"}', 'limit=1'));
     $res = $res->results[0];
     $items = $res->items;
     //json字符串转数组
     $items = json_decode($items);
     if (empty($items)) {
         header('Location: ' . base_url('user/upload'));
     } else {
         //检测文件是否解析完成,若未完成,则返回
         $bmobObj = new BmobObject('File_Info');
         $num = count($this->cart->getItems());
         foreach ($this->cart->getItems() as &$item) {
             $fileMD5 = $item->fileMD5;
             $res = $bmobObj->get('', array('where={"fileMD5":"' . $fileMD5 . '"}', 'limit=1'));
             if (count($res->results) == 1) {
                 $num--;
             }
         }
         if ($num == 0) {
             //剩余数量为0,载入页面
             //载入之前,将page,subtotal信息录入到bmob
             $k = 0;
             while (isset($items[$k])) {
                 $item = new MY_Item($items[$k]->filename, $items[$k]->fileMD5);
                 $item->printSettings = $items[$k]->printSettings;
                 $items[$k]->pages = $item->get_pages();
                 $items[$k]->subtotal = $item->get_subtotal();
                 $k++;
             }
             $this->cart->update_items($items);
             //更新到数据库
             try {
             } catch (Exception $e) {
             }
             $this->load->view('user/confirm_page', array('items' => $items));
         } else {
             //echo $num;
             header('Location: ' . base_url('user/upload'));
         }
     }
 }
Exemplo n.º 2
0
                        <th class="leaf">单/双面</th>
                        <th class="direction">横/竖</th>
                        <th class="ppt-mount">每面PPT的数量</th>
                        <th class="size">大小</th>
                        <th class="single-price">单价</th>
                        <th class="copies">份数</th>
                        <th class="gross">小记</th>
                        <th class="delete">删除</th>
                    </thead>
                    <tbody>
                    <?php 
//传值,array,$items
$num = 1;
$total = 0;
foreach ($items as $one) {
    $item = new MY_Item($one->filename, $one->fileMD5);
    $item->printSettings = $one->printSettings;
    ?>
                   <!--    <tr>
                            <td role="order">1</td>
                            <td >
                                <div><i class="logo-ppt"></i><span class="file-name" role="file-name">2015年春微积分模拟卷(启明)</span></td>
                            </div>
                            <td>
                                <div>
                                    <div>
                                        <input type="radio" name="share1" role="share" value="yes" checked>是</div>
                                    <div>
                                        <input type="radio" name="share1" role="share" value="no">否</div>
                                </div>
                            </td>
Exemplo n.º 3
0
 /**
  * 更改打印设定
  * 返回单价
  */
 public function changePrintSetting($fileMD5, $option, $optionValue)
 {
     //找到item
     $items = $this->getItems();
     $key = 0;
     foreach ($items as $one) {
         if ($one->fileMD5 == $fileMD5) {
             $isIn = true;
             break;
         }
         $key++;
     }
     switch ($option) {
         case 'paperSize':
             if (in_array($optionValue, paperSize::getPaperSize())) {
                 $items[$key]->printSettings->paperSize = $optionValue;
             }
             break;
         case 'TwoSides':
             if ($optionValue == 'double') {
                 $optionValue = true;
             } else {
                 $optionValue = false;
             }
             //echo $optionValue;
             //if (in_array($optionValue,array(true,false))) {
             $items[$key]->printSettings->isTwoSides = $optionValue;
             //}
             break;
         case 'pptPerPage':
             $optionValue = intval($optionValue);
             if (in_array($optionValue, pptPerPage::getPptPerPage())) {
                 $items[$key]->printSettings->pptPerPage = $optionValue;
             }
             break;
         case 'amount':
             $optionValue = intval($optionValue);
             if ($optionValue > 0) {
                 $items[$key]->printSettings->amount = $optionValue;
             }
             break;
         case 'direction':
             if (in_array($optionValue, printDirection::getPrintDirection())) {
                 $items[$key]->printSettings->direction = $optionValue;
             }
             break;
         default:
             break;
     }
     $newItem = new MY_Item($items[$key]->filename, $items[$key]->fileMD5);
     $newItem->printSettings = $items[$key]->printSettings;
     //更新bmob数据,加入价格信息
     try {
         $items[$key]->subtotal = $newItem->get_subtotal();
         $items[$key]->pages = $newItem->get_pages();
         $this->bmobObject->update($this->cartId, array('items' => json_encode($items)));
         //var_dump($items);
         //var_dump($this->getItems());
     } catch (Exception $e) {
         throw new MY_Exception($e->error_msg);
     }
     //返回单价和小记
     return array('unitPrice' => $newItem->get_price_per_copy() / 100, 'subtotal' => $newItem->get_price_per_copy() * $items[$key]->printSettings->amount / 100);
 }