示例#1
0
 /**
  * Gets the profile picture for a specifc user.
  * @param string $userId The Id of the user to get profile picture. If this is empty, the current user's avatar will be returned.
  * @param string $type The type of picture to return (original, thumb.profile, thumb.feed, thumb.icon)
  * @return array The picture info (path, alt, title, width, height)
  */
 public static function getPictureInfo($userId = '', $type = 'orginal')
 {
     if (empty($userId)) {
         $userId = Yii::app()->user->getId();
         if (empty($userId)) {
             return null;
         }
     }
     $pictureId = Profile::model()->getFieldInfo($userId, User::PREFIX, 'picture');
     if ($pictureId === null) {
         return self::getDefaultPicture($userId, $type);
     }
     $pictureInfo = Storage::model()->get($pictureId);
     // Alt and title
     $info = array('alt' => $pictureInfo['title'] . ' - ' . $pictureInfo['description'], 'title' => $pictureInfo['title']);
     // Path
     if ($type === 'original') {
         $info['path'] = $pictureInfo['storage_path'];
     } else {
         if (isset($pictureInfo[$type])) {
             $info['path'] = $pictureInfo[$type];
         } else {
             $info['path'] = Yii::app()->getBaseUrl(true) . '/files/images/error.jpg';
             $info['width'] = $info['height'] = 160;
         }
     }
     // Size
     if (!isset($info['width'])) {
         $imageInfo = getimagesize($info['path']);
         $info['width'] = $imageInfo[0];
         $info['height'] = $imageInfo[1];
     }
     return $info;
 }
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionTodayStorage()
 {
     $dates = date('Y:m:d');
     $depId = $_POST['depId'];
     $Products = array();
     /*$model = DepBalance::model()->with('products')->findAll('t.department_id = :depId AND t.type = :type',array(':depId'=>$depId,'type'=>1));
       foreach ($model as $val) {
           $products[$val->prod_id] = $val->getRelated('products')->name;
       }*/
     //$model = new Products();
     //$products = $model->getProdName($depId);
     $storageModel = Storage::model()->findAll();
     $balanceModel = Balance::model()->with('products')->findAll('b_date = :b_date', array(':b_date' => $dates));
     if (!empty($balanceModel)) {
         foreach ($balanceModel as $val) {
             $products[$val->prod_id] = $val->getRelated('products')->name;
             $Products[$val->prod_id] = $Products[$val->prod_id] + $val->startCount;
         }
     } else {
         foreach ($storageModel as $val) {
             $Products[$val->prod_id] = $Products[$val->prod_id] + $val->curCount;
         }
     }
     $realizedProd = Faktura::model()->with('realize.products')->findAll('date(realize_date) = :realize_date', array('realize_date' => $dates));
     foreach ($realizedProd as $value) {
         foreach ($value->getRelated('realize') as $val) {
             $Products[$val->prod_id] = $Products[$val->prod_id] + $val->count;
         }
     }
     $realizeStorageProd = DepFaktura::model()->with('realizedProd')->findAll('date(real_date) = :real_date AND fromDepId = :fromDepId', array(':real_date' => $dates, ':fromDepId' => 0));
     foreach ($realizeStorageProd as $value) {
         foreach ($value->getRelated('realizedProd') as $val) {
             $Products[$val->prod_id] = $Products[$val->prod_id] - $val->count;
         }
     }
     $expBalance = Yii::app()->db->createCommand()->select('ord.just_id,ord.count')->from('expense ex')->join('orders ord', 'ord.expense_id = ex.expense_id')->where('date(ex.order_date) = :dates AND ex.kind = :kind ', array(':dates' => $dates, ':kind' => 1))->queryAll();
     foreach ($expBalance as $val) {
         $Products[$val['just_id']] = $Products[$val['just_id']] - $val['count'];
     }
     $this->renderPartial('todayStorage', array('Products' => $Products, 'products' => $products, 'depId' => $depId));
 }
示例#3
0
文件: Iwi.php 项目: kilylabs/iwi
 /**
  * @return bool
  */
 public function createOrNone()
 {
     $this->verifyTable();
     if (!Storage::model()->findByAttributes(array('key' => $this->hash()))) {
         $storage = new Storage();
         $storage->key = $this->hash();
         $storage->value = json_encode($this->generateBrief());
         return $storage->save();
     }
     return false;
 }
 public function actionCalendarEvents()
 {
     $items = array();
     $model = Storage::model()->findAll();
     foreach ($model as $value) {
         $items[] = array('id' => $value->storage_id, 'url' => '#');
     }
     echo CJSON::encode($items);
     Yii::app()->end();
 }