InvoiceAjaxController.php 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274
  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. /**
  66. * 获得已经结算完成的培训班
  67. */
  68. function ajaxGetInvoiceTrainByEnd(){
  69. Doo::loadModel ( 'invoiceTraining' );
  70. $invoiceTraining = new invoiceTraining ();
  71. $invoiceTrainingList = $invoiceTraining->getInvoiceTrainBySettlementStatus ( 0 ,$this->staff[0]['cid'],0);
  72. echo json_encode ( array (
  73. 'status' => 1,
  74. 'invoiceTrainingList' => $invoiceTrainingList
  75. ) );
  76. }
  77. function ajaxGetInvoice(){
  78. $iidKey = $this->get_args ( 'iidKey' ) ? $this->get_args ( 'iidKey' ) : "";
  79. Doo::loadClass ( 'XDeode' );
  80. $XDeode = new XDeode ( 5 );
  81. $iid = $XDeode->decode ( $iidKey );
  82. if (! is_numeric ( $iid )){
  83. echo json_encode ( array (
  84. 'status' => 0,
  85. 'invoiceDetail' => array()
  86. ) );
  87. die ( 'illegal request' );
  88. }
  89. Doo::loadModel ( 'invoice' );
  90. $invoice = new invoice ();
  91. $invoiceDetail = $invoice->getInvoiceByIid ( $iid );
  92. Doo::loadModel ( 'invoiceTraining' );
  93. $invoiceTraining = new invoiceTraining ();
  94. $itList = $invoiceTraining->getInvoiceTrainingByCid ( $invoiceDetail ['cid'] );
  95. Doo::loadModel ( 'receipt' );
  96. $receipt = new receipt ();
  97. foreach ( $itList as $key => $value ) { // 不展示已结算完结的培训班
  98. $receiptDetail = $receipt->getReceiptByinvoiceTrainId ( $value ['itid'] );
  99. if (! empty ( $receiptDetail )) {
  100. if ($receiptDetail ['status'] == 8 || $receiptDetail ['status'] == 9) {
  101. unset ( $itList [$key] );
  102. }
  103. }
  104. }
  105. $html='';
  106. foreach ($itList as $key=>$value){
  107. if($value['itid']==$invoiceDetail ['trainId']){
  108. $html.='<option selected value="'.$value['itidKey'].'">'.$value['trainDate'].'&nbsp;'.$value['trainName'].'</option>';
  109. }else{
  110. $html.='<option value="'.$value['itidKey'].'">'.$value['trainDate'].'&nbsp;'.$value['trainName'].'</option>';
  111. }
  112. }
  113. $invoiceDetail['itList']=$itList;
  114. echo json_encode ( array (
  115. 'status' => 1,
  116. 'invoiceDetail' => $invoiceDetail,
  117. 'settlementHtml'=>$html
  118. ) );
  119. }
  120. /**
  121. * 旧输入导入
  122. */
  123. function _GetFileEXT($filename) {
  124. $pics = explode ( '.', $filename );
  125. $num = count ( $pics );
  126. return $pics [$num - 1];
  127. }
  128. /**
  129. * 获取get或者POST值
  130. *
  131. * @param string $name 属性名称
  132. * @return fixed 值
  133. */
  134. function get_args($name) {
  135. if (isset ( $_GET [$name] )) {
  136. if (is_array ( $_GET [$name] ))
  137. return $_GET [$name];
  138. else
  139. return addslashes ( $_GET [$name] );
  140. } elseif (isset ( $_POST [$name] )) {
  141. if (is_array ( $_POST [$name] ))
  142. return $_POST [$name];
  143. else
  144. return addslashes ( $_POST [$name] );
  145. } else
  146. return false;
  147. }
  148. function SafeFilter(&$arr) {
  149. $ra = Array (
  150. '/([\x00-\x08,\x0b-\x0c,\x0e-\x19])/',
  151. '/script/',
  152. '/javascript/',
  153. '/vbscript/',
  154. '/expression/',
  155. '/applet/',
  156. '/meta/',
  157. '/xml/',
  158. '/blink/',
  159. '/link/',
  160. '/style/',
  161. '/embed/',
  162. '/object/',
  163. '/frame/',
  164. '/layer/',
  165. '/title/',
  166. '/bgsound/',
  167. '/base/',
  168. '/onload/',
  169. '/onunload/',
  170. '/onchange/',
  171. '/onsubmit/',
  172. '/onreset/',
  173. '/onselect/',
  174. '/onblur/',
  175. '/onfocus/',
  176. '/onabort/',
  177. '/onkeydown/',
  178. '/onkeypress/',
  179. '/onkeyup/',
  180. '/onclick/',
  181. '/ondblclick/',
  182. '/onmousedown/',
  183. '/onmousemove/',
  184. '/onmouseout/',
  185. '/onmouseover/',
  186. '/onmouseup/',
  187. '/onunload/'
  188. );
  189. if (is_array ( $arr )) {
  190. foreach ( $arr as $key => $value ) {
  191. if (! is_array ( $value )) {
  192. if (! get_magic_quotes_gpc ()) // 不对magic_quotes_gpc转义过的字符使用addslashes(),避免双重转义。
  193. {
  194. $value = addslashes ( $value ); // 给单引号(')、双引号(")、反斜线(\)与 NUL(NULL 字符)加上反斜线转义
  195. }
  196. $value = preg_replace ( $ra, '', $value ); // 删除非打印字符,粗暴式过滤xss可疑字符串
  197. $arr [$key] = htmlentities ( strip_tags ( $value ) ); // 去除 HTML 和 PHP 标记并转换为 HTML 实体
  198. } else {
  199. SafeFilter ( $arr [$key] );
  200. }
  201. }
  202. }
  203. }
  204. /**
  205. * Escape String
  206. *
  207. * @access public
  208. * @param string
  209. * @param bool whether or not the string will be used in a LIKE condition
  210. * @return string
  211. */
  212. function escape_str($str, $like = FALSE) {
  213. if (is_array ( $str )) {
  214. foreach ( $str as $key => $val ) {
  215. $str [$key] = $this->escape_str ( $val, $like );
  216. }
  217. return $str;
  218. }
  219. var_dump ( Doo::db ()->getDbObject () );
  220. die ();
  221. if (function_exists ( 'mysql_real_escape_string' ) and is_resource ( Doo::db ()->getDbObject () )) { // Doo::db ()->getDbObject()
  222. $str = mysql_real_escape_string ( $str, Doo::db ()->getDbObject () );
  223. } elseif (function_exists ( 'mysql_escape_string' )) {
  224. $str = mysql_escape_string ( $str );
  225. } else {
  226. $str = addslashes ( $str );
  227. }
  228. // escape LIKE condition wildcards
  229. if ($like === TRUE) {
  230. $str = str_replace ( array (
  231. '%',
  232. '_'
  233. ), array (
  234. '\\%',
  235. '\\_'
  236. ), $str );
  237. }
  238. return $str;
  239. }
  240. }
  241. ?>