123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347 |
- <?php
- /**
- * @author darkredz
- */
- class InvoiceController extends DooController {
- public $staff;
- public $verifyId;
- public $executeId;
- public static $NEW = 0;
- public static $NEW2 = 0;
-
-
-
-
- function __construct() {
- if(isset($_COOKIE["staff"])){
-
- if(!empty($_COOKIE["staff"])){
-
- Doo::loadModel ( 'staff' );
- Doo::loadModel('verify');
- $verify=new verify();
- $staff = new staff ();
- Doo::loadModel("execute");
- $execute=new execute();
-
- $verifyList=$verify->find(array('select'=>'staff','asArray'=>true));
- $list=array();
-
- //判断角色的审批权限
- foreach ($verifyList as $key=>$value){
- $ver=json_decode($value['staff']);
-
- foreach ($ver as $k=>$v){
- if ($v[1]=='ROLE'){
- $roleList=json_decode($v[3]);
- foreach ($roleList as $t=>$g){
- $gList=explode("_", $g);
- array_push($list, $gList[0]);
- //print_r($list);
- }
- }else
- array_push($list, $v[0]);
- }
- }
-
- //判断执行人的审批权限
- $executeList=$execute->find(array('select'=>'staff','asArray'=>true));
- $list2=array();
- foreach ($executeList as $key=>$value){
- $ver=json_decode($value['staff']);
-
- foreach ($ver as $k=>$v){
- array_push($list2, $v[0]);
- }
- }
-
- $eidList=file_get_contents("protected/config/execute/execute.ini");
- $eidList=array_filter(explode(",", $eidList));
-
- $this->executeId= array_merge($list2,$eidList);
-
- $this->verifyId=$list;
- $this->staff=$staff->getUserByIdList($_COOKIE["staff"]);
- ReceiptController::$NEW= $this->getReceiptCount();
- ReceiptController::$NEW2= $this->getExeCount();
- return "/";
- }
- }
-
- Doo::loadCore ( 'uri/DooUriRouter' );
- $router = new DooUriRouter ();
- $routeRs = $router->execute ( Doo::app ()->route, Doo::conf ()->SUBFOLDER );
-
- if($routeRs['1']!="login"){
- header ( 'Content-Type:text/html;charset=utf-8' );
- @header ( "Location: /login" );
- }
- }
-
- function invoice(){
-
- $data['memu']="invoice";
- $data['staff']=$this->staff;
- $data['receiptMemu']='invoice';
- $data['verifyId']=$this->verifyId;
- $data['executeId']=$this->executeId;
- $this->render ( "/admin/invoice", $data );
- }
-
- function invoiceAdd(){
- Doo::loadModel('L_category');
- $lCategory=new L_category();
-
- $category=$lCategory->find(array('asArray'=>true));
-
- $data['category']=$category;
-
- $data['memu']="invoice";
- $data['staff']=$this->staff;
- $data['receiptMemu']='invoice';
- $data['verifyId']=$this->verifyId;
- $data['executeId']=$this->executeId;
- $this->render ( "/admin/invoiceAdd", $data );
- }
-
- function invoiceAddDo(){
- $cid=$this->get_args('cid')&&is_numeric($this->get_args('cid'))?$this->get_args('cid'):0;
- $invoiceType=$this->get_args('invoiceType')&&is_numeric($this->get_args('invoiceType'))?$this->get_args('invoiceType'):0;
- $doPost=$this->get_args('doPost')&&is_numeric($this->get_args('doPost'))?$this->get_args('doPost'):0;
- $invoicePrice=$this->get_args('invoicePrice')?$this->get_args('invoicePrice'):"";
- $invoiceElement=$this->get_args('invoiceElement')?$this->get_args('invoiceElement'):"";
- $invoiceTitle=$this->get_args('invoiceTitle')?$this->get_args('invoiceTitle'):"";
- $invoiceCompany=$this->get_args('invoiceCompany')?$this->get_args('invoiceCompany'):"";
- $TIN=$this->get_args('TIN')?$this->get_args('TIN'):"";
- $address=$this->get_args('address')?$this->get_args('address'):"";
- $phone=$this->get_args('phone')?$this->get_args('phone'):"";
- $bank=$this->get_args('bank')?$this->get_args('bank'):"";
- $bankAccount=$this->get_args('bankAccount')?$this->get_args('bankAccount'):"";
- $recipients=$this->get_args('recipients')?$this->get_args('recipients'):"";
- $recipientsPhone=$this->get_args('recipientsPhone')?$this->get_args('recipientsPhone'):"";
- $recipientsAddress=$this->get_args('recipientsAddress')?$this->get_args('recipientsAddress'):"";
-
- $mailItems=$this->get_args('mailItems')?$this->get_args('mailItems'):"";
- $remark=$this->get_args('remark')?$this->get_args('remark'):"";
- //&&!empty($invoiceTitle)&&!empty($invoiceCompany)&&!empty($TIN)&&!empty($address)
- // &&!empty($phone)&&!empty($bank)&&!empty($bankAccount)&&!empty($recipients)&&!empty($recipientsPhone)&&!empty($recipientsAddress)
- if(!empty($cid)&&!empty($invoicePrice)&&!empty($invoiceElement)){
- Doo::loadModel('invoice');
- $invoice=new invoice();
- Doo::loadModel('L_category');
- $lCategory=new L_category();
- Doo::loadModel('invoiceManage');
- $invoiceManage=new invoiceManage();
-
- $categoryDetil=$lCategory->getOne(array('SELECT'=>'title','where'=>'cid='.$cid,'asArray'=>true));
- $invoiceManageDetail=$invoiceManage->getOne(array('SELECT'=>'title','where'=>'mold="发票审批"','asArray'=>true));
-
- $invoice->cid=$cid;
- $invoice->categoryName=$categoryDetil['title'];
- $invoice->invoiceElement=$invoiceElement;
- $invoice->invoicePrice=$invoicePrice;
-
- $invoice->invoiceType=$invoiceType;
- if ($invoiceType==0)
- $invoice->invoiceTitle=$invoiceTitle;
- elseif ($invoiceType==1){
- $invoice->invoiceTitle=$invoiceCompany;
- $invoice->TIN=$TIN;
- $invoice->address=$address;
- $invoice->phone=$phone;
- $invoice->bank=$bank;
- $invoice->bankAccount=$$bankAccount;
- }
-
- $invoice->doPost=$doPost;
- if ($doPost==1){
- $invoice->recipients=$recipients;
- $invoice->recipientsPhone=$recipientsPhone;
- $invoice->recipientsAddress=$recipientsAddress;
- }
- $invoice->status=1;
- $invoice->invoiceSerial="#F".date("Ymd").mt_rand(1000,9999);
- $invoice->date=date("'Y-m-d H:i:s");
- $invoice->sid=$this->staff[0]['sid'];
- $invoice->userName=$this->staff[0]['username'];
- $invoice->invoiceManage=$invoiceManageDetail['staff'];
- $staffId=$a=json_decode($invoiceManageDetail['staff']);
- $invoice->pendingApprovals=$staffId[0][0];
- $invoice->insert();
- }
-
- return "/invoice";
- }
-
- function invoiceApproval(){
-
- Doo::loadModel('invoice');
- $invoice=new invoice();
- Doo::loadModel('invoiceManage');
- $invoiceManage=new invoiceManage();
-
- $invoiceList=$invoice->find(array('where'=>'status=1 and pendingApprovals='.$this->staff[0]['sid'],'asArray'=>true));
-
- $data['invoiceList']=$invoiceList;
-
- $data['memu']="invoice";
- $data['staff']=$this->staff;
- $data['receiptMemu']='invoiceApproval';
- $data['verifyId']=$this->verifyId;
- $data['executeId']=$this->executeId;
- $this->render ( "/admin/invoiceApproval", $data );
- }
-
- function invoiceDetail(){
-
- $iid=isset($this->params['iid'])&&is_numeric($this->params['iid'])?$this->params['iid']:0;
-
- Doo::loadModel('invoice');
- $invoice=new invoice();
- Doo::loadModel('invoiceManage');
- $invoiceManage=new invoiceManage();
-
- $invoiceDetail=$invoice->getOne(array('where'=>'status=1 and pendingApprovals='.$this->staff[0]['sid'],'asArray'=>true));
-
- $invoiceManageDetail=$invoiceManage->getOne(array('SELECT'=>'title','where'=>'mold="发票审批"','asArray'=>true));
-
- $a=json_decode($invoiceManageDetail['staff']);
-
-
- $data['invoiceDetail']=$invoiceDetail;
-
- $data['memu']="invoice";
- $data['staff']=$this->staff;
- $data['receiptMemu']='invoiceApproval';
- $data['verifyId']=$this->verifyId;
- $data['executeId']=$this->executeId;
- $this->render ( "/admin/invoiceApprovalDetail", $data );
- }
-
- private function getExeCount(){
- Doo::loadModel('receipt');
- $receipt=new receipt();
- $receiptList=$receipt->find(array('where'=>'(executeCopy like \'%["'.$this->staff[0]['sid'].'%\' and executeStaff NOT LIKE \'%'.$this->staff[0]['sid'].'%\' ) and (status=1 or status=6)','desc'=>'rid','asArray'=>true));
-
- return count($receiptList);
- }
-
- private function getReceiptCount(){
-
- $status=2;
- $year=date('Y');
-
- Doo::loadModel('receipt');
- $receipt=new receipt();
- Doo::loadModel('verify');
- $dateCondition=" and Year(date) =".$year;
-
- $approvalCondition=' and nowStaff like "%'.$this->staff[0]['sid'].'%" ';
- $receiptList=$receipt->find(array('where'=>' status='.$status.$dateCondition.$approvalCondition,'desc'=>'rid','asArray'=>true));
-
- return count($receiptList);
- }
-
- function _GetFileEXT($filename) {
- $pics = explode ( '.', $filename );
- $num = count ( $pics );
- return $pics [$num - 1];
- }
-
- /**
- * 获取get或者POST值
- * @param string $name 属性名称
- * @return fixed 值
- */
- function get_args($name) {
- if (isset ( $_GET [$name] )) {
- if (is_array ( $_GET [$name] ))
- return $_GET [$name];
- else
- return addslashes ( $_GET [$name] );
-
- } elseif (isset ( $_POST [$name] )) {
- if (is_array ( $_POST [$name] ))
- return $_POST [$name];
- else
- return addslashes ( $_POST [$name] );
- } else
- return false;
- }
-
- function num_to_rmb($num){
- $c1 = "零壹贰叁肆伍陆柒捌玖";
- $c2 = "分角元拾佰仟万拾佰仟亿";
- //精确到分后面就不要了,所以只留两个小数位
- $num = round($num, 2);
- //将数字转化为整数
- $num = $num * 100;
- if (strlen($num) > 10) {
- return "金额太大,请检查";
- }
- $i = 0;
- $c = "";
- while (1) {
- if ($i == 0) {
- //获取最后一位数字
- $n = substr($num, strlen($num)-1, 1);
- } else {
- $n = $num % 10;
- }
- //每次将最后一位数字转化为中文
- $p1 = substr($c1, 3 * $n, 3);
- $p2 = substr($c2, 3 * $i, 3);
- if ($n != '0' || ($n == '0' && ($p2 == '亿' || $p2 == '万' || $p2 == '元'))) {
- $c = $p1 . $p2 . $c;
- } else {
- $c = $p1 . $c;
- }
- $i = $i + 1;
- //去掉数字最后一位了
- $num = $num / 10;
- $num = (int)$num;
- //结束循环
- if ($num == 0) {
- break;
- }
- }
- $j = 0;
- $slen = strlen($c);
- while ($j < $slen) {
- //utf8一个汉字相当3个字符
- $m = substr($c, $j, 6);
- //处理数字中很多0的情况,每次循环去掉一个汉字“零”
- if ($m == '零元' || $m == '零万' || $m == '零亿' || $m == '零零') {
- $left = substr($c, 0, $j);
- $right = substr($c, $j + 3);
- $c = $left . $right;
- $j = $j-3;
- $slen = $slen-3;
- }
- $j = $j + 3;
- }
- //这个是为了去掉类似23.0中最后一个“零”字
- if (substr($c, strlen($c)-3, 3) == '零') {
- $c = substr($c, 0, strlen($c)-3);
- }
- //将处理的汉字加上“整”
- if (empty($c)) {
- return "零元整";
- }else{
- return $c . "整";
- }
- }
- }
- class ReceiptController{
- public static $NEW = 0;
- public static $NEW2 = 0;
- }
- ?>
|