コード例 #1
0
 public function actionCreate()
 {
     $model = new ProductAddition();
     $model->dpid = $this->companyId;
     $pslid = Yii::app()->request->getParam('psid');
     $model->mproduct_id = $pslid;
     if (Yii::app()->request->isPostRequest) {
         $model->attributes = Yii::app()->request->getPost('ProductAddition');
         //var_dump($model->attributes);exit;
         $se = new Sequence("product_addition");
         $model->lid = $se->nextval();
         $model->create_at = date('Y-m-d H:i:s', time());
         $model->update_at = date('Y-m-d H:i:s', time());
         $model->delete_flag = '0';
         //var_dump($model);exit;
         if ($model->save()) {
             Yii::app()->user->setFlash('success', yii::t('app', '添加成功'));
             $this->redirect(array('productAddition/detail', 'companyId' => $this->companyId, 'lid' => $model->mproduct_id));
         }
     }
     $categories = $this->getCategories();
     $categoryId = 0;
     $products = $this->getProducts($categoryId);
     $productslist = CHtml::listData($products, 'lid', 'product_name');
     $this->render('detailcreate', array('model' => $model, 'categories' => $categories, 'categoryId' => $categoryId, 'products' => $productslist));
 }
コード例 #2
0
ファイル: WMsg.php プロジェクト: song-yuan/wymenujp
 /**
  * 被下单、加菜、在线支付、信息反馈等调用
  * 对应的cmd分别是XD、JC、ZXZF、XXFK
  * data的格式按照接口文档封装
  */
 protected function saveMsg($cmd, $data)
 {
     $db = Yii::app()->db;
     $se = new Sequence("data_sync");
     $this->lid = $se->nextval();
     $sql = 'insert into nb_data_sync(lid,dpid,cmd_code,cmd_data,create_at,is_interface,sync_result) values(:lid,:dpid,:cmd_code,:cmd_data,sysdate(),:is_interface,:sync_result)';
     $command = $db->createCommand($sql);
     $command->bindValue(":lid", $this->lid);
     $command->bindValue(":dpid", $this->dpid);
     $command->bindValue(":cmd_code", $cmd);
     $command->bindValue(":cmd_data", $data);
     $command->bindValue(":is_interface", '1');
     $command->bindValue(":sync_result", '0');
     $command->execute();
     /*$ds=new DataSync;
       $se=new Sequence("data_sync");
       $this->lid = $se->nextval();
       $ds->dpid =  $this->dpid;
       $ds->lid = $this->lid;
       $ds->cmd_code = $cmd;
       $ds->cmd_data =$data;
       $ds->create_at = date('y-m-d h:i:s',time());
       $ds->is_interface = '1';
       $ds->sync_result = '0';
       $ds->save();*/
 }
コード例 #3
0
 public function actionCreate()
 {
     $model = new Product();
     $model->dpid = $this->companyId;
     //$model->create_time = time();
     if (Yii::app()->request->isPostRequest) {
         $model->attributes = Yii::app()->request->getPost('Product');
         $se = new Sequence("product");
         $model->lid = $se->nextval();
         $model->create_at = date('Y-m-d H:i:s', time());
         $model->update_at = date('Y-m-d H:i:s', time());
         $model->delete_flag = '0';
         $py = new Pinyin();
         $model->simple_code = $py->py($model->product_name);
         //var_dump($model);exit;
         if ($model->save()) {
             Yii::app()->user->setFlash('success', yii::t('app', '添加成功!'));
             $this->redirect(array('product/index', 'companyId' => $this->companyId));
         }
     }
     $categories = $this->getCategoryList();
     //$departments = $this->getDepartments();
     //echo 'ss';exit;
     $this->render('create', array('model' => $model, 'categories' => $categories));
 }
コード例 #4
0
 public function actionGetSitePersons()
 {
     $companyid = Yii::app()->request->getParam('companyid', 0);
     $padid = Yii::app()->request->getParam('padid', 0);
     $stlid = Yii::app()->request->getParam('stlid', 0);
     $splid = Yii::app()->request->getParam('splid', 0);
     $ret = array();
     $nowqueueno = "000";
     $queueno = "A001";
     $waitingno = 0;
     if (empty($companyid) || empty($padid)) {
         Yii::app()->end(json_encode(array('status' => false, 'msg' => '店铺或设备不存在!')));
     }
     $pad = Pad::model()->with("printer")->find(' t.dpid=:companyId and t.lid=:padid', array(':companyId' => $companyid, ':padid' => $padid));
     //var_dump($pad);exit;
     if (!empty($pad)) {
         //生成新的排队号
         $siteType = SiteType::model()->find(" dpid=:dpid and lid=:lid", array(":dpid" => $companyid, ":lid" => $stlid));
         //var_dump($siteType);exit;
         $criteria = new CDbCriteria();
         $criteria->condition = " dpid=" . $companyid . " and stlid=" . $stlid . " and splid=" . $splid . " and create_at >='" . date('Y-m-d', time()) . " 00:00:00' and create_at <='" . date('Y-m-d', time()) . " 23:59:59'";
         $criteria->order = ' lid ';
         $queuePerson = QueuePersons::model()->findAll($criteria);
         if (empty($siteType)) {
             Yii::app()->end(json_encode(array('status' => false, 'msg' => '座位类型不存在!')));
         }
         //var_dump($queuePerson);exit;
         if (!empty($queuePerson)) {
             $countsp = count($queuePerson);
             $queueno = $siteType->simplecode . substr("000" . (string) ($countsp + 1), -3);
             for ($sti = $countsp - 1; $sti >= 0; $sti--) {
                 if ($queuePerson[$sti]->status == "0") {
                     $waitingno++;
                 } else {
                     break;
                 }
             }
         } else {
             $queueno = $siteType->simplecode . "001";
             $waitingno = 0;
         }
         $se = new Sequence("queue_persons");
         $queuelid = $se->nextval();
         $data = array('lid' => $queuelid, 'dpid' => $companyid, 'create_at' => date('Y-m-d H:i:s', time()), 'update_at' => date('Y-m-d H:i:s', time()), 'stlid' => $stlid, 'splid' => $splid, 'queue_no' => $queueno, 'status' => '0', 'slid' => "0000000000", 'delete_flag' => '0');
         Yii::app()->db->createCommand()->insert('nb_queue_persons', $data);
         $waitingno++;
         //返回现有的等待人数
         $precode = "";
         $printserver = "0";
         //
         $memo = "排队号:" . $queueno . ",(还有" . $waitingno . "组在等待)";
         $ret = Helper::printQueue($pad, $precode, $printserver, $memo);
         if ($ret['status']) {
             $ret['waitingnum'] = $waitingno;
         }
     } else {
         $ret = array('status' => false, 'msg' => '没有找到PAD');
     }
     Yii::app()->end(json_encode($ret));
 }
コード例 #5
0
ファイル: SiteController.php プロジェクト: song-yuan/wymenujp
 public function actionCreate()
 {
     $typeId = Yii::app()->request->getParam('typeId', 0);
     $model = new Site();
     $model->dpid = $this->companyId;
     $model->type_id = $typeId;
     if (Yii::app()->request->isPostRequest) {
         $model->attributes = Yii::app()->request->getPost('Site');
         $se = new Sequence("site");
         $model->lid = $se->nextval();
         $model->create_at = date('Y-m-d H:i:s', time());
         $model->update_at = date('Y-m-d H:i:s', time());
         $model->delete_flag = '0';
         //var_dump($model);exit;
         if ($model->save()) {
             Yii::app()->user->setFlash('success', yii::t('app', '添加成功'));
             $this->redirect(array('site/index', 'typeId' => $typeId, 'companyId' => $this->companyId));
         }
     }
     $types = $this->getTypes();
     $floors = $this->getFloors();
     $sitepersons = $this->getSitePersons();
     //var_dump($floors);
     //var_dump($types);exit;
     $this->render('create', array('model' => $model, 'types' => $types, 'floors' => $floors, 'sitepersons' => $sitepersons));
 }
コード例 #6
0
ファイル: SequenceTest.php プロジェクト: amaivsimau/dojos
 public function testShouldGroupThreeGroupsElement()
 {
     $sequence = new Sequence([1, 2, 3, 5, 7]);
     $result = $sequence->group();
     $expected = [[1, 3], [5], [7]];
     $this->assertEquals($expected, $result);
 }
コード例 #7
0
ファイル: SequenceTest.php プロジェクト: nicoder/eris
 /**
  * @expectedException DomainException
  */
 public function testCannotShrinkSomethingThatIsNotContainedInDomain()
 {
     $aString = 'a string';
     $this->assertFalse($this->singleElementGenerator->contains($aString));
     $generator = new Sequence($this->singleElementGenerator);
     $generator->shrink([$aString]);
 }
コード例 #8
0
ファイル: BaseDataMsg.php プロジェクト: song-yuan/wymenujp
 public function saveCmd($cmd)
 {
     //$ds=new DataSync();
     $db = Yii::app()->db;
     $se = new Sequence("data_sync");
     $this->lid = $se->nextval();
     $sql = 'insert into nb_data_sync(lid,dpid,cmd_code,cmd_data,create_at,is_interface,sync_result) values(:lid,:dpid,:cmd_code,:cmd_data,sysdate(),:is_interface,:sync_result)';
     $command = $db->createCommand($sql);
     $command->bindValue(":lid", $this->lid);
     $command->bindValue(":dpid", $this->dpid);
     $command->bindValue(":cmd_code", $cmd);
     $command->bindValue(":cmd_data", '');
     $command->bindValue(":is_interface", '1');
     $command->bindValue(":sync_result", '0');
     $command->execute();
     /*
             $ds->dpid =  $this->dpid;
             $ds->lid = $this->lid;
             $ds->cmd_code = $cmd;
             $ds->cmd_data = '';
             $ds->create_at = date('y-m-d h:i:s',time());
             $ds->is_interface = '1';
             $ds->sync_result = '0';
             //var_dump($ds);
             if(!$ds->save())
             {
                 var_dump($ds->getErrors());
                 echo 'insert error!!!!';
             }*/
 }
コード例 #9
0
 public function beforeSave($data)
 {
     $defaults = array();
     $files = array();
     // set new sequential ID
     $sequence = new Sequence();
     $seq = $sequence->getNewId('property');
     $data['sequence'] = $seq;
     $data['propertyId'] = Config::get('ia.property_id_prefix') . $seq;
     if ($data['submit'] == 'Publish') {
         $data['publishStatus'] = 'published';
     } else {
         $data['publishStatus'] = 'draft';
     }
     $data['publishDate'] = $data['lastUpdate'];
     if (isset($data['file_id']) && count($data['file_id'])) {
         $data['defaultpic'] = isset($data['defaultpic']) ? $data['defaultpic'] : $data['file_id'][0];
         for ($i = 0; $i < count($data['thumbnail_url']); $i++) {
             if ($data['defaultpic'] == $data['file_id'][$i]) {
                 $defaults['thumbnail_url'] = $data['thumbnail_url'][$i];
                 $defaults['large_url'] = $data['large_url'][$i];
                 $defaults['medium_url'] = $data['medium_url'][$i];
             }
             $files[$data['file_id'][$i]]['thumbnail_url'] = $data['thumbnail_url'][$i];
             $files[$data['file_id'][$i]]['large_url'] = $data['large_url'][$i];
             $files[$data['file_id'][$i]]['medium_url'] = $data['medium_url'][$i];
             $files[$data['file_id'][$i]]['delete_type'] = $data['delete_type'][$i];
             $files[$data['file_id'][$i]]['delete_url'] = $data['delete_url'][$i];
             $files[$data['file_id'][$i]]['filename'] = $data['filename'][$i];
             $files[$data['file_id'][$i]]['filesize'] = $data['filesize'][$i];
             $files[$data['file_id'][$i]]['temp_dir'] = $data['temp_dir'][$i];
             $files[$data['file_id'][$i]]['filetype'] = $data['filetype'][$i];
             $files[$data['file_id'][$i]]['fileurl'] = $data['fileurl'][$i];
             $files[$data['file_id'][$i]]['file_id'] = $data['file_id'][$i];
             $files[$data['file_id'][$i]]['caption'] = $data['caption'][$i];
         }
     } else {
         $data['thumbnail_url'] = array();
         $data['large_url'] = array();
         $data['medium_url'] = array();
         $data['delete_type'] = array();
         $data['delete_url'] = array();
         $data['filename'] = array();
         $data['filesize'] = array();
         $data['temp_dir'] = array();
         $data['filetype'] = array();
         $data['fileurl'] = array();
         $data['file_id'] = array();
         $data['caption'] = array();
         $data['defaultpic'] = '';
     }
     $data['defaultpictures'] = $defaults;
     $data['files'] = $files;
     return $data;
 }
コード例 #10
0
 public function testInterviewQuestionA()
 {
     /*
        The sum of all natural numbers below 10 that are multiples of 3 or 5 are 23 (3 + 5 + 6 + 9)
        Write a php script that will find the sum of all the multiples of 3 or 5 below 1000. The script
        should run from command line and put the result on screen. We will judge this task based on
        simplicity, efficiency and cleverness of the code.
     */
     $limit = 1000;
     $values = range(0, $limit);
     $a = 3;
     $b = 5;
     $fnFilterMaker = function ($a, $b) {
         return function ($v) use($a, $b) {
             return $v % $a == 0 || $v % $b == 0;
         };
     };
     // test: sum of multiples of 3 or 5 below 10 is 23 (3 + 5 + 6 + 9)
     $this->assertTrue(Sequence::make(range(0, 9))->filter($fnFilterMaker(3, 5))->reduce(0, FnGen::fnSum()) == 23);
     $filteredValues = Sequence::make($values)->filter($fnFilterMaker($a, $b))->to_a();
     $this->assertArrayHasKey($a, $filteredValues);
     $this->assertArrayHasKey($b, $filteredValues);
     $this->assertArrayNotHasKey($a * $b + 1, $filteredValues);
     $valuesOnly = array_values($filteredValues);
     $subsetA = range(0, $limit, $a);
     $subsetB = range(0, $limit, $b);
     $this->assertTrue($subsetA == array_values(array_intersect($valuesOnly, $subsetA)));
     $this->assertTrue($subsetB == array_values(array_intersect($valuesOnly, $subsetB)));
     $this->assertTrue(!count(array_diff($valuesOnly, $subsetA, $subsetB)));
 }
コード例 #11
0
    function run($max_time) {
        global $cfg;

        $i18n = new Internationalization($cfg->get('system_language', 'en_US'));
        $sequences = $i18n->getTemplate('sequence.yaml')->getData();
        foreach ($sequences as $s) {
            Sequence::create($s)->save();
        }
        db_query('UPDATE '.SEQUENCE_TABLE.' SET `next`= '
            .'(SELECT MAX(ticket_id)+1 FROM '.TICKET_TABLE.') '
            .'WHERE `id`=1');

        require_once(INCLUDE_DIR . 'class.list.php');

        $lists = $i18n->getTemplate('list.yaml')->getData();
        foreach ($lists as $l) {
            DynamicList::create($l);
        }

        $statuses = $i18n->getTemplate('ticket_status.yaml')->getData();
        foreach ($statuses as $s) {
            TicketStatus::__create($s);
        }

        // Initialize MYSQL search backend
        MysqlSearchBackend::__init();
    }
コード例 #12
0
    public static function generateDatasetName() {
        $sequenceName = 'dataset.name';

        $datasetSuffixId = Sequence::getNextSequenceValue($sequenceName);
        $datasetSuffix = str_pad(base_convert($datasetSuffixId, 10, 36), self::$LENGTH_NAME__DATASET, '0', STR_PAD_LEFT);

        return self::$PREFIX_NAME__DATASET . $datasetSuffix;
    }
コード例 #13
0
 public function actionCreate()
 {
     $model = new Printer();
     $model->dpid = $this->companyId;
     if (Yii::app()->request->isPostRequest) {
         $model->attributes = Yii::app()->request->getPost('Printer');
         $se = new Sequence("printer");
         $model->lid = $se->nextval();
         $model->create_at = date('Y-m-d H:i:s', time());
         $model->update_at = date('Y-m-d H:i:s', time());
         $model->delete_flag = '0';
         if ($model->save()) {
             Yii::app()->user->setFlash('success', yii::t('app', '添加成功'));
             $this->redirect(array('printer/index', 'companyId' => $this->companyId));
         }
     }
     $this->render('create', array('model' => $model));
 }
    protected function getRequestId() {
        $requestId = &drupal_static(__CLASS__ . '::requestId');
        if (!isset($requestId)) {
            $sequenceName = NameSpaceHelper::addNameSpace(get_class($this), 'requestId');
            $requestId = Sequence::getNextSequenceValue($sequenceName);
        }

        return $requestId;
    }
コード例 #15
0
 public function actionCreate()
 {
     $companyId = Helper::getCompanyId(Yii::app()->request->getParam('companyId'));
     $model = new CompanyWifi();
     $model->dpid = $companyId;
     if (Yii::app()->request->isPostRequest) {
         $model->attributes = Yii::app()->request->getPost('CompanyWifi');
         $se = new Sequence("company_wifi");
         $model->lid = $se->nextval();
         $model->create_at = date('Y-m-d H:i:s');
         $model->update_at = date('Y-m-d H:i:s');
         if ($model->save()) {
             Yii::app()->user->setFlash('success', yii::t('app', '添加成功'));
             $this->redirect(array('companyWifi/index', 'companyId' => $companyId));
         }
     }
     $this->render('create', array('model' => $model));
 }
コード例 #16
0
 public function actionCreate()
 {
     $model = new SitePersons();
     $model->dpid = $this->companyId;
     if (Yii::app()->request->isPostRequest) {
         $model->attributes = Yii::app()->request->getPost('SitePersons');
         $se = new Sequence("site_type");
         $model->lid = $se->nextval();
         $model->create_at = date('Y-m-d H:i:s', time());
         $model->update_at = date('Y-m-d H:i:s', time());
         //var_dump($model);exit;
         if ($model->save()) {
             Yii::app()->user->setFlash('success', yii::t('app', '添加成功'));
             $this->redirect(array('sitePersons/index', 'companyId' => $this->companyId));
         }
     }
     $this->render('create', array('model' => $model));
 }
コード例 #17
0
 /**
  * @return TraverseSequence|MappedSequence
  */
 public function getChildren()
 {
     $x = $this->current();
     if ($this->canGoDeeper()) {
         return TraverseSequence::make($x, $this->key(), $this->pathSeparator)->setMaxDepth($this->depth - 1);
     } else {
         return IterationTraits::map(Sequence::make($x), FnGen::fnIdentity(), FnString::fnAddPrefix($this->key() . $this->pathSeparator));
     }
 }
コード例 #18
0
ファイル: FnStringTest.php プロジェクト: revinate/sequence
 public function testFnTrim()
 {
     $fn = FnString::fnTrim();
     $this->assertEquals('test', $fn('  test '));
     $array = array(' 352', '354 ', '333', ' 12 34 ', "\n  Cool Stuff  \n", "\r", "CRLF\r\n");
     $expectedTrimmedArray = array('352', '354', '333', '12 34', 'Cool Stuff', '', 'CRLF');
     $this->assertNotEquals($array, $expectedTrimmedArray);
     $trimmedArray = Sequence::make($array)->map(FnString::fnTrim())->to_a();
     $this->assertEquals($trimmedArray, $expectedTrimmedArray);
 }
コード例 #19
0
ファイル: FnReduceTest.php プロジェクト: revinate/sequence
 public function testFnAvg()
 {
     $range = range(1, 10);
     $this->assertEquals(5.5, Sequence::make($range)->reduce(0, FnGen::fnAvg()));
     $fruit = array(array('name' => 'apple', 'count' => 1), array('name' => 'orange', 'count' => 5), array('name' => 'apple', 'count' => 3), array('name' => 'banana', 'count' => 9), array('name' => 'Out of Stock'), array('name' => 'orange', 'count' => 5));
     $counts = Sequence::make($fruit)->map(FnGen::fnPluck('count'))->filter(FnGen::fnKeepIsSet())->to_a();
     $avg = array_sum($counts) / count($counts);
     $avg2 = Sequence::make($fruit)->reduce(0, FnReduce::fnAvg(FnGen::fnPluck('count')));
     $this->assertEquals($avg, $avg2);
 }
コード例 #20
0
 public function actionCreate()
 {
     $companyId = Helper::getCompanyId(Yii::app()->request->getParam('companyId'));
     $model = new PaymentMethod();
     $model->dpid = $companyId;
     if (Yii::app()->request->isPostRequest) {
         $model->attributes = Yii::app()->request->getPost('PaymentMethod');
         $se = new Sequence("payment_method");
         $model->lid = $se->nextval();
         $model->create_at = date('Y-m-d H:i:s');
         $model->update_at = date('Y-m-d H:i:s', time());
         //			var_dump($model->attributes);exit;
         if ($model->save()) {
             Yii::app()->user->setFlash('success', yii::t('app', '添加成功'));
             $this->redirect(array('payMethod/index', 'companyId' => $companyId));
         }
     }
     $this->render('create', array('model' => $model));
 }
コード例 #21
0
ファイル: unick.php プロジェクト: infrajs/layer-unick
 public static function &find($name, $value)
 {
     $right = Sequence::right($name);
     return Controller::run(static::$layers, function &(&$layer) use($right, $value) {
         if (Sequence::get($layer, $right) == $value) {
             return $layer;
         }
         $r = null;
         return $r;
     });
 }
コード例 #22
0
 public function actionCreate()
 {
     $allflag = Yii::app()->request->getParam('allflag', 0);
     $model = new Feedback();
     $model->dpid = $this->companyId;
     if (Yii::app()->request->isPostRequest) {
         $model->attributes = Yii::app()->request->getPost('Feedback');
         $se = new Sequence("feedback");
         $model->lid = $se->nextval();
         $model->allflag = $allflag;
         $model->create_at = date('Y-m-d H:i:s', time());
         $model->update_at = date('Y-m-d H:i:s', time());
         $model->delete_flag = '0';
         //var_dump($model);exit;
         if ($model->save()) {
             Yii::app()->user->setFlash('success', yii::t('app', '添加成功'));
             $this->redirect(array('feedback/index', 'companyId' => $this->companyId, 'allflag' => $allflag));
         }
     }
     $this->render('create', array('model' => $model, 'allflag' => $allflag));
 }
コード例 #23
0
 public function actionCreate()
 {
     $this->layout = '/layouts/main_picture';
     $pid = Yii::app()->request->getParam('pid', 0);
     $model = new ProductCategory();
     $model->dpid = $this->companyId;
     if ($pid) {
         $model->pid = $pid;
     }
     if (Yii::app()->request->isPostRequest) {
         $model->attributes = Yii::app()->request->getPost('ProductCategory');
         $category = ProductCategory::model()->find('dpid=:dpid and category_name=:name and delete_flag=0', array(':dpid' => $this->companyId, ':name' => $model->category_name));
         if ($category) {
             $this->redirect(array('productCategory/index', 'id' => $category->lid, 'companyId' => $this->companyId));
         }
         $se = new Sequence("product_category");
         $model->lid = $se->nextval();
         $model->create_at = date('Y-m-d H:i:s', time());
         $model->delete_flag = '0';
         $model->update_at = date('Y-m-d H:i:s', time());
         if ($model->save()) {
             //var_dump($model);exit;
             $self = ProductCategory::model()->find('lid=:pid and dpid=:dpid', array(':pid' => $model->lid, ':dpid' => $this->companyId));
             if ($self->pid != '0') {
                 $parent = ProductCategory::model()->find('lid=:pid and dpid=:dpid', array(':pid' => $model->pid, ':dpid' => $this->companyId));
                 $self->tree = $parent->tree . ',' . $self->lid;
             } else {
                 $self->tree = '0,' . $self->lid;
             }
             //var_dump($model);exit;
             $self->update();
             Yii::app()->user->setFlash('success', yii::t('app', '添加成功'));
             $this->redirect(array('productCategory/index', 'id' => $self->lid, 'companyId' => $this->companyId));
         } else {
             Yii::app()->user->setFlash('error', yii::t('app', '添加失败'));
             $this->redirect(array('productCategory/index', 'companyId' => $this->companyId));
         }
     }
     $this->render('_form1', array('model' => $model, 'action' => $this->createUrl('productCategory/create', array('companyId' => $this->companyId))));
 }
コード例 #24
0
 public function prepareDimension(MetaModel $metamodel, DatasetMetaData $dataset, $columnName, CubeMetaData $cube)
 {
     $column = $dataset->getColumn($columnName);
     $sourceDatasetColumn = $cube->sourceDataset->getColumn($columnName);
     $dimension = $cube->getDimension($columnName);
     $this->prepareYearLevel($dimension, $column);
     // cube source dataset column contains a reference to year identifier
     $sourceDatasetColumn->initializeTypeFrom(Sequence::getSequenceColumnType());
     // adding a reference to date dataset
     $referenceName = DateDimensionDatasetNames::LEVEL_YEARS;
     $metamodel->registerSimpleReferencePoint($referenceName, DateDimensionDatasetNames::LEVEL_YEARS, 'year_id');
     $metamodel->registerSimpleReferencePoint($referenceName, $cube->sourceDatasetName, $columnName);
 }
コード例 #25
0
 public function actionCreate()
 {
     $productId = Yii::app()->request->getParam('productId');
     $model = new ProductDiscount();
     $model->dpid = $this->companyId;
     $product = Product::model()->find('lid=:lid and dpid=:dpid and delete_flag=0', array(':lid' => $productId, ':dpid' => $this->companyId));
     //		$productSets = ProductSet::model()->findAll('dpid=:dpid and delete_flag=0 and is_discount=1 and status=0',array(':dpid'=>$this->companyId));
     if (Yii::app()->request->isPostRequest) {
         $postData = Yii::app()->request->getPost('ProductDiscount');
         $model->attributes = $postData;
         $se = new Sequence("retreat");
         $model->lid = $se->nextval();
         $model->create_at = date('Y-m-d H:i:s', time());
         $model->update_at = date('Y-m-d H:i:s', time());
         if ($model->save()) {
             Yii::app()->user->setFlash('success', yii::t('app', '添加成功'));
             $this->redirect(array('productSales/updatedetail', 'companyId' => $this->companyId, 'id' => $productId));
         }
     }
     //		var_dump($products);exit;
     $this->render('create', array('model' => $model, 'product' => $product));
 }
    public function prepareDimension(MetaModel $metamodel, DatasetMetaData $dataset, $columnName, CubeMetaData $cube) {
        $logicalColumn = $dataset->getColumn($columnName);
        $column = $cube->factsDataset->getColumn($columnName);
        $dimension = $cube->getDimension($columnName);

        // preparing the dimension properties
        $dimension->attributeColumnName = $columnName;
        $dimension->setDatasetName(StarSchemaNamingConvention::getAttributeRelatedName($dataset->name, $columnName));

        // preparing dimension dataset
        $dimension->dataset = new DatasetMetaData();
        $dimension->dataset->name = $dimension->datasetName;
        $dimension->dataset->publicName = $dataset->publicName . " [$logicalColumn->publicName]";
        $dimension->dataset->description = t("Lookup table to store unique values from '@columnName' column", array('@columnName' => $logicalColumn->publicName));
        $dimension->dataset->datasourceName = $dataset->datasourceName;
        $dimension->dataset->source = StarSchemaNamingConvention::getAttributeRelatedName($dataset->source, $columnName);
        $dimension->dataset->markAsPrivate();
        // adding dimension dataset aliases
        if (isset($dataset->aliases)) {
            foreach ($dataset->aliases as $alias) {
                $dimension->dataset->aliases[] = StarSchemaNamingConvention::getAttributeRelatedName($alias, $columnName);
            }
        }

        // adding key column
        $keyColumn = $dimension->dataset->registerColumn($columnName);
        $keyColumn->publicName = $logicalColumn->publicName;
        $keyColumn->description = t("System generated ID to identify each unique value from '@columnName' column", array('@columnName' => $logicalColumn->publicName));
        $keyColumn->initializeTypeFrom(Sequence::getSequenceColumnType());
        $keyColumn->key = TRUE;
        $keyColumn->visible = FALSE;
        
        // adding 'value' column
        $valueColumn = $dimension->dataset->registerColumn('value');
        $valueColumn->publicName = $logicalColumn->publicName;
        $valueColumn->description = t("Actual value from '@columnName' column", array('@columnName' => $logicalColumn->publicName));
        $valueColumn->initializeTypeFrom($logicalColumn->type);

        // facts dataset column contains a reference to lookup
        $column->initializeTypeFrom(Sequence::getSequenceColumnType());
        $column->type->logicalApplicationType = StringDataTypeHandler::DATA_TYPE;

        // marking that the dimension dataset object contains complete meta data & registering it in meta model
        $dimension->dataset->markAsComplete();
        $metamodel->registerDataset($dimension->dataset);

        // adding a reference to the dimension dataset
        $referenceName = $dimension->datasetName;
        $metamodel->registerSimpleReferencePoint($referenceName, $dimension->datasetName, $columnName);
        $metamodel->registerSimpleReferencePoint($referenceName, $cube->factsDatasetName, $columnName);
    }
コード例 #27
0
ファイル: Flattener.class.php プロジェクト: xp-forge/sequence
 /**
  * Returns the iterator for the next sequence, or NULL if the end of
  * the outer iterator has been reached.
  *
  * @return  php.Iterator
  */
 protected function sequence()
 {
     while ($this->it->valid()) {
         $value = $this->it->current();
         $seq = $value instanceof Sequence ? $value->getIterator() : Sequence::of($value)->getIterator();
         $seq->rewind();
         if ($seq->valid()) {
             return $seq;
         } else {
             $this->it->next();
         }
     }
     return null;
 }
コード例 #28
0
ファイル: UserForm.php プロジェクト: song-yuan/wymenujp
 public function save()
 {
     if ($this->lid) {
         $model = User::model()->find('lid=:id', array(':id' => $this->lid));
     } else {
         $model = new User();
         $se = new Sequence("user");
         $model->lid = $se->nextval();
         $model->create_at = date('Y-m-d H:i:s', time());
         $model->delete_flag = '0';
         //$model->lid = $this->getPkValue();
     }
     $model->username = $this->username;
     $model->mobile = $this->mobile;
     $model->staff_no = $this->staff_no;
     $model->email = $this->email;
     $model->role = $this->role;
     $model->dpid = $this->dpid;
     $model->status = 1;
     if ($this->password_old != $this->password) {
         $model->password_hash = $this->password;
     }
     if ($model->validate()) {
         if ($this->password_old != $this->password) {
             $model->password_hash = Helper::genPassword($this->password);
         }
         //var_dump($model);exit;
         $model->save();
         return true;
     } else {
         $this->addErrors($model->getErrors());
         if ($passwordError = $model->getError('password_hash')) {
             $this->addError('password', $passwordError);
         }
         return false;
     }
 }
コード例 #29
0
 /**
  * Ajax: GET|POST /sequence/manage
  *
  * Gets a dialog box content or updates data from the content
  *
  * Post-Arguments:
  * seq[<id>][*] - Updated information for existing sequences
  * seq[<new-*>[*] - Information for new sequences
  * seq[<id>][deleted] - If set to true, indicates that the sequence
  *      should be deleted from the database
  *
  * Throws:
  * 403 - Not logged in
  * 422 - Information sent for update of unknown sequence
  */
 function manage()
 {
     global $thisstaff;
     if (!$thisstaff) {
         Http::response(403, 'Login required');
     }
     $sequences = Sequence::objects()->all();
     $info = array('action' => '#sequence/manage');
     $valid = true;
     if ($_POST) {
         foreach ($_POST['seq'] as $id => $info) {
             if (strpos($id, 'new-') === 0) {
                 unset($info['id']);
                 $sequences[] = Sequence::create($info);
             } else {
                 foreach ($sequences as $s) {
                     if ($s->id == $id) {
                         break;
                     }
                     $s = false;
                 }
                 if (!$s) {
                     Http::response(422, $id . ': Invalid or unknown sequence');
                 } elseif ($info['deleted']) {
                     $s->delete();
                     continue;
                 }
                 foreach ($info as $f => $val) {
                     if (isset($s->{$f})) {
                         $s->set($f, $val);
                     } elseif ($f == 'current') {
                         $s->next = $val;
                     }
                 }
                 if (($v = $s->isValid()) !== true) {
                     $msg = sprintf('%s: %s', $s->getName(), $valid);
                     $valid = false;
                 }
             }
         }
         if ($valid) {
             foreach ($sequences as $s) {
                 $s->save();
             }
             Http::response(205, 'All sequences updated');
         }
     }
     include STAFFINC_DIR . 'templates/sequence-manage.tmpl.php';
 }
コード例 #30
0
 public function getAttributes($args = array(), $alias = null)
 {
     $attributes = $this->attributes;
     if ($alias !== null) {
         if (!isset($this->aliases[$alias])) {
             throw new FactoryException(\Yii::t(Factory::LOG_CATEGORY, 'Alias "{alias}" not found for class "{class}"', array('{alias}' => $alias, '{class}' => $this->className)));
         }
         $attributes = array_merge($attributes, $this->aliases[$alias]);
     }
     $attributes = array_merge($attributes, $args);
     foreach ($attributes as $key => $value) {
         $attributes[$key] = is_object($value) ? $value : Sequence::get($value);
     }
     return $attributes;
 }