Beispiel #1
0
 protected function find()
 {
     $this->startKeyInDate = Input::get('start');
     $this->endKeyInDate = Input::get('end');
     if (!empty($this->startKeyInDate) && !empty($this->endKeyInDate)) {
         if ($this->endKeyInDate < $this->startKeyInDate) {
             $tmp = $this->startKeyInDate;
             $this->startKeyInDate = $this->endKeyInDate;
             $this->endKeyInDate = $tmp;
         }
     }
     $q = Processor::table('CCS_OrderDivIndex WITH(NOLOCK)')->select(DB::raw("MAX(CCS_OrderIndex.OrderNo) AS 單號,MAX(CCS_OrderIndex.KeyInDate) AS 出貨日,MAX(CCS_OrderIndex.OrderDate) AS 訂單日,MAX(CCS_OrderDivIndex.IndexSerNo) AS 流水號,MAX(CCS_OrderIndex.MustPayTotal) AS 應付帳款, MAX(POS_Member.Name) AS 會員姓名,COUNT(*) AS 分寄單數, MAX(CCS_OrderIndex.VerifyDate) AS 覆核日, MAX(CCS_OrderIndex.Status) AS 狀態, MAX(CCS_OrderDivIndex.City) AS 縣市, MAX(CCS_OrderDivIndex.Town) AS 區, MAX(CCS_OrderDivIndex.Address) AS 地址"))->leftJoin('CCS_OrderIndex WITH(NOLOCK)', 'CCS_OrderIndex.SerNo', '=', 'CCS_OrderDivIndex.IndexSerNo')->leftJoin('POS_Member WITH(NOLOCK)', 'POS_Member.SerNo', '=', 'CCS_OrderIndex.MemberSerNo')->groupBy('CCS_OrderDivIndex.IndexSerNo')->orderBy('MAX(CCS_OrderIndex.KeyInDate)');
     if (!empty($this->startKeyInDate)) {
         $q->where('CCS_OrderIndex.KeyInDate', '>=', $this->startKeyInDate);
     }
     if (!empty($this->endKeyInDate)) {
         $q->where('CCS_OrderIndex.KeyInDate', '<=', $this->endKeyInDate);
     }
     if (empty($this->startKeyInDate) && empty($this->endKeyInDate)) {
         $this->startKeyInDate = Carbon::now()->format('Ymd');
         $this->endKeyInDate = Carbon::now()->format('Ymd');
         $q->where('CCS_OrderIndex.KeyInDate', '>=', $this->startKeyInDate);
         $q->where('CCS_OrderIndex.KeyInDate', '<=', $this->endKeyInDate);
     }
     $result = Processor::getArrayResult($q);
     return array_values($this->filter($result));
 }
Beispiel #2
0
 public function insertProc(PosMemberImportContent $content)
 {
     $row = array_get(Processor::getArrayResult('SELECT * FROM dbo.chinghwa_fnGetCMemberSerNoByTable()'), 0);
     list($content->serno, $content->code, $content->sernoi) = array_values($row);
     Processor::execErp($this->getInsertProcQuery($content));
     return $this->memberflagUpdateProc($content)->contentUpdateProc($content);
 }
 public function rollback()
 {
     $members = Processor::getArrayResult("SELECT TOP 3000 * FROM POS_Member WITH(NOLOCK) WHERE Code LIKE 'T%' AND CRT_TIME>= '2016-02-18 00:00:00' ORDER BY SerNo DESC");
     foreach ($members as $member) {
         print "EXEC dbo.sp_DeleteHBMember '{$member['SerNo']}'<br/>";
     }
     return '<hr>請將畫面上的SQL語句貼在欲直行的資料庫進行還原~';
 }
 public function index()
 {
     $corpCodes = explode(',', env('CORPS'));
     $emps = HRS_Employee::findByCorps($corpCodes);
     $corps = Processor::getArrayResult(Processor::table('FAS_Corp')->select('Name, Code')->whereIn('Code', $corpCodes));
     $campaigns = Campaign::findValid();
     return view('report.ctilayout.index', ['corps' => $corps, 'empCorpGroups' => array_group($emps, 'FName'), 'campaigns' => $campaigns]);
 }
Beispiel #5
0
 public function import()
 {
     $insertRows = Processor::getArrayResult($this->getUserDataQuery());
     foreach ($insertRows as $row) {
         $this->insert($row);
     }
     Session::flash('success', '輔翼使用者資料匯入完成');
     return redirect('user');
 }
 protected function fetchEachMonthData($dateString)
 {
     $data = [];
     for ($i = 0; $i < 12; $i++) {
         $date = with(new Carbon($dateString))->modify("+ {$i} months");
         $data[] = Processor::getArrayResult($this->getFetchQuery($date->modify('first day of this month')->format('Ymd'), $date->modify('last day of this month')->format('Ymd')));
     }
     return $data;
 }
 public function copy(array $codes)
 {
     foreach ($codes as $code) {
         $lastSerNo = array_get(Processor::getArrayResult($this->genFetchLastSerNoQuery()), '0.SerNo');
         $row = Processor::getArrayResult($this->genSelectQuery([$code]));
         Processor::execErp($this->genInsertQuery($row[0], $lastSerNo));
     }
     return $this;
 }
Beispiel #8
0
 /**
  * Memory leak caused by Sys_DMTaskInfo.maintain, it contains strange sp...
  */
 protected function compareDisplay($columnName, $tableName)
 {
     $c = Processor::getArrayResult("SELECT TOP 1 [{$columnName}] FROM {$tableName} WITH(NOLOCK)");
     $serNo = array_get($c, "0.{$columnName}", null);
     if ($this->isTarget($columnName, $serNo)) {
         echo '記憶體使用:' . memory_get_usage() . ':';
         echo $serNo . ':';
         echo $columnName . ':';
         echo $tableName . "<br />";
     }
 }
Beispiel #9
0
 public function backmail()
 {
     set_time_limit(0);
     $startTime = microtime(true);
     $chunkSize = 200;
     $r = explode(',', file_get_contents(__DIR__ . '/backemail.txt'));
     $realGetCountTotal = 0;
     $totalNum = count($r);
     for ($i = 0; $i < $totalNum; $i = $i + $chunkSize) {
         $partialArr = array_slice($r, $i, $chunkSize);
         $data = Processor::getArrayResult($this->getQuery($partialArr));
         $realGetCount = count($data);
         echo "{$i}:realGet:{$realGetCount}<br/>";
         Processor::execErp($this->getUpdateQuery(array_pluck($data, 'SerNo')));
         $realGetCountTotal += $realGetCount;
     }
     $endTime = microtime(true);
     dd("費時:" . floor($endTime - $startTime) . ",共計{$realGetCountTotal}人");
 }
Beispiel #10
0
 protected function fetchEng()
 {
     $whereStr = $this->getCriteria()->apply($this->getOptions())->getWhereStr();
     return Processor::getArrayResult($this->genAndGetEngSql($whereStr), Processor::DB_CTI);
 }
Beispiel #11
0
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function angular()
 {
     try {
         $data = Processor::getArrayResult($this->getMarqQuery());
         $count = count($data);
         $offset = Input::get('offset', 0);
         $data = array_slice($data, $offset, 8);
         $this->extendMarqTarget($data);
         return view('board.marq.rivets', ['data' => json_encode($data), 'offset' => $offset + 5]);
     } catch (\Exception $e) {
     }
 }
Beispiel #12
0
 protected function fetchEntitysCountImplement($flag = 'Erp')
 {
     $sql = str_replace(['$mdtTime', '$dependLimitTime'], [$this->mdtTime->format('Y-m-d H:i:s'), $this->dependLimitTime->format('Y-m-d H:i:s')], Processor::getStorageSql("FV/Sync/{$this->type}_count.sql"));
     return array_get(Processor::getArrayResult($sql, $flag), 0)['_count'];
 }
Beispiel #13
0
 public function fetchTargetCount()
 {
     $sql = str_replace(['$date', '$serno'], [$this->_getSpecificDateStr(), MemberCode::genSerNoStr(1)], Processor::getStorageSql('FV/Import/list_and_log_target_count.sql'));
     return array_get(Processor::getArrayResult($sql), 0)['_count'];
 }
Beispiel #14
0
 /**
  * Handle the event.
  *
  * @param  FindEvent  $event
  * @return void
  */
 public function handle(Event $event)
 {
     $codes = $event->getCodes();
     return $event->setGoodses(Processor::getArrayResult($this->getQuery($codes)));
 }
Beispiel #15
0
 protected function findLatestCCode()
 {
     return Processor::getArrayResult($this->getFindLatestCCodeQuery());
 }
Beispiel #16
0
 public function fetchErpGroups($startDate, $endDate)
 {
     $this->erpGroups = $this->splitErpDataByGroup(Processor::getArrayResult($this->getQuery('ERP', $startDate, $endDate), 'Erp'));
     return $this;
 }
Beispiel #17
0
 protected function fetchMembers(array $ids)
 {
     $whereCondition = 'WHERE POS_Member.Code IN(' . sqlInWrap($ids) . ')';
     return Processor::getArrayResult(str_replace(['$whereCondition', '$begin', '$end'], [$whereCondition, 0, self::MAX_LIMIT_ROWS], Processor::getStorageSql('FV/Import/member.sql')));
 }
Beispiel #18
0
 protected function getExistCtCodes(Event $event)
 {
     return array_pluck(Processor::getArrayResult($this->getQuery($this->genCtPrefixCodes($event))), 'Code');
 }
Beispiel #19
0
 public static function findValid()
 {
     return Processor::getArrayResult(Processor::table('Campaign')->select('*')->where('Campaign.Enabled', '=', 1)->where('Campaign.StartDate', '<=', Carbon::now()->format('Ymd'))->where('Campaign.EndDate', '>=', Carbon::now()->format('Ymd')), 'Cti');
 }
Beispiel #20
0
 public static function findByCorps(array $corps)
 {
     $q = Processor::table('HRS_Employee')->select(DB::raw('HRS_Employee.Code, HRS_Employee.Name, FAS_Corp.Code AS FCode, FAS_Corp.Name AS FName'))->leftJoin('FAS_Corp', 'HRS_Employee.CorpSerNo', '=', 'FAS_Corp.SerNo')->whereIn('FAS_Corp.Code', $corps)->where('HRS_Employee.Leave', '=', 0)->orderBy('FAS_Corp.Code', 'ASC')->orderBy('HRS_Employee.Code', 'ASC');
     return Processor::getArrayResult($q);
 }
Beispiel #21
0
 public static function getCategorySerNo($str)
 {
     $q = Processor::table('POS_MemberCategory')->select('TOP 1 SerNo')->where('Code', '=', $str);
     return array_get(Processor::getArrayResult($q), '0.SerNo');
 }
Beispiel #22
0
 public static function fetchCtiRes(array $options)
 {
     $selectStr = 'DataSchema.SchemaCD,DataSchema.SchemaName,CampaignCallList.CampaignCD,CampaignCallList.CampaignName,Campaign.StartDate,Campaign.EndDate,CampaignCallList.AgentCD,CampaignCallList.AgentName,CampaignCallList.CustName,CampaignCallList.ID,CampaignCallList.Tel1,CampaignCallList.Tel2,CampaignCallList.Tel3,CampaignCallList.TelHistory,CampaignCallList.StatusCD,CampaignCallList.StatusName,CampaignCallList.ResultCD,CampaignCallList.ResultName,CampaignCallList.SourceCD,CampaignCallList.FollowupDate,CampaignCallList.DialingTime,CampaignCallList.Payday,CampaignCallList.AssignDate,CampaignCallList.Data01,CampaignCallList.Data02,CampaignCallList.Data03,CampaignCallList.Data04,CampaignCallList.Data05,CampaignCallList.Data06,CampaignCallList.Data08,CampaignCallList.Data09,CampaignCallList.Data11,CampaignCallList.Data12,CampaignCallList.Data15,CampaignCallList.Data16,CampaignCallList.Data17,CampaignCallList.Data20,CampaignCallList.Note,CampaignCallList.modified_by,CampaignCallList.modified_at,CampaignCallList.created_by,CampaignCallList.created_at';
     $q = Processor::table('CampaignCallList WITH(NOLOCK)')->select($selectStr)->leftJoin('Campaign', 'CampaignCallList.CampaignCD', '=', 'Campaign.CampaignCD')->leftJoin('DataSchema', 'Campaign.DefSchemaCD', '=', 'DataSchema.SchemaCD');
     return Processor::getArrayResult(self::condition($q, $options), 'Cti');
 }
Beispiel #23
0
 protected function fetchCampaignsCount()
 {
     $sql = str_replace(['$yesterday', '$tomorrow'], [Carbon::now()->format('Y-m-d H:i:s'), Carbon::now()->format('Y-m-d H:i:s')], Processor::getStorageSql('FV/Import/campaign_count.sql'));
     return array_get(Processor::getArrayResult($sql, Processor::DB_CTI), 0)['_count'];
 }
Beispiel #24
0
 protected function fetchMembers(array $chunk)
 {
     return Processor::getArrayResult(str_replace('$memberCode', sqlInWrap($chunk), Processor::getStorageSql('CTILayout.sql')));
 }
Beispiel #25
0
 protected function getNextCTOrderNo($ctOrderNo)
 {
     $res = Processor::getArrayResult("SELECT TOP 1 * FROM CCS_OrderIndex WHERE OrderNo='{$ctOrderNo}' ORDER BY SerNo DESC");
     $numPart = substr(array_get($res, '0.OrderNo'), 2);
     return self::COMETRUES_PREFIX . ++$numPart;
 }
 public function index()
 {
     dd(Processor::getArrayResult("select * FROM [dbo].[lubri_DSR_Product]('20160522', '20160531')"));
 }
 protected function getThisYearRetailSaleRes()
 {
     $startDate = with(new Carbon('first day of january'))->format('Ymd');
     $endDate = with(new Carbon('last day of last month'))->format('Ymd');
     return Processor::getArrayResult($this->getRetailSaleQuery($startDate, $endDate), 'pos');
 }
 protected function fetch($promoteQ)
 {
     $query = $this->getQuery($this->getDateString($promoteQ, 'start_at', self::DEFAULT_START), $this->getDateString($promoteQ, 'end_at', self::DEFAULT_END), array_get($promoteQ, 'code', self::DEFAULT_CODE));
     return Processor::getArrayResult($query);
 }
Beispiel #29
0
 public static function find(array $options)
 {
     return Processor::getArrayResult(self::getBase($options)->select('*'));
 }
Beispiel #30
0
 public function get(User $user)
 {
     return Processor::getArrayResult($this->getQb($user));
 }