|
62 | 62 | </file> |
63 | 63 |
|
64 | 64 | <file name="admin/controller/sale/order.php"> |
65 | | - <operation> |
66 | | - <search position="replace"><![CDATA[public function invoice() {]]></search> |
67 | | - <add><![CDATA[public function invoice($custom_array = null) {]]></add> |
68 | | - </operation> |
69 | | - |
70 | 65 | <operation> |
71 | 66 | <search position="after"><![CDATA[$data['button_invoice_print'] = $this->language->get('button_invoice_print');]]></search> |
72 | 67 | <add><![CDATA[$data['button_pdf_invoice'] = $this->language->get('button_pdf_invoice');]]></add> |
73 | 68 | </operation> |
74 | | - |
75 | 69 | <operation> |
76 | | - <search position="replace"><![CDATA[$orders = array();]]></search> |
| 70 | + <search position="after"><![CDATA[invoice() {]]></search> |
| 71 | + <add><![CDATA[$pdf = false;]]></add> |
| 72 | + </operation> |
| 73 | + <operation> |
| 74 | + <search position="replace" offset="7"><![CDATA[$orders = array();]]></search> |
77 | 75 | <add><![CDATA[ |
78 | 76 |
|
79 | 77 | $orders = array(); |
80 | 78 |
|
81 | | - // custom orders ID delivered from argument |
82 | | - if(isset($custom_array['orders'])) |
83 | | - { |
84 | | - array_merge($orders, $custom_array['orders']); |
85 | | - } |
| 79 | + if (isset($this->request->post['selected'])) { |
86 | 80 |
|
87 | | - // pdf from administrator request |
88 | | - $pdf = (isset($this->request->get['pdf'])) ? true : false; |
89 | | - $return_invoice_path = false; |
| 81 | + $orders = $this->request->post['selected']; |
| 82 | + $pdf = (isset($this->request->get['pdf'])) ? true : false; |
90 | 83 |
|
| 84 | + } elseif (isset($this->request->get['order_id'])) { |
| 85 | +
|
| 86 | + $orders[] = $this->request->get['order_id']; |
| 87 | + $pdf = (isset($this->request->get['pdf'])) ? true : false; |
| 88 | +
|
| 89 | + } |
91 | 90 | ]]> |
92 | 91 | </add> |
93 | 92 | </operation> |
94 | | - |
95 | 93 | <operation> |
96 | | - <search position="replace"><![CDATA[$this->response->setOutput($this->load->view('sale/order_invoice', $data));]]></search> |
| 94 | + <search position="after"><![CDATA[$this->response->setOutput($this->load->view('sale/order_invoice', $data));]]></search> |
97 | 95 | <add><![CDATA[ |
98 | 96 |
|
99 | | - // return just data for request from catalog |
100 | | - if(isset($custom_array['return_invoice_path'])) |
101 | | - { |
102 | | - $pdf = true; |
103 | | - $return_invoice_path = true; |
104 | | - } |
105 | | -
|
106 | | - // print pdf to request from administrator |
107 | 97 | if ($pdf) |
108 | 98 | { |
109 | 99 | $order_view = $this->load->view('sale/order_invoice', $data); |
110 | | - return invoice_pdf($order_view, $data, $return_invoice_path); |
111 | | - } |
112 | | -
|
113 | | - // default response |
114 | | - if(!isset($custom_array['return_only_data']) && false == $pdf) |
115 | | - { |
116 | | - echo "tady je klasicky vystup"; |
117 | | - //$this->response->setOutput($this->load->view('sale/order_invoice', $data)); |
| 100 | + $pdf_printer = invoice_pdf($order_view, $data); |
| 101 | + $this->response->setOutput(); |
118 | 102 | } |
119 | 103 |
|
120 | 104 | ]]> |
|
196 | 180 | </add> |
197 | 181 | </operation> |
198 | 182 |
|
199 | | - |
200 | | - <operation info="generate invoice if order status id done"> |
201 | | - <search position="before"><![CDATA[$mail = new Mail();]]></search> |
| 183 | + <operation info="new feature attachment to order history"> |
| 184 | + <search position="after"><![CDATA[$mail->setText($text);]]></search> |
202 | 185 | <add> |
203 | 186 | <![CDATA[ |
204 | | - $success_status_array = array_flip($this->config->get('config_complete_status')); |
205 | | -
|
206 | | - if(array_key_exists($order_status_id, $success_status_array)) |
207 | | - { |
208 | | - // request to generate invoice file |
209 | | - $url = "{$order_info['store_url']}admin/index.php?route=module/invoicepdf&order_id={$order_id}"; |
210 | | - $request = do_curl_request($url); |
211 | | - $response = json_decode($request); |
212 | 187 |
|
213 | | - // add invoice to the mail |
214 | | - $attachment = isset($response->path) ? $response->path : ''; |
| 188 | + if(!empty($attachment) && file_exist($invoice))) { |
| 189 | + $mail->addAttachment($invoice); |
215 | 190 | } |
| 191 | +
|
216 | 192 | ]]> |
217 | 193 | </add> |
218 | 194 | </operation> |
219 | 195 |
|
220 | | - |
221 | | - <operation info="new feature attachment to order history"> |
222 | | - <search position="after"><![CDATA[$mail->setText($text);]]></search> |
| 196 | + <operation info="generate invoice number"> |
| 197 | + <search position="before" offset="3"><![CDATA[// Admin Alert Mail]]></search> |
223 | 198 | <add> |
224 | 199 | <![CDATA[ |
225 | | - if(!empty($attachment) && file_exists($attachment)) { |
226 | | - $mail->addAttachment($attachment); |
227 | | - } |
| 200 | + $url = "{$order_info['store_url']}/admin/index.php?route=module/invoicepdf&order_id={$order_id}"; |
| 201 | + $json = do_curl_request($url, $fields); |
| 202 | +
|
| 203 | + $invoice = json_decode($json)['invoice']; |
| 204 | +
|
| 205 | + // add invoice to the mail |
| 206 | + $mail->addAttachment($invoice); |
228 | 207 | ]]> |
229 | 208 | </add> |
230 | 209 | </operation> |
|
0 commit comments