Ejemplo n.º 1
0
 /**
  * 运行方法
  * @author Colin <*****@*****.**>
  */
 public static function run()
 {
     try {
         //加载配置文件
         self::loadConfig();
         //注册autoload方法
         spl_autoload_register('MyClass\\libs\\MyClass::autoload');
         //收集错误
         MyError::error_traceassstring();
         //判断文件夹是否存在
         self::Dir();
         //视图初始化
         self::View();
         //初始化URL模式
         self::UrlModel();
     } catch (MyError $m) {
         die($m);
     }
 }
Ejemplo n.º 2
0
 private function checkInventoryLevels()
 {
     $errors = array();
     //check inventory levels
     $pdetailIds = array();
     $entries = $this->Ccart->getContents();
     foreach ($entries as $e) {
         if (!empty($e->uniques['pdetail'])) {
             array_push($pdetailIds, $e->uniques['pdetail']);
         }
     }
     if (count($pdetailIds) > 0) {
         $info = $this->Pdetail->find('all', array('conditions' => array('Pdetail.id IN (' . implode(',', $pdetailIds) . ')')));
         foreach ($entries as $e) {
             if ($e->getType() == 'product') {
                 //dont have enough product
                 $color = 'Unknown';
                 $size = 'Unknown';
                 $count = 'Unknown';
                 foreach ($info as $entry) {
                     //debug($entry);
                     if ($e->uniques['pdetail'] == $entry['Pdetail']['id']) {
                         $color = $entry['Color']['name'];
                         $size = $entry['Size']['display'];
                         $count = $entry['Pdetail']['inventory'];
                     }
                 }
                 if ($count < $e->qty) {
                     $error = new MyError('inventory_level');
                     $error->setMsg('Sorry, Inventory too low for "' . $entry['Product']['name'] . '".<br/><span class="eline2">Available inventory (size: ' . $size . ', color: ' . $color . ') is <b>' . $count . '</b>.</span>');
                     array_push($errors, $error);
                 }
             }
         }
     } else {
         array_push($errors, new MyError('no_products'));
     }
     return $errors;
 }
Ejemplo n.º 3
0
 function register_ajax()
 {
     $this->layout = 'ajax';
     if (!empty($this->data)) {
         $error = $this->checkUserData($this->data, true);
     } else {
         $error = new MyError('no_error');
     }
     echo $error->getJSON();
 }