/** * 取得異匯異動金額 * @param type $ary = array ('Z01'=>1, 'Z02'=>1); * @return int */ public function getMoneyChange($ary) { $sum = 0; $service = TbsService::model()->findAllByAttributes(array('type1' => '6')); if (count($service) > 0) { foreach ($service as $row) { if (isset($ary[$row->serviceno])) { $sum = $sum + $ary[$row->serviceno] * $row->chgprice; } } } return $sum; }
/** * 取得販賣金額(染膏燙劑) * 門市販賣.沒有設計師抽成的商品 * @param type $ary = array ('N011'=>1, 'N012'=>1); * @return int */ public function getRpt11MoneySellandReduce($ary) { $str['sum'] = 0; $str['sum2'] = 0; $str['item'] = ''; $str['item2'] = ''; $service = TbsService::model()->findAllByAttributes(array(), $conditon = " type1 =4 and price!=0 "); if (count($service) > 0) { foreach ($service as $row) { if (isset($ary[$row->serviceno])) { if ($row->price != 0) { $str['sum'] = $str['sum'] + $ary[$row->serviceno] * $row->price; $str['item'] .= $row->cname . ':' . $ary[$row->serviceno]; } } } } $service2 = TbsService::model()->findAllByAttributes(array('type1' => '5')); if (count($service2) > 0) { foreach ($service2 as $row) { if (isset($ary[$row->serviceno])) { // print_r ($row->serviceno.' '.$row->noreceive.'<br>'); $data = TbsService::model()->findByAttributes(array('serviceno' => $row->noreceive)); if ($data != NULL) { $str['sum'] = $str['sum'] + $ary[$row->serviceno] * $data->price; $str['item'] .= '少收' . $data->cname . ':' . $ary[$row->serviceno]; } } } //foreach ($service2 as $row) { } //if(count($service2)>0){ $service3 = TbsService::model()->findAllByAttributes(array('type1' => '6')); if (count($service3) > 0) { foreach ($service3 as $row) { if (isset($ary[$row->serviceno])) { // print_r ($row->serviceno.' '.$row->noreceive.'<br>'); $data = TbsService::model()->findByAttributes(array('serviceno' => $row->serviceno)); if ($data != NULL) { $str['sum2'] = $str['sum2'] + $ary[$row->serviceno] * $data->chgprice; $str['item2'] .= '優待票' . $data->cname . ':' . $ary[$row->serviceno]; } } } //foreach ($service3 as $row) { } //if(count($service3)>0){ return $str; }
/** * * @param type $emplog - 員工資料 * @param type $stores - 門市陣列 * @param type $qry_dateS - 起 * @param type $qry_dateE - 訖 * @return type */ private function getDailyData($emplog) { //輸出陣列 $colAry = array(); //CVarDumper::dump($emplog,10,true); //每一行的陣列 $Arylog = array(); //儲存serviceno的金額 $Aryprice = array(); $servicenoPrice = TbsService::model()->findAllByAttributes(array(), $condition = "type1 != 5 AND opt1 = '1' ORDER BY serviceno "); //得到serviceno對應price if (count($servicenoPrice > 0)) { $temp = array(); for ($i = 0; $i < count($servicenoPrice); $i++) { $temp[$servicenoPrice[$i]->serviceno] = $servicenoPrice[$i]->price; //編號=>金額 } array_push($Aryprice, $temp); } unset($servicenoPrice); if (count($emplog > 0)) { if (isset($emplog[0]['pdate']) or isset($emplog[0]['storecode'])) { $day = $emplog[0]['pdate']; $storecode = $emplog[0]['storecode']; //流水號初始值 // static $count = 1; // 每一行的陣列 $row = array(); for ($i = 0; $i < count($emplog); $i++) { if ($emplog[$i]['pdate'] == $day and $emplog[$i]['storecode'] == $storecode) { // $row['receiptno'] = $emplog[$i]['pdate'].'00'.$count; $row['receiptno'] = $emplog[$i]['pdate'] . $emplog[$i]['storecode']; } else { //$count++; //累積流水號 $day = $emplog[$i]['pdate']; //day設成進來的日期 $storecode = $emplog[$i]['storecode']; //storecode設成進來的店編 //$row['receiptno'] = $emplog[$i]['pdate'].'00'.$count; $row['receiptno'] = $emplog[$i]['pdate'] . $emplog[$i]['storecode']; } $row['pdate'] = $emplog[$i]['pdate']; $row['personno'] = $emplog[$i]['storecode']; $row['sales'] = $emplog[$i]['storecode']; $row['storecode'] = $emplog[$i]['storecode']; $row['currency'] = 'NTD'; $row['price'] = '1'; $row['taxclass'] = '4'; // $logAry[$emplog[$i]['serviceno']] = $emplog[$i]['num']; $row['amount'] = $emplog[$i]['num']; //得到服務編碼 $serno = $emplog[$i]['serviceno']; // 取得選取的服務項目產生欄位 $serviceno = TbsService::model()->findByAttributes(array(), $condition = "serviceno = '{$serno}' AND opt1 = '1' ORDER BY serviceno "); $row['warehouseno'] = $emplog[$i]['storecode']; $row['old_productno'] = $emplog[$i]['serviceno']; if (isset($serviceno)) { //轉成mappingno $row['productno'] = $serviceno->mappingno; //得到單價 if ($serviceno->type1 == 5) { //為了細項描述寫的 $row['co25'] = $serviceno->cname; foreach ($Aryprice as $value) { $row['uprice'] = $value[$serviceno->noreceive]; } } else { $row['uprice'] = $serviceno->price; } //得到金額 $row['total'] = $row['amount'] * $row['uprice']; //是否贈品 if ($serviceno->opt2 == 1) { $row['gift'] = 1; } else { $row['gift'] = 0; } } //if(isset($serviceno)) array_push($Arylog, $row); } //for ($i = 0; $i < count($emplog); $i++) } //if(isset($emplog[0]['pdate']) OR isset($emplog[0]['storecode']) ) } //if(count($emplog>0)) unset($Aryprice); unset($emplog); //處理排序問題 $ary = array(); foreach ($Arylog as $log) { if ($log['productno'] != null) { //過濾mappingno是空值 $ary[$log['pdate'] . $log['storecode'] . $log['productno'] . $log['old_productno']] = $log; } } //釋放 unset($Arylog); ksort($ary); $index_key = array_keys($ary); // CVarDumper::dump($ary,10,true); if (count($ary > 0)) { if (isset($ary[$index_key[0]]['pdate']) and isset($ary[$index_key[0]]['productno']) and isset($ary[$index_key[0]]['personno'])) { //預設第一筆資料 $pdate = $ary[$index_key[0]]['pdate']; $personno = $ary[$index_key[0]]['personno']; $productno = $ary[$index_key[0]]['productno']; $amount = $ary[$index_key[0]]['amount']; $price = $ary[$index_key[0]]['uprice']; $row = $ary[$index_key[0]]; //第一個array整個資料 $row['amount'] = 0; //第一個array的amount預設0 foreach ($ary as $key => $value) { if ($value['pdate'] == $pdate and $value['personno'] == $personno) { if ($value['productno'] == $productno) { if ($value['gift'] == 0) { $row['amount'] = $row['amount'] + $value['amount']; $row['total'] = $row['amount'] * $value['uprice']; //如果少收 if (isset($value['co25'])) { $row['co25'] = $value['co25'] . '*' . $value['amount']; } } else { $row['amount'] = $row['amount'] - $value['amount']; $row['total'] = $row['amount'] * $price; $value['co25'] = ''; //防止免費眷殘留之前文字 array_push($colAry, $row); $row = $value; } } else { array_push($colAry, $row); $pdate = $value['pdate']; $personno = $value['personno']; $productno = $value['productno']; $amount = $value['amount']; $price = $value['uprice']; $value['co25'] = ''; //歸0不然此欄位會殘留之前的 $row = $value; } } else { array_push($colAry, $row); $pdate = $value['pdate']; $personno = $value['personno']; $productno = $value['productno']; $amount = $value['amount']; $price = $value['uprice']; $value['co25'] = ''; //歸0不然此欄位會殘留之前的 $row = $value; } } // foreach ($ary as $key => $value) { array_push($colAry, $row); } // if(isset($ary[$index_key[0]]['pdate']) and isset($ary[$index_key[0]]['productno']) and isset($ary[$index_key[0]]['personno']) ){ } // if(count($ary>0)) unset($ary); // CVarDumper::dump($row,10,true); return $colAry; }