InvoiceAjaxController.php 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285
  1. <?php
  2. /**
  3. * 开票功能控制器
  4. * @author CP
  5. * @version 1.0
  6. * @namespace invoice
  7. * @package invoiceController
  8. */
  9. class InvoiceAjaxController extends DooController {
  10. public $staff;
  11. public $NEW;
  12. public $data;
  13. private $INVOICEKEY = "APPROVAL";
  14. private $INVOICECOLLECTPATH = "protected/cache/invoiceCollect/";
  15. private $ACTION = '';
  16. private $appId = 'wx3ee46531947a1384';
  17. private $appSecret = 'awGWzy3J5q_96VXKBLA2BQ9RpiT0LiPXnkMF-xV6h5o'; // awGWzy3J5q_96VXKBLA2BXU6mVCGynPGD-sxUCsdNDE //'PeiQVH8tbQE7pM9pVO4AIPlX9FFNpwu7O6Iy6VFcAVtpjTA3Qn42dbNmktBFkUHo';
  18. function __construct() {
  19. if (isset ( $_COOKIE ["staff"] )) {
  20. if (! empty ( $_COOKIE ["staff"] )) {
  21. Doo::loadModel ( 'staff' );
  22. $staff = new staff ();
  23. $uriPartsOrig = explode ( '/', $_SERVER ['REQUEST_URI'] );
  24. $this->ACTION = $uriPartsOrig [1];
  25. $this->data ['new'] = $this->isInvoiceNew ();
  26. $this->staff = $staff->getUserByIdList ( $_COOKIE ["staff"] );
  27. $this->data ['isStaffCompleteMsg'] = false;
  28. $detail = $staff->checkStaffInfoIsComplete ( $_COOKIE ["staff"] );
  29. if (! empty ( $detail ))
  30. $this->data ['isStaffCompleteMsg'] = true;
  31. return "/";
  32. }
  33. }
  34. Doo::loadCore ( 'uri/DooUriRouter' );
  35. $router = new DooUriRouter ();
  36. $routeRs = $router->execute ( Doo::app ()->route, Doo::conf ()->SUBFOLDER );
  37. if ($routeRs ['1'] != "login") {
  38. header ( 'Content-Type:text/html;charset=utf-8' );
  39. @header ( "Location: /login" );
  40. }
  41. }
  42. /**
  43. * 自动填写
  44. */
  45. function autoFillInIFB() {
  46. $fill = $this->get_args ( 'fill' ) ? $this->get_args ( 'fill' ) : "";
  47. $fillType = $this->get_args ( 'fillType' ) ? $this->get_args ( 'fillType' ) : "TITLE";
  48. if (! empty ( $fill )) {
  49. Doo::loadModel ( 'invoiceInfoBase' );
  50. $invoiceInfoBase = new invoiceInfoBase ();
  51. if ($fillType=='TIN'){
  52. $ifbList = $invoiceInfoBase->getIFBByTIN ( $fill );
  53. }else{
  54. $ifbList = $invoiceInfoBase->getIFBByTitle ( $fill );
  55. }
  56. echo json_encode ( $ifbList );
  57. } else {
  58. echo json_encode ( array (
  59. 0 => array (
  60. 'invoiceTitle' => ''
  61. )
  62. ) );
  63. }
  64. }
  65. function api_invoice(){
  66. $filter = $_GET['filter'];
  67. $filter=json_decode($filter,true);
  68. Doo::loadModel ( 'invoice' );
  69. $invoice = new invoice ();
  70. $result=$invoice->get_invoice($filter);
  71. echo json_encode ( $result );
  72. }
  73. /**
  74. * 获得已经结算完成的培训班
  75. */
  76. function ajaxGetInvoiceTrainByEnd(){
  77. Doo::loadModel ( 'invoiceTraining' );
  78. $invoiceTraining = new invoiceTraining ();
  79. $invoiceTrainingList = $invoiceTraining->getInvoiceTrainBySettlementStatus ( 0 ,$this->staff[0]['cid'],0);
  80. echo json_encode ( array (
  81. 'status' => 1,
  82. 'invoiceTrainingList' => $invoiceTrainingList
  83. ) );
  84. }
  85. function ajaxGetInvoice(){
  86. $iidKey = $this->get_args ( 'iidKey' ) ? $this->get_args ( 'iidKey' ) : "";
  87. Doo::loadClass ( 'XDeode' );
  88. $XDeode = new XDeode ( 5 );
  89. $iid = $XDeode->decode ( $iidKey );
  90. if (! is_numeric ( $iid )){
  91. echo json_encode ( array (
  92. 'status' => 0,
  93. 'invoiceDetail' => array()
  94. ) );
  95. die ( 'illegal request' );
  96. }
  97. Doo::loadModel ( 'invoice' );
  98. $invoice = new invoice ();
  99. $invoiceDetail = $invoice->getInvoiceByIid ( $iid );
  100. Doo::loadModel ( 'invoiceTraining' );
  101. $invoiceTraining = new invoiceTraining ();
  102. $itList = $invoiceTraining->getInvoiceTrainingByCid ( $invoiceDetail ['cid'] );
  103. Doo::loadModel ( 'receipt' );
  104. $receipt = new receipt ();
  105. foreach ( $itList as $key => $value ) { // 不展示已结算完结的培训班
  106. $receiptDetail = $receipt->getReceiptByinvoiceTrainId ( $value ['itid'] );
  107. if (! empty ( $receiptDetail )) {
  108. if ($receiptDetail ['status'] == 8 || $receiptDetail ['status'] == 9) {
  109. unset ( $itList [$key] );
  110. }
  111. }
  112. }
  113. $html='';
  114. foreach ($itList as $key=>$value){
  115. if($value['itid']==$invoiceDetail ['trainId']){
  116. $html.='<option selected value="'.$value['itidKey'].'">'.$value['trainDate'].'&nbsp;'.$value['trainName'].'</option>';
  117. }else{
  118. $html.='<option value="'.$value['itidKey'].'">'.$value['trainDate'].'&nbsp;'.$value['trainName'].'</option>';
  119. }
  120. }
  121. $invoiceDetail['itList']=$itList;
  122. echo json_encode ( array (
  123. 'status' => 1,
  124. 'invoiceDetail' => $invoiceDetail,
  125. 'settlementHtml'=>$html
  126. ) );
  127. }
  128. /**
  129. * 旧输入导入
  130. */
  131. function _GetFileEXT($filename) {
  132. $pics = explode ( '.', $filename );
  133. $num = count ( $pics );
  134. return $pics [$num - 1];
  135. }
  136. /**
  137. * 获取get或者POST值
  138. *
  139. * @param string $name 属性名称
  140. * @return fixed 值
  141. */
  142. function get_args($name) {
  143. if (isset ( $_GET [$name] )) {
  144. if (is_array ( $_GET [$name] ))
  145. return $_GET [$name];
  146. else
  147. return addslashes ( $_GET [$name] );
  148. } elseif (isset ( $_POST [$name] )) {
  149. if (is_array ( $_POST [$name] ))
  150. return $_POST [$name];
  151. else
  152. return addslashes ( $_POST [$name] );
  153. } else
  154. return false;
  155. }
  156. function SafeFilter(&$arr) {
  157. $ra = Array (
  158. '/([\x00-\x08,\x0b-\x0c,\x0e-\x19])/',
  159. '/script/',
  160. '/javascript/',
  161. '/vbscript/',
  162. '/expression/',
  163. '/applet/',
  164. '/meta/',
  165. '/xml/',
  166. '/blink/',
  167. '/link/',
  168. '/style/',
  169. '/embed/',
  170. '/object/',
  171. '/frame/',
  172. '/layer/',
  173. '/title/',
  174. '/bgsound/',
  175. '/base/',
  176. '/onload/',
  177. '/onunload/',
  178. '/onchange/',
  179. '/onsubmit/',
  180. '/onreset/',
  181. '/onselect/',
  182. '/onblur/',
  183. '/onfocus/',
  184. '/onabort/',
  185. '/onkeydown/',
  186. '/onkeypress/',
  187. '/onkeyup/',
  188. '/onclick/',
  189. '/ondblclick/',
  190. '/onmousedown/',
  191. '/onmousemove/',
  192. '/onmouseout/',
  193. '/onmouseover/',
  194. '/onmouseup/',
  195. '/onunload/'
  196. );
  197. if (is_array ( $arr )) {
  198. foreach ( $arr as $key => $value ) {
  199. if (! is_array ( $value )) {
  200. if (! get_magic_quotes_gpc ()) // 不对magic_quotes_gpc转义过的字符使用addslashes(),避免双重转义。
  201. {
  202. $value = addslashes ( $value ); // 给单引号(')、双引号(")、反斜线(\)与 NUL(NULL 字符)加上反斜线转义
  203. }
  204. $value = preg_replace ( $ra, '', $value ); // 删除非打印字符,粗暴式过滤xss可疑字符串
  205. $arr [$key] = htmlentities ( strip_tags ( $value ) ); // 去除 HTML 和 PHP 标记并转换为 HTML 实体
  206. } else {
  207. SafeFilter ( $arr [$key] );
  208. }
  209. }
  210. }
  211. }
  212. /**
  213. * Escape String
  214. *
  215. * @access public
  216. * @param string
  217. * @param bool whether or not the string will be used in a LIKE condition
  218. * @return string
  219. */
  220. function escape_str($str, $like = FALSE) {
  221. if (is_array ( $str )) {
  222. foreach ( $str as $key => $val ) {
  223. $str [$key] = $this->escape_str ( $val, $like );
  224. }
  225. return $str;
  226. }
  227. var_dump ( Doo::db ()->getDbObject () );
  228. die ();
  229. if (function_exists ( 'mysql_real_escape_string' ) and is_resource ( Doo::db ()->getDbObject () )) { // Doo::db ()->getDbObject()
  230. $str = mysql_real_escape_string ( $str, Doo::db ()->getDbObject () );
  231. } elseif (function_exists ( 'mysql_escape_string' )) {
  232. $str = mysql_escape_string ( $str );
  233. } else {
  234. $str = addslashes ( $str );
  235. }
  236. // escape LIKE condition wildcards
  237. if ($like === TRUE) {
  238. $str = str_replace ( array (
  239. '%',
  240. '_'
  241. ), array (
  242. '\\%',
  243. '\\_'
  244. ), $str );
  245. }
  246. return $str;
  247. }
  248. }
  249. ?>