29 include_once DOL_DOCUMENT_ROOT.
'/core/modules/DolibarrModules.class.php';
50 $this->family =
"financial";
51 $this->module_position =
'11';
53 $this->
name = preg_replace(
'/^mod/i',
'', get_class($this));
57 $this->version =
'dolibarr';
59 $this->const_name =
'MAIN_MODULE_'.strtoupper($this->
name);
60 $this->picto =
'bill';
63 $this->dirs = array(
"/facture/temp");
66 $this->depends = array(
'always'=>
"modSociete");
67 $this->requiredby = array(
"modComptabilite",
"modAccounting");
68 $this->conflictwith = array();
69 $this->langfiles = array(
"bills",
"companies",
"compta",
"products");
70 $this->warnings_activation = array();
71 $this->warnings_activation_ext = array();
74 $this->config_page_url = array(
"facture.php");
77 $this->
const = array();
80 $this->
const[$r][0] =
"FACTURE_ADDON";
81 $this->
const[$r][1] =
"chaine";
82 $this->
const[$r][2] =
"mod_facture_terre";
83 $this->
const[$r][3] =
'Name of numbering numerotation rules of invoice';
84 $this->
const[$r][4] = 0;
87 $this->
const[$r][0] =
"FACTURE_ADDON_PDF";
88 $this->
const[$r][1] =
"chaine";
89 $this->
const[$r][2] =
"crabe";
90 $this->
const[$r][3] =
'Name of PDF model of invoice';
91 $this->
const[$r][4] = 0;
94 $this->
const[$r][0] =
"FACTURE_ADDON_PDF_ODT_PATH";
95 $this->
const[$r][1] =
"chaine";
96 $this->
const[$r][2] =
"DOL_DATA_ROOT/doctemplates/invoices";
97 $this->
const[$r][3] =
"";
98 $this->
const[$r][4] = 0;
111 $this->boxes = array(
112 0=>array(
'file'=>
'box_factures_imp.php',
'enabledbydefaulton'=>
'Home'),
113 1=>array(
'file'=>
'box_factures.php',
'enabledbydefaulton'=>
'Home'),
114 2=>array(
'file'=>
'box_graph_invoices_permonth.php',
'enabledbydefaulton'=>
'Home'),
115 3=>array(
'file'=>
'box_customers_outstanding_bill_reached.php',
'enabledbydefaulton'=>
'Home')
120 $datestart =
dol_mktime(23, 0, 0, $arraydate[
'mon'], $arraydate[
'mday'], $arraydate[
'year']);
121 $this->cronjobs = array(
122 0=>array(
'label'=>
'RecurringInvoices',
'jobtype'=>
'method',
'class'=>
'compta/facture/class/facture-rec.class.php',
'objectname'=>
'FactureRec',
'method'=>
'createRecurringInvoices',
'parameters'=>
'',
'comment'=>
'Generate recurring invoices',
'frequency'=>1,
'unitfrequency'=>3600 * 24,
'priority'=>50,
'status'=>1,
'test'=>
'$conf->facture->enabled',
'datestart'=>$datestart),
126 $this->rights = array();
127 $this->rights_class =
'facture';
131 $this->rights[$r][0] = 11;
132 $this->rights[$r][1] =
'Read invoices';
133 $this->rights[$r][2] =
'a';
134 $this->rights[$r][3] = 0;
135 $this->rights[$r][4] =
'lire';
138 $this->rights[$r][0] = 12;
139 $this->rights[$r][1] =
'Create and update invoices';
140 $this->rights[$r][2] =
'a';
141 $this->rights[$r][3] = 0;
142 $this->rights[$r][4] =
'creer';
146 $this->rights[$r][0] = 13;
147 $this->rights[$r][1] =
'Devalidate invoices';
148 $this->rights[$r][2] =
'a';
149 $this->rights[$r][3] = 0;
150 $this->rights[$r][4] =
'invoice_advance';
151 $this->rights[$r][5] =
'unvalidate';
154 $this->rights[$r][0] = 14;
155 $this->rights[$r][1] =
'Validate invoices';
156 $this->rights[$r][2] =
'a';
157 $this->rights[$r][3] = 0;
158 $this->rights[$r][4] =
'invoice_advance';
159 $this->rights[$r][5] =
'validate';
162 $this->rights[$r][0] = 15;
163 $this->rights[$r][1] =
'Send invoices by email';
164 $this->rights[$r][2] =
'a';
165 $this->rights[$r][3] = 0;
166 $this->rights[$r][4] =
'invoice_advance';
167 $this->rights[$r][5] =
'send';
170 $this->rights[$r][0] = 16;
171 $this->rights[$r][1] =
'Issue payments on invoices';
172 $this->rights[$r][2] =
'a';
173 $this->rights[$r][3] = 0;
174 $this->rights[$r][4] =
'paiement';
177 $this->rights[$r][0] = 19;
178 $this->rights[$r][1] =
'Delete invoices';
179 $this->rights[$r][2] =
'a';
180 $this->rights[$r][3] = 0;
181 $this->rights[$r][4] =
'supprimer';
184 $this->rights[$r][0] = 1321;
185 $this->rights[$r][1] =
'Export customer invoices, attributes and payments';
186 $this->rights[$r][2] =
'r';
187 $this->rights[$r][3] = 0;
188 $this->rights[$r][4] =
'facture';
189 $this->rights[$r][5] =
'export';
192 $this->rights[$r][0] = 1322;
193 $this->rights[$r][1] =
'Re-open a fully paid invoice';
194 $this->rights[$r][2] =
'r';
195 $this->rights[$r][3] = 0;
196 $this->rights[$r][4] =
'invoice_advance';
197 $this->rights[$r][5] =
'reopen';
209 $this->export_code[$r] = $this->rights_class.
'_'.$r;
210 $this->export_label[$r] =
'CustomersInvoicesAndInvoiceLines';
211 $this->export_icon[$r] =
'invoice';
212 $this->export_permission[$r] = array(array(
"facture",
"facture",
"export",
"other"));
213 $this->export_fields_array[$r] = array(
214 's.rowid'=>
"IdCompany",
's.nom'=>
'CompanyName',
's.code_client'=>
'CustomerCode',
's.address'=>
'Address',
's.zip'=>
'Zip',
's.town'=>
'Town',
'c.code'=>
'CountryCode',
'cd.nom'=>
'State',
216 's.siren'=>
'ProfId1',
's.siret'=>
'ProfId2',
's.ape'=>
'ProfId3',
's.idprof4'=>
'ProfId4',
217 's.code_compta'=>
'CustomerAccountancyCode',
218 's.code_compta_fournisseur'=>
'SupplierAccountancyCode',
219 's.tva_intra'=>
'VATIntra',
220 'f.rowid'=>
"InvoiceId",
'f.ref'=>
"InvoiceRef",
'f.ref_client'=>
'RefCustomer',
221 'f.type'=>
"Type",
'f.datec'=>
"InvoiceDateCreation",
'f.datef'=>
"DateInvoice",
'f.date_lim_reglement'=>
"DateDue",
'f.total'=>
"TotalHT",
222 'f.total_ttc'=>
"TotalTTC",
'f.tva'=>
"TotalVAT",
'f.localtax1'=>
'LT1',
'f.localtax2'=>
'LT2',
'f.paye'=>
"InvoicePaidCompletely",
'f.fk_statut'=>
'InvoiceStatus',
'f.close_code'=>
'EarlyClosingReason',
'f.close_note'=>
'EarlyClosingComment',
224 'f.note_private'=>
"NotePrivate",
'f.note_public'=>
"NotePublic",
'f.fk_user_author'=>
'CreatedById',
'uc.login'=>
'CreatedByLogin',
225 'f.fk_user_valid'=>
'ValidatedById',
'uv.login'=>
'ValidatedByLogin',
'pj.ref'=>
'ProjectRef',
'pj.title'=>
'ProjectLabel',
'fd.rowid'=>
'LineId',
'fd.description'=>
"LineDescription",
226 'fd.subprice'=>
"LineUnitPrice",
'fd.tva_tx'=>
"LineVATRate",
'fd.qty'=>
"LineQty",
'fd.total_ht'=>
"LineTotalHT",
'fd.total_tva'=>
"LineTotalVAT",
227 'fd.total_ttc'=>
"LineTotalTTC",
'fd.date_start'=>
"DateStart",
'fd.date_end'=>
"DateEnd",
'fd.special_code'=>
'SpecialCode',
228 'fd.product_type'=>
"TypeOfLineServiceOrProduct",
'fd.fk_product'=>
'ProductId',
'p.ref'=>
'ProductRef',
'p.label'=>
'ProductLabel',
229 'p.accountancy_code_sell'=>
'ProductAccountancySellCode'
231 if (!empty($conf->multicurrency->enabled))
233 $this->export_fields_array[$r][
'f.multicurrency_code'] =
'Currency';
234 $this->export_fields_array[$r][
'f.multicurrency_tx'] =
'CurrencyRate';
235 $this->export_fields_array[$r][
'f.multicurrency_total_ht'] =
'MulticurrencyAmountHT';
236 $this->export_fields_array[$r][
'f.multicurrency_total_tva'] =
'MulticurrencyAmountVAT';
237 $this->export_fields_array[$r][
'f.multicurrency_total_ttc'] =
'MulticurrencyAmountTTC';
239 if (!empty($conf->cashdesk->enabled) || !empty($conf->takepos->enabled) || !empty($conf->global->INVOICE_SHOW_POS))
241 $this->export_fields_array[$r][
'f.module_source'] =
'Module';
242 $this->export_fields_array[$r][
'f.pos_source'] =
'POSTerminal';
244 $this->export_TypeFields_array[$r] = array(
245 's.rowid'=>
'Numeric',
's.nom'=>
'Text',
's.code_client'=>
'Text',
's.address'=>
'Text',
's.zip'=>
'Text',
's.town'=>
'Text',
'c.code'=>
'Text',
'cd.nom'=>
'Text',
's.phone'=>
'Text',
's.siren'=>
'Text',
246 's.siret'=>
'Text',
's.ape'=>
'Text',
's.idprof4'=>
'Text',
's.code_compta'=>
'Text',
's.code_compta_fournisseur'=>
'Text',
's.tva_intra'=>
'Text',
247 'f.rowid'=>
'Numeric',
'f.ref'=>
"Text",
'f.ref_client'=>
'Text',
'f.type'=>
"Numeric",
'f.datec'=>
"Date",
'f.datef'=>
"Date",
'f.date_lim_reglement'=>
"Date",
248 'f.total'=>
"Numeric",
'f.total_ttc'=>
"Numeric",
'f.tva'=>
"Numeric",
'f.localtax1'=>
'Numeric',
'f.localtax2'=>
'Numeric',
'f.paye'=>
"Boolean",
'f.fk_statut'=>
'Numeric',
'f.close_code'=>
'Text',
'f.close_note'=>
'Text',
249 'none.rest'=>
"NumericCompute",
250 'f.note_private'=>
"Text",
'f.note_public'=>
"Text",
'f.fk_user_author'=>
'Numeric',
'uc.login'=>
'Text',
'f.fk_user_valid'=>
'Numeric',
'uv.login'=>
'Text',
251 'pj.ref'=>
'Text',
'pj.title'=>
'Text',
'fd.rowid'=>
'Numeric',
'fd.label'=>
'Text',
'fd.description'=>
"Text",
'fd.subprice'=>
"Numeric",
'fd.tva_tx'=>
"Numeric",
252 'fd.qty'=>
"Numeric",
'fd.total_ht'=>
"Numeric",
'fd.total_tva'=>
"Numeric",
'fd.total_ttc'=>
"Numeric",
'fd.date_start'=>
"Date",
'fd.date_end'=>
"Date",
253 'fd.special_code'=>
'Numeric',
'fd.product_type'=>
"Numeric",
'fd.fk_product'=>
'List:product:label',
'p.ref'=>
'Text',
'p.label'=>
'Text',
254 'p.accountancy_code_sell'=>
'Text'
256 if (!empty($conf->cashdesk->enabled) || !empty($conf->takepos->enabled) || !empty($conf->global->INVOICE_SHOW_POS))
258 $this->export_TypeFields_array[$r][
'f.module_source'] =
'Text';
259 $this->export_TypeFields_array[$r][
'f.pos_source'] =
'Text';
261 $this->export_entities_array[$r] = array(
262 's.rowid'=>
"company",
's.nom'=>
'company',
's.code_client'=>
'company',
's.address'=>
'company',
's.zip'=>
'company',
's.town'=>
'company',
'c.code'=>
'company',
'cd.nom'=>
'company',
's.phone'=>
'company',
263 's.siren'=>
'company',
's.siret'=>
'company',
's.ape'=>
'company',
's.idprof4'=>
'company',
's.code_compta'=>
'company',
's.code_compta_fournisseur'=>
'company',
264 's.tva_intra'=>
'company',
'pj.ref'=>
'project',
'pj.title'=>
'project',
'fd.rowid'=>
'invoice_line',
'fd.label'=>
"invoice_line",
'fd.description'=>
"invoice_line",
265 'fd.subprice'=>
"invoice_line",
'fd.total_ht'=>
"invoice_line",
'fd.total_tva'=>
"invoice_line",
'fd.total_ttc'=>
"invoice_line",
'fd.tva_tx'=>
"invoice_line",
266 'fd.qty'=>
"invoice_line",
'fd.date_start'=>
"invoice_line",
'fd.date_end'=>
"invoice_line",
'fd.special_code'=>
'invoice_line',
267 'fd.product_type'=>
'invoice_line',
'fd.fk_product'=>
'product',
'p.ref'=>
'product',
'p.label'=>
'product',
'p.accountancy_code_sell'=>
'product',
268 'f.fk_user_author'=>
'user',
'uc.login'=>
'user',
'f.fk_user_valid'=>
'user',
'uv.login'=>
'user'
270 $this->export_special_array[$r] = array(
'none.rest'=>
'getRemainToPay');
271 $this->export_dependencies_array[$r] = array(
'invoice_line'=>
'fd.rowid',
'product'=>
'fd.rowid',
'none.rest'=>array(
'f.rowid',
'f.total_ttc',
'f.close_code'));
272 $keyforselect =
'facture'; $keyforelement =
'invoice'; $keyforaliasextra =
'extra';
273 include DOL_DOCUMENT_ROOT.
'/core/extrafieldsinexport.inc.php';
274 $keyforselect =
'facturedet'; $keyforelement =
'invoice_line'; $keyforaliasextra =
'extra2';
275 include DOL_DOCUMENT_ROOT.
'/core/extrafieldsinexport.inc.php';
276 $keyforselect =
'product'; $keyforelement =
'product'; $keyforaliasextra =
'extra3';
277 include DOL_DOCUMENT_ROOT.
'/core/extrafieldsinexport.inc.php';
278 $this->export_sql_start[$r] =
'SELECT DISTINCT ';
279 $this->export_sql_end[$r] =
' FROM '.MAIN_DB_PREFIX.
'societe as s';
280 if (empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'societe_commerciaux as sc ON sc.fk_soc = s.rowid';
281 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'c_country as c on s.fk_pays = c.rowid';
282 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'c_departements as cd on s.fk_departement = cd.rowid,';
283 $this->export_sql_end[$r] .=
' '.MAIN_DB_PREFIX.
'facture as f';
284 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'projet as pj ON f.fk_projet = pj.rowid';
285 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'user as uc ON f.fk_user_author = uc.rowid';
286 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'user as uv ON f.fk_user_valid = uv.rowid';
287 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'facture_extrafields as extra ON f.rowid = extra.fk_object';
288 $this->export_sql_end[$r] .=
' , '.MAIN_DB_PREFIX.
'facturedet as fd';
289 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'facturedet_extrafields as extra2 on fd.rowid = extra2.fk_object';
290 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'product as p on (fd.fk_product = p.rowid)';
291 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'product_extrafields as extra3 on p.rowid = extra3.fk_object';
292 $this->export_sql_end[$r] .=
' WHERE f.fk_soc = s.rowid AND f.rowid = fd.fk_facture';
293 $this->export_sql_end[$r] .=
' AND f.entity IN ('.getEntity(
'invoice').
')';
294 if (empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .=
' AND sc.fk_user = '.(empty($user) ? 0 : $user->id);
298 $this->export_code[$r] = $this->rights_class.
'_'.$r;
299 $this->export_label[$r] =
'CustomersInvoicesAndPayments';
300 $this->export_icon[$r] =
'invoice';
301 $this->export_permission[$r] = array(array(
"facture",
"facture",
"export"));
302 $this->export_fields_array[$r] = array(
303 's.rowid'=>
"IdCompany",
's.nom'=>
'CompanyName',
's.code_client'=>
'CustomerCode',
's.address'=>
'Address',
's.zip'=>
'Zip',
's.town'=>
'Town',
'c.code'=>
'CountryCode',
'cd.nom'=>
'State',
305 's.siren'=>
'ProfId1',
's.siret'=>
'ProfId2',
's.ape'=>
'ProfId3',
's.idprof4'=>
'ProfId4',
's.code_compta'=>
'CustomerAccountancyCode',
306 's.code_compta_fournisseur'=>
'SupplierAccountancyCode',
's.tva_intra'=>
'VATIntra',
307 'f.rowid'=>
"InvoiceId",
'f.ref'=>
"InvoiceRef",
'f.ref_client'=>
'RefCustomer',
308 'f.type'=>
"Type",
'f.datec'=>
"InvoiceDateCreation",
'f.datef'=>
"DateInvoice",
'f.date_lim_reglement'=>
"DateDue",
'f.total'=>
"TotalHT",
309 'f.total_ttc'=>
"TotalTTC",
'f.tva'=>
"TotalVAT",
'f.localtax1'=>
'LT1',
'f.localtax2'=>
'LT2',
'f.paye'=>
"InvoicePaidCompletely",
'f.fk_statut'=>
'InvoiceStatus',
'f.close_code'=>
'EarlyClosingReason',
'f.close_note'=>
'EarlyClosingComment',
311 'f.note_private'=>
"NotePrivate",
'f.note_public'=>
"NotePublic",
'f.fk_user_author'=>
'CreatedById',
'uc.login'=>
'CreatedByLogin',
312 'f.fk_user_valid'=>
'ValidatedById',
'uv.login'=>
'ValidatedByLogin',
'pj.ref'=>
'ProjectRef',
'pj.title'=>
'ProjectLabel',
'p.rowid'=>
'PaymentId',
'p.ref'=>
'PaymentRef',
313 'p.amount'=>
'AmountPayment',
'pf.amount'=>
'AmountPaymentDistributedOnInvoice',
'p.datep'=>
'DatePayment',
'p.num_paiement'=>
'PaymentNumber',
314 'pt.code'=>
'CodePaymentMode',
'pt.libelle'=>
'LabelPaymentMode',
'p.note'=>
'PaymentNote',
'p.fk_bank'=>
'IdTransaction',
'ba.ref'=>
'AccountRef'
316 $this->export_help_array[$r] = array(
'f.paye'=>
'InvoicePaidCompletelyHelp');
317 if (!empty($conf->multicurrency->enabled))
319 $this->export_fields_array[$r][
'f.multicurrency_code'] =
'Currency';
320 $this->export_fields_array[$r][
'f.multicurrency_tx'] =
'CurrencyRate';
321 $this->export_fields_array[$r][
'f.multicurrency_total_ht'] =
'MulticurrencyAmountHT';
322 $this->export_fields_array[$r][
'f.multicurrency_total_tva'] =
'MulticurrencyAmountVAT';
323 $this->export_fields_array[$r][
'f.multicurrency_total_ttc'] =
'MulticurrencyAmountTTC';
324 $this->export_examplevalues_array[$r][
'f.multicurrency_code'] =
'EUR';
326 if (!empty($conf->cashdesk->enabled) || !empty($conf->takepos->enabled) || !empty($conf->global->INVOICE_SHOW_POS))
328 $this->export_fields_array[$r][
'f.module_source'] =
'POSModule';
329 $this->export_fields_array[$r][
'f.pos_source'] =
'POSTerminal';
331 $this->export_TypeFields_array[$r] = array(
332 's.rowid'=>
'Numeric',
's.nom'=>
'Text',
's.code_client'=>
'Text',
's.address'=>
'Text',
's.zip'=>
'Text',
's.town'=>
'Text',
'c.code'=>
'Text',
'cd.nom'=>
'Text',
's.phone'=>
'Text',
's.siren'=>
'Text',
333 's.siret'=>
'Text',
's.ape'=>
'Text',
's.idprof4'=>
'Text',
's.code_compta'=>
'Text',
's.code_compta_fournisseur'=>
'Text',
's.tva_intra'=>
'Text',
334 'f.rowid'=>
"Numeric",
'f.ref'=>
"Text",
'f.ref_client'=>
'Text',
'f.type'=>
"Numeric",
'f.datec'=>
"Date",
'f.datef'=>
"Date",
'f.date_lim_reglement'=>
"Date",
335 'f.total'=>
"Numeric",
'f.total_ttc'=>
"Numeric",
'f.tva'=>
"Numeric",
'f.localtax1'=>
'Numeric',
'f.localtax2'=>
'Numeric',
'f.paye'=>
"Boolean",
'f.fk_statut'=>
'Status',
'f.close_code'=>
'Text',
'f.close_note'=>
'Text',
336 'none.rest'=>
'NumericCompute',
337 'f.note_private'=>
"Text",
'f.note_public'=>
"Text",
'f.fk_user_author'=>
'Numeric',
'uc.login'=>
'Text',
'f.fk_user_valid'=>
'Numeric',
'uv.login'=>
'Text',
338 'pj.ref'=>
'Text',
'pj.title'=>
'Text',
'p.amount'=>
'Numeric',
'pf.amount'=>
'Numeric',
'p.rowid'=>
'Numeric',
'p.ref'=>
'Text',
'p.title'=>
'Text',
'p.datep'=>
'Date',
'p.num_paiement'=>
'Numeric',
339 'p.fk_bank'=>
'Numeric',
'p.note'=>
'Text',
'pt.code'=>
'Text',
'pt.libelle'=>
'text',
'ba.ref'=>
'Text'
341 if (!empty($conf->cashdesk->enabled) || !empty($conf->takepos->enabled) || !empty($conf->global->INVOICE_SHOW_POS))
343 $this->export_fields_array[$r][
'f.module_source'] =
'POSModule';
344 $this->export_fields_array[$r][
'f.pos_source'] =
'POSTerminal';
346 $this->export_entities_array[$r] = array(
347 's.rowid'=>
"company",
's.nom'=>
'company',
's.code_client'=>
'company',
's.address'=>
'company',
's.zip'=>
'company',
's.town'=>
'company',
'c.code'=>
'company',
'cd.nom'=>
'company',
's.phone'=>
'company',
348 's.siren'=>
'company',
's.siret'=>
'company',
's.ape'=>
'company',
's.idprof4'=>
'company',
's.code_compta'=>
'company',
's.code_compta_fournisseur'=>
'company',
349 's.tva_intra'=>
'company',
'pj.ref'=>
'project',
'pj.title'=>
'project',
'p.rowid'=>
'payment',
'p.ref'=>
'payment',
'p.amount'=>
'payment',
'pf.amount'=>
'payment',
'p.datep'=>
'payment',
350 'p.num_paiement'=>
'payment',
'pt.code'=>
'payment',
'pt.libelle'=>
'payment',
'p.note'=>
'payment',
'f.fk_user_author'=>
'user',
'uc.login'=>
'user',
351 'f.fk_user_valid'=>
'user',
'uv.login'=>
'user',
'p.fk_bank'=>
'account',
'ba.ref'=>
'account'
353 $this->export_special_array[$r] = array(
'none.rest'=>
'getRemainToPay');
354 $this->export_dependencies_array[$r] = array(
'payment'=>
'p.rowid',
'none.rest'=>array(
'f.rowid',
'f.total_ttc',
'f.close_code'));
355 $keyforselect =
'facture'; $keyforelement =
'invoice'; $keyforaliasextra =
'extra';
356 include DOL_DOCUMENT_ROOT.
'/core/extrafieldsinexport.inc.php';
357 $this->export_sql_start[$r] =
'SELECT DISTINCT ';
358 $this->export_sql_end[$r] =
' FROM '.MAIN_DB_PREFIX.
'societe as s';
359 if (empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'societe_commerciaux as sc ON sc.fk_soc = s.rowid';
360 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'c_country as c on s.fk_pays = c.rowid';
361 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'c_departements as cd on s.fk_departement = cd.rowid,';
362 $this->export_sql_end[$r] .=
' '.MAIN_DB_PREFIX.
'facture as f';
363 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'projet as pj ON f.fk_projet = pj.rowid';
364 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'user as uc ON f.fk_user_author = uc.rowid';
365 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'user as uv ON f.fk_user_valid = uv.rowid';
366 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'facture_extrafields as extra ON f.rowid = extra.fk_object';
367 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'paiement_facture as pf ON pf.fk_facture = f.rowid';
368 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'paiement as p ON pf.fk_paiement = p.rowid';
369 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'c_paiement as pt ON pt.id = p.fk_paiement';
370 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'bank as b ON b.rowid = p.fk_bank';
371 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'bank_account as ba ON ba.rowid = b.fk_account';
372 $this->export_sql_end[$r] .=
' WHERE f.fk_soc = s.rowid';
373 $this->export_sql_end[$r] .=
' AND f.entity IN ('.getEntity(
'invoice').
')';
374 if (empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .=
' AND sc.fk_user = '.(empty($user) ? 0 : $user->id);
387 public function init($options =
'')
389 global $conf, $langs;
392 $this->
remove($options);
395 $src = DOL_DOCUMENT_ROOT.
'/install/doctemplates/invoices/template_invoice.odt';
396 $dirodt = DOL_DATA_ROOT.
'/doctemplates/invoices';
397 $dest = $dirodt.
'/template_invoice.odt';
399 if (file_exists($src) && !file_exists($dest))
401 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
403 $result =
dol_copy($src, $dest, 0, 0);
406 $langs->load(
"errors");
407 $this->error = $langs->trans(
'ErrorFailToCopyFile', $src, $dest);
413 "DELETE FROM ".MAIN_DB_PREFIX.
"document_model WHERE nom = '".$this->db->escape($this->const[1][2]).
"' AND type = 'invoice' AND entity = ".$conf->entity,
414 "INSERT INTO ".MAIN_DB_PREFIX.
"document_model (nom, type, entity) VALUES('".$this->
db->escape($this->
const[1][2]).
"','invoice',".$conf->entity.
")"
417 return $this->
_init($sql, $options);
dol_copy($srcfile, $destfile, $newmask=0, $overwriteifexists=1)
Copy a file to another file.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm= 'auto', $check=1)
Return a timestamp date built from detailed informations (by default a local PHP server timestamp) Re...
</td > param sortfield sortorder printFieldListOption< tdclass="liste_titremaxwidthsearchright"></td ></tr >< trclass="liste_titre">< inputtype="checkbox"onClick="toggle(this)"/> Ref p ref Label p label Duration p duration center DesiredStock p desiredstock right StockLimitShort p seuil_stock_alerte right stock_physique right stock_real_warehouse right Ordered right StockToBuy right SupplierRef right param sortfield sortorder printFieldListTitle warehouseinternal SELECT description FROM product_lang WHERE qty< br > qty qty qty StockTooLow StockTooLow help help help< trclass="oddeven">< td >< inputtype="checkbox"class="check"name="choose'.$i.'"></td >< tdclass="nowrap"> stock</td >< td >< inputtype="hidden"name="desc'.$i.'"value="'.dol_escape_htmltag($objp-> description
Only used if Module[ID]Desc translation string is not found.
dol_now($mode= 'auto')
Return date for now.
init($options= '')
Function called when module is enabled.
$conf db name
Only used if Module[ID]Name translation string is not found.
$conf db
API class for accounts.
__construct($db)
Constructor.
dol_getdate($timestamp, $fast=false, $forcetimezone= '')
Return an array with locale date info.
_init($array_sql, $options= '')
Enables a module.
Class to describe module customer invoices.
dol_mkdir($dir, $dataroot= '', $newmask=null)
Creation of a directory (this can create recursive subdir)