InvoiceAjaxController.php 6.9 KB

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