@@ -30,28 +30,28 @@ discard block |
||
30 | 30 | */ |
31 | 31 | class mod_supplier_payment_brodator extends ModeleNumRefSupplierPayments |
32 | 32 | { |
33 | - /** |
|
33 | + /** |
|
34 | 34 | * Dolibarr version of the loaded document |
35 | 35 | * @public string |
36 | 36 | */ |
37 | - public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' |
|
37 | + public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' |
|
38 | 38 | |
39 | - /** |
|
39 | + /** |
|
40 | 40 | * @var string Error code (or message) |
41 | 41 | */ |
42 | 42 | public $error = ''; |
43 | 43 | |
44 | - /** |
|
45 | - * @var string Nom du modele |
|
46 | - * @deprecated |
|
47 | - * @see name |
|
48 | - */ |
|
49 | - public $nom='Brodator'; |
|
44 | + /** |
|
45 | + * @var string Nom du modele |
|
46 | + * @deprecated |
|
47 | + * @see name |
|
48 | + */ |
|
49 | + public $nom='Brodator'; |
|
50 | 50 | |
51 | - /** |
|
52 | - * @var string model name |
|
53 | - */ |
|
54 | - public $name='Brodator'; |
|
51 | + /** |
|
52 | + * @var string model name |
|
53 | + */ |
|
54 | + public $name='Brodator'; |
|
55 | 55 | |
56 | 56 | |
57 | 57 | /** |
@@ -59,39 +59,39 @@ discard block |
||
59 | 59 | * |
60 | 60 | * @return string Texte descripif |
61 | 61 | */ |
62 | - function info() |
|
62 | + function info() |
|
63 | 63 | { |
64 | - global $conf, $langs; |
|
64 | + global $conf, $langs; |
|
65 | 65 | |
66 | - $langs->load("bills"); |
|
66 | + $langs->load("bills"); |
|
67 | 67 | |
68 | - $form = new Form($this->db); |
|
68 | + $form = new Form($this->db); |
|
69 | 69 | |
70 | - $texte = $langs->trans('GenericNumRefModelDesc')."<br>\n"; |
|
71 | - $texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">'; |
|
72 | - $texte.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
73 | - $texte.= '<input type="hidden" name="action" value="updateMask">'; |
|
74 | - $texte.= '<input type="hidden" name="maskconstsupplierpayment" value="SUPPLIER_PAYMENT_BRODATOR_MASK">'; |
|
75 | - $texte.= '<table class="nobordernopadding" width="100%">'; |
|
70 | + $texte = $langs->trans('GenericNumRefModelDesc')."<br>\n"; |
|
71 | + $texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">'; |
|
72 | + $texte.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
73 | + $texte.= '<input type="hidden" name="action" value="updateMask">'; |
|
74 | + $texte.= '<input type="hidden" name="maskconstsupplierpayment" value="SUPPLIER_PAYMENT_BRODATOR_MASK">'; |
|
75 | + $texte.= '<table class="nobordernopadding" width="100%">'; |
|
76 | 76 | |
77 | - $tooltip=$langs->trans("GenericMaskCodes",$langs->transnoentities("Order"),$langs->transnoentities("Order")); |
|
78 | - $tooltip.=$langs->trans("GenericMaskCodes2"); |
|
79 | - $tooltip.=$langs->trans("GenericMaskCodes3"); |
|
80 | - $tooltip.=$langs->trans("GenericMaskCodes4a",$langs->transnoentities("Order"),$langs->transnoentities("Order")); |
|
81 | - $tooltip.=$langs->trans("GenericMaskCodes5"); |
|
77 | + $tooltip=$langs->trans("GenericMaskCodes",$langs->transnoentities("Order"),$langs->transnoentities("Order")); |
|
78 | + $tooltip.=$langs->trans("GenericMaskCodes2"); |
|
79 | + $tooltip.=$langs->trans("GenericMaskCodes3"); |
|
80 | + $tooltip.=$langs->trans("GenericMaskCodes4a",$langs->transnoentities("Order"),$langs->transnoentities("Order")); |
|
81 | + $tooltip.=$langs->trans("GenericMaskCodes5"); |
|
82 | 82 | |
83 | - // Parametrage du prefix |
|
84 | - $texte.= '<tr><td>'.$langs->trans("Mask").':</td>'; |
|
85 | - $texte.= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="masksupplierpayment" value="'.$conf->global->SUPPLIER_PAYMENT_BRODATOR_MASK.'">',$tooltip,1,1).'</td>'; |
|
83 | + // Parametrage du prefix |
|
84 | + $texte.= '<tr><td>'.$langs->trans("Mask").':</td>'; |
|
85 | + $texte.= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="masksupplierpayment" value="'.$conf->global->SUPPLIER_PAYMENT_BRODATOR_MASK.'">',$tooltip,1,1).'</td>'; |
|
86 | 86 | |
87 | - $texte.= '<td align="left" rowspan="2"> <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>'; |
|
87 | + $texte.= '<td align="left" rowspan="2"> <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>'; |
|
88 | 88 | |
89 | - $texte.= '</tr>'; |
|
89 | + $texte.= '</tr>'; |
|
90 | 90 | |
91 | - $texte.= '</table>'; |
|
92 | - $texte.= '</form>'; |
|
91 | + $texte.= '</table>'; |
|
92 | + $texte.= '</form>'; |
|
93 | 93 | |
94 | - return $texte; |
|
94 | + return $texte; |
|
95 | 95 | } |
96 | 96 | |
97 | 97 | /** |
@@ -101,55 +101,55 @@ discard block |
||
101 | 101 | */ |
102 | 102 | function getExample() |
103 | 103 | { |
104 | - global $conf,$langs,$mysoc; |
|
105 | - |
|
106 | - $old_code_client=$mysoc->code_client; |
|
107 | - $mysoc->code_client='CCCCCCCCCC'; |
|
108 | - $numExample = $this->getNextValue($mysoc,''); |
|
109 | - $mysoc->code_client=$old_code_client; |
|
110 | - |
|
111 | - if (! $numExample) |
|
112 | - { |
|
113 | - $numExample = $langs->trans('NotConfigured'); |
|
114 | - } |
|
115 | - return $numExample; |
|
104 | + global $conf,$langs,$mysoc; |
|
105 | + |
|
106 | + $old_code_client=$mysoc->code_client; |
|
107 | + $mysoc->code_client='CCCCCCCCCC'; |
|
108 | + $numExample = $this->getNextValue($mysoc,''); |
|
109 | + $mysoc->code_client=$old_code_client; |
|
110 | + |
|
111 | + if (! $numExample) |
|
112 | + { |
|
113 | + $numExample = $langs->trans('NotConfigured'); |
|
114 | + } |
|
115 | + return $numExample; |
|
116 | 116 | } |
117 | 117 | |
118 | - /** |
|
119 | - * Return next free value |
|
120 | - * |
|
121 | - * @param Societe $objsoc Object thirdparty |
|
122 | - * @param Object $object Object we need next value for |
|
123 | - * @return string Value if KO, <0 if KO |
|
124 | - */ |
|
118 | + /** |
|
119 | + * Return next free value |
|
120 | + * |
|
121 | + * @param Societe $objsoc Object thirdparty |
|
122 | + * @param Object $object Object we need next value for |
|
123 | + * @return string Value if KO, <0 if KO |
|
124 | + */ |
|
125 | 125 | function getNextValue($objsoc,$object) |
126 | 126 | { |
127 | - global $db,$conf; |
|
127 | + global $db,$conf; |
|
128 | 128 | |
129 | - require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php'; |
|
129 | + require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php'; |
|
130 | 130 | |
131 | - // We get cursor rule |
|
132 | - $mask=$conf->global->SUPPLIER_PAYMENT_BRODATOR_MASK; |
|
131 | + // We get cursor rule |
|
132 | + $mask=$conf->global->SUPPLIER_PAYMENT_BRODATOR_MASK; |
|
133 | 133 | |
134 | - if (! $mask) |
|
135 | - { |
|
136 | - $this->error='NotConfigured'; |
|
137 | - return 0; |
|
138 | - } |
|
134 | + if (! $mask) |
|
135 | + { |
|
136 | + $this->error='NotConfigured'; |
|
137 | + return 0; |
|
138 | + } |
|
139 | 139 | |
140 | - $numFinal=get_next_value($db,$mask,'paiementfourn','ref','',$objsoc,$object->datepaye); |
|
140 | + $numFinal=get_next_value($db,$mask,'paiementfourn','ref','',$objsoc,$object->datepaye); |
|
141 | 141 | |
142 | - return $numFinal; |
|
143 | - } |
|
142 | + return $numFinal; |
|
143 | + } |
|
144 | 144 | |
145 | 145 | |
146 | 146 | // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps |
147 | - /** |
|
148 | - * Return next free value |
|
149 | - * |
|
150 | - * @param Societe $objsoc Object third party |
|
151 | - * @param string $objforref Object for number to search |
|
152 | - * @return string Next free value |
|
147 | + /** |
|
148 | + * Return next free value |
|
149 | + * |
|
150 | + * @param Societe $objsoc Object third party |
|
151 | + * @param string $objforref Object for number to search |
|
152 | + * @return string Next free value |
|
153 | 153 | */ |
154 | 154 | function commande_get_num($objsoc,$objforref) |
155 | 155 | { |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | * \brief File containing class for numbering module Brodator |
23 | 23 | */ |
24 | 24 | |
25 | -require_once DOL_DOCUMENT_ROOT .'/core/modules/supplier_payment/modules_supplier_payment.php'; |
|
25 | +require_once DOL_DOCUMENT_ROOT.'/core/modules/supplier_payment/modules_supplier_payment.php'; |
|
26 | 26 | |
27 | 27 | |
28 | 28 | /** |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | * Dolibarr version of the loaded document |
35 | 35 | * @public string |
36 | 36 | */ |
37 | - public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' |
|
37 | + public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' |
|
38 | 38 | |
39 | 39 | /** |
40 | 40 | * @var string Error code (or message) |
@@ -46,12 +46,12 @@ discard block |
||
46 | 46 | * @deprecated |
47 | 47 | * @see name |
48 | 48 | */ |
49 | - public $nom='Brodator'; |
|
49 | + public $nom = 'Brodator'; |
|
50 | 50 | |
51 | 51 | /** |
52 | 52 | * @var string model name |
53 | 53 | */ |
54 | - public $name='Brodator'; |
|
54 | + public $name = 'Brodator'; |
|
55 | 55 | |
56 | 56 | |
57 | 57 | /** |
@@ -68,28 +68,28 @@ discard block |
||
68 | 68 | $form = new Form($this->db); |
69 | 69 | |
70 | 70 | $texte = $langs->trans('GenericNumRefModelDesc')."<br>\n"; |
71 | - $texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">'; |
|
72 | - $texte.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
73 | - $texte.= '<input type="hidden" name="action" value="updateMask">'; |
|
74 | - $texte.= '<input type="hidden" name="maskconstsupplierpayment" value="SUPPLIER_PAYMENT_BRODATOR_MASK">'; |
|
75 | - $texte.= '<table class="nobordernopadding" width="100%">'; |
|
76 | - |
|
77 | - $tooltip=$langs->trans("GenericMaskCodes",$langs->transnoentities("Order"),$langs->transnoentities("Order")); |
|
78 | - $tooltip.=$langs->trans("GenericMaskCodes2"); |
|
79 | - $tooltip.=$langs->trans("GenericMaskCodes3"); |
|
80 | - $tooltip.=$langs->trans("GenericMaskCodes4a",$langs->transnoentities("Order"),$langs->transnoentities("Order")); |
|
81 | - $tooltip.=$langs->trans("GenericMaskCodes5"); |
|
71 | + $texte .= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">'; |
|
72 | + $texte .= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
73 | + $texte .= '<input type="hidden" name="action" value="updateMask">'; |
|
74 | + $texte .= '<input type="hidden" name="maskconstsupplierpayment" value="SUPPLIER_PAYMENT_BRODATOR_MASK">'; |
|
75 | + $texte .= '<table class="nobordernopadding" width="100%">'; |
|
76 | + |
|
77 | + $tooltip = $langs->trans("GenericMaskCodes", $langs->transnoentities("Order"), $langs->transnoentities("Order")); |
|
78 | + $tooltip .= $langs->trans("GenericMaskCodes2"); |
|
79 | + $tooltip .= $langs->trans("GenericMaskCodes3"); |
|
80 | + $tooltip .= $langs->trans("GenericMaskCodes4a", $langs->transnoentities("Order"), $langs->transnoentities("Order")); |
|
81 | + $tooltip .= $langs->trans("GenericMaskCodes5"); |
|
82 | 82 | |
83 | 83 | // Parametrage du prefix |
84 | - $texte.= '<tr><td>'.$langs->trans("Mask").':</td>'; |
|
85 | - $texte.= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="masksupplierpayment" value="'.$conf->global->SUPPLIER_PAYMENT_BRODATOR_MASK.'">',$tooltip,1,1).'</td>'; |
|
84 | + $texte .= '<tr><td>'.$langs->trans("Mask").':</td>'; |
|
85 | + $texte .= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="masksupplierpayment" value="'.$conf->global->SUPPLIER_PAYMENT_BRODATOR_MASK.'">', $tooltip, 1, 1).'</td>'; |
|
86 | 86 | |
87 | - $texte.= '<td align="left" rowspan="2"> <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>'; |
|
87 | + $texte .= '<td align="left" rowspan="2"> <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>'; |
|
88 | 88 | |
89 | - $texte.= '</tr>'; |
|
89 | + $texte .= '</tr>'; |
|
90 | 90 | |
91 | - $texte.= '</table>'; |
|
92 | - $texte.= '</form>'; |
|
91 | + $texte .= '</table>'; |
|
92 | + $texte .= '</form>'; |
|
93 | 93 | |
94 | 94 | return $texte; |
95 | 95 | } |
@@ -101,14 +101,14 @@ discard block |
||
101 | 101 | */ |
102 | 102 | function getExample() |
103 | 103 | { |
104 | - global $conf,$langs,$mysoc; |
|
104 | + global $conf, $langs, $mysoc; |
|
105 | 105 | |
106 | - $old_code_client=$mysoc->code_client; |
|
107 | - $mysoc->code_client='CCCCCCCCCC'; |
|
108 | - $numExample = $this->getNextValue($mysoc,''); |
|
109 | - $mysoc->code_client=$old_code_client; |
|
106 | + $old_code_client = $mysoc->code_client; |
|
107 | + $mysoc->code_client = 'CCCCCCCCCC'; |
|
108 | + $numExample = $this->getNextValue($mysoc, ''); |
|
109 | + $mysoc->code_client = $old_code_client; |
|
110 | 110 | |
111 | - if (! $numExample) |
|
111 | + if (!$numExample) |
|
112 | 112 | { |
113 | 113 | $numExample = $langs->trans('NotConfigured'); |
114 | 114 | } |
@@ -122,22 +122,22 @@ discard block |
||
122 | 122 | * @param Object $object Object we need next value for |
123 | 123 | * @return string Value if KO, <0 if KO |
124 | 124 | */ |
125 | - function getNextValue($objsoc,$object) |
|
125 | + function getNextValue($objsoc, $object) |
|
126 | 126 | { |
127 | - global $db,$conf; |
|
127 | + global $db, $conf; |
|
128 | 128 | |
129 | - require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php'; |
|
129 | + require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; |
|
130 | 130 | |
131 | 131 | // We get cursor rule |
132 | - $mask=$conf->global->SUPPLIER_PAYMENT_BRODATOR_MASK; |
|
132 | + $mask = $conf->global->SUPPLIER_PAYMENT_BRODATOR_MASK; |
|
133 | 133 | |
134 | - if (! $mask) |
|
134 | + if (!$mask) |
|
135 | 135 | { |
136 | - $this->error='NotConfigured'; |
|
136 | + $this->error = 'NotConfigured'; |
|
137 | 137 | return 0; |
138 | 138 | } |
139 | 139 | |
140 | - $numFinal=get_next_value($db,$mask,'paiementfourn','ref','',$objsoc,$object->datepaye); |
|
140 | + $numFinal = get_next_value($db, $mask, 'paiementfourn', 'ref', '', $objsoc, $object->datepaye); |
|
141 | 141 | |
142 | 142 | return $numFinal; |
143 | 143 | } |
@@ -151,9 +151,9 @@ discard block |
||
151 | 151 | * @param string $objforref Object for number to search |
152 | 152 | * @return string Next free value |
153 | 153 | */ |
154 | - function commande_get_num($objsoc,$objforref) |
|
154 | + function commande_get_num($objsoc, $objforref) |
|
155 | 155 | { |
156 | 156 | // phpcs:enable |
157 | - return $this->getNextValue($objsoc,$objforref); |
|
157 | + return $this->getNextValue($objsoc, $objforref); |
|
158 | 158 | } |
159 | 159 | } |
@@ -36,164 +36,164 @@ |
||
36 | 36 | class modTax extends DolibarrModules |
37 | 37 | { |
38 | 38 | |
39 | - /** |
|
40 | - * Constructor. Define names, constants, directories, boxes, permissions |
|
41 | - * |
|
42 | - * @param DoliDB $db Database handler |
|
43 | - */ |
|
44 | - function __construct($db) |
|
45 | - { |
|
46 | - global $conf; |
|
47 | - |
|
48 | - $this->db = $db; |
|
49 | - $this->numero = 500; |
|
50 | - |
|
51 | - $this->family = "financial"; |
|
52 | - // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) |
|
53 | - $this->name = preg_replace('/^mod/i','',get_class($this)); |
|
54 | - // Module description used if translation string 'ModuleXXXDesc' not found (where XXX is value of numeric property 'numero' of module) |
|
55 | - $this->description = "Gestion des taxes, charges sociales et dividendes"; |
|
56 | - |
|
57 | - // Possible values for version are: 'development', 'experimental', 'dolibarr' or version |
|
58 | - $this->version = 'dolibarr'; |
|
59 | - |
|
60 | - $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); |
|
61 | - $this->picto='bill'; |
|
62 | - |
|
63 | - // Data directories to create when module is enabled |
|
64 | - $this->dirs = array("/tax/temp"); |
|
65 | - |
|
66 | - // Config pages |
|
67 | - $this->config_page_url = array("taxes.php"); |
|
68 | - |
|
69 | - // Dependencies |
|
70 | - $this->hidden = false; // A condition to hide module |
|
71 | - $this->depends = array(); // List of module class names as string that must be enabled if this module is enabled |
|
72 | - $this->requiredby = array(); // List of module ids to disable if this one is disabled |
|
73 | - $this->conflictwith = array(); // List of module class names as string this module is in conflict with |
|
74 | - $this->phpmin = array(5,4); // Minimum version of PHP required by module |
|
75 | - $this->langfiles = array("compta","bills"); |
|
76 | - |
|
77 | - // Constants |
|
78 | - $this->const = array(); |
|
79 | - |
|
80 | - // Boxes |
|
81 | - $this->boxes = array(); |
|
82 | - |
|
83 | - // Permissions |
|
84 | - $this->rights = array(); |
|
85 | - $this->rights_class = 'tax'; |
|
86 | - $r=0; |
|
87 | - |
|
88 | - $r++; |
|
89 | - $this->rights[$r][0] = 91; |
|
90 | - $this->rights[$r][1] = 'Lire les charges'; |
|
91 | - $this->rights[$r][2] = 'r'; |
|
92 | - $this->rights[$r][3] = 0; |
|
93 | - $this->rights[$r][4] = 'charges'; |
|
94 | - $this->rights[$r][5] = 'lire'; |
|
95 | - |
|
96 | - $r++; |
|
97 | - $this->rights[$r][0] = 92; |
|
98 | - $this->rights[$r][1] = 'Creer/modifier les charges'; |
|
99 | - $this->rights[$r][2] = 'w'; |
|
100 | - $this->rights[$r][3] = 0; |
|
101 | - $this->rights[$r][4] = 'charges'; |
|
102 | - $this->rights[$r][5] = 'creer'; |
|
103 | - |
|
104 | - $r++; |
|
105 | - $this->rights[$r][0] = 93; |
|
106 | - $this->rights[$r][1] = 'Supprimer les charges'; |
|
107 | - $this->rights[$r][2] = 'd'; |
|
108 | - $this->rights[$r][3] = 0; |
|
109 | - $this->rights[$r][4] = 'charges'; |
|
110 | - $this->rights[$r][5] = 'supprimer'; |
|
111 | - |
|
112 | - $r++; |
|
113 | - $this->rights[$r][0] = 94; |
|
114 | - $this->rights[$r][1] = 'Exporter les charges'; |
|
115 | - $this->rights[$r][2] = 'r'; |
|
116 | - $this->rights[$r][3] = 0; |
|
117 | - $this->rights[$r][4] = 'charges'; |
|
118 | - $this->rights[$r][5] = 'export'; |
|
119 | - |
|
120 | - |
|
121 | - // Menus |
|
122 | - $this->menu = 1; // This module add menu entries. They are coded into menu manager. |
|
123 | - |
|
124 | - |
|
125 | - // Exports |
|
126 | - $r=0; |
|
127 | - |
|
128 | - $r++; |
|
129 | - $this->export_code[$r]=$this->rights_class.'_'.$r; |
|
130 | - $this->export_label[$r]='Taxes et charges sociales, et leurs reglements'; |
|
131 | - $this->export_permission[$r]=array(array("tax","charges","export")); |
|
132 | - $this->export_fields_array[$r]=array('cc.libelle'=>"Type",'c.rowid'=>"IdSocialContribution",'c.libelle'=>"Label",'c.date_ech'=>'DateDue','c.periode'=>'Period','c.amount'=>"AmountExpected","c.paye"=>"Status",'p.rowid'=>'PaymentId','p.datep'=>'DatePayment','p.amount'=>'AmountPayment','p.num_paiement'=>'Numero'); |
|
133 | - $this->export_TypeFields_array[$r]=array('cc.libelle'=>"List:c_chargesociales:libelle:id",'c.libelle'=>"Text",'c.date_ech'=>'Date','c.periode'=>'Period','c.amount'=>"Numeric","c.paye"=>"Boolean",'p.datep'=>'Date','p.amount'=>'Numeric','p.num_paiement'=>'Numeric'); |
|
134 | - $this->export_entities_array[$r]=array('cc.libelle'=>"tax_type",'c.rowid'=>"tax",'c.libelle'=>'tax','c.date_ech'=>'tax','c.periode'=>'tax','c.amount'=>"tax","c.paye"=>"tax",'p.rowid'=>'payment','p.datep'=>'payment','p.amount'=>'payment','p.num_paiement'=>'payment'); |
|
135 | - |
|
136 | - $this->export_sql_start[$r]='SELECT DISTINCT '; |
|
137 | - $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'c_chargesociales as cc, '.MAIN_DB_PREFIX.'chargesociales as c'; |
|
138 | - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'paiementcharge as p ON p.fk_charge = c.rowid'; |
|
139 | - $this->export_sql_end[$r] .=' WHERE c.fk_type = cc.id'; |
|
140 | - $this->export_sql_end[$r] .=' AND c.entity IN ('.getEntity('tax').')'; |
|
141 | - |
|
142 | - // Import social contributions |
|
143 | - $r++; |
|
144 | - $this->import_code[$r]=$this->rights_class.'_'.$r; |
|
145 | - $this->import_label[$r]="ImportDataset_tax_contrib"; // Translation key |
|
146 | - $this->import_icon[$r]='tax'; |
|
147 | - $this->import_entities_array[$r]=array(); // We define here only fields that use another icon that the one defined into import_icon |
|
148 | - $this->import_tables_array[$r]=array('t'=>MAIN_DB_PREFIX.'chargesociales'); |
|
149 | - $this->import_fields_array[$r]=array('t.libelle'=>"Label*",'t.fk_type'=>"Type", |
|
150 | - 't.amount'=>"Amount*",'t.date_ech'=>"DateDue*",'t.periode'=>"PeriodEndDate*" |
|
151 | - ); |
|
152 | - |
|
153 | - $this->import_convertvalue_array[$r]=array( |
|
154 | - 't.fk_type'=>array('rule'=>'fetchidfromref','classfile'=>'/compta/sociales/class/cchargesociales.class.php','class'=>'Cchargesociales','method'=>'fetch','element'=>'Cchargesociales') |
|
155 | - ); |
|
156 | - $this->import_examplevalues_array[$r]=array('t.libelle'=>"Social/fiscal contribution",'t.fk_type'=>"TAXPRO (must be id or code found into dictionary)", |
|
157 | - 't.date_ech'=>"2016-01-01", 't.periode'=>"2016-01-01" |
|
158 | - ); |
|
159 | - |
|
160 | - // Import Taxes |
|
161 | - $r++; |
|
162 | - $this->import_code[$r]=$this->rights_class.'_'.$r; |
|
163 | - $this->import_label[$r]="ImportDataset_tax_vat"; // Translation key |
|
164 | - $this->import_icon[$r]='tax'; |
|
165 | - $this->import_entities_array[$r]=array(); // We define here only fields that use another icon that the one defined into import_icon |
|
166 | - $this->import_tables_array[$r]=array('t'=>MAIN_DB_PREFIX.'tva'); |
|
167 | - $this->import_fields_array[$r]=array('t.datep'=>"DatePayment*",'t.datev'=>"DateValue*",'t.label'=>"Label*",'t.fk_typepayment'=>"PaymentMode*", |
|
168 | - 't.amount'=>"Amount*",'t.num_payment'=>'Numero' |
|
169 | - ); |
|
170 | - |
|
171 | - $this->import_convertvalue_array[$r]=array( |
|
172 | - 't.fk_typepayment'=>array('rule'=>'fetchidfromref','classfile'=>'/compta/paiement/class/cpaiement.class.php','class'=>'Cpaiement','method'=>'fetch','element'=>'Cpaiement') |
|
173 | - ); |
|
174 | - $this->import_examplevalues_array[$r]=array('t.label'=>"VAT Payment 1st quarter 2016",'t.fk_typepayment'=>"CHQ (must be id or code found into dictionary)", |
|
175 | - 't.datep'=>"2016-04-02", 't.datev'=>"2016-03-31", 't.amount'=>1000, 't.num_payment'=>'123456' |
|
176 | - ); |
|
177 | - } |
|
178 | - |
|
179 | - |
|
180 | - /** |
|
181 | - * Function called when module is enabled. |
|
182 | - * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. |
|
183 | - * It also creates data directories |
|
184 | - * |
|
39 | + /** |
|
40 | + * Constructor. Define names, constants, directories, boxes, permissions |
|
41 | + * |
|
42 | + * @param DoliDB $db Database handler |
|
43 | + */ |
|
44 | + function __construct($db) |
|
45 | + { |
|
46 | + global $conf; |
|
47 | + |
|
48 | + $this->db = $db; |
|
49 | + $this->numero = 500; |
|
50 | + |
|
51 | + $this->family = "financial"; |
|
52 | + // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) |
|
53 | + $this->name = preg_replace('/^mod/i','',get_class($this)); |
|
54 | + // Module description used if translation string 'ModuleXXXDesc' not found (where XXX is value of numeric property 'numero' of module) |
|
55 | + $this->description = "Gestion des taxes, charges sociales et dividendes"; |
|
56 | + |
|
57 | + // Possible values for version are: 'development', 'experimental', 'dolibarr' or version |
|
58 | + $this->version = 'dolibarr'; |
|
59 | + |
|
60 | + $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); |
|
61 | + $this->picto='bill'; |
|
62 | + |
|
63 | + // Data directories to create when module is enabled |
|
64 | + $this->dirs = array("/tax/temp"); |
|
65 | + |
|
66 | + // Config pages |
|
67 | + $this->config_page_url = array("taxes.php"); |
|
68 | + |
|
69 | + // Dependencies |
|
70 | + $this->hidden = false; // A condition to hide module |
|
71 | + $this->depends = array(); // List of module class names as string that must be enabled if this module is enabled |
|
72 | + $this->requiredby = array(); // List of module ids to disable if this one is disabled |
|
73 | + $this->conflictwith = array(); // List of module class names as string this module is in conflict with |
|
74 | + $this->phpmin = array(5,4); // Minimum version of PHP required by module |
|
75 | + $this->langfiles = array("compta","bills"); |
|
76 | + |
|
77 | + // Constants |
|
78 | + $this->const = array(); |
|
79 | + |
|
80 | + // Boxes |
|
81 | + $this->boxes = array(); |
|
82 | + |
|
83 | + // Permissions |
|
84 | + $this->rights = array(); |
|
85 | + $this->rights_class = 'tax'; |
|
86 | + $r=0; |
|
87 | + |
|
88 | + $r++; |
|
89 | + $this->rights[$r][0] = 91; |
|
90 | + $this->rights[$r][1] = 'Lire les charges'; |
|
91 | + $this->rights[$r][2] = 'r'; |
|
92 | + $this->rights[$r][3] = 0; |
|
93 | + $this->rights[$r][4] = 'charges'; |
|
94 | + $this->rights[$r][5] = 'lire'; |
|
95 | + |
|
96 | + $r++; |
|
97 | + $this->rights[$r][0] = 92; |
|
98 | + $this->rights[$r][1] = 'Creer/modifier les charges'; |
|
99 | + $this->rights[$r][2] = 'w'; |
|
100 | + $this->rights[$r][3] = 0; |
|
101 | + $this->rights[$r][4] = 'charges'; |
|
102 | + $this->rights[$r][5] = 'creer'; |
|
103 | + |
|
104 | + $r++; |
|
105 | + $this->rights[$r][0] = 93; |
|
106 | + $this->rights[$r][1] = 'Supprimer les charges'; |
|
107 | + $this->rights[$r][2] = 'd'; |
|
108 | + $this->rights[$r][3] = 0; |
|
109 | + $this->rights[$r][4] = 'charges'; |
|
110 | + $this->rights[$r][5] = 'supprimer'; |
|
111 | + |
|
112 | + $r++; |
|
113 | + $this->rights[$r][0] = 94; |
|
114 | + $this->rights[$r][1] = 'Exporter les charges'; |
|
115 | + $this->rights[$r][2] = 'r'; |
|
116 | + $this->rights[$r][3] = 0; |
|
117 | + $this->rights[$r][4] = 'charges'; |
|
118 | + $this->rights[$r][5] = 'export'; |
|
119 | + |
|
120 | + |
|
121 | + // Menus |
|
122 | + $this->menu = 1; // This module add menu entries. They are coded into menu manager. |
|
123 | + |
|
124 | + |
|
125 | + // Exports |
|
126 | + $r=0; |
|
127 | + |
|
128 | + $r++; |
|
129 | + $this->export_code[$r]=$this->rights_class.'_'.$r; |
|
130 | + $this->export_label[$r]='Taxes et charges sociales, et leurs reglements'; |
|
131 | + $this->export_permission[$r]=array(array("tax","charges","export")); |
|
132 | + $this->export_fields_array[$r]=array('cc.libelle'=>"Type",'c.rowid'=>"IdSocialContribution",'c.libelle'=>"Label",'c.date_ech'=>'DateDue','c.periode'=>'Period','c.amount'=>"AmountExpected","c.paye"=>"Status",'p.rowid'=>'PaymentId','p.datep'=>'DatePayment','p.amount'=>'AmountPayment','p.num_paiement'=>'Numero'); |
|
133 | + $this->export_TypeFields_array[$r]=array('cc.libelle'=>"List:c_chargesociales:libelle:id",'c.libelle'=>"Text",'c.date_ech'=>'Date','c.periode'=>'Period','c.amount'=>"Numeric","c.paye"=>"Boolean",'p.datep'=>'Date','p.amount'=>'Numeric','p.num_paiement'=>'Numeric'); |
|
134 | + $this->export_entities_array[$r]=array('cc.libelle'=>"tax_type",'c.rowid'=>"tax",'c.libelle'=>'tax','c.date_ech'=>'tax','c.periode'=>'tax','c.amount'=>"tax","c.paye"=>"tax",'p.rowid'=>'payment','p.datep'=>'payment','p.amount'=>'payment','p.num_paiement'=>'payment'); |
|
135 | + |
|
136 | + $this->export_sql_start[$r]='SELECT DISTINCT '; |
|
137 | + $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'c_chargesociales as cc, '.MAIN_DB_PREFIX.'chargesociales as c'; |
|
138 | + $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'paiementcharge as p ON p.fk_charge = c.rowid'; |
|
139 | + $this->export_sql_end[$r] .=' WHERE c.fk_type = cc.id'; |
|
140 | + $this->export_sql_end[$r] .=' AND c.entity IN ('.getEntity('tax').')'; |
|
141 | + |
|
142 | + // Import social contributions |
|
143 | + $r++; |
|
144 | + $this->import_code[$r]=$this->rights_class.'_'.$r; |
|
145 | + $this->import_label[$r]="ImportDataset_tax_contrib"; // Translation key |
|
146 | + $this->import_icon[$r]='tax'; |
|
147 | + $this->import_entities_array[$r]=array(); // We define here only fields that use another icon that the one defined into import_icon |
|
148 | + $this->import_tables_array[$r]=array('t'=>MAIN_DB_PREFIX.'chargesociales'); |
|
149 | + $this->import_fields_array[$r]=array('t.libelle'=>"Label*",'t.fk_type'=>"Type", |
|
150 | + 't.amount'=>"Amount*",'t.date_ech'=>"DateDue*",'t.periode'=>"PeriodEndDate*" |
|
151 | + ); |
|
152 | + |
|
153 | + $this->import_convertvalue_array[$r]=array( |
|
154 | + 't.fk_type'=>array('rule'=>'fetchidfromref','classfile'=>'/compta/sociales/class/cchargesociales.class.php','class'=>'Cchargesociales','method'=>'fetch','element'=>'Cchargesociales') |
|
155 | + ); |
|
156 | + $this->import_examplevalues_array[$r]=array('t.libelle'=>"Social/fiscal contribution",'t.fk_type'=>"TAXPRO (must be id or code found into dictionary)", |
|
157 | + 't.date_ech'=>"2016-01-01", 't.periode'=>"2016-01-01" |
|
158 | + ); |
|
159 | + |
|
160 | + // Import Taxes |
|
161 | + $r++; |
|
162 | + $this->import_code[$r]=$this->rights_class.'_'.$r; |
|
163 | + $this->import_label[$r]="ImportDataset_tax_vat"; // Translation key |
|
164 | + $this->import_icon[$r]='tax'; |
|
165 | + $this->import_entities_array[$r]=array(); // We define here only fields that use another icon that the one defined into import_icon |
|
166 | + $this->import_tables_array[$r]=array('t'=>MAIN_DB_PREFIX.'tva'); |
|
167 | + $this->import_fields_array[$r]=array('t.datep'=>"DatePayment*",'t.datev'=>"DateValue*",'t.label'=>"Label*",'t.fk_typepayment'=>"PaymentMode*", |
|
168 | + 't.amount'=>"Amount*",'t.num_payment'=>'Numero' |
|
169 | + ); |
|
170 | + |
|
171 | + $this->import_convertvalue_array[$r]=array( |
|
172 | + 't.fk_typepayment'=>array('rule'=>'fetchidfromref','classfile'=>'/compta/paiement/class/cpaiement.class.php','class'=>'Cpaiement','method'=>'fetch','element'=>'Cpaiement') |
|
173 | + ); |
|
174 | + $this->import_examplevalues_array[$r]=array('t.label'=>"VAT Payment 1st quarter 2016",'t.fk_typepayment'=>"CHQ (must be id or code found into dictionary)", |
|
175 | + 't.datep'=>"2016-04-02", 't.datev'=>"2016-03-31", 't.amount'=>1000, 't.num_payment'=>'123456' |
|
176 | + ); |
|
177 | + } |
|
178 | + |
|
179 | + |
|
180 | + /** |
|
181 | + * Function called when module is enabled. |
|
182 | + * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. |
|
183 | + * It also creates data directories |
|
184 | + * |
|
185 | 185 | * @param string $options Options when enabling module ('', 'noboxes') |
186 | - * @return int 1 if OK, 0 if KO |
|
187 | - */ |
|
188 | - function init($options='') |
|
189 | - { |
|
190 | - global $conf; |
|
186 | + * @return int 1 if OK, 0 if KO |
|
187 | + */ |
|
188 | + function init($options='') |
|
189 | + { |
|
190 | + global $conf; |
|
191 | 191 | |
192 | - // Nettoyage avant activation |
|
193 | - $this->remove($options); |
|
192 | + // Nettoyage avant activation |
|
193 | + $this->remove($options); |
|
194 | 194 | |
195 | - $sql = array(); |
|
195 | + $sql = array(); |
|
196 | 196 | |
197 | - return $this->_init($sql,$options); |
|
198 | - } |
|
197 | + return $this->_init($sql,$options); |
|
198 | + } |
|
199 | 199 | } |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | * \ingroup tax |
28 | 28 | * \brief Fichier de description et activation du module Taxe |
29 | 29 | */ |
30 | -include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php'; |
|
30 | +include_once DOL_DOCUMENT_ROOT.'/core/modules/DolibarrModules.class.php'; |
|
31 | 31 | |
32 | 32 | |
33 | 33 | /** |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | |
51 | 51 | $this->family = "financial"; |
52 | 52 | // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) |
53 | - $this->name = preg_replace('/^mod/i','',get_class($this)); |
|
53 | + $this->name = preg_replace('/^mod/i', '', get_class($this)); |
|
54 | 54 | // Module description used if translation string 'ModuleXXXDesc' not found (where XXX is value of numeric property 'numero' of module) |
55 | 55 | $this->description = "Gestion des taxes, charges sociales et dividendes"; |
56 | 56 | |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | $this->version = 'dolibarr'; |
59 | 59 | |
60 | 60 | $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); |
61 | - $this->picto='bill'; |
|
61 | + $this->picto = 'bill'; |
|
62 | 62 | |
63 | 63 | // Data directories to create when module is enabled |
64 | 64 | $this->dirs = array("/tax/temp"); |
@@ -67,12 +67,12 @@ discard block |
||
67 | 67 | $this->config_page_url = array("taxes.php"); |
68 | 68 | |
69 | 69 | // Dependencies |
70 | - $this->hidden = false; // A condition to hide module |
|
71 | - $this->depends = array(); // List of module class names as string that must be enabled if this module is enabled |
|
72 | - $this->requiredby = array(); // List of module ids to disable if this one is disabled |
|
73 | - $this->conflictwith = array(); // List of module class names as string this module is in conflict with |
|
74 | - $this->phpmin = array(5,4); // Minimum version of PHP required by module |
|
75 | - $this->langfiles = array("compta","bills"); |
|
70 | + $this->hidden = false; // A condition to hide module |
|
71 | + $this->depends = array(); // List of module class names as string that must be enabled if this module is enabled |
|
72 | + $this->requiredby = array(); // List of module ids to disable if this one is disabled |
|
73 | + $this->conflictwith = array(); // List of module class names as string this module is in conflict with |
|
74 | + $this->phpmin = array(5, 4); // Minimum version of PHP required by module |
|
75 | + $this->langfiles = array("compta", "bills"); |
|
76 | 76 | |
77 | 77 | // Constants |
78 | 78 | $this->const = array(); |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | // Permissions |
84 | 84 | $this->rights = array(); |
85 | 85 | $this->rights_class = 'tax'; |
86 | - $r=0; |
|
86 | + $r = 0; |
|
87 | 87 | |
88 | 88 | $r++; |
89 | 89 | $this->rights[$r][0] = 91; |
@@ -119,59 +119,59 @@ discard block |
||
119 | 119 | |
120 | 120 | |
121 | 121 | // Menus |
122 | - $this->menu = 1; // This module add menu entries. They are coded into menu manager. |
|
122 | + $this->menu = 1; // This module add menu entries. They are coded into menu manager. |
|
123 | 123 | |
124 | 124 | |
125 | 125 | // Exports |
126 | - $r=0; |
|
126 | + $r = 0; |
|
127 | 127 | |
128 | 128 | $r++; |
129 | - $this->export_code[$r]=$this->rights_class.'_'.$r; |
|
130 | - $this->export_label[$r]='Taxes et charges sociales, et leurs reglements'; |
|
131 | - $this->export_permission[$r]=array(array("tax","charges","export")); |
|
132 | - $this->export_fields_array[$r]=array('cc.libelle'=>"Type",'c.rowid'=>"IdSocialContribution",'c.libelle'=>"Label",'c.date_ech'=>'DateDue','c.periode'=>'Period','c.amount'=>"AmountExpected","c.paye"=>"Status",'p.rowid'=>'PaymentId','p.datep'=>'DatePayment','p.amount'=>'AmountPayment','p.num_paiement'=>'Numero'); |
|
133 | - $this->export_TypeFields_array[$r]=array('cc.libelle'=>"List:c_chargesociales:libelle:id",'c.libelle'=>"Text",'c.date_ech'=>'Date','c.periode'=>'Period','c.amount'=>"Numeric","c.paye"=>"Boolean",'p.datep'=>'Date','p.amount'=>'Numeric','p.num_paiement'=>'Numeric'); |
|
134 | - $this->export_entities_array[$r]=array('cc.libelle'=>"tax_type",'c.rowid'=>"tax",'c.libelle'=>'tax','c.date_ech'=>'tax','c.periode'=>'tax','c.amount'=>"tax","c.paye"=>"tax",'p.rowid'=>'payment','p.datep'=>'payment','p.amount'=>'payment','p.num_paiement'=>'payment'); |
|
135 | - |
|
136 | - $this->export_sql_start[$r]='SELECT DISTINCT '; |
|
137 | - $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'c_chargesociales as cc, '.MAIN_DB_PREFIX.'chargesociales as c'; |
|
138 | - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'paiementcharge as p ON p.fk_charge = c.rowid'; |
|
139 | - $this->export_sql_end[$r] .=' WHERE c.fk_type = cc.id'; |
|
140 | - $this->export_sql_end[$r] .=' AND c.entity IN ('.getEntity('tax').')'; |
|
129 | + $this->export_code[$r] = $this->rights_class.'_'.$r; |
|
130 | + $this->export_label[$r] = 'Taxes et charges sociales, et leurs reglements'; |
|
131 | + $this->export_permission[$r] = array(array("tax", "charges", "export")); |
|
132 | + $this->export_fields_array[$r] = array('cc.libelle'=>"Type", 'c.rowid'=>"IdSocialContribution", 'c.libelle'=>"Label", 'c.date_ech'=>'DateDue', 'c.periode'=>'Period', 'c.amount'=>"AmountExpected", "c.paye"=>"Status", 'p.rowid'=>'PaymentId', 'p.datep'=>'DatePayment', 'p.amount'=>'AmountPayment', 'p.num_paiement'=>'Numero'); |
|
133 | + $this->export_TypeFields_array[$r] = array('cc.libelle'=>"List:c_chargesociales:libelle:id", 'c.libelle'=>"Text", 'c.date_ech'=>'Date', 'c.periode'=>'Period', 'c.amount'=>"Numeric", "c.paye"=>"Boolean", 'p.datep'=>'Date', 'p.amount'=>'Numeric', 'p.num_paiement'=>'Numeric'); |
|
134 | + $this->export_entities_array[$r] = array('cc.libelle'=>"tax_type", 'c.rowid'=>"tax", 'c.libelle'=>'tax', 'c.date_ech'=>'tax', 'c.periode'=>'tax', 'c.amount'=>"tax", "c.paye"=>"tax", 'p.rowid'=>'payment', 'p.datep'=>'payment', 'p.amount'=>'payment', 'p.num_paiement'=>'payment'); |
|
135 | + |
|
136 | + $this->export_sql_start[$r] = 'SELECT DISTINCT '; |
|
137 | + $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'c_chargesociales as cc, '.MAIN_DB_PREFIX.'chargesociales as c'; |
|
138 | + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'paiementcharge as p ON p.fk_charge = c.rowid'; |
|
139 | + $this->export_sql_end[$r] .= ' WHERE c.fk_type = cc.id'; |
|
140 | + $this->export_sql_end[$r] .= ' AND c.entity IN ('.getEntity('tax').')'; |
|
141 | 141 | |
142 | 142 | // Import social contributions |
143 | 143 | $r++; |
144 | - $this->import_code[$r]=$this->rights_class.'_'.$r; |
|
145 | - $this->import_label[$r]="ImportDataset_tax_contrib"; // Translation key |
|
146 | - $this->import_icon[$r]='tax'; |
|
147 | - $this->import_entities_array[$r]=array(); // We define here only fields that use another icon that the one defined into import_icon |
|
148 | - $this->import_tables_array[$r]=array('t'=>MAIN_DB_PREFIX.'chargesociales'); |
|
149 | - $this->import_fields_array[$r]=array('t.libelle'=>"Label*",'t.fk_type'=>"Type", |
|
150 | - 't.amount'=>"Amount*",'t.date_ech'=>"DateDue*",'t.periode'=>"PeriodEndDate*" |
|
144 | + $this->import_code[$r] = $this->rights_class.'_'.$r; |
|
145 | + $this->import_label[$r] = "ImportDataset_tax_contrib"; // Translation key |
|
146 | + $this->import_icon[$r] = 'tax'; |
|
147 | + $this->import_entities_array[$r] = array(); // We define here only fields that use another icon that the one defined into import_icon |
|
148 | + $this->import_tables_array[$r] = array('t'=>MAIN_DB_PREFIX.'chargesociales'); |
|
149 | + $this->import_fields_array[$r] = array('t.libelle'=>"Label*", 't.fk_type'=>"Type", |
|
150 | + 't.amount'=>"Amount*", 't.date_ech'=>"DateDue*", 't.periode'=>"PeriodEndDate*" |
|
151 | 151 | ); |
152 | 152 | |
153 | - $this->import_convertvalue_array[$r]=array( |
|
154 | - 't.fk_type'=>array('rule'=>'fetchidfromref','classfile'=>'/compta/sociales/class/cchargesociales.class.php','class'=>'Cchargesociales','method'=>'fetch','element'=>'Cchargesociales') |
|
153 | + $this->import_convertvalue_array[$r] = array( |
|
154 | + 't.fk_type'=>array('rule'=>'fetchidfromref', 'classfile'=>'/compta/sociales/class/cchargesociales.class.php', 'class'=>'Cchargesociales', 'method'=>'fetch', 'element'=>'Cchargesociales') |
|
155 | 155 | ); |
156 | - $this->import_examplevalues_array[$r]=array('t.libelle'=>"Social/fiscal contribution",'t.fk_type'=>"TAXPRO (must be id or code found into dictionary)", |
|
156 | + $this->import_examplevalues_array[$r] = array('t.libelle'=>"Social/fiscal contribution", 't.fk_type'=>"TAXPRO (must be id or code found into dictionary)", |
|
157 | 157 | 't.date_ech'=>"2016-01-01", 't.periode'=>"2016-01-01" |
158 | 158 | ); |
159 | 159 | |
160 | 160 | // Import Taxes |
161 | 161 | $r++; |
162 | - $this->import_code[$r]=$this->rights_class.'_'.$r; |
|
163 | - $this->import_label[$r]="ImportDataset_tax_vat"; // Translation key |
|
164 | - $this->import_icon[$r]='tax'; |
|
165 | - $this->import_entities_array[$r]=array(); // We define here only fields that use another icon that the one defined into import_icon |
|
166 | - $this->import_tables_array[$r]=array('t'=>MAIN_DB_PREFIX.'tva'); |
|
167 | - $this->import_fields_array[$r]=array('t.datep'=>"DatePayment*",'t.datev'=>"DateValue*",'t.label'=>"Label*",'t.fk_typepayment'=>"PaymentMode*", |
|
168 | - 't.amount'=>"Amount*",'t.num_payment'=>'Numero' |
|
162 | + $this->import_code[$r] = $this->rights_class.'_'.$r; |
|
163 | + $this->import_label[$r] = "ImportDataset_tax_vat"; // Translation key |
|
164 | + $this->import_icon[$r] = 'tax'; |
|
165 | + $this->import_entities_array[$r] = array(); // We define here only fields that use another icon that the one defined into import_icon |
|
166 | + $this->import_tables_array[$r] = array('t'=>MAIN_DB_PREFIX.'tva'); |
|
167 | + $this->import_fields_array[$r] = array('t.datep'=>"DatePayment*", 't.datev'=>"DateValue*", 't.label'=>"Label*", 't.fk_typepayment'=>"PaymentMode*", |
|
168 | + 't.amount'=>"Amount*", 't.num_payment'=>'Numero' |
|
169 | 169 | ); |
170 | 170 | |
171 | - $this->import_convertvalue_array[$r]=array( |
|
172 | - 't.fk_typepayment'=>array('rule'=>'fetchidfromref','classfile'=>'/compta/paiement/class/cpaiement.class.php','class'=>'Cpaiement','method'=>'fetch','element'=>'Cpaiement') |
|
171 | + $this->import_convertvalue_array[$r] = array( |
|
172 | + 't.fk_typepayment'=>array('rule'=>'fetchidfromref', 'classfile'=>'/compta/paiement/class/cpaiement.class.php', 'class'=>'Cpaiement', 'method'=>'fetch', 'element'=>'Cpaiement') |
|
173 | 173 | ); |
174 | - $this->import_examplevalues_array[$r]=array('t.label'=>"VAT Payment 1st quarter 2016",'t.fk_typepayment'=>"CHQ (must be id or code found into dictionary)", |
|
174 | + $this->import_examplevalues_array[$r] = array('t.label'=>"VAT Payment 1st quarter 2016", 't.fk_typepayment'=>"CHQ (must be id or code found into dictionary)", |
|
175 | 175 | 't.datep'=>"2016-04-02", 't.datev'=>"2016-03-31", 't.amount'=>1000, 't.num_payment'=>'123456' |
176 | 176 | ); |
177 | 177 | } |
@@ -185,7 +185,7 @@ discard block |
||
185 | 185 | * @param string $options Options when enabling module ('', 'noboxes') |
186 | 186 | * @return int 1 if OK, 0 if KO |
187 | 187 | */ |
188 | - function init($options='') |
|
188 | + function init($options = '') |
|
189 | 189 | { |
190 | 190 | global $conf; |
191 | 191 | |
@@ -194,6 +194,6 @@ discard block |
||
194 | 194 | |
195 | 195 | $sql = array(); |
196 | 196 | |
197 | - return $this->_init($sql,$options); |
|
197 | + return $this->_init($sql, $options); |
|
198 | 198 | } |
199 | 199 | } |
@@ -36,76 +36,76 @@ discard block |
||
36 | 36 | class modSociete extends DolibarrModules |
37 | 37 | { |
38 | 38 | |
39 | - /** |
|
40 | - * Constructor. Define names, constants, directories, boxes, permissions |
|
41 | - * |
|
42 | - * @param DoliDB $db Database handler |
|
43 | - */ |
|
44 | - function __construct($db) |
|
45 | - { |
|
46 | - global $conf, $user; |
|
47 | - |
|
48 | - $this->db = $db; |
|
49 | - $this->numero = 1; |
|
50 | - |
|
51 | - $this->family = "crm"; |
|
52 | - $this->module_position = '10'; |
|
53 | - // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) |
|
54 | - $this->name = preg_replace('/^mod/i','',get_class($this)); |
|
55 | - $this->description = "Gestion des sociétés et contacts"; |
|
56 | - |
|
57 | - // Possible values for version are: 'development', 'experimental', 'dolibarr' or version |
|
58 | - $this->version = 'dolibarr'; |
|
59 | - |
|
60 | - $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); |
|
61 | - $this->config_page_url = array("societe.php@societe"); |
|
62 | - // Name of image file used for this module. |
|
63 | - $this->picto='company'; |
|
64 | - |
|
65 | - // Data directories to create when module is enabled |
|
66 | - $this->dirs = array("/societe/temp"); |
|
67 | - |
|
68 | - // Dependencies |
|
69 | - $this->hidden = false; // A condition to hide module |
|
70 | - $this->depends = array(); // List of module class names as string that must be enabled if this module is enabled |
|
71 | - $this->requiredby = array("modExpedition","modFacture","modFournisseur","modFicheinter","modPropale","modContrat","modCommande"); // List of module ids to disable if this one is disabled |
|
72 | - $this->conflictwith = array(); // List of module class names as string this module is in conflict with |
|
73 | - $this->phpmin = array(5,4); // Minimum version of PHP required by module |
|
74 | - $this->langfiles = array("companies",'bills'); |
|
75 | - |
|
76 | - // Constants |
|
77 | - $this->const = array(); |
|
78 | - $r=0; |
|
79 | - |
|
80 | - $this->const[$r][0] = "SOCIETE_CODECLIENT_ADDON"; |
|
81 | - $this->const[$r][1] = "chaine"; |
|
82 | - $this->const[$r][2] = "mod_codeclient_monkey"; |
|
83 | - $this->const[$r][3] = 'Module to control third parties codes'; |
|
84 | - $this->const[$r][4] = 0; |
|
85 | - $r++; |
|
39 | + /** |
|
40 | + * Constructor. Define names, constants, directories, boxes, permissions |
|
41 | + * |
|
42 | + * @param DoliDB $db Database handler |
|
43 | + */ |
|
44 | + function __construct($db) |
|
45 | + { |
|
46 | + global $conf, $user; |
|
47 | + |
|
48 | + $this->db = $db; |
|
49 | + $this->numero = 1; |
|
50 | + |
|
51 | + $this->family = "crm"; |
|
52 | + $this->module_position = '10'; |
|
53 | + // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) |
|
54 | + $this->name = preg_replace('/^mod/i','',get_class($this)); |
|
55 | + $this->description = "Gestion des sociétés et contacts"; |
|
56 | + |
|
57 | + // Possible values for version are: 'development', 'experimental', 'dolibarr' or version |
|
58 | + $this->version = 'dolibarr'; |
|
59 | + |
|
60 | + $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); |
|
61 | + $this->config_page_url = array("societe.php@societe"); |
|
62 | + // Name of image file used for this module. |
|
63 | + $this->picto='company'; |
|
64 | + |
|
65 | + // Data directories to create when module is enabled |
|
66 | + $this->dirs = array("/societe/temp"); |
|
67 | + |
|
68 | + // Dependencies |
|
69 | + $this->hidden = false; // A condition to hide module |
|
70 | + $this->depends = array(); // List of module class names as string that must be enabled if this module is enabled |
|
71 | + $this->requiredby = array("modExpedition","modFacture","modFournisseur","modFicheinter","modPropale","modContrat","modCommande"); // List of module ids to disable if this one is disabled |
|
72 | + $this->conflictwith = array(); // List of module class names as string this module is in conflict with |
|
73 | + $this->phpmin = array(5,4); // Minimum version of PHP required by module |
|
74 | + $this->langfiles = array("companies",'bills'); |
|
75 | + |
|
76 | + // Constants |
|
77 | + $this->const = array(); |
|
78 | + $r=0; |
|
79 | + |
|
80 | + $this->const[$r][0] = "SOCIETE_CODECLIENT_ADDON"; |
|
81 | + $this->const[$r][1] = "chaine"; |
|
82 | + $this->const[$r][2] = "mod_codeclient_monkey"; |
|
83 | + $this->const[$r][3] = 'Module to control third parties codes'; |
|
84 | + $this->const[$r][4] = 0; |
|
85 | + $r++; |
|
86 | 86 | |
87 | - $this->const[$r][0] = "SOCIETE_CODECOMPTA_ADDON"; |
|
88 | - $this->const[$r][1] = "chaine"; |
|
89 | - $this->const[$r][2] = "mod_codecompta_panicum"; |
|
90 | - $this->const[$r][3] = 'Module to control third parties codes'; |
|
91 | - $this->const[$r][4] = 0; |
|
92 | - $r++; |
|
87 | + $this->const[$r][0] = "SOCIETE_CODECOMPTA_ADDON"; |
|
88 | + $this->const[$r][1] = "chaine"; |
|
89 | + $this->const[$r][2] = "mod_codecompta_panicum"; |
|
90 | + $this->const[$r][3] = 'Module to control third parties codes'; |
|
91 | + $this->const[$r][4] = 0; |
|
92 | + $r++; |
|
93 | 93 | |
94 | - $this->const[$r][0] = "SOCIETE_FISCAL_MONTH_START"; |
|
95 | - $this->const[$r][1] = "chaine"; |
|
96 | - $this->const[$r][2] = "0"; |
|
97 | - $this->const[$r][3] = "Enter the month number of the first month of the fiscal year, e. g. 9 for September"; |
|
98 | - $this->const[$r][4] = 0; |
|
99 | - $r++; |
|
94 | + $this->const[$r][0] = "SOCIETE_FISCAL_MONTH_START"; |
|
95 | + $this->const[$r][1] = "chaine"; |
|
96 | + $this->const[$r][2] = "0"; |
|
97 | + $this->const[$r][3] = "Enter the month number of the first month of the fiscal year, e. g. 9 for September"; |
|
98 | + $this->const[$r][4] = 0; |
|
99 | + $r++; |
|
100 | 100 | |
101 | - $this->const[$r][0] = "COMPANY_ADDON_PDF_ODT_PATH"; |
|
102 | - $this->const[$r][1] = "chaine"; |
|
103 | - $this->const[$r][2] = "DOL_DATA_ROOT/doctemplates/thirdparties"; |
|
104 | - $this->const[$r][3] = ""; |
|
105 | - $this->const[$r][4] = 0; |
|
106 | - $r++; |
|
101 | + $this->const[$r][0] = "COMPANY_ADDON_PDF_ODT_PATH"; |
|
102 | + $this->const[$r][1] = "chaine"; |
|
103 | + $this->const[$r][2] = "DOL_DATA_ROOT/doctemplates/thirdparties"; |
|
104 | + $this->const[$r][3] = ""; |
|
105 | + $this->const[$r][4] = 0; |
|
106 | + $r++; |
|
107 | 107 | |
108 | - /* |
|
108 | + /* |
|
109 | 109 | $this->const[$r][0] = "COMPANY_HIDE_INACTIVE_IN_COMBOBOX"; |
110 | 110 | $this->const[$r][1] = "chaine"; |
111 | 111 | $this->const[$r][2] = "0"; |
@@ -114,20 +114,20 @@ discard block |
||
114 | 114 | $r++; |
115 | 115 | */ |
116 | 116 | |
117 | - $this->const[$r][0] = "SOCIETE_ADD_REF_IN_LIST"; |
|
118 | - $this->const[$r][1] = "yesno"; |
|
119 | - $this->const[$r][2] = "0"; |
|
120 | - $this->const[$r][3] = "Display customer ref into select list"; |
|
121 | - $this->const[$r][4] = 0; |
|
122 | - $r++; |
|
117 | + $this->const[$r][0] = "SOCIETE_ADD_REF_IN_LIST"; |
|
118 | + $this->const[$r][1] = "yesno"; |
|
119 | + $this->const[$r][2] = "0"; |
|
120 | + $this->const[$r][3] = "Display customer ref into select list"; |
|
121 | + $this->const[$r][4] = 0; |
|
122 | + $r++; |
|
123 | 123 | |
124 | - // Boxes |
|
125 | - $this->boxes = array(); |
|
126 | - $r=0; |
|
127 | - $this->boxes[$r][1] = "box_clients.php"; |
|
128 | - $r++; |
|
129 | - $this->boxes[$r][1] = "box_prospect.php"; |
|
130 | - $r++; |
|
124 | + // Boxes |
|
125 | + $this->boxes = array(); |
|
126 | + $r=0; |
|
127 | + $this->boxes[$r][1] = "box_clients.php"; |
|
128 | + $r++; |
|
129 | + $this->boxes[$r][1] = "box_prospect.php"; |
|
130 | + $r++; |
|
131 | 131 | $this->boxes[$r][1] = "box_contacts.php"; |
132 | 132 | $r++; |
133 | 133 | $this->boxes[$r][1] = "box_activity.php"; |
@@ -136,17 +136,17 @@ discard block |
||
136 | 136 | $this->boxes[$r][1] = "box_goodcustomers.php"; |
137 | 137 | $this->boxes[$r][2] = '(WarningUsingThisBoxSlowDown)'; |
138 | 138 | $r++; |
139 | - // Permissions |
|
140 | - $this->rights = array(); |
|
141 | - $this->rights_class = 'societe'; |
|
142 | - $r=0; |
|
139 | + // Permissions |
|
140 | + $this->rights = array(); |
|
141 | + $this->rights_class = 'societe'; |
|
142 | + $r=0; |
|
143 | 143 | |
144 | - $r++; |
|
145 | - $this->rights[$r][0] = 121; // id de la permission |
|
146 | - $this->rights[$r][1] = 'Read third parties'; // libelle de la permission |
|
147 | - $this->rights[$r][2] = 'r'; // type de la permission (deprecie a ce jour) |
|
148 | - $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut |
|
149 | - $this->rights[$r][4] = 'lire'; |
|
144 | + $r++; |
|
145 | + $this->rights[$r][0] = 121; // id de la permission |
|
146 | + $this->rights[$r][1] = 'Read third parties'; // libelle de la permission |
|
147 | + $this->rights[$r][2] = 'r'; // type de la permission (deprecie a ce jour) |
|
148 | + $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut |
|
149 | + $this->rights[$r][4] = 'lire'; |
|
150 | 150 | |
151 | 151 | /* $r++; |
152 | 152 | $this->rights[$r][0] = 241; |
@@ -165,12 +165,12 @@ discard block |
||
165 | 165 | $this->rights[$r][5] = 'read'; |
166 | 166 | */ |
167 | 167 | |
168 | - $r++; |
|
169 | - $this->rights[$r][0] = 122; // id de la permission |
|
170 | - $this->rights[$r][1] = 'Create and update third parties'; // libelle de la permission |
|
171 | - $this->rights[$r][2] = 'w'; // type de la permission (deprecie a ce jour) |
|
172 | - $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut |
|
173 | - $this->rights[$r][4] = 'creer'; |
|
168 | + $r++; |
|
169 | + $this->rights[$r][0] = 122; // id de la permission |
|
170 | + $this->rights[$r][1] = 'Create and update third parties'; // libelle de la permission |
|
171 | + $this->rights[$r][2] = 'w'; // type de la permission (deprecie a ce jour) |
|
172 | + $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut |
|
173 | + $this->rights[$r][4] = 'creer'; |
|
174 | 174 | |
175 | 175 | /* $r++; |
176 | 176 | $this->rights[$r][0] = 251; |
@@ -189,163 +189,163 @@ discard block |
||
189 | 189 | $this->rights[$r][5] = 'read'; |
190 | 190 | */ |
191 | 191 | |
192 | - $r++; |
|
193 | - $this->rights[$r][0] = 125; // id de la permission |
|
194 | - $this->rights[$r][1] = 'Delete third parties'; // libelle de la permission |
|
195 | - $this->rights[$r][2] = 'd'; // type de la permission (deprecie a ce jour) |
|
196 | - $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut |
|
197 | - $this->rights[$r][4] = 'supprimer'; |
|
192 | + $r++; |
|
193 | + $this->rights[$r][0] = 125; // id de la permission |
|
194 | + $this->rights[$r][1] = 'Delete third parties'; // libelle de la permission |
|
195 | + $this->rights[$r][2] = 'd'; // type de la permission (deprecie a ce jour) |
|
196 | + $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut |
|
197 | + $this->rights[$r][4] = 'supprimer'; |
|
198 | 198 | |
199 | - $r++; |
|
200 | - $this->rights[$r][0] = 126; // id de la permission |
|
201 | - $this->rights[$r][1] = 'Export third parties'; // libelle de la permission |
|
202 | - $this->rights[$r][2] = 'r'; // type de la permission (deprecie a ce jour) |
|
203 | - $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut |
|
204 | - $this->rights[$r][4] = 'export'; |
|
199 | + $r++; |
|
200 | + $this->rights[$r][0] = 126; // id de la permission |
|
201 | + $this->rights[$r][1] = 'Export third parties'; // libelle de la permission |
|
202 | + $this->rights[$r][2] = 'r'; // type de la permission (deprecie a ce jour) |
|
203 | + $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut |
|
204 | + $this->rights[$r][4] = 'export'; |
|
205 | 205 | |
206 | - // 262 : Resteindre l'acces des commerciaux |
|
207 | - $r++; |
|
208 | - $this->rights[$r][0] = 262; |
|
209 | - $this->rights[$r][1] = 'Read all third parties by internal users (otherwise only if commercial contact). Not effective for external users (limited to themselves).'; |
|
210 | - $this->rights[$r][2] = 'r'; |
|
211 | - $this->rights[$r][3] = 0; |
|
212 | - $this->rights[$r][4] = 'client'; |
|
213 | - $this->rights[$r][5] = 'voir'; |
|
206 | + // 262 : Resteindre l'acces des commerciaux |
|
207 | + $r++; |
|
208 | + $this->rights[$r][0] = 262; |
|
209 | + $this->rights[$r][1] = 'Read all third parties by internal users (otherwise only if commercial contact). Not effective for external users (limited to themselves).'; |
|
210 | + $this->rights[$r][2] = 'r'; |
|
211 | + $this->rights[$r][3] = 0; |
|
212 | + $this->rights[$r][4] = 'client'; |
|
213 | + $this->rights[$r][5] = 'voir'; |
|
214 | 214 | |
215 | - $r++; |
|
216 | - $this->rights[$r][0] = 281; // id de la permission |
|
217 | - $this->rights[$r][1] = 'Read contacts'; // libelle de la permission |
|
218 | - $this->rights[$r][2] = 'r'; // type de la permission (deprecie a ce jour) |
|
219 | - $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut |
|
220 | - $this->rights[$r][4] = 'contact'; |
|
221 | - $this->rights[$r][5] = 'lire'; |
|
215 | + $r++; |
|
216 | + $this->rights[$r][0] = 281; // id de la permission |
|
217 | + $this->rights[$r][1] = 'Read contacts'; // libelle de la permission |
|
218 | + $this->rights[$r][2] = 'r'; // type de la permission (deprecie a ce jour) |
|
219 | + $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut |
|
220 | + $this->rights[$r][4] = 'contact'; |
|
221 | + $this->rights[$r][5] = 'lire'; |
|
222 | 222 | |
223 | - $r++; |
|
224 | - $this->rights[$r][0] = 282; // id de la permission |
|
225 | - $this->rights[$r][1] = 'Create and update contact'; // libelle de la permission |
|
226 | - $this->rights[$r][2] = 'w'; // type de la permission (deprecie a ce jour) |
|
227 | - $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut |
|
228 | - $this->rights[$r][4] = 'contact'; |
|
229 | - $this->rights[$r][5] = 'creer'; |
|
223 | + $r++; |
|
224 | + $this->rights[$r][0] = 282; // id de la permission |
|
225 | + $this->rights[$r][1] = 'Create and update contact'; // libelle de la permission |
|
226 | + $this->rights[$r][2] = 'w'; // type de la permission (deprecie a ce jour) |
|
227 | + $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut |
|
228 | + $this->rights[$r][4] = 'contact'; |
|
229 | + $this->rights[$r][5] = 'creer'; |
|
230 | 230 | |
231 | - $r++; |
|
232 | - $this->rights[$r][0] = 283; // id de la permission |
|
233 | - $this->rights[$r][1] = 'Delete contacts'; // libelle de la permission |
|
234 | - $this->rights[$r][2] = 'd'; // type de la permission (deprecie a ce jour) |
|
235 | - $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut |
|
236 | - $this->rights[$r][4] = 'contact'; |
|
237 | - $this->rights[$r][5] = 'supprimer'; |
|
231 | + $r++; |
|
232 | + $this->rights[$r][0] = 283; // id de la permission |
|
233 | + $this->rights[$r][1] = 'Delete contacts'; // libelle de la permission |
|
234 | + $this->rights[$r][2] = 'd'; // type de la permission (deprecie a ce jour) |
|
235 | + $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut |
|
236 | + $this->rights[$r][4] = 'contact'; |
|
237 | + $this->rights[$r][5] = 'supprimer'; |
|
238 | 238 | |
239 | - $r++; |
|
240 | - $this->rights[$r][0] = 286; // id de la permission |
|
241 | - $this->rights[$r][1] = 'Export contacts'; // libelle de la permission |
|
242 | - $this->rights[$r][2] = 'd'; // type de la permission (deprecie a ce jour) |
|
243 | - $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut |
|
244 | - $this->rights[$r][4] = 'contact'; |
|
245 | - $this->rights[$r][5] = 'export'; |
|
239 | + $r++; |
|
240 | + $this->rights[$r][0] = 286; // id de la permission |
|
241 | + $this->rights[$r][1] = 'Export contacts'; // libelle de la permission |
|
242 | + $this->rights[$r][2] = 'd'; // type de la permission (deprecie a ce jour) |
|
243 | + $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut |
|
244 | + $this->rights[$r][4] = 'contact'; |
|
245 | + $this->rights[$r][5] = 'export'; |
|
246 | 246 | |
247 | 247 | |
248 | - // Menus |
|
249 | - //------- |
|
250 | - $this->menu = 1; // This module add menu entries. They are coded into menu manager. |
|
248 | + // Menus |
|
249 | + //------- |
|
250 | + $this->menu = 1; // This module add menu entries. They are coded into menu manager. |
|
251 | 251 | |
252 | 252 | |
253 | - // Exports |
|
254 | - //-------- |
|
255 | - $r=0; |
|
253 | + // Exports |
|
254 | + //-------- |
|
255 | + $r=0; |
|
256 | 256 | |
257 | - // Export list of third parties and attributes |
|
258 | - $r++; |
|
259 | - $this->export_code[$r]=$this->rights_class.'_'.$r; |
|
260 | - $this->export_label[$r]='ExportDataset_company_1'; |
|
261 | - $this->export_icon[$r]='company'; |
|
262 | - $this->export_permission[$r]=array(array("societe","export")); |
|
263 | - $this->export_fields_array[$r]=array( |
|
264 | - 's.rowid'=>"Id",'s.nom'=>"Name",'s.name_alias'=>"AliasNames",'s.status'=>"Status",'s.client'=>"Customer",'s.fournisseur'=>"Supplier",'s.datec'=>"DateCreation",'s.tms'=>"DateLastModification", |
|
265 | - 's.code_client'=>"CustomerCode",'s.code_fournisseur'=>"SupplierCode",'s.code_compta'=>"AccountancyCode",'s.code_compta_fournisseur'=>"SupplierAccountancyCode", |
|
266 | - 's.address'=>"Address",'s.zip'=>"Zip",'s.town'=>"Town",'d.nom'=>'State','c.label'=>"Country",'c.code'=>"CountryCode",'s.phone'=>"Phone",'s.fax'=>"Fax", |
|
267 | - 's.url'=>"Url",'s.email'=>"Email",'s.default_lang'=>"DefaultLang",'s.siren'=>"ProfId1",'s.siret'=>"ProfId2",'s.ape'=>"ProfId3",'s.idprof4'=>"ProfId4", |
|
268 | - 's.idprof5'=>"ProfId5",'s.idprof6'=>"ProfId6",'s.tva_intra'=>"VATIntraShort",'s.capital'=>"Capital",'s.note_private'=>"NotePrivate",'s.note_public'=>"NotePublic",'s.canvas'=>"Canvas", |
|
269 | - 't.libelle'=>"ThirdPartyType",'ce.code'=>"Staff","cfj.libelle"=>"JuridicalStatus",'s.fk_prospectlevel'=>'ProspectLevel', |
|
270 | - 'st.code'=>'ProspectStatus','payterm.libelle'=>'PaymentConditions','paymode.libelle'=>'PaymentMode' |
|
271 | - ); |
|
272 | - if (! empty($conf->global->SOCIETE_USEPREFIX)) $this->export_fields_array[$r]['s.prefix']='Prefix'; |
|
273 | - // Add multicompany field |
|
274 | - if (! empty($conf->global->MULTICOMPANY_ENTITY_IN_EXPORT_IF_SHARED)) |
|
275 | - { |
|
276 | - $nbofallowedentities=count(explode(',',getEntity('societe'))); // If project are shared, nb will be > 1 |
|
277 | - if (! empty($conf->multicompany->enabled) && $nbofallowedentities > 1) $this->export_fields_array[$r]+=array('s.entity'=>'Entity'); |
|
278 | - } |
|
279 | - $keyforselect='societe'; $keyforelement='company'; $keyforaliasextra='extra'; |
|
280 | - include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; |
|
281 | - $this->export_fields_array[$r]+=array('u.login'=>'SaleRepresentativeLogin','u.firstname'=>'SaleRepresentativeFirstname', 'u.lastname'=>'SaleRepresentativeLastname'); |
|
282 | - //$this->export_TypeFields_array[$r]=array( |
|
283 | - // 's.rowid'=>"List:societe:nom", 's.nom'=>"Text", 's.name_alias'=>"Text", 's.status'=>"Text",'s.client'=>"Boolean",'s.fournisseur'=>"Boolean",'s.datec'=>"Date",'s.tms'=>"Date", |
|
284 | - // 's.code_client'=>"Text",'s.code_fournisseur'=>"Text",'s.address'=>"Text",'s.zip'=>"Text",'s.town'=>"Text",'c.label'=>"List:c_country:label:label", |
|
285 | - // 'c.code'=>"Text",'s.phone'=>"Text",'s.fax'=>"Text",'s.url'=>"Text",'s.email'=>"Text",'s.default_lang'=>"Text",'s.siret'=>"Text",'s.siren'=>"Text", |
|
286 | - // 's.ape'=>"Text",'s.idprof4'=>"Text",'s.idprof5'=>"Text",'s.idprof6'=>"Text",'s.tva_intra'=>"Text",'s.capital'=>"Numeric",'s.note'=>"Text", |
|
287 | - // 't.libelle'=>"Text",'ce.code'=>"List:c_effectif:libelle:code","cfj.libelle"=>"Text",'s.fk_prospectlevel'=>'List:c_prospectlevel:label:code', |
|
288 | - // 's.fk_stcomm'=>'List:c_stcomm:libelle:code','d.nom'=>'List:c_departements:nom:rowid' |
|
289 | - //); |
|
290 | - $this->export_TypeFields_array[$r]=array( |
|
291 | - 's.rowid'=>"Numeric", 's.nom'=>"Text", 's.name_alias'=>"Text", 's.status'=>"Numeric",'s.client'=>"Numeric",'s.fournisseur'=>"Boolean",'s.datec'=>"Date",'s.tms'=>"Date", |
|
292 | - 's.code_client'=>"Text",'s.code_fournisseur'=>"Text",'s.code_compta'=>"Text",'s.code_compta_fournisseur'=>"Text",'s.address'=>"Text",'s.zip'=>"Text", |
|
293 | - 's.town'=>"Text",'c.label'=>"List:c_country:label:label",'c.code'=>"Text",'s.phone'=>"Text",'s.fax'=>"Text",'s.url'=>"Text",'s.email'=>"Text", |
|
294 | - 's.default_lang'=>"Text",'s.siret'=>"Text",'s.siren'=>"Text",'s.ape'=>"Text",'s.idprof4'=>"Text",'s.idprof5'=>"Text",'s.idprof6'=>"Text", |
|
295 | - 's.tva_intra'=>"Text",'s.capital'=>"Numeric",'s.note_private'=>"Text",'s.note_public'=>"Text",'s.canvas'=>"Text",'t.libelle'=>"Text", |
|
296 | - 'ce.code'=>"List:c_effectif:libelle:code","cfj.libelle"=>"Text",'s.fk_prospectlevel'=>'List:c_prospectlevel:label:code', |
|
297 | - 'st.code'=>'List:c_stcomm:libelle:code','d.nom'=>'Text','u.login'=>'Text','u.firstname'=>'Text','u.lastname'=>'Text','payterm.libelle'=>'Text', |
|
298 | - 'paymode.libelle'=>'Text','s.entity'=>'Numeric' |
|
299 | - ); |
|
300 | - |
|
301 | - $this->export_entities_array[$r]=array('u.login'=>'user','u.firstname'=>'user','u.lastname'=>'user'); // We define here only fields that use another picto |
|
302 | - $this->export_examplevalues_array[$r]=array('s.client'=>'0 (no customer no prospect)/1 (customer)/2 (prospect)/3 (customer and prospect)','s.fournisseur'=>'0 (not a supplier) or 1 (supplier)'); |
|
303 | - $this->export_sql_start[$r]='SELECT DISTINCT '; |
|
304 | - $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'societe as s'; |
|
257 | + // Export list of third parties and attributes |
|
258 | + $r++; |
|
259 | + $this->export_code[$r]=$this->rights_class.'_'.$r; |
|
260 | + $this->export_label[$r]='ExportDataset_company_1'; |
|
261 | + $this->export_icon[$r]='company'; |
|
262 | + $this->export_permission[$r]=array(array("societe","export")); |
|
263 | + $this->export_fields_array[$r]=array( |
|
264 | + 's.rowid'=>"Id",'s.nom'=>"Name",'s.name_alias'=>"AliasNames",'s.status'=>"Status",'s.client'=>"Customer",'s.fournisseur'=>"Supplier",'s.datec'=>"DateCreation",'s.tms'=>"DateLastModification", |
|
265 | + 's.code_client'=>"CustomerCode",'s.code_fournisseur'=>"SupplierCode",'s.code_compta'=>"AccountancyCode",'s.code_compta_fournisseur'=>"SupplierAccountancyCode", |
|
266 | + 's.address'=>"Address",'s.zip'=>"Zip",'s.town'=>"Town",'d.nom'=>'State','c.label'=>"Country",'c.code'=>"CountryCode",'s.phone'=>"Phone",'s.fax'=>"Fax", |
|
267 | + 's.url'=>"Url",'s.email'=>"Email",'s.default_lang'=>"DefaultLang",'s.siren'=>"ProfId1",'s.siret'=>"ProfId2",'s.ape'=>"ProfId3",'s.idprof4'=>"ProfId4", |
|
268 | + 's.idprof5'=>"ProfId5",'s.idprof6'=>"ProfId6",'s.tva_intra'=>"VATIntraShort",'s.capital'=>"Capital",'s.note_private'=>"NotePrivate",'s.note_public'=>"NotePublic",'s.canvas'=>"Canvas", |
|
269 | + 't.libelle'=>"ThirdPartyType",'ce.code'=>"Staff","cfj.libelle"=>"JuridicalStatus",'s.fk_prospectlevel'=>'ProspectLevel', |
|
270 | + 'st.code'=>'ProspectStatus','payterm.libelle'=>'PaymentConditions','paymode.libelle'=>'PaymentMode' |
|
271 | + ); |
|
272 | + if (! empty($conf->global->SOCIETE_USEPREFIX)) $this->export_fields_array[$r]['s.prefix']='Prefix'; |
|
273 | + // Add multicompany field |
|
274 | + if (! empty($conf->global->MULTICOMPANY_ENTITY_IN_EXPORT_IF_SHARED)) |
|
275 | + { |
|
276 | + $nbofallowedentities=count(explode(',',getEntity('societe'))); // If project are shared, nb will be > 1 |
|
277 | + if (! empty($conf->multicompany->enabled) && $nbofallowedentities > 1) $this->export_fields_array[$r]+=array('s.entity'=>'Entity'); |
|
278 | + } |
|
279 | + $keyforselect='societe'; $keyforelement='company'; $keyforaliasextra='extra'; |
|
280 | + include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; |
|
281 | + $this->export_fields_array[$r]+=array('u.login'=>'SaleRepresentativeLogin','u.firstname'=>'SaleRepresentativeFirstname', 'u.lastname'=>'SaleRepresentativeLastname'); |
|
282 | + //$this->export_TypeFields_array[$r]=array( |
|
283 | + // 's.rowid'=>"List:societe:nom", 's.nom'=>"Text", 's.name_alias'=>"Text", 's.status'=>"Text",'s.client'=>"Boolean",'s.fournisseur'=>"Boolean",'s.datec'=>"Date",'s.tms'=>"Date", |
|
284 | + // 's.code_client'=>"Text",'s.code_fournisseur'=>"Text",'s.address'=>"Text",'s.zip'=>"Text",'s.town'=>"Text",'c.label'=>"List:c_country:label:label", |
|
285 | + // 'c.code'=>"Text",'s.phone'=>"Text",'s.fax'=>"Text",'s.url'=>"Text",'s.email'=>"Text",'s.default_lang'=>"Text",'s.siret'=>"Text",'s.siren'=>"Text", |
|
286 | + // 's.ape'=>"Text",'s.idprof4'=>"Text",'s.idprof5'=>"Text",'s.idprof6'=>"Text",'s.tva_intra'=>"Text",'s.capital'=>"Numeric",'s.note'=>"Text", |
|
287 | + // 't.libelle'=>"Text",'ce.code'=>"List:c_effectif:libelle:code","cfj.libelle"=>"Text",'s.fk_prospectlevel'=>'List:c_prospectlevel:label:code', |
|
288 | + // 's.fk_stcomm'=>'List:c_stcomm:libelle:code','d.nom'=>'List:c_departements:nom:rowid' |
|
289 | + //); |
|
290 | + $this->export_TypeFields_array[$r]=array( |
|
291 | + 's.rowid'=>"Numeric", 's.nom'=>"Text", 's.name_alias'=>"Text", 's.status'=>"Numeric",'s.client'=>"Numeric",'s.fournisseur'=>"Boolean",'s.datec'=>"Date",'s.tms'=>"Date", |
|
292 | + 's.code_client'=>"Text",'s.code_fournisseur'=>"Text",'s.code_compta'=>"Text",'s.code_compta_fournisseur'=>"Text",'s.address'=>"Text",'s.zip'=>"Text", |
|
293 | + 's.town'=>"Text",'c.label'=>"List:c_country:label:label",'c.code'=>"Text",'s.phone'=>"Text",'s.fax'=>"Text",'s.url'=>"Text",'s.email'=>"Text", |
|
294 | + 's.default_lang'=>"Text",'s.siret'=>"Text",'s.siren'=>"Text",'s.ape'=>"Text",'s.idprof4'=>"Text",'s.idprof5'=>"Text",'s.idprof6'=>"Text", |
|
295 | + 's.tva_intra'=>"Text",'s.capital'=>"Numeric",'s.note_private'=>"Text",'s.note_public'=>"Text",'s.canvas'=>"Text",'t.libelle'=>"Text", |
|
296 | + 'ce.code'=>"List:c_effectif:libelle:code","cfj.libelle"=>"Text",'s.fk_prospectlevel'=>'List:c_prospectlevel:label:code', |
|
297 | + 'st.code'=>'List:c_stcomm:libelle:code','d.nom'=>'Text','u.login'=>'Text','u.firstname'=>'Text','u.lastname'=>'Text','payterm.libelle'=>'Text', |
|
298 | + 'paymode.libelle'=>'Text','s.entity'=>'Numeric' |
|
299 | + ); |
|
300 | + |
|
301 | + $this->export_entities_array[$r]=array('u.login'=>'user','u.firstname'=>'user','u.lastname'=>'user'); // We define here only fields that use another picto |
|
302 | + $this->export_examplevalues_array[$r]=array('s.client'=>'0 (no customer no prospect)/1 (customer)/2 (prospect)/3 (customer and prospect)','s.fournisseur'=>'0 (not a supplier) or 1 (supplier)'); |
|
303 | + $this->export_sql_start[$r]='SELECT DISTINCT '; |
|
304 | + $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'societe as s'; |
|
305 | 305 | $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'societe_extrafields as extra ON s.rowid = extra.fk_object'; |
306 | - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_typent as t ON s.fk_typent = t.id'; |
|
307 | - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as c ON s.fk_pays = c.rowid'; |
|
308 | - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_effectif as ce ON s.fk_effectif = ce.id'; |
|
309 | - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_forme_juridique as cfj ON s.fk_forme_juridique = cfj.code'; |
|
310 | - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_departements as d ON s.fk_departement = d.rowid'; |
|
311 | - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_stcomm as st ON s.fk_stcomm = st.id'; |
|
312 | - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid LEFT JOIN '.MAIN_DB_PREFIX.'user as u ON sc.fk_user = u.rowid'; |
|
313 | - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_payment_term as payterm ON s.cond_reglement = payterm.rowid'; |
|
314 | - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as paymode ON s.mode_reglement = paymode.id'; |
|
315 | - $this->export_sql_end[$r] .=' WHERE s.entity IN ('.getEntity('societe').')'; |
|
316 | - if (is_object($user) && empty($user->rights->societe->client->voir)) { |
|
317 | - $this->export_sql_end[$r] .=' AND (sc.fk_user = '.$user->id.' '; |
|
318 | - if (! empty($conf->global->SOCIETE_EXPORT_SUBORDINATES_CHILDS)) { |
|
319 | - $subordinatesids = $user->getAllChildIds(); |
|
320 | - $this->export_sql_end[$r] .=count($subordinatesids)>0 ? ' OR (sc.fk_user IN ('.implode(',',$subordinatesids).')' : ''; |
|
321 | - } |
|
322 | - $this->export_sql_end[$r] .=')'; |
|
323 | - } |
|
324 | - |
|
325 | - // Export list of contacts and attributes |
|
326 | - $r++; |
|
327 | - $this->export_code[$r]=$this->rights_class.'_'.$r; |
|
328 | - $this->export_label[$r]='ExportDataset_company_2'; |
|
329 | - $this->export_icon[$r]='contact'; |
|
330 | - $this->export_permission[$r]=array(array("societe","contact","export")); |
|
331 | - $this->export_fields_array[$r]=array( |
|
332 | - 'c.rowid'=>"IdContact",'c.civility'=>"CivilityCode",'c.lastname'=>'Lastname','c.firstname'=>'Firstname','c.poste'=>'PostOrFunction', |
|
333 | - 'c.datec'=>"DateCreation",'c.tms'=>"DateLastModification",'c.priv'=>"ContactPrivate",'c.address'=>"Address",'c.zip'=>"Zip",'c.town'=>"Town", |
|
334 | - 'd.nom'=>'State','co.label'=>"Country",'co.code'=>"CountryCode",'c.phone'=>"Phone",'c.fax'=>"Fax",'c.phone_mobile'=>"Mobile",'c.email'=>"EMail", |
|
335 | - 's.rowid'=>"IdCompany",'s.nom'=>"CompanyName",'s.status'=>"Status",'s.code_client'=>"CustomerCode",'s.code_fournisseur'=>"SupplierCode", |
|
336 | - 's.client'=>'Customer','s.fournisseur'=>'Supplier' |
|
337 | - ); |
|
338 | - $this->export_examplevalues_array[$r]=array('s.client'=>'0 (no customer no prospect)/1 (customer)/2 (prospect)/3 (customer and prospect)','s.fournisseur'=>'0 (not a supplier) or 1 (supplier)'); |
|
339 | - $this->export_TypeFields_array[$r]=array( |
|
340 | - 'c.civility'=>"List:c_civility:label:code",'c.lastname'=>'Text','c.firstname'=>'Text','c.poste'=>'Text','c.datec'=>"Date",'c.priv'=>"Boolean", |
|
341 | - 'c.address'=>"Text",'c.zip'=>"Text",'c.town'=>"Text",'d.nom'=>'Text','co.label'=>"List:c_country:label:rowid",'co.code'=>"Text",'c.phone'=>"Text", |
|
342 | - 'c.fax'=>"Text",'c.email'=>"Text",'s.rowid'=>"List:societe:nom",'s.nom'=>"Text",'s.status'=>"Status",'s.code_client'=>"Text",'s.code_fournisseur'=>"Text", |
|
343 | - 's.client'=>"Text",'s.fournisseur'=>"Text" |
|
344 | - ); |
|
345 | - $this->export_entities_array[$r]=array( |
|
346 | - 's.rowid'=>"company",'s.nom'=>"company", 's.status'=>'company', 's.code_client'=>"company",'s.code_fournisseur'=>"company", 's.client'=>"company", |
|
347 | - 's.fournisseur'=>"company" |
|
348 | - ); // We define here only fields that use another picto |
|
306 | + $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_typent as t ON s.fk_typent = t.id'; |
|
307 | + $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as c ON s.fk_pays = c.rowid'; |
|
308 | + $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_effectif as ce ON s.fk_effectif = ce.id'; |
|
309 | + $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_forme_juridique as cfj ON s.fk_forme_juridique = cfj.code'; |
|
310 | + $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_departements as d ON s.fk_departement = d.rowid'; |
|
311 | + $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_stcomm as st ON s.fk_stcomm = st.id'; |
|
312 | + $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid LEFT JOIN '.MAIN_DB_PREFIX.'user as u ON sc.fk_user = u.rowid'; |
|
313 | + $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_payment_term as payterm ON s.cond_reglement = payterm.rowid'; |
|
314 | + $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as paymode ON s.mode_reglement = paymode.id'; |
|
315 | + $this->export_sql_end[$r] .=' WHERE s.entity IN ('.getEntity('societe').')'; |
|
316 | + if (is_object($user) && empty($user->rights->societe->client->voir)) { |
|
317 | + $this->export_sql_end[$r] .=' AND (sc.fk_user = '.$user->id.' '; |
|
318 | + if (! empty($conf->global->SOCIETE_EXPORT_SUBORDINATES_CHILDS)) { |
|
319 | + $subordinatesids = $user->getAllChildIds(); |
|
320 | + $this->export_sql_end[$r] .=count($subordinatesids)>0 ? ' OR (sc.fk_user IN ('.implode(',',$subordinatesids).')' : ''; |
|
321 | + } |
|
322 | + $this->export_sql_end[$r] .=')'; |
|
323 | + } |
|
324 | + |
|
325 | + // Export list of contacts and attributes |
|
326 | + $r++; |
|
327 | + $this->export_code[$r]=$this->rights_class.'_'.$r; |
|
328 | + $this->export_label[$r]='ExportDataset_company_2'; |
|
329 | + $this->export_icon[$r]='contact'; |
|
330 | + $this->export_permission[$r]=array(array("societe","contact","export")); |
|
331 | + $this->export_fields_array[$r]=array( |
|
332 | + 'c.rowid'=>"IdContact",'c.civility'=>"CivilityCode",'c.lastname'=>'Lastname','c.firstname'=>'Firstname','c.poste'=>'PostOrFunction', |
|
333 | + 'c.datec'=>"DateCreation",'c.tms'=>"DateLastModification",'c.priv'=>"ContactPrivate",'c.address'=>"Address",'c.zip'=>"Zip",'c.town'=>"Town", |
|
334 | + 'd.nom'=>'State','co.label'=>"Country",'co.code'=>"CountryCode",'c.phone'=>"Phone",'c.fax'=>"Fax",'c.phone_mobile'=>"Mobile",'c.email'=>"EMail", |
|
335 | + 's.rowid'=>"IdCompany",'s.nom'=>"CompanyName",'s.status'=>"Status",'s.code_client'=>"CustomerCode",'s.code_fournisseur'=>"SupplierCode", |
|
336 | + 's.client'=>'Customer','s.fournisseur'=>'Supplier' |
|
337 | + ); |
|
338 | + $this->export_examplevalues_array[$r]=array('s.client'=>'0 (no customer no prospect)/1 (customer)/2 (prospect)/3 (customer and prospect)','s.fournisseur'=>'0 (not a supplier) or 1 (supplier)'); |
|
339 | + $this->export_TypeFields_array[$r]=array( |
|
340 | + 'c.civility'=>"List:c_civility:label:code",'c.lastname'=>'Text','c.firstname'=>'Text','c.poste'=>'Text','c.datec'=>"Date",'c.priv'=>"Boolean", |
|
341 | + 'c.address'=>"Text",'c.zip'=>"Text",'c.town'=>"Text",'d.nom'=>'Text','co.label'=>"List:c_country:label:rowid",'co.code'=>"Text",'c.phone'=>"Text", |
|
342 | + 'c.fax'=>"Text",'c.email'=>"Text",'s.rowid'=>"List:societe:nom",'s.nom'=>"Text",'s.status'=>"Status",'s.code_client'=>"Text",'s.code_fournisseur'=>"Text", |
|
343 | + 's.client'=>"Text",'s.fournisseur'=>"Text" |
|
344 | + ); |
|
345 | + $this->export_entities_array[$r]=array( |
|
346 | + 's.rowid'=>"company",'s.nom'=>"company", 's.status'=>'company', 's.code_client'=>"company",'s.code_fournisseur'=>"company", 's.client'=>"company", |
|
347 | + 's.fournisseur'=>"company" |
|
348 | + ); // We define here only fields that use another picto |
|
349 | 349 | if (empty($conf->fournisseur->enabled)) |
350 | 350 | { |
351 | 351 | unset($this->export_fields_array[$r]['s.code_fournisseur']); |
@@ -356,193 +356,193 @@ discard block |
||
356 | 356 | $keyforselect='societe'; $keyforelement='company'; $keyforaliasextra='extrasoc'; |
357 | 357 | include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; |
358 | 358 | $this->export_sql_start[$r]='SELECT DISTINCT '; |
359 | - $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'socpeople as c'; |
|
360 | - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'societe as s ON c.fk_soc = s.rowid'; |
|
361 | - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'societe_extrafields as extrasoc ON s.rowid = extrasoc.fk_object'; |
|
362 | - if (is_object($user) && 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'; |
|
363 | - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_departements as d ON c.fk_departement = d.rowid'; |
|
364 | - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as co ON c.fk_pays = co.rowid'; |
|
365 | - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'socpeople_extrafields as extra ON extra.fk_object = c.rowid'; |
|
366 | - $this->export_sql_end[$r] .=' WHERE c.entity IN ('.getEntity('socpeople').')'; |
|
367 | - if (is_object($user) && empty($user->rights->societe->client->voir)) { |
|
368 | - $this->export_sql_end[$r] .=' AND (sc.fk_user = '.$user->id.' '; |
|
369 | - if (! empty($conf->global->SOCIETE_EXPORT_SUBORDINATES_CHILDS)) { |
|
370 | - $subordinatesids = $user->getAllChildIds(); |
|
371 | - $this->export_sql_end[$r] .=count($subordinatesids)>0 ? ' OR (sc.fk_user IN ('.implode(',',$subordinatesids).')' : ''; |
|
372 | - } |
|
373 | - $this->export_sql_end[$r] .=')'; |
|
374 | - } |
|
375 | - |
|
376 | - |
|
377 | - // Imports |
|
378 | - //-------- |
|
379 | - $r=0; |
|
380 | - |
|
381 | - // Import list of third parties and attributes |
|
382 | - $r++; |
|
383 | - $this->import_code[$r]=$this->rights_class.'_'.$r; |
|
384 | - $this->import_label[$r]='ImportDataset_company_1'; |
|
385 | - $this->import_icon[$r]='company'; |
|
386 | - $this->import_entities_array[$r]=array(); // We define here only fields that use another icon that the one defined into import_icon |
|
387 | - $this->import_tables_array[$r]=array('s'=>MAIN_DB_PREFIX.'societe','extra'=>MAIN_DB_PREFIX.'societe_extrafields'); // List of tables to insert into (insert done in same order) |
|
388 | - $this->import_fields_array[$r]=array( |
|
389 | - 's.nom'=>"Name*", 's.name_alias'=>"Alias", 's.status'=>"Status",'s.client'=>"Customer*",'s.fournisseur'=>"Supplier*",'s.code_client'=>"CustomerCode",'s.code_fournisseur'=>"SupplierCode", |
|
390 | - 's.code_compta'=>"CustomerAccountancyCode",'s.code_compta_fournisseur'=>"SupplierAccountancyCode",'s.address'=>"Address",'s.zip'=>"Zip",'s.town'=>"Town", |
|
391 | - 's.fk_departement'=>"StateId",'s.fk_pays'=>"CountryCode",'s.phone'=>"Phone",'s.fax'=>"Fax",'s.url'=>"Url",'s.email'=>"Email",'s.siren'=>"ProfId1", |
|
392 | - 's.siret'=>"ProfId2",'s.ape'=>"ProfId3",'s.idprof4'=>"ProfId4",'s.idprof5'=>"ProfId5",'s.idprof6'=>"ProfId6",'s.tva_intra'=>"VATIntraShort", |
|
393 | - 's.capital'=>"Capital",'s.note_private'=>"NotePrivate",'s.note_public'=>"NotePublic",'s.canvas'=>"Canvas",'s.fk_typent'=>"ThirdPartyType",'s.fk_effectif'=>"Staff", |
|
394 | - "s.fk_forme_juridique"=>"JuridicalStatus",'s.fk_prospectlevel'=>'ProspectLevel','s.fk_stcomm'=>'ProspectStatus','s.default_lang'=>'DefaultLanguage', |
|
395 | - 's.barcode'=>'BarCode','s.datec'=>"DateCreation" |
|
396 | - ); |
|
397 | - // Add extra fields |
|
398 | - $sql="SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'societe' AND entity IN (0,".$conf->entity.")"; |
|
399 | - $resql=$this->db->query($sql); |
|
400 | - if ($resql) // This can fail when class is used on old database (during migration for example) |
|
401 | - { |
|
402 | - while ($obj=$this->db->fetch_object($resql)) |
|
403 | - { |
|
404 | - $fieldname='extra.'.$obj->name; |
|
405 | - $fieldlabel=ucfirst($obj->label); |
|
406 | - $this->import_fields_array[$r][$fieldname]=$fieldlabel.($obj->fieldrequired?'*':''); |
|
407 | - } |
|
408 | - } |
|
409 | - // End add extra fields |
|
410 | - $this->import_fieldshidden_array[$r]=array('s.fk_user_creat'=>'user->id','extra.fk_object'=>'lastrowid-'.MAIN_DB_PREFIX.'societe'); // aliastable.field => ('user->id' or 'lastrowid-'.tableparent) |
|
411 | - $this->import_convertvalue_array[$r]=array( |
|
412 | - 's.fk_typent'=>array('rule'=>'fetchidfromcodeorlabel','classfile'=>'/core/class/ctypent.class.php','class'=>'Ctypent','method'=>'fetch','dict'=>'DictionaryCompanyType'), |
|
413 | - 's.fk_departement'=>array('rule'=>'fetchidfromcodeid','classfile'=>'/core/class/cstate.class.php','class'=>'Cstate','method'=>'fetch','dict'=>'DictionaryState'), |
|
414 | - 's.fk_pays'=>array('rule'=>'fetchidfromcodeid','classfile'=>'/core/class/ccountry.class.php','class'=>'Ccountry','method'=>'fetch','dict'=>'DictionaryCountry'), |
|
415 | - 's.fk_stcomm'=>array('rule'=>'zeroifnull'), |
|
416 | - 's.code_client'=>array('rule'=>'getcustomercodeifauto'), |
|
417 | - 's.code_fournisseur'=>array('rule'=>'getsuppliercodeifauto'), |
|
418 | - 's.code_compta'=>array('rule'=>'getcustomeraccountancycodeifauto'), |
|
419 | - 's.code_compta_fournisseur'=>array('rule'=>'getsupplieraccountancycodeifauto'), |
|
420 | - 's.capital'=>array('rule'=>'numeric') |
|
421 | - ); |
|
422 | - //$this->import_convertvalue_array[$r]=array('s.fk_soc'=>array('rule'=>'lastrowid',table='t'); |
|
423 | - $this->import_regex_array[$r]=array('s.status'=>'^[0|1]','s.client'=>'^[0|1|2|3]','s.fournisseur'=>'^[0|1]','s.fk_typent'=>'id@'.MAIN_DB_PREFIX.'c_typent','s.datec'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]( [0-9][0-9]:[0-9][0-9]:[0-9][0-9])?$'); |
|
424 | - $this->import_examplevalues_array[$r]=array( |
|
425 | - 's.nom'=>"MyBigCompany", 's.name_alias'=>"MyBigAlias", 's.status'=>"0 (closed) or 1 (active)",'s.client'=>'0 (no customer no prospect)/1 (customer)/2 (prospect)/3 (customer and prospect)', |
|
426 | - 's.fournisseur'=>'0 or 1','s.datec'=>dol_print_date(dol_now(),'%Y-%m-%d'),'s.code_client'=>'CU01-0001 or empty or "auto"','s.code_fournisseur'=>'SU01-0001 or empty or "auto"', |
|
427 | - 's.address'=>"61 jump street",'s.zip'=>"123456",'s.town'=>"Big town",'s.fk_pays'=>'US, FR, DE...','s.phone'=>"0101010101",'s.fax'=>"0101010102", |
|
428 | - 's.url'=>"http://mycompany.com",'s.email'=>"[email protected]",'s.siret'=>"",'s.siren'=>"",'s.ape'=>"",'s.idprof4'=>"",'s.idprof5'=>"",'s.idprof6'=>"", |
|
429 | - 's.tva_intra'=>"FR0123456789",'s.capital'=>"10000",'s.note_private'=>"This is an example of private note for record",'s.note_public'=>"This is an example of public note for record", |
|
430 | - 's.fk_typent'=>"2",'s.fk_effectif'=>"3","s.fk_forme_juridique"=>"1",'s.fk_prospectlevel'=>'PL_MEDIUM','s.fk_stcomm'=>'0','s.default_lang'=>'en_US','s.barcode'=>'123456789', |
|
431 | - 's.datec'=>"2015-01-01 or 2015-01-01 12:30:00" |
|
432 | - ); |
|
433 | - $this->import_updatekeys_array[$r]=array('s.nom'=>'Name','s.code_client'=>'CustomerCode','s.code_fournisseur'=>'SupplierCode','s.code_compta'=>'CustomerAccountancyCode','s.code_compta_fournisseur'=>'SupplierAccountancyCode'); |
|
434 | - |
|
435 | - // Import list of contact and attributes |
|
436 | - $r++; |
|
437 | - $this->import_code[$r]=$this->rights_class.'_'.$r; |
|
438 | - $this->import_label[$r]='ImportDataset_company_2'; |
|
439 | - $this->import_icon[$r]='contact'; |
|
440 | - $this->import_entities_array[$r]=array('s.fk_soc'=>'company'); // We define here only fields that use another icon that the one defined into import_icon |
|
441 | - $this->import_tables_array[$r]=array('s'=>MAIN_DB_PREFIX.'socpeople','extra'=>MAIN_DB_PREFIX.'socpeople_extrafields'); // List of tables to insert into (insert done in same order) |
|
442 | - $this->import_fields_array[$r]=array( |
|
443 | - 's.fk_soc'=>'ThirdPartyName','s.civility'=>'UserTitle','s.lastname'=>"Lastname*",'s.firstname'=>"Firstname",'s.address'=>"Address",'s.zip'=>"Zip", |
|
444 | - 's.town'=>"Town",'s.fk_departement'=>"StateId",'s.fk_pays'=>"CountryCode",'s.birthday'=>"BirthdayDate",'s.poste'=>"Role",'s.phone'=>"Phone",'s.phone_perso'=>"PhonePerso", |
|
445 | - 's.phone_mobile'=>"PhoneMobile",'s.fax'=>"Fax",'s.email'=>"Email",'s.note_private'=>"Note",'s.note_public'=>"Note",'s.datec'=>"DateCreation" |
|
446 | - ); |
|
447 | - // Add extra fields |
|
448 | - $sql="SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'socpeople' AND entity IN (0,".$conf->entity.")"; |
|
449 | - $resql=$this->db->query($sql); |
|
450 | - if ($resql) // This can fail when class is used on old database (during migration for example) |
|
451 | - { |
|
452 | - while ($obj=$this->db->fetch_object($resql)) |
|
453 | - { |
|
454 | - $fieldname='extra.'.$obj->name; |
|
455 | - $fieldlabel=ucfirst($obj->label); |
|
456 | - $this->import_fields_array[$r][$fieldname]=$fieldlabel.($obj->fieldrequired?'*':''); |
|
457 | - } |
|
458 | - } |
|
459 | - // End add extra fields |
|
460 | - $this->import_fieldshidden_array[$r]=array('s.fk_user_creat'=>'user->id','extra.fk_object'=>'lastrowid-'.MAIN_DB_PREFIX.'socpeople'); // aliastable.field => ('user->id' or 'lastrowid-'.tableparent) |
|
461 | - $this->import_convertvalue_array[$r]=array( |
|
462 | - 's.fk_soc'=>array('rule'=>'fetchidfromref','file'=>'/societe/class/societe.class.php','class'=>'Societe','method'=>'fetch','element'=>'ThirdParty'), |
|
463 | - 's.fk_departement'=>array('rule'=>'fetchidfromcodeid','classfile'=>'/core/class/cstate.class.php','class'=>'Cstate','method'=>'fetch','dict'=>'DictionaryState'), |
|
464 | - 's.fk_pays'=>array('rule'=>'fetchidfromcodeid','classfile'=>'/core/class/ccountry.class.php','class'=>'Ccountry','method'=>'fetch','dict'=>'DictionaryCountry'), |
|
465 | - ); |
|
466 | - //$this->import_convertvalue_array[$r]=array('s.fk_soc'=>array('rule'=>'lastrowid',table='t'); |
|
467 | - $this->import_regex_array[$r]=array('s.birthday'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$','s.datec'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]( [0-9][0-9]:[0-9][0-9]:[0-9][0-9])?$'); |
|
468 | - $this->import_examplevalues_array[$r]=array( |
|
469 | - 's.fk_soc'=>'MyBigCompany','s.civility'=>"MR",'s.lastname'=>"Smith",'s.firstname'=>'John','s.address'=>'61 jump street','s.zip'=>'75000', |
|
470 | - 's.town'=>'Bigtown','s.fk_pays'=>'US, FR, DE...','s.datec'=>'1972-10-10','s.poste'=>"Director",'s.phone'=>"5551122",'s.phone_perso'=>"5551133", |
|
471 | - 's.phone_mobile'=>"5551144",'s.fax'=>"5551155",'s.email'=>"[email protected]",'s.note_private'=>"My private note",'s.note_public'=>"My public note" |
|
472 | - ); |
|
473 | - |
|
474 | - // Import Bank Accounts |
|
475 | - $r++; |
|
476 | - $this->import_code[$r]=$this->rights_class.'_'.$r; |
|
477 | - $this->import_label[$r]="ImportDataset_company_3"; // Translation key |
|
478 | - $this->import_icon[$r]='company'; |
|
479 | - $this->import_entities_array[$r]=array(); // We define here only fields that use another icon that the one defined into import_icon |
|
480 | - $this->import_tables_array[$r]=array('sr'=>MAIN_DB_PREFIX.'societe_rib'); |
|
481 | - $this->import_fields_array[$r]=array('sr.fk_soc'=>"ThirdPartyName*",'sr.bank'=>"Bank", |
|
482 | - 'sr.code_banque'=>"BankCode",'sr.code_guichet'=>"DeskCode",'sr.number'=>"BankAccountNumber*", |
|
483 | - 'sr.cle_rib'=>"BankAccountNumberKey",'sr.bic'=>"BIC",'sr.iban_prefix'=>"IBAN", 'sr.domiciliation'=>"BankAccountDomiciliation",'sr.proprio' => "BankAccountOwner", 'sr.owner_address' => "BankAccountOwnerAddress", 'sr.default_rib' => 'Default' |
|
484 | - ); |
|
485 | - |
|
486 | - $this->import_convertvalue_array[$r]=array( |
|
487 | - 'sr.fk_soc'=>array('rule'=>'fetchidfromref','classfile'=>'/societe/class/societe.class.php','class'=>'Societe','method'=>'fetch','element'=>'ThirdParty') |
|
488 | - ); |
|
489 | - $this->import_examplevalues_array[$r]=array('sr.fk_soc'=>"MyBigCompany",'sr.bank'=>"ING", |
|
490 | - 'sr.code_banque'=>"0000", 'sr.code_guichet'=>"1111",'sr.number'=>"3333333333", |
|
491 | - 'sr.cle_rib'=>"22",'sr.bic'=>"USHINGMMXXX",'sr.iban_prefix'=>"US00 0000 1111 22 3333 3333",'sr.domiciliation'=>"PARIS",'sr.proprio' => "Name of owner", 'sr.owner_address' => "15 paris street 75000 Paris", 'sr.default_rib' => '1 or 0' |
|
492 | - ); |
|
493 | - |
|
494 | - // Import Company Sales representatives |
|
495 | - $r++; |
|
496 | - $this->import_code[$r]=$this->rights_class.'_'.$r; |
|
497 | - $this->import_label[$r]="ImportDataset_company_4"; // Translation key |
|
498 | - $this->import_icon[$r]='company'; |
|
499 | - $this->import_entities_array[$r]=array('sr.fk_user'=>'user'); // We define here only fields that use another icon that the one defined into import_icon |
|
500 | - $this->import_tables_array[$r]=array('sr'=>MAIN_DB_PREFIX.'societe_commerciaux'); |
|
501 | - $this->import_fields_array[$r]=array('sr.fk_soc'=>"ThirdPartyName*",'sr.fk_user'=>"User*"); |
|
359 | + $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'socpeople as c'; |
|
360 | + $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'societe as s ON c.fk_soc = s.rowid'; |
|
361 | + $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'societe_extrafields as extrasoc ON s.rowid = extrasoc.fk_object'; |
|
362 | + if (is_object($user) && 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'; |
|
363 | + $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_departements as d ON c.fk_departement = d.rowid'; |
|
364 | + $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as co ON c.fk_pays = co.rowid'; |
|
365 | + $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'socpeople_extrafields as extra ON extra.fk_object = c.rowid'; |
|
366 | + $this->export_sql_end[$r] .=' WHERE c.entity IN ('.getEntity('socpeople').')'; |
|
367 | + if (is_object($user) && empty($user->rights->societe->client->voir)) { |
|
368 | + $this->export_sql_end[$r] .=' AND (sc.fk_user = '.$user->id.' '; |
|
369 | + if (! empty($conf->global->SOCIETE_EXPORT_SUBORDINATES_CHILDS)) { |
|
370 | + $subordinatesids = $user->getAllChildIds(); |
|
371 | + $this->export_sql_end[$r] .=count($subordinatesids)>0 ? ' OR (sc.fk_user IN ('.implode(',',$subordinatesids).')' : ''; |
|
372 | + } |
|
373 | + $this->export_sql_end[$r] .=')'; |
|
374 | + } |
|
502 | 375 | |
503 | - $this->import_convertvalue_array[$r]=array( |
|
504 | - 'sr.fk_soc'=>array('rule'=>'fetchidfromref','classfile'=>'/societe/class/societe.class.php','class'=>'Societe','method'=>'fetch','element'=>'ThirdParty'), |
|
505 | - 'sr.fk_user'=>array('rule'=>'fetchidfromref','classfile'=>'/user/class/user.class.php','class'=>'User','method'=>'fetch','element'=>'User') |
|
506 | - ); |
|
507 | - $this->import_examplevalues_array[$r]=array('sr.fk_soc'=>"MyBigCompany",'sr.fk_user'=>"login"); |
|
508 | - } |
|
376 | + |
|
377 | + // Imports |
|
378 | + //-------- |
|
379 | + $r=0; |
|
380 | + |
|
381 | + // Import list of third parties and attributes |
|
382 | + $r++; |
|
383 | + $this->import_code[$r]=$this->rights_class.'_'.$r; |
|
384 | + $this->import_label[$r]='ImportDataset_company_1'; |
|
385 | + $this->import_icon[$r]='company'; |
|
386 | + $this->import_entities_array[$r]=array(); // We define here only fields that use another icon that the one defined into import_icon |
|
387 | + $this->import_tables_array[$r]=array('s'=>MAIN_DB_PREFIX.'societe','extra'=>MAIN_DB_PREFIX.'societe_extrafields'); // List of tables to insert into (insert done in same order) |
|
388 | + $this->import_fields_array[$r]=array( |
|
389 | + 's.nom'=>"Name*", 's.name_alias'=>"Alias", 's.status'=>"Status",'s.client'=>"Customer*",'s.fournisseur'=>"Supplier*",'s.code_client'=>"CustomerCode",'s.code_fournisseur'=>"SupplierCode", |
|
390 | + 's.code_compta'=>"CustomerAccountancyCode",'s.code_compta_fournisseur'=>"SupplierAccountancyCode",'s.address'=>"Address",'s.zip'=>"Zip",'s.town'=>"Town", |
|
391 | + 's.fk_departement'=>"StateId",'s.fk_pays'=>"CountryCode",'s.phone'=>"Phone",'s.fax'=>"Fax",'s.url'=>"Url",'s.email'=>"Email",'s.siren'=>"ProfId1", |
|
392 | + 's.siret'=>"ProfId2",'s.ape'=>"ProfId3",'s.idprof4'=>"ProfId4",'s.idprof5'=>"ProfId5",'s.idprof6'=>"ProfId6",'s.tva_intra'=>"VATIntraShort", |
|
393 | + 's.capital'=>"Capital",'s.note_private'=>"NotePrivate",'s.note_public'=>"NotePublic",'s.canvas'=>"Canvas",'s.fk_typent'=>"ThirdPartyType",'s.fk_effectif'=>"Staff", |
|
394 | + "s.fk_forme_juridique"=>"JuridicalStatus",'s.fk_prospectlevel'=>'ProspectLevel','s.fk_stcomm'=>'ProspectStatus','s.default_lang'=>'DefaultLanguage', |
|
395 | + 's.barcode'=>'BarCode','s.datec'=>"DateCreation" |
|
396 | + ); |
|
397 | + // Add extra fields |
|
398 | + $sql="SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'societe' AND entity IN (0,".$conf->entity.")"; |
|
399 | + $resql=$this->db->query($sql); |
|
400 | + if ($resql) // This can fail when class is used on old database (during migration for example) |
|
401 | + { |
|
402 | + while ($obj=$this->db->fetch_object($resql)) |
|
403 | + { |
|
404 | + $fieldname='extra.'.$obj->name; |
|
405 | + $fieldlabel=ucfirst($obj->label); |
|
406 | + $this->import_fields_array[$r][$fieldname]=$fieldlabel.($obj->fieldrequired?'*':''); |
|
407 | + } |
|
408 | + } |
|
409 | + // End add extra fields |
|
410 | + $this->import_fieldshidden_array[$r]=array('s.fk_user_creat'=>'user->id','extra.fk_object'=>'lastrowid-'.MAIN_DB_PREFIX.'societe'); // aliastable.field => ('user->id' or 'lastrowid-'.tableparent) |
|
411 | + $this->import_convertvalue_array[$r]=array( |
|
412 | + 's.fk_typent'=>array('rule'=>'fetchidfromcodeorlabel','classfile'=>'/core/class/ctypent.class.php','class'=>'Ctypent','method'=>'fetch','dict'=>'DictionaryCompanyType'), |
|
413 | + 's.fk_departement'=>array('rule'=>'fetchidfromcodeid','classfile'=>'/core/class/cstate.class.php','class'=>'Cstate','method'=>'fetch','dict'=>'DictionaryState'), |
|
414 | + 's.fk_pays'=>array('rule'=>'fetchidfromcodeid','classfile'=>'/core/class/ccountry.class.php','class'=>'Ccountry','method'=>'fetch','dict'=>'DictionaryCountry'), |
|
415 | + 's.fk_stcomm'=>array('rule'=>'zeroifnull'), |
|
416 | + 's.code_client'=>array('rule'=>'getcustomercodeifauto'), |
|
417 | + 's.code_fournisseur'=>array('rule'=>'getsuppliercodeifauto'), |
|
418 | + 's.code_compta'=>array('rule'=>'getcustomeraccountancycodeifauto'), |
|
419 | + 's.code_compta_fournisseur'=>array('rule'=>'getsupplieraccountancycodeifauto'), |
|
420 | + 's.capital'=>array('rule'=>'numeric') |
|
421 | + ); |
|
422 | + //$this->import_convertvalue_array[$r]=array('s.fk_soc'=>array('rule'=>'lastrowid',table='t'); |
|
423 | + $this->import_regex_array[$r]=array('s.status'=>'^[0|1]','s.client'=>'^[0|1|2|3]','s.fournisseur'=>'^[0|1]','s.fk_typent'=>'id@'.MAIN_DB_PREFIX.'c_typent','s.datec'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]( [0-9][0-9]:[0-9][0-9]:[0-9][0-9])?$'); |
|
424 | + $this->import_examplevalues_array[$r]=array( |
|
425 | + 's.nom'=>"MyBigCompany", 's.name_alias'=>"MyBigAlias", 's.status'=>"0 (closed) or 1 (active)",'s.client'=>'0 (no customer no prospect)/1 (customer)/2 (prospect)/3 (customer and prospect)', |
|
426 | + 's.fournisseur'=>'0 or 1','s.datec'=>dol_print_date(dol_now(),'%Y-%m-%d'),'s.code_client'=>'CU01-0001 or empty or "auto"','s.code_fournisseur'=>'SU01-0001 or empty or "auto"', |
|
427 | + 's.address'=>"61 jump street",'s.zip'=>"123456",'s.town'=>"Big town",'s.fk_pays'=>'US, FR, DE...','s.phone'=>"0101010101",'s.fax'=>"0101010102", |
|
428 | + 's.url'=>"http://mycompany.com",'s.email'=>"[email protected]",'s.siret'=>"",'s.siren'=>"",'s.ape'=>"",'s.idprof4'=>"",'s.idprof5'=>"",'s.idprof6'=>"", |
|
429 | + 's.tva_intra'=>"FR0123456789",'s.capital'=>"10000",'s.note_private'=>"This is an example of private note for record",'s.note_public'=>"This is an example of public note for record", |
|
430 | + 's.fk_typent'=>"2",'s.fk_effectif'=>"3","s.fk_forme_juridique"=>"1",'s.fk_prospectlevel'=>'PL_MEDIUM','s.fk_stcomm'=>'0','s.default_lang'=>'en_US','s.barcode'=>'123456789', |
|
431 | + 's.datec'=>"2015-01-01 or 2015-01-01 12:30:00" |
|
432 | + ); |
|
433 | + $this->import_updatekeys_array[$r]=array('s.nom'=>'Name','s.code_client'=>'CustomerCode','s.code_fournisseur'=>'SupplierCode','s.code_compta'=>'CustomerAccountancyCode','s.code_compta_fournisseur'=>'SupplierAccountancyCode'); |
|
434 | + |
|
435 | + // Import list of contact and attributes |
|
436 | + $r++; |
|
437 | + $this->import_code[$r]=$this->rights_class.'_'.$r; |
|
438 | + $this->import_label[$r]='ImportDataset_company_2'; |
|
439 | + $this->import_icon[$r]='contact'; |
|
440 | + $this->import_entities_array[$r]=array('s.fk_soc'=>'company'); // We define here only fields that use another icon that the one defined into import_icon |
|
441 | + $this->import_tables_array[$r]=array('s'=>MAIN_DB_PREFIX.'socpeople','extra'=>MAIN_DB_PREFIX.'socpeople_extrafields'); // List of tables to insert into (insert done in same order) |
|
442 | + $this->import_fields_array[$r]=array( |
|
443 | + 's.fk_soc'=>'ThirdPartyName','s.civility'=>'UserTitle','s.lastname'=>"Lastname*",'s.firstname'=>"Firstname",'s.address'=>"Address",'s.zip'=>"Zip", |
|
444 | + 's.town'=>"Town",'s.fk_departement'=>"StateId",'s.fk_pays'=>"CountryCode",'s.birthday'=>"BirthdayDate",'s.poste'=>"Role",'s.phone'=>"Phone",'s.phone_perso'=>"PhonePerso", |
|
445 | + 's.phone_mobile'=>"PhoneMobile",'s.fax'=>"Fax",'s.email'=>"Email",'s.note_private'=>"Note",'s.note_public'=>"Note",'s.datec'=>"DateCreation" |
|
446 | + ); |
|
447 | + // Add extra fields |
|
448 | + $sql="SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'socpeople' AND entity IN (0,".$conf->entity.")"; |
|
449 | + $resql=$this->db->query($sql); |
|
450 | + if ($resql) // This can fail when class is used on old database (during migration for example) |
|
451 | + { |
|
452 | + while ($obj=$this->db->fetch_object($resql)) |
|
453 | + { |
|
454 | + $fieldname='extra.'.$obj->name; |
|
455 | + $fieldlabel=ucfirst($obj->label); |
|
456 | + $this->import_fields_array[$r][$fieldname]=$fieldlabel.($obj->fieldrequired?'*':''); |
|
457 | + } |
|
458 | + } |
|
459 | + // End add extra fields |
|
460 | + $this->import_fieldshidden_array[$r]=array('s.fk_user_creat'=>'user->id','extra.fk_object'=>'lastrowid-'.MAIN_DB_PREFIX.'socpeople'); // aliastable.field => ('user->id' or 'lastrowid-'.tableparent) |
|
461 | + $this->import_convertvalue_array[$r]=array( |
|
462 | + 's.fk_soc'=>array('rule'=>'fetchidfromref','file'=>'/societe/class/societe.class.php','class'=>'Societe','method'=>'fetch','element'=>'ThirdParty'), |
|
463 | + 's.fk_departement'=>array('rule'=>'fetchidfromcodeid','classfile'=>'/core/class/cstate.class.php','class'=>'Cstate','method'=>'fetch','dict'=>'DictionaryState'), |
|
464 | + 's.fk_pays'=>array('rule'=>'fetchidfromcodeid','classfile'=>'/core/class/ccountry.class.php','class'=>'Ccountry','method'=>'fetch','dict'=>'DictionaryCountry'), |
|
465 | + ); |
|
466 | + //$this->import_convertvalue_array[$r]=array('s.fk_soc'=>array('rule'=>'lastrowid',table='t'); |
|
467 | + $this->import_regex_array[$r]=array('s.birthday'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$','s.datec'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]( [0-9][0-9]:[0-9][0-9]:[0-9][0-9])?$'); |
|
468 | + $this->import_examplevalues_array[$r]=array( |
|
469 | + 's.fk_soc'=>'MyBigCompany','s.civility'=>"MR",'s.lastname'=>"Smith",'s.firstname'=>'John','s.address'=>'61 jump street','s.zip'=>'75000', |
|
470 | + 's.town'=>'Bigtown','s.fk_pays'=>'US, FR, DE...','s.datec'=>'1972-10-10','s.poste'=>"Director",'s.phone'=>"5551122",'s.phone_perso'=>"5551133", |
|
471 | + 's.phone_mobile'=>"5551144",'s.fax'=>"5551155",'s.email'=>"[email protected]",'s.note_private'=>"My private note",'s.note_public'=>"My public note" |
|
472 | + ); |
|
473 | + |
|
474 | + // Import Bank Accounts |
|
475 | + $r++; |
|
476 | + $this->import_code[$r]=$this->rights_class.'_'.$r; |
|
477 | + $this->import_label[$r]="ImportDataset_company_3"; // Translation key |
|
478 | + $this->import_icon[$r]='company'; |
|
479 | + $this->import_entities_array[$r]=array(); // We define here only fields that use another icon that the one defined into import_icon |
|
480 | + $this->import_tables_array[$r]=array('sr'=>MAIN_DB_PREFIX.'societe_rib'); |
|
481 | + $this->import_fields_array[$r]=array('sr.fk_soc'=>"ThirdPartyName*",'sr.bank'=>"Bank", |
|
482 | + 'sr.code_banque'=>"BankCode",'sr.code_guichet'=>"DeskCode",'sr.number'=>"BankAccountNumber*", |
|
483 | + 'sr.cle_rib'=>"BankAccountNumberKey",'sr.bic'=>"BIC",'sr.iban_prefix'=>"IBAN", 'sr.domiciliation'=>"BankAccountDomiciliation",'sr.proprio' => "BankAccountOwner", 'sr.owner_address' => "BankAccountOwnerAddress", 'sr.default_rib' => 'Default' |
|
484 | + ); |
|
485 | + |
|
486 | + $this->import_convertvalue_array[$r]=array( |
|
487 | + 'sr.fk_soc'=>array('rule'=>'fetchidfromref','classfile'=>'/societe/class/societe.class.php','class'=>'Societe','method'=>'fetch','element'=>'ThirdParty') |
|
488 | + ); |
|
489 | + $this->import_examplevalues_array[$r]=array('sr.fk_soc'=>"MyBigCompany",'sr.bank'=>"ING", |
|
490 | + 'sr.code_banque'=>"0000", 'sr.code_guichet'=>"1111",'sr.number'=>"3333333333", |
|
491 | + 'sr.cle_rib'=>"22",'sr.bic'=>"USHINGMMXXX",'sr.iban_prefix'=>"US00 0000 1111 22 3333 3333",'sr.domiciliation'=>"PARIS",'sr.proprio' => "Name of owner", 'sr.owner_address' => "15 paris street 75000 Paris", 'sr.default_rib' => '1 or 0' |
|
492 | + ); |
|
493 | + |
|
494 | + // Import Company Sales representatives |
|
495 | + $r++; |
|
496 | + $this->import_code[$r]=$this->rights_class.'_'.$r; |
|
497 | + $this->import_label[$r]="ImportDataset_company_4"; // Translation key |
|
498 | + $this->import_icon[$r]='company'; |
|
499 | + $this->import_entities_array[$r]=array('sr.fk_user'=>'user'); // We define here only fields that use another icon that the one defined into import_icon |
|
500 | + $this->import_tables_array[$r]=array('sr'=>MAIN_DB_PREFIX.'societe_commerciaux'); |
|
501 | + $this->import_fields_array[$r]=array('sr.fk_soc'=>"ThirdPartyName*",'sr.fk_user'=>"User*"); |
|
502 | + |
|
503 | + $this->import_convertvalue_array[$r]=array( |
|
504 | + 'sr.fk_soc'=>array('rule'=>'fetchidfromref','classfile'=>'/societe/class/societe.class.php','class'=>'Societe','method'=>'fetch','element'=>'ThirdParty'), |
|
505 | + 'sr.fk_user'=>array('rule'=>'fetchidfromref','classfile'=>'/user/class/user.class.php','class'=>'User','method'=>'fetch','element'=>'User') |
|
506 | + ); |
|
507 | + $this->import_examplevalues_array[$r]=array('sr.fk_soc'=>"MyBigCompany",'sr.fk_user'=>"login"); |
|
508 | + } |
|
509 | 509 | |
510 | 510 | |
511 | 511 | /** |
512 | - * Function called when module is enabled. |
|
513 | - * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. |
|
514 | - * It also creates data directories |
|
515 | - * |
|
512 | + * Function called when module is enabled. |
|
513 | + * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. |
|
514 | + * It also creates data directories |
|
515 | + * |
|
516 | 516 | * @param string $options Options when enabling module ('', 'noboxes') |
517 | - * @return int 1 if OK, 0 if KO |
|
517 | + * @return int 1 if OK, 0 if KO |
|
518 | 518 | */ |
519 | - function init($options='') |
|
520 | - { |
|
521 | - global $conf, $langs; |
|
522 | - |
|
523 | - // We disable this to prevent pb of modules not correctly disabled |
|
524 | - //$this->remove($options); |
|
525 | - |
|
526 | - //ODT template |
|
527 | - $src=DOL_DOCUMENT_ROOT.'/install/doctemplates/thirdparties/template_thirdparty.odt'; |
|
528 | - $dirodt=DOL_DATA_ROOT.'/doctemplates/thirdparties'; |
|
529 | - $dest=$dirodt.'/template_thirdparty.odt'; |
|
530 | - |
|
531 | - if (file_exists($src) && ! file_exists($dest)) |
|
532 | - { |
|
533 | - require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; |
|
534 | - dol_mkdir($dirodt); |
|
535 | - $result=dol_copy($src,$dest,0,0); |
|
536 | - if ($result < 0) |
|
537 | - { |
|
538 | - $langs->load("errors"); |
|
539 | - $this->error=$langs->trans('ErrorFailToCopyFile',$src,$dest); |
|
540 | - return 0; |
|
541 | - } |
|
542 | - } |
|
543 | - |
|
544 | - $sql = array(); |
|
545 | - |
|
546 | - return $this->_init($sql,$options); |
|
547 | - } |
|
519 | + function init($options='') |
|
520 | + { |
|
521 | + global $conf, $langs; |
|
522 | + |
|
523 | + // We disable this to prevent pb of modules not correctly disabled |
|
524 | + //$this->remove($options); |
|
525 | + |
|
526 | + //ODT template |
|
527 | + $src=DOL_DOCUMENT_ROOT.'/install/doctemplates/thirdparties/template_thirdparty.odt'; |
|
528 | + $dirodt=DOL_DATA_ROOT.'/doctemplates/thirdparties'; |
|
529 | + $dest=$dirodt.'/template_thirdparty.odt'; |
|
530 | + |
|
531 | + if (file_exists($src) && ! file_exists($dest)) |
|
532 | + { |
|
533 | + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; |
|
534 | + dol_mkdir($dirodt); |
|
535 | + $result=dol_copy($src,$dest,0,0); |
|
536 | + if ($result < 0) |
|
537 | + { |
|
538 | + $langs->load("errors"); |
|
539 | + $this->error=$langs->trans('ErrorFailToCopyFile',$src,$dest); |
|
540 | + return 0; |
|
541 | + } |
|
542 | + } |
|
543 | + |
|
544 | + $sql = array(); |
|
545 | + |
|
546 | + return $this->_init($sql,$options); |
|
547 | + } |
|
548 | 548 | } |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | * \ingroup societe |
28 | 28 | * \brief Fichier de description et activation du module Societe |
29 | 29 | */ |
30 | -include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php'; |
|
30 | +include_once DOL_DOCUMENT_ROOT.'/core/modules/DolibarrModules.class.php'; |
|
31 | 31 | |
32 | 32 | |
33 | 33 | /** |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | $this->family = "crm"; |
52 | 52 | $this->module_position = '10'; |
53 | 53 | // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) |
54 | - $this->name = preg_replace('/^mod/i','',get_class($this)); |
|
54 | + $this->name = preg_replace('/^mod/i', '', get_class($this)); |
|
55 | 55 | $this->description = "Gestion des sociétés et contacts"; |
56 | 56 | |
57 | 57 | // Possible values for version are: 'development', 'experimental', 'dolibarr' or version |
@@ -60,22 +60,22 @@ discard block |
||
60 | 60 | $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); |
61 | 61 | $this->config_page_url = array("societe.php@societe"); |
62 | 62 | // Name of image file used for this module. |
63 | - $this->picto='company'; |
|
63 | + $this->picto = 'company'; |
|
64 | 64 | |
65 | 65 | // Data directories to create when module is enabled |
66 | 66 | $this->dirs = array("/societe/temp"); |
67 | 67 | |
68 | 68 | // Dependencies |
69 | - $this->hidden = false; // A condition to hide module |
|
70 | - $this->depends = array(); // List of module class names as string that must be enabled if this module is enabled |
|
71 | - $this->requiredby = array("modExpedition","modFacture","modFournisseur","modFicheinter","modPropale","modContrat","modCommande"); // List of module ids to disable if this one is disabled |
|
72 | - $this->conflictwith = array(); // List of module class names as string this module is in conflict with |
|
73 | - $this->phpmin = array(5,4); // Minimum version of PHP required by module |
|
74 | - $this->langfiles = array("companies",'bills'); |
|
69 | + $this->hidden = false; // A condition to hide module |
|
70 | + $this->depends = array(); // List of module class names as string that must be enabled if this module is enabled |
|
71 | + $this->requiredby = array("modExpedition", "modFacture", "modFournisseur", "modFicheinter", "modPropale", "modContrat", "modCommande"); // List of module ids to disable if this one is disabled |
|
72 | + $this->conflictwith = array(); // List of module class names as string this module is in conflict with |
|
73 | + $this->phpmin = array(5, 4); // Minimum version of PHP required by module |
|
74 | + $this->langfiles = array("companies", 'bills'); |
|
75 | 75 | |
76 | 76 | // Constants |
77 | 77 | $this->const = array(); |
78 | - $r=0; |
|
78 | + $r = 0; |
|
79 | 79 | |
80 | 80 | $this->const[$r][0] = "SOCIETE_CODECLIENT_ADDON"; |
81 | 81 | $this->const[$r][1] = "chaine"; |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | |
124 | 124 | // Boxes |
125 | 125 | $this->boxes = array(); |
126 | - $r=0; |
|
126 | + $r = 0; |
|
127 | 127 | $this->boxes[$r][1] = "box_clients.php"; |
128 | 128 | $r++; |
129 | 129 | $this->boxes[$r][1] = "box_prospect.php"; |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | // Permissions |
140 | 140 | $this->rights = array(); |
141 | 141 | $this->rights_class = 'societe'; |
142 | - $r=0; |
|
142 | + $r = 0; |
|
143 | 143 | |
144 | 144 | $r++; |
145 | 145 | $this->rights[$r][0] = 121; // id de la permission |
@@ -247,38 +247,38 @@ discard block |
||
247 | 247 | |
248 | 248 | // Menus |
249 | 249 | //------- |
250 | - $this->menu = 1; // This module add menu entries. They are coded into menu manager. |
|
250 | + $this->menu = 1; // This module add menu entries. They are coded into menu manager. |
|
251 | 251 | |
252 | 252 | |
253 | 253 | // Exports |
254 | 254 | //-------- |
255 | - $r=0; |
|
255 | + $r = 0; |
|
256 | 256 | |
257 | 257 | // Export list of third parties and attributes |
258 | 258 | $r++; |
259 | - $this->export_code[$r]=$this->rights_class.'_'.$r; |
|
260 | - $this->export_label[$r]='ExportDataset_company_1'; |
|
261 | - $this->export_icon[$r]='company'; |
|
262 | - $this->export_permission[$r]=array(array("societe","export")); |
|
263 | - $this->export_fields_array[$r]=array( |
|
264 | - 's.rowid'=>"Id",'s.nom'=>"Name",'s.name_alias'=>"AliasNames",'s.status'=>"Status",'s.client'=>"Customer",'s.fournisseur'=>"Supplier",'s.datec'=>"DateCreation",'s.tms'=>"DateLastModification", |
|
265 | - 's.code_client'=>"CustomerCode",'s.code_fournisseur'=>"SupplierCode",'s.code_compta'=>"AccountancyCode",'s.code_compta_fournisseur'=>"SupplierAccountancyCode", |
|
266 | - 's.address'=>"Address",'s.zip'=>"Zip",'s.town'=>"Town",'d.nom'=>'State','c.label'=>"Country",'c.code'=>"CountryCode",'s.phone'=>"Phone",'s.fax'=>"Fax", |
|
267 | - 's.url'=>"Url",'s.email'=>"Email",'s.default_lang'=>"DefaultLang",'s.siren'=>"ProfId1",'s.siret'=>"ProfId2",'s.ape'=>"ProfId3",'s.idprof4'=>"ProfId4", |
|
268 | - 's.idprof5'=>"ProfId5",'s.idprof6'=>"ProfId6",'s.tva_intra'=>"VATIntraShort",'s.capital'=>"Capital",'s.note_private'=>"NotePrivate",'s.note_public'=>"NotePublic",'s.canvas'=>"Canvas", |
|
269 | - 't.libelle'=>"ThirdPartyType",'ce.code'=>"Staff","cfj.libelle"=>"JuridicalStatus",'s.fk_prospectlevel'=>'ProspectLevel', |
|
270 | - 'st.code'=>'ProspectStatus','payterm.libelle'=>'PaymentConditions','paymode.libelle'=>'PaymentMode' |
|
259 | + $this->export_code[$r] = $this->rights_class.'_'.$r; |
|
260 | + $this->export_label[$r] = 'ExportDataset_company_1'; |
|
261 | + $this->export_icon[$r] = 'company'; |
|
262 | + $this->export_permission[$r] = array(array("societe", "export")); |
|
263 | + $this->export_fields_array[$r] = array( |
|
264 | + 's.rowid'=>"Id", 's.nom'=>"Name", 's.name_alias'=>"AliasNames", 's.status'=>"Status", 's.client'=>"Customer", 's.fournisseur'=>"Supplier", 's.datec'=>"DateCreation", 's.tms'=>"DateLastModification", |
|
265 | + 's.code_client'=>"CustomerCode", 's.code_fournisseur'=>"SupplierCode", 's.code_compta'=>"AccountancyCode", 's.code_compta_fournisseur'=>"SupplierAccountancyCode", |
|
266 | + 's.address'=>"Address", 's.zip'=>"Zip", 's.town'=>"Town", 'd.nom'=>'State', 'c.label'=>"Country", 'c.code'=>"CountryCode", 's.phone'=>"Phone", 's.fax'=>"Fax", |
|
267 | + 's.url'=>"Url", 's.email'=>"Email", 's.default_lang'=>"DefaultLang", 's.siren'=>"ProfId1", 's.siret'=>"ProfId2", 's.ape'=>"ProfId3", 's.idprof4'=>"ProfId4", |
|
268 | + 's.idprof5'=>"ProfId5", 's.idprof6'=>"ProfId6", 's.tva_intra'=>"VATIntraShort", 's.capital'=>"Capital", 's.note_private'=>"NotePrivate", 's.note_public'=>"NotePublic", 's.canvas'=>"Canvas", |
|
269 | + 't.libelle'=>"ThirdPartyType", 'ce.code'=>"Staff", "cfj.libelle"=>"JuridicalStatus", 's.fk_prospectlevel'=>'ProspectLevel', |
|
270 | + 'st.code'=>'ProspectStatus', 'payterm.libelle'=>'PaymentConditions', 'paymode.libelle'=>'PaymentMode' |
|
271 | 271 | ); |
272 | - if (! empty($conf->global->SOCIETE_USEPREFIX)) $this->export_fields_array[$r]['s.prefix']='Prefix'; |
|
272 | + if (!empty($conf->global->SOCIETE_USEPREFIX)) $this->export_fields_array[$r]['s.prefix'] = 'Prefix'; |
|
273 | 273 | // Add multicompany field |
274 | - if (! empty($conf->global->MULTICOMPANY_ENTITY_IN_EXPORT_IF_SHARED)) |
|
274 | + if (!empty($conf->global->MULTICOMPANY_ENTITY_IN_EXPORT_IF_SHARED)) |
|
275 | 275 | { |
276 | - $nbofallowedentities=count(explode(',',getEntity('societe'))); // If project are shared, nb will be > 1 |
|
277 | - if (! empty($conf->multicompany->enabled) && $nbofallowedentities > 1) $this->export_fields_array[$r]+=array('s.entity'=>'Entity'); |
|
276 | + $nbofallowedentities = count(explode(',', getEntity('societe'))); // If project are shared, nb will be > 1 |
|
277 | + if (!empty($conf->multicompany->enabled) && $nbofallowedentities > 1) $this->export_fields_array[$r] += array('s.entity'=>'Entity'); |
|
278 | 278 | } |
279 | - $keyforselect='societe'; $keyforelement='company'; $keyforaliasextra='extra'; |
|
279 | + $keyforselect = 'societe'; $keyforelement = 'company'; $keyforaliasextra = 'extra'; |
|
280 | 280 | include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; |
281 | - $this->export_fields_array[$r]+=array('u.login'=>'SaleRepresentativeLogin','u.firstname'=>'SaleRepresentativeFirstname', 'u.lastname'=>'SaleRepresentativeLastname'); |
|
281 | + $this->export_fields_array[$r] += array('u.login'=>'SaleRepresentativeLogin', 'u.firstname'=>'SaleRepresentativeFirstname', 'u.lastname'=>'SaleRepresentativeLastname'); |
|
282 | 282 | //$this->export_TypeFields_array[$r]=array( |
283 | 283 | // 's.rowid'=>"List:societe:nom", 's.nom'=>"Text", 's.name_alias'=>"Text", 's.status'=>"Text",'s.client'=>"Boolean",'s.fournisseur'=>"Boolean",'s.datec'=>"Date",'s.tms'=>"Date", |
284 | 284 | // 's.code_client'=>"Text",'s.code_fournisseur'=>"Text",'s.address'=>"Text",'s.zip'=>"Text",'s.town'=>"Text",'c.label'=>"List:c_country:label:label", |
@@ -287,131 +287,131 @@ discard block |
||
287 | 287 | // 't.libelle'=>"Text",'ce.code'=>"List:c_effectif:libelle:code","cfj.libelle"=>"Text",'s.fk_prospectlevel'=>'List:c_prospectlevel:label:code', |
288 | 288 | // 's.fk_stcomm'=>'List:c_stcomm:libelle:code','d.nom'=>'List:c_departements:nom:rowid' |
289 | 289 | //); |
290 | - $this->export_TypeFields_array[$r]=array( |
|
291 | - 's.rowid'=>"Numeric", 's.nom'=>"Text", 's.name_alias'=>"Text", 's.status'=>"Numeric",'s.client'=>"Numeric",'s.fournisseur'=>"Boolean",'s.datec'=>"Date",'s.tms'=>"Date", |
|
292 | - 's.code_client'=>"Text",'s.code_fournisseur'=>"Text",'s.code_compta'=>"Text",'s.code_compta_fournisseur'=>"Text",'s.address'=>"Text",'s.zip'=>"Text", |
|
293 | - 's.town'=>"Text",'c.label'=>"List:c_country:label:label",'c.code'=>"Text",'s.phone'=>"Text",'s.fax'=>"Text",'s.url'=>"Text",'s.email'=>"Text", |
|
294 | - 's.default_lang'=>"Text",'s.siret'=>"Text",'s.siren'=>"Text",'s.ape'=>"Text",'s.idprof4'=>"Text",'s.idprof5'=>"Text",'s.idprof6'=>"Text", |
|
295 | - 's.tva_intra'=>"Text",'s.capital'=>"Numeric",'s.note_private'=>"Text",'s.note_public'=>"Text",'s.canvas'=>"Text",'t.libelle'=>"Text", |
|
296 | - 'ce.code'=>"List:c_effectif:libelle:code","cfj.libelle"=>"Text",'s.fk_prospectlevel'=>'List:c_prospectlevel:label:code', |
|
297 | - 'st.code'=>'List:c_stcomm:libelle:code','d.nom'=>'Text','u.login'=>'Text','u.firstname'=>'Text','u.lastname'=>'Text','payterm.libelle'=>'Text', |
|
298 | - 'paymode.libelle'=>'Text','s.entity'=>'Numeric' |
|
290 | + $this->export_TypeFields_array[$r] = array( |
|
291 | + 's.rowid'=>"Numeric", 's.nom'=>"Text", 's.name_alias'=>"Text", 's.status'=>"Numeric", 's.client'=>"Numeric", 's.fournisseur'=>"Boolean", 's.datec'=>"Date", 's.tms'=>"Date", |
|
292 | + 's.code_client'=>"Text", 's.code_fournisseur'=>"Text", 's.code_compta'=>"Text", 's.code_compta_fournisseur'=>"Text", 's.address'=>"Text", 's.zip'=>"Text", |
|
293 | + 's.town'=>"Text", 'c.label'=>"List:c_country:label:label", 'c.code'=>"Text", 's.phone'=>"Text", 's.fax'=>"Text", 's.url'=>"Text", 's.email'=>"Text", |
|
294 | + 's.default_lang'=>"Text", 's.siret'=>"Text", 's.siren'=>"Text", 's.ape'=>"Text", 's.idprof4'=>"Text", 's.idprof5'=>"Text", 's.idprof6'=>"Text", |
|
295 | + 's.tva_intra'=>"Text", 's.capital'=>"Numeric", 's.note_private'=>"Text", 's.note_public'=>"Text", 's.canvas'=>"Text", 't.libelle'=>"Text", |
|
296 | + 'ce.code'=>"List:c_effectif:libelle:code", "cfj.libelle"=>"Text", 's.fk_prospectlevel'=>'List:c_prospectlevel:label:code', |
|
297 | + 'st.code'=>'List:c_stcomm:libelle:code', 'd.nom'=>'Text', 'u.login'=>'Text', 'u.firstname'=>'Text', 'u.lastname'=>'Text', 'payterm.libelle'=>'Text', |
|
298 | + 'paymode.libelle'=>'Text', 's.entity'=>'Numeric' |
|
299 | 299 | ); |
300 | 300 | |
301 | - $this->export_entities_array[$r]=array('u.login'=>'user','u.firstname'=>'user','u.lastname'=>'user'); // We define here only fields that use another picto |
|
302 | - $this->export_examplevalues_array[$r]=array('s.client'=>'0 (no customer no prospect)/1 (customer)/2 (prospect)/3 (customer and prospect)','s.fournisseur'=>'0 (not a supplier) or 1 (supplier)'); |
|
303 | - $this->export_sql_start[$r]='SELECT DISTINCT '; |
|
304 | - $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'societe as s'; |
|
305 | - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'societe_extrafields as extra ON s.rowid = extra.fk_object'; |
|
306 | - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_typent as t ON s.fk_typent = t.id'; |
|
307 | - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as c ON s.fk_pays = c.rowid'; |
|
308 | - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_effectif as ce ON s.fk_effectif = ce.id'; |
|
309 | - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_forme_juridique as cfj ON s.fk_forme_juridique = cfj.code'; |
|
310 | - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_departements as d ON s.fk_departement = d.rowid'; |
|
311 | - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_stcomm as st ON s.fk_stcomm = st.id'; |
|
312 | - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid LEFT JOIN '.MAIN_DB_PREFIX.'user as u ON sc.fk_user = u.rowid'; |
|
313 | - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_payment_term as payterm ON s.cond_reglement = payterm.rowid'; |
|
314 | - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as paymode ON s.mode_reglement = paymode.id'; |
|
315 | - $this->export_sql_end[$r] .=' WHERE s.entity IN ('.getEntity('societe').')'; |
|
301 | + $this->export_entities_array[$r] = array('u.login'=>'user', 'u.firstname'=>'user', 'u.lastname'=>'user'); // We define here only fields that use another picto |
|
302 | + $this->export_examplevalues_array[$r] = array('s.client'=>'0 (no customer no prospect)/1 (customer)/2 (prospect)/3 (customer and prospect)', 's.fournisseur'=>'0 (not a supplier) or 1 (supplier)'); |
|
303 | + $this->export_sql_start[$r] = 'SELECT DISTINCT '; |
|
304 | + $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'societe as s'; |
|
305 | + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe_extrafields as extra ON s.rowid = extra.fk_object'; |
|
306 | + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_typent as t ON s.fk_typent = t.id'; |
|
307 | + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as c ON s.fk_pays = c.rowid'; |
|
308 | + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_effectif as ce ON s.fk_effectif = ce.id'; |
|
309 | + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_forme_juridique as cfj ON s.fk_forme_juridique = cfj.code'; |
|
310 | + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_departements as d ON s.fk_departement = d.rowid'; |
|
311 | + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_stcomm as st ON s.fk_stcomm = st.id'; |
|
312 | + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid LEFT JOIN '.MAIN_DB_PREFIX.'user as u ON sc.fk_user = u.rowid'; |
|
313 | + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_payment_term as payterm ON s.cond_reglement = payterm.rowid'; |
|
314 | + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as paymode ON s.mode_reglement = paymode.id'; |
|
315 | + $this->export_sql_end[$r] .= ' WHERE s.entity IN ('.getEntity('societe').')'; |
|
316 | 316 | if (is_object($user) && empty($user->rights->societe->client->voir)) { |
317 | - $this->export_sql_end[$r] .=' AND (sc.fk_user = '.$user->id.' '; |
|
318 | - if (! empty($conf->global->SOCIETE_EXPORT_SUBORDINATES_CHILDS)) { |
|
317 | + $this->export_sql_end[$r] .= ' AND (sc.fk_user = '.$user->id.' '; |
|
318 | + if (!empty($conf->global->SOCIETE_EXPORT_SUBORDINATES_CHILDS)) { |
|
319 | 319 | $subordinatesids = $user->getAllChildIds(); |
320 | - $this->export_sql_end[$r] .=count($subordinatesids)>0 ? ' OR (sc.fk_user IN ('.implode(',',$subordinatesids).')' : ''; |
|
320 | + $this->export_sql_end[$r] .= count($subordinatesids) > 0 ? ' OR (sc.fk_user IN ('.implode(',', $subordinatesids).')' : ''; |
|
321 | 321 | } |
322 | - $this->export_sql_end[$r] .=')'; |
|
322 | + $this->export_sql_end[$r] .= ')'; |
|
323 | 323 | } |
324 | 324 | |
325 | 325 | // Export list of contacts and attributes |
326 | 326 | $r++; |
327 | - $this->export_code[$r]=$this->rights_class.'_'.$r; |
|
328 | - $this->export_label[$r]='ExportDataset_company_2'; |
|
329 | - $this->export_icon[$r]='contact'; |
|
330 | - $this->export_permission[$r]=array(array("societe","contact","export")); |
|
331 | - $this->export_fields_array[$r]=array( |
|
332 | - 'c.rowid'=>"IdContact",'c.civility'=>"CivilityCode",'c.lastname'=>'Lastname','c.firstname'=>'Firstname','c.poste'=>'PostOrFunction', |
|
333 | - 'c.datec'=>"DateCreation",'c.tms'=>"DateLastModification",'c.priv'=>"ContactPrivate",'c.address'=>"Address",'c.zip'=>"Zip",'c.town'=>"Town", |
|
334 | - 'd.nom'=>'State','co.label'=>"Country",'co.code'=>"CountryCode",'c.phone'=>"Phone",'c.fax'=>"Fax",'c.phone_mobile'=>"Mobile",'c.email'=>"EMail", |
|
335 | - 's.rowid'=>"IdCompany",'s.nom'=>"CompanyName",'s.status'=>"Status",'s.code_client'=>"CustomerCode",'s.code_fournisseur'=>"SupplierCode", |
|
336 | - 's.client'=>'Customer','s.fournisseur'=>'Supplier' |
|
327 | + $this->export_code[$r] = $this->rights_class.'_'.$r; |
|
328 | + $this->export_label[$r] = 'ExportDataset_company_2'; |
|
329 | + $this->export_icon[$r] = 'contact'; |
|
330 | + $this->export_permission[$r] = array(array("societe", "contact", "export")); |
|
331 | + $this->export_fields_array[$r] = array( |
|
332 | + 'c.rowid'=>"IdContact", 'c.civility'=>"CivilityCode", 'c.lastname'=>'Lastname', 'c.firstname'=>'Firstname', 'c.poste'=>'PostOrFunction', |
|
333 | + 'c.datec'=>"DateCreation", 'c.tms'=>"DateLastModification", 'c.priv'=>"ContactPrivate", 'c.address'=>"Address", 'c.zip'=>"Zip", 'c.town'=>"Town", |
|
334 | + 'd.nom'=>'State', 'co.label'=>"Country", 'co.code'=>"CountryCode", 'c.phone'=>"Phone", 'c.fax'=>"Fax", 'c.phone_mobile'=>"Mobile", 'c.email'=>"EMail", |
|
335 | + 's.rowid'=>"IdCompany", 's.nom'=>"CompanyName", 's.status'=>"Status", 's.code_client'=>"CustomerCode", 's.code_fournisseur'=>"SupplierCode", |
|
336 | + 's.client'=>'Customer', 's.fournisseur'=>'Supplier' |
|
337 | 337 | ); |
338 | - $this->export_examplevalues_array[$r]=array('s.client'=>'0 (no customer no prospect)/1 (customer)/2 (prospect)/3 (customer and prospect)','s.fournisseur'=>'0 (not a supplier) or 1 (supplier)'); |
|
339 | - $this->export_TypeFields_array[$r]=array( |
|
340 | - 'c.civility'=>"List:c_civility:label:code",'c.lastname'=>'Text','c.firstname'=>'Text','c.poste'=>'Text','c.datec'=>"Date",'c.priv'=>"Boolean", |
|
341 | - 'c.address'=>"Text",'c.zip'=>"Text",'c.town'=>"Text",'d.nom'=>'Text','co.label'=>"List:c_country:label:rowid",'co.code'=>"Text",'c.phone'=>"Text", |
|
342 | - 'c.fax'=>"Text",'c.email'=>"Text",'s.rowid'=>"List:societe:nom",'s.nom'=>"Text",'s.status'=>"Status",'s.code_client'=>"Text",'s.code_fournisseur'=>"Text", |
|
343 | - 's.client'=>"Text",'s.fournisseur'=>"Text" |
|
338 | + $this->export_examplevalues_array[$r] = array('s.client'=>'0 (no customer no prospect)/1 (customer)/2 (prospect)/3 (customer and prospect)', 's.fournisseur'=>'0 (not a supplier) or 1 (supplier)'); |
|
339 | + $this->export_TypeFields_array[$r] = array( |
|
340 | + 'c.civility'=>"List:c_civility:label:code", 'c.lastname'=>'Text', 'c.firstname'=>'Text', 'c.poste'=>'Text', 'c.datec'=>"Date", 'c.priv'=>"Boolean", |
|
341 | + 'c.address'=>"Text", 'c.zip'=>"Text", 'c.town'=>"Text", 'd.nom'=>'Text', 'co.label'=>"List:c_country:label:rowid", 'co.code'=>"Text", 'c.phone'=>"Text", |
|
342 | + 'c.fax'=>"Text", 'c.email'=>"Text", 's.rowid'=>"List:societe:nom", 's.nom'=>"Text", 's.status'=>"Status", 's.code_client'=>"Text", 's.code_fournisseur'=>"Text", |
|
343 | + 's.client'=>"Text", 's.fournisseur'=>"Text" |
|
344 | 344 | ); |
345 | - $this->export_entities_array[$r]=array( |
|
346 | - 's.rowid'=>"company",'s.nom'=>"company", 's.status'=>'company', 's.code_client'=>"company",'s.code_fournisseur'=>"company", 's.client'=>"company", |
|
345 | + $this->export_entities_array[$r] = array( |
|
346 | + 's.rowid'=>"company", 's.nom'=>"company", 's.status'=>'company', 's.code_client'=>"company", 's.code_fournisseur'=>"company", 's.client'=>"company", |
|
347 | 347 | 's.fournisseur'=>"company" |
348 | - ); // We define here only fields that use another picto |
|
348 | + ); // We define here only fields that use another picto |
|
349 | 349 | if (empty($conf->fournisseur->enabled)) |
350 | 350 | { |
351 | 351 | unset($this->export_fields_array[$r]['s.code_fournisseur']); |
352 | 352 | unset($this->export_entities_array[$r]['s.code_fournisseur']); |
353 | 353 | } |
354 | - $keyforselect='socpeople'; $keyforelement='contact'; $keyforaliasextra='extra'; |
|
354 | + $keyforselect = 'socpeople'; $keyforelement = 'contact'; $keyforaliasextra = 'extra'; |
|
355 | 355 | include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; |
356 | - $keyforselect='societe'; $keyforelement='company'; $keyforaliasextra='extrasoc'; |
|
356 | + $keyforselect = 'societe'; $keyforelement = 'company'; $keyforaliasextra = 'extrasoc'; |
|
357 | 357 | include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; |
358 | - $this->export_sql_start[$r]='SELECT DISTINCT '; |
|
359 | - $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'socpeople as c'; |
|
360 | - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'societe as s ON c.fk_soc = s.rowid'; |
|
361 | - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'societe_extrafields as extrasoc ON s.rowid = extrasoc.fk_object'; |
|
362 | - if (is_object($user) && 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'; |
|
363 | - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_departements as d ON c.fk_departement = d.rowid'; |
|
364 | - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as co ON c.fk_pays = co.rowid'; |
|
365 | - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'socpeople_extrafields as extra ON extra.fk_object = c.rowid'; |
|
366 | - $this->export_sql_end[$r] .=' WHERE c.entity IN ('.getEntity('socpeople').')'; |
|
358 | + $this->export_sql_start[$r] = 'SELECT DISTINCT '; |
|
359 | + $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'socpeople as c'; |
|
360 | + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe as s ON c.fk_soc = s.rowid'; |
|
361 | + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe_extrafields as extrasoc ON s.rowid = extrasoc.fk_object'; |
|
362 | + if (is_object($user) && 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'; |
|
363 | + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_departements as d ON c.fk_departement = d.rowid'; |
|
364 | + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as co ON c.fk_pays = co.rowid'; |
|
365 | + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'socpeople_extrafields as extra ON extra.fk_object = c.rowid'; |
|
366 | + $this->export_sql_end[$r] .= ' WHERE c.entity IN ('.getEntity('socpeople').')'; |
|
367 | 367 | if (is_object($user) && empty($user->rights->societe->client->voir)) { |
368 | - $this->export_sql_end[$r] .=' AND (sc.fk_user = '.$user->id.' '; |
|
369 | - if (! empty($conf->global->SOCIETE_EXPORT_SUBORDINATES_CHILDS)) { |
|
368 | + $this->export_sql_end[$r] .= ' AND (sc.fk_user = '.$user->id.' '; |
|
369 | + if (!empty($conf->global->SOCIETE_EXPORT_SUBORDINATES_CHILDS)) { |
|
370 | 370 | $subordinatesids = $user->getAllChildIds(); |
371 | - $this->export_sql_end[$r] .=count($subordinatesids)>0 ? ' OR (sc.fk_user IN ('.implode(',',$subordinatesids).')' : ''; |
|
371 | + $this->export_sql_end[$r] .= count($subordinatesids) > 0 ? ' OR (sc.fk_user IN ('.implode(',', $subordinatesids).')' : ''; |
|
372 | 372 | } |
373 | - $this->export_sql_end[$r] .=')'; |
|
373 | + $this->export_sql_end[$r] .= ')'; |
|
374 | 374 | } |
375 | 375 | |
376 | 376 | |
377 | 377 | // Imports |
378 | 378 | //-------- |
379 | - $r=0; |
|
379 | + $r = 0; |
|
380 | 380 | |
381 | 381 | // Import list of third parties and attributes |
382 | 382 | $r++; |
383 | - $this->import_code[$r]=$this->rights_class.'_'.$r; |
|
384 | - $this->import_label[$r]='ImportDataset_company_1'; |
|
385 | - $this->import_icon[$r]='company'; |
|
386 | - $this->import_entities_array[$r]=array(); // We define here only fields that use another icon that the one defined into import_icon |
|
387 | - $this->import_tables_array[$r]=array('s'=>MAIN_DB_PREFIX.'societe','extra'=>MAIN_DB_PREFIX.'societe_extrafields'); // List of tables to insert into (insert done in same order) |
|
388 | - $this->import_fields_array[$r]=array( |
|
389 | - 's.nom'=>"Name*", 's.name_alias'=>"Alias", 's.status'=>"Status",'s.client'=>"Customer*",'s.fournisseur'=>"Supplier*",'s.code_client'=>"CustomerCode",'s.code_fournisseur'=>"SupplierCode", |
|
390 | - 's.code_compta'=>"CustomerAccountancyCode",'s.code_compta_fournisseur'=>"SupplierAccountancyCode",'s.address'=>"Address",'s.zip'=>"Zip",'s.town'=>"Town", |
|
391 | - 's.fk_departement'=>"StateId",'s.fk_pays'=>"CountryCode",'s.phone'=>"Phone",'s.fax'=>"Fax",'s.url'=>"Url",'s.email'=>"Email",'s.siren'=>"ProfId1", |
|
392 | - 's.siret'=>"ProfId2",'s.ape'=>"ProfId3",'s.idprof4'=>"ProfId4",'s.idprof5'=>"ProfId5",'s.idprof6'=>"ProfId6",'s.tva_intra'=>"VATIntraShort", |
|
393 | - 's.capital'=>"Capital",'s.note_private'=>"NotePrivate",'s.note_public'=>"NotePublic",'s.canvas'=>"Canvas",'s.fk_typent'=>"ThirdPartyType",'s.fk_effectif'=>"Staff", |
|
394 | - "s.fk_forme_juridique"=>"JuridicalStatus",'s.fk_prospectlevel'=>'ProspectLevel','s.fk_stcomm'=>'ProspectStatus','s.default_lang'=>'DefaultLanguage', |
|
395 | - 's.barcode'=>'BarCode','s.datec'=>"DateCreation" |
|
383 | + $this->import_code[$r] = $this->rights_class.'_'.$r; |
|
384 | + $this->import_label[$r] = 'ImportDataset_company_1'; |
|
385 | + $this->import_icon[$r] = 'company'; |
|
386 | + $this->import_entities_array[$r] = array(); // We define here only fields that use another icon that the one defined into import_icon |
|
387 | + $this->import_tables_array[$r] = array('s'=>MAIN_DB_PREFIX.'societe', 'extra'=>MAIN_DB_PREFIX.'societe_extrafields'); // List of tables to insert into (insert done in same order) |
|
388 | + $this->import_fields_array[$r] = array( |
|
389 | + 's.nom'=>"Name*", 's.name_alias'=>"Alias", 's.status'=>"Status", 's.client'=>"Customer*", 's.fournisseur'=>"Supplier*", 's.code_client'=>"CustomerCode", 's.code_fournisseur'=>"SupplierCode", |
|
390 | + 's.code_compta'=>"CustomerAccountancyCode", 's.code_compta_fournisseur'=>"SupplierAccountancyCode", 's.address'=>"Address", 's.zip'=>"Zip", 's.town'=>"Town", |
|
391 | + 's.fk_departement'=>"StateId", 's.fk_pays'=>"CountryCode", 's.phone'=>"Phone", 's.fax'=>"Fax", 's.url'=>"Url", 's.email'=>"Email", 's.siren'=>"ProfId1", |
|
392 | + 's.siret'=>"ProfId2", 's.ape'=>"ProfId3", 's.idprof4'=>"ProfId4", 's.idprof5'=>"ProfId5", 's.idprof6'=>"ProfId6", 's.tva_intra'=>"VATIntraShort", |
|
393 | + 's.capital'=>"Capital", 's.note_private'=>"NotePrivate", 's.note_public'=>"NotePublic", 's.canvas'=>"Canvas", 's.fk_typent'=>"ThirdPartyType", 's.fk_effectif'=>"Staff", |
|
394 | + "s.fk_forme_juridique"=>"JuridicalStatus", 's.fk_prospectlevel'=>'ProspectLevel', 's.fk_stcomm'=>'ProspectStatus', 's.default_lang'=>'DefaultLanguage', |
|
395 | + 's.barcode'=>'BarCode', 's.datec'=>"DateCreation" |
|
396 | 396 | ); |
397 | 397 | // Add extra fields |
398 | - $sql="SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'societe' AND entity IN (0,".$conf->entity.")"; |
|
399 | - $resql=$this->db->query($sql); |
|
398 | + $sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'societe' AND entity IN (0,".$conf->entity.")"; |
|
399 | + $resql = $this->db->query($sql); |
|
400 | 400 | if ($resql) // This can fail when class is used on old database (during migration for example) |
401 | 401 | { |
402 | - while ($obj=$this->db->fetch_object($resql)) |
|
402 | + while ($obj = $this->db->fetch_object($resql)) |
|
403 | 403 | { |
404 | - $fieldname='extra.'.$obj->name; |
|
405 | - $fieldlabel=ucfirst($obj->label); |
|
406 | - $this->import_fields_array[$r][$fieldname]=$fieldlabel.($obj->fieldrequired?'*':''); |
|
404 | + $fieldname = 'extra.'.$obj->name; |
|
405 | + $fieldlabel = ucfirst($obj->label); |
|
406 | + $this->import_fields_array[$r][$fieldname] = $fieldlabel.($obj->fieldrequired ? '*' : ''); |
|
407 | 407 | } |
408 | 408 | } |
409 | 409 | // End add extra fields |
410 | - $this->import_fieldshidden_array[$r]=array('s.fk_user_creat'=>'user->id','extra.fk_object'=>'lastrowid-'.MAIN_DB_PREFIX.'societe'); // aliastable.field => ('user->id' or 'lastrowid-'.tableparent) |
|
411 | - $this->import_convertvalue_array[$r]=array( |
|
412 | - 's.fk_typent'=>array('rule'=>'fetchidfromcodeorlabel','classfile'=>'/core/class/ctypent.class.php','class'=>'Ctypent','method'=>'fetch','dict'=>'DictionaryCompanyType'), |
|
413 | - 's.fk_departement'=>array('rule'=>'fetchidfromcodeid','classfile'=>'/core/class/cstate.class.php','class'=>'Cstate','method'=>'fetch','dict'=>'DictionaryState'), |
|
414 | - 's.fk_pays'=>array('rule'=>'fetchidfromcodeid','classfile'=>'/core/class/ccountry.class.php','class'=>'Ccountry','method'=>'fetch','dict'=>'DictionaryCountry'), |
|
410 | + $this->import_fieldshidden_array[$r] = array('s.fk_user_creat'=>'user->id', 'extra.fk_object'=>'lastrowid-'.MAIN_DB_PREFIX.'societe'); // aliastable.field => ('user->id' or 'lastrowid-'.tableparent) |
|
411 | + $this->import_convertvalue_array[$r] = array( |
|
412 | + 's.fk_typent'=>array('rule'=>'fetchidfromcodeorlabel', 'classfile'=>'/core/class/ctypent.class.php', 'class'=>'Ctypent', 'method'=>'fetch', 'dict'=>'DictionaryCompanyType'), |
|
413 | + 's.fk_departement'=>array('rule'=>'fetchidfromcodeid', 'classfile'=>'/core/class/cstate.class.php', 'class'=>'Cstate', 'method'=>'fetch', 'dict'=>'DictionaryState'), |
|
414 | + 's.fk_pays'=>array('rule'=>'fetchidfromcodeid', 'classfile'=>'/core/class/ccountry.class.php', 'class'=>'Ccountry', 'method'=>'fetch', 'dict'=>'DictionaryCountry'), |
|
415 | 415 | 's.fk_stcomm'=>array('rule'=>'zeroifnull'), |
416 | 416 | 's.code_client'=>array('rule'=>'getcustomercodeifauto'), |
417 | 417 | 's.code_fournisseur'=>array('rule'=>'getsuppliercodeifauto'), |
@@ -420,91 +420,91 @@ discard block |
||
420 | 420 | 's.capital'=>array('rule'=>'numeric') |
421 | 421 | ); |
422 | 422 | //$this->import_convertvalue_array[$r]=array('s.fk_soc'=>array('rule'=>'lastrowid',table='t'); |
423 | - $this->import_regex_array[$r]=array('s.status'=>'^[0|1]','s.client'=>'^[0|1|2|3]','s.fournisseur'=>'^[0|1]','s.fk_typent'=>'id@'.MAIN_DB_PREFIX.'c_typent','s.datec'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]( [0-9][0-9]:[0-9][0-9]:[0-9][0-9])?$'); |
|
424 | - $this->import_examplevalues_array[$r]=array( |
|
425 | - 's.nom'=>"MyBigCompany", 's.name_alias'=>"MyBigAlias", 's.status'=>"0 (closed) or 1 (active)",'s.client'=>'0 (no customer no prospect)/1 (customer)/2 (prospect)/3 (customer and prospect)', |
|
426 | - 's.fournisseur'=>'0 or 1','s.datec'=>dol_print_date(dol_now(),'%Y-%m-%d'),'s.code_client'=>'CU01-0001 or empty or "auto"','s.code_fournisseur'=>'SU01-0001 or empty or "auto"', |
|
427 | - 's.address'=>"61 jump street",'s.zip'=>"123456",'s.town'=>"Big town",'s.fk_pays'=>'US, FR, DE...','s.phone'=>"0101010101",'s.fax'=>"0101010102", |
|
428 | - 's.url'=>"http://mycompany.com",'s.email'=>"[email protected]",'s.siret'=>"",'s.siren'=>"",'s.ape'=>"",'s.idprof4'=>"",'s.idprof5'=>"",'s.idprof6'=>"", |
|
429 | - 's.tva_intra'=>"FR0123456789",'s.capital'=>"10000",'s.note_private'=>"This is an example of private note for record",'s.note_public'=>"This is an example of public note for record", |
|
430 | - 's.fk_typent'=>"2",'s.fk_effectif'=>"3","s.fk_forme_juridique"=>"1",'s.fk_prospectlevel'=>'PL_MEDIUM','s.fk_stcomm'=>'0','s.default_lang'=>'en_US','s.barcode'=>'123456789', |
|
423 | + $this->import_regex_array[$r] = array('s.status'=>'^[0|1]', 's.client'=>'^[0|1|2|3]', 's.fournisseur'=>'^[0|1]', 's.fk_typent'=>'id@'.MAIN_DB_PREFIX.'c_typent', 's.datec'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]( [0-9][0-9]:[0-9][0-9]:[0-9][0-9])?$'); |
|
424 | + $this->import_examplevalues_array[$r] = array( |
|
425 | + 's.nom'=>"MyBigCompany", 's.name_alias'=>"MyBigAlias", 's.status'=>"0 (closed) or 1 (active)", 's.client'=>'0 (no customer no prospect)/1 (customer)/2 (prospect)/3 (customer and prospect)', |
|
426 | + 's.fournisseur'=>'0 or 1', 's.datec'=>dol_print_date(dol_now(), '%Y-%m-%d'), 's.code_client'=>'CU01-0001 or empty or "auto"', 's.code_fournisseur'=>'SU01-0001 or empty or "auto"', |
|
427 | + 's.address'=>"61 jump street", 's.zip'=>"123456", 's.town'=>"Big town", 's.fk_pays'=>'US, FR, DE...', 's.phone'=>"0101010101", 's.fax'=>"0101010102", |
|
428 | + 's.url'=>"http://mycompany.com", 's.email'=>"[email protected]", 's.siret'=>"", 's.siren'=>"", 's.ape'=>"", 's.idprof4'=>"", 's.idprof5'=>"", 's.idprof6'=>"", |
|
429 | + 's.tva_intra'=>"FR0123456789", 's.capital'=>"10000", 's.note_private'=>"This is an example of private note for record", 's.note_public'=>"This is an example of public note for record", |
|
430 | + 's.fk_typent'=>"2", 's.fk_effectif'=>"3", "s.fk_forme_juridique"=>"1", 's.fk_prospectlevel'=>'PL_MEDIUM', 's.fk_stcomm'=>'0', 's.default_lang'=>'en_US', 's.barcode'=>'123456789', |
|
431 | 431 | 's.datec'=>"2015-01-01 or 2015-01-01 12:30:00" |
432 | 432 | ); |
433 | - $this->import_updatekeys_array[$r]=array('s.nom'=>'Name','s.code_client'=>'CustomerCode','s.code_fournisseur'=>'SupplierCode','s.code_compta'=>'CustomerAccountancyCode','s.code_compta_fournisseur'=>'SupplierAccountancyCode'); |
|
433 | + $this->import_updatekeys_array[$r] = array('s.nom'=>'Name', 's.code_client'=>'CustomerCode', 's.code_fournisseur'=>'SupplierCode', 's.code_compta'=>'CustomerAccountancyCode', 's.code_compta_fournisseur'=>'SupplierAccountancyCode'); |
|
434 | 434 | |
435 | 435 | // Import list of contact and attributes |
436 | 436 | $r++; |
437 | - $this->import_code[$r]=$this->rights_class.'_'.$r; |
|
438 | - $this->import_label[$r]='ImportDataset_company_2'; |
|
439 | - $this->import_icon[$r]='contact'; |
|
440 | - $this->import_entities_array[$r]=array('s.fk_soc'=>'company'); // We define here only fields that use another icon that the one defined into import_icon |
|
441 | - $this->import_tables_array[$r]=array('s'=>MAIN_DB_PREFIX.'socpeople','extra'=>MAIN_DB_PREFIX.'socpeople_extrafields'); // List of tables to insert into (insert done in same order) |
|
442 | - $this->import_fields_array[$r]=array( |
|
443 | - 's.fk_soc'=>'ThirdPartyName','s.civility'=>'UserTitle','s.lastname'=>"Lastname*",'s.firstname'=>"Firstname",'s.address'=>"Address",'s.zip'=>"Zip", |
|
444 | - 's.town'=>"Town",'s.fk_departement'=>"StateId",'s.fk_pays'=>"CountryCode",'s.birthday'=>"BirthdayDate",'s.poste'=>"Role",'s.phone'=>"Phone",'s.phone_perso'=>"PhonePerso", |
|
445 | - 's.phone_mobile'=>"PhoneMobile",'s.fax'=>"Fax",'s.email'=>"Email",'s.note_private'=>"Note",'s.note_public'=>"Note",'s.datec'=>"DateCreation" |
|
437 | + $this->import_code[$r] = $this->rights_class.'_'.$r; |
|
438 | + $this->import_label[$r] = 'ImportDataset_company_2'; |
|
439 | + $this->import_icon[$r] = 'contact'; |
|
440 | + $this->import_entities_array[$r] = array('s.fk_soc'=>'company'); // We define here only fields that use another icon that the one defined into import_icon |
|
441 | + $this->import_tables_array[$r] = array('s'=>MAIN_DB_PREFIX.'socpeople', 'extra'=>MAIN_DB_PREFIX.'socpeople_extrafields'); // List of tables to insert into (insert done in same order) |
|
442 | + $this->import_fields_array[$r] = array( |
|
443 | + 's.fk_soc'=>'ThirdPartyName', 's.civility'=>'UserTitle', 's.lastname'=>"Lastname*", 's.firstname'=>"Firstname", 's.address'=>"Address", 's.zip'=>"Zip", |
|
444 | + 's.town'=>"Town", 's.fk_departement'=>"StateId", 's.fk_pays'=>"CountryCode", 's.birthday'=>"BirthdayDate", 's.poste'=>"Role", 's.phone'=>"Phone", 's.phone_perso'=>"PhonePerso", |
|
445 | + 's.phone_mobile'=>"PhoneMobile", 's.fax'=>"Fax", 's.email'=>"Email", 's.note_private'=>"Note", 's.note_public'=>"Note", 's.datec'=>"DateCreation" |
|
446 | 446 | ); |
447 | 447 | // Add extra fields |
448 | - $sql="SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'socpeople' AND entity IN (0,".$conf->entity.")"; |
|
449 | - $resql=$this->db->query($sql); |
|
448 | + $sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'socpeople' AND entity IN (0,".$conf->entity.")"; |
|
449 | + $resql = $this->db->query($sql); |
|
450 | 450 | if ($resql) // This can fail when class is used on old database (during migration for example) |
451 | 451 | { |
452 | - while ($obj=$this->db->fetch_object($resql)) |
|
452 | + while ($obj = $this->db->fetch_object($resql)) |
|
453 | 453 | { |
454 | - $fieldname='extra.'.$obj->name; |
|
455 | - $fieldlabel=ucfirst($obj->label); |
|
456 | - $this->import_fields_array[$r][$fieldname]=$fieldlabel.($obj->fieldrequired?'*':''); |
|
454 | + $fieldname = 'extra.'.$obj->name; |
|
455 | + $fieldlabel = ucfirst($obj->label); |
|
456 | + $this->import_fields_array[$r][$fieldname] = $fieldlabel.($obj->fieldrequired ? '*' : ''); |
|
457 | 457 | } |
458 | 458 | } |
459 | 459 | // End add extra fields |
460 | - $this->import_fieldshidden_array[$r]=array('s.fk_user_creat'=>'user->id','extra.fk_object'=>'lastrowid-'.MAIN_DB_PREFIX.'socpeople'); // aliastable.field => ('user->id' or 'lastrowid-'.tableparent) |
|
461 | - $this->import_convertvalue_array[$r]=array( |
|
462 | - 's.fk_soc'=>array('rule'=>'fetchidfromref','file'=>'/societe/class/societe.class.php','class'=>'Societe','method'=>'fetch','element'=>'ThirdParty'), |
|
463 | - 's.fk_departement'=>array('rule'=>'fetchidfromcodeid','classfile'=>'/core/class/cstate.class.php','class'=>'Cstate','method'=>'fetch','dict'=>'DictionaryState'), |
|
464 | - 's.fk_pays'=>array('rule'=>'fetchidfromcodeid','classfile'=>'/core/class/ccountry.class.php','class'=>'Ccountry','method'=>'fetch','dict'=>'DictionaryCountry'), |
|
460 | + $this->import_fieldshidden_array[$r] = array('s.fk_user_creat'=>'user->id', 'extra.fk_object'=>'lastrowid-'.MAIN_DB_PREFIX.'socpeople'); // aliastable.field => ('user->id' or 'lastrowid-'.tableparent) |
|
461 | + $this->import_convertvalue_array[$r] = array( |
|
462 | + 's.fk_soc'=>array('rule'=>'fetchidfromref', 'file'=>'/societe/class/societe.class.php', 'class'=>'Societe', 'method'=>'fetch', 'element'=>'ThirdParty'), |
|
463 | + 's.fk_departement'=>array('rule'=>'fetchidfromcodeid', 'classfile'=>'/core/class/cstate.class.php', 'class'=>'Cstate', 'method'=>'fetch', 'dict'=>'DictionaryState'), |
|
464 | + 's.fk_pays'=>array('rule'=>'fetchidfromcodeid', 'classfile'=>'/core/class/ccountry.class.php', 'class'=>'Ccountry', 'method'=>'fetch', 'dict'=>'DictionaryCountry'), |
|
465 | 465 | ); |
466 | 466 | //$this->import_convertvalue_array[$r]=array('s.fk_soc'=>array('rule'=>'lastrowid',table='t'); |
467 | - $this->import_regex_array[$r]=array('s.birthday'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$','s.datec'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]( [0-9][0-9]:[0-9][0-9]:[0-9][0-9])?$'); |
|
468 | - $this->import_examplevalues_array[$r]=array( |
|
469 | - 's.fk_soc'=>'MyBigCompany','s.civility'=>"MR",'s.lastname'=>"Smith",'s.firstname'=>'John','s.address'=>'61 jump street','s.zip'=>'75000', |
|
470 | - 's.town'=>'Bigtown','s.fk_pays'=>'US, FR, DE...','s.datec'=>'1972-10-10','s.poste'=>"Director",'s.phone'=>"5551122",'s.phone_perso'=>"5551133", |
|
471 | - 's.phone_mobile'=>"5551144",'s.fax'=>"5551155",'s.email'=>"[email protected]",'s.note_private'=>"My private note",'s.note_public'=>"My public note" |
|
467 | + $this->import_regex_array[$r] = array('s.birthday'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$', 's.datec'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]( [0-9][0-9]:[0-9][0-9]:[0-9][0-9])?$'); |
|
468 | + $this->import_examplevalues_array[$r] = array( |
|
469 | + 's.fk_soc'=>'MyBigCompany', 's.civility'=>"MR", 's.lastname'=>"Smith", 's.firstname'=>'John', 's.address'=>'61 jump street', 's.zip'=>'75000', |
|
470 | + 's.town'=>'Bigtown', 's.fk_pays'=>'US, FR, DE...', 's.datec'=>'1972-10-10', 's.poste'=>"Director", 's.phone'=>"5551122", 's.phone_perso'=>"5551133", |
|
471 | + 's.phone_mobile'=>"5551144", 's.fax'=>"5551155", 's.email'=>"[email protected]", 's.note_private'=>"My private note", 's.note_public'=>"My public note" |
|
472 | 472 | ); |
473 | 473 | |
474 | 474 | // Import Bank Accounts |
475 | 475 | $r++; |
476 | - $this->import_code[$r]=$this->rights_class.'_'.$r; |
|
477 | - $this->import_label[$r]="ImportDataset_company_3"; // Translation key |
|
478 | - $this->import_icon[$r]='company'; |
|
479 | - $this->import_entities_array[$r]=array(); // We define here only fields that use another icon that the one defined into import_icon |
|
480 | - $this->import_tables_array[$r]=array('sr'=>MAIN_DB_PREFIX.'societe_rib'); |
|
481 | - $this->import_fields_array[$r]=array('sr.fk_soc'=>"ThirdPartyName*",'sr.bank'=>"Bank", |
|
482 | - 'sr.code_banque'=>"BankCode",'sr.code_guichet'=>"DeskCode",'sr.number'=>"BankAccountNumber*", |
|
483 | - 'sr.cle_rib'=>"BankAccountNumberKey",'sr.bic'=>"BIC",'sr.iban_prefix'=>"IBAN", 'sr.domiciliation'=>"BankAccountDomiciliation",'sr.proprio' => "BankAccountOwner", 'sr.owner_address' => "BankAccountOwnerAddress", 'sr.default_rib' => 'Default' |
|
476 | + $this->import_code[$r] = $this->rights_class.'_'.$r; |
|
477 | + $this->import_label[$r] = "ImportDataset_company_3"; // Translation key |
|
478 | + $this->import_icon[$r] = 'company'; |
|
479 | + $this->import_entities_array[$r] = array(); // We define here only fields that use another icon that the one defined into import_icon |
|
480 | + $this->import_tables_array[$r] = array('sr'=>MAIN_DB_PREFIX.'societe_rib'); |
|
481 | + $this->import_fields_array[$r] = array('sr.fk_soc'=>"ThirdPartyName*", 'sr.bank'=>"Bank", |
|
482 | + 'sr.code_banque'=>"BankCode", 'sr.code_guichet'=>"DeskCode", 'sr.number'=>"BankAccountNumber*", |
|
483 | + 'sr.cle_rib'=>"BankAccountNumberKey", 'sr.bic'=>"BIC", 'sr.iban_prefix'=>"IBAN", 'sr.domiciliation'=>"BankAccountDomiciliation", 'sr.proprio' => "BankAccountOwner", 'sr.owner_address' => "BankAccountOwnerAddress", 'sr.default_rib' => 'Default' |
|
484 | 484 | ); |
485 | 485 | |
486 | - $this->import_convertvalue_array[$r]=array( |
|
487 | - 'sr.fk_soc'=>array('rule'=>'fetchidfromref','classfile'=>'/societe/class/societe.class.php','class'=>'Societe','method'=>'fetch','element'=>'ThirdParty') |
|
486 | + $this->import_convertvalue_array[$r] = array( |
|
487 | + 'sr.fk_soc'=>array('rule'=>'fetchidfromref', 'classfile'=>'/societe/class/societe.class.php', 'class'=>'Societe', 'method'=>'fetch', 'element'=>'ThirdParty') |
|
488 | 488 | ); |
489 | - $this->import_examplevalues_array[$r]=array('sr.fk_soc'=>"MyBigCompany",'sr.bank'=>"ING", |
|
490 | - 'sr.code_banque'=>"0000", 'sr.code_guichet'=>"1111",'sr.number'=>"3333333333", |
|
491 | - 'sr.cle_rib'=>"22",'sr.bic'=>"USHINGMMXXX",'sr.iban_prefix'=>"US00 0000 1111 22 3333 3333",'sr.domiciliation'=>"PARIS",'sr.proprio' => "Name of owner", 'sr.owner_address' => "15 paris street 75000 Paris", 'sr.default_rib' => '1 or 0' |
|
489 | + $this->import_examplevalues_array[$r] = array('sr.fk_soc'=>"MyBigCompany", 'sr.bank'=>"ING", |
|
490 | + 'sr.code_banque'=>"0000", 'sr.code_guichet'=>"1111", 'sr.number'=>"3333333333", |
|
491 | + 'sr.cle_rib'=>"22", 'sr.bic'=>"USHINGMMXXX", 'sr.iban_prefix'=>"US00 0000 1111 22 3333 3333", 'sr.domiciliation'=>"PARIS", 'sr.proprio' => "Name of owner", 'sr.owner_address' => "15 paris street 75000 Paris", 'sr.default_rib' => '1 or 0' |
|
492 | 492 | ); |
493 | 493 | |
494 | 494 | // Import Company Sales representatives |
495 | 495 | $r++; |
496 | - $this->import_code[$r]=$this->rights_class.'_'.$r; |
|
497 | - $this->import_label[$r]="ImportDataset_company_4"; // Translation key |
|
498 | - $this->import_icon[$r]='company'; |
|
499 | - $this->import_entities_array[$r]=array('sr.fk_user'=>'user'); // We define here only fields that use another icon that the one defined into import_icon |
|
500 | - $this->import_tables_array[$r]=array('sr'=>MAIN_DB_PREFIX.'societe_commerciaux'); |
|
501 | - $this->import_fields_array[$r]=array('sr.fk_soc'=>"ThirdPartyName*",'sr.fk_user'=>"User*"); |
|
502 | - |
|
503 | - $this->import_convertvalue_array[$r]=array( |
|
504 | - 'sr.fk_soc'=>array('rule'=>'fetchidfromref','classfile'=>'/societe/class/societe.class.php','class'=>'Societe','method'=>'fetch','element'=>'ThirdParty'), |
|
505 | - 'sr.fk_user'=>array('rule'=>'fetchidfromref','classfile'=>'/user/class/user.class.php','class'=>'User','method'=>'fetch','element'=>'User') |
|
496 | + $this->import_code[$r] = $this->rights_class.'_'.$r; |
|
497 | + $this->import_label[$r] = "ImportDataset_company_4"; // Translation key |
|
498 | + $this->import_icon[$r] = 'company'; |
|
499 | + $this->import_entities_array[$r] = array('sr.fk_user'=>'user'); // We define here only fields that use another icon that the one defined into import_icon |
|
500 | + $this->import_tables_array[$r] = array('sr'=>MAIN_DB_PREFIX.'societe_commerciaux'); |
|
501 | + $this->import_fields_array[$r] = array('sr.fk_soc'=>"ThirdPartyName*", 'sr.fk_user'=>"User*"); |
|
502 | + |
|
503 | + $this->import_convertvalue_array[$r] = array( |
|
504 | + 'sr.fk_soc'=>array('rule'=>'fetchidfromref', 'classfile'=>'/societe/class/societe.class.php', 'class'=>'Societe', 'method'=>'fetch', 'element'=>'ThirdParty'), |
|
505 | + 'sr.fk_user'=>array('rule'=>'fetchidfromref', 'classfile'=>'/user/class/user.class.php', 'class'=>'User', 'method'=>'fetch', 'element'=>'User') |
|
506 | 506 | ); |
507 | - $this->import_examplevalues_array[$r]=array('sr.fk_soc'=>"MyBigCompany",'sr.fk_user'=>"login"); |
|
507 | + $this->import_examplevalues_array[$r] = array('sr.fk_soc'=>"MyBigCompany", 'sr.fk_user'=>"login"); |
|
508 | 508 | } |
509 | 509 | |
510 | 510 | |
@@ -516,7 +516,7 @@ discard block |
||
516 | 516 | * @param string $options Options when enabling module ('', 'noboxes') |
517 | 517 | * @return int 1 if OK, 0 if KO |
518 | 518 | */ |
519 | - function init($options='') |
|
519 | + function init($options = '') |
|
520 | 520 | { |
521 | 521 | global $conf, $langs; |
522 | 522 | |
@@ -524,25 +524,25 @@ discard block |
||
524 | 524 | //$this->remove($options); |
525 | 525 | |
526 | 526 | //ODT template |
527 | - $src=DOL_DOCUMENT_ROOT.'/install/doctemplates/thirdparties/template_thirdparty.odt'; |
|
528 | - $dirodt=DOL_DATA_ROOT.'/doctemplates/thirdparties'; |
|
529 | - $dest=$dirodt.'/template_thirdparty.odt'; |
|
527 | + $src = DOL_DOCUMENT_ROOT.'/install/doctemplates/thirdparties/template_thirdparty.odt'; |
|
528 | + $dirodt = DOL_DATA_ROOT.'/doctemplates/thirdparties'; |
|
529 | + $dest = $dirodt.'/template_thirdparty.odt'; |
|
530 | 530 | |
531 | - if (file_exists($src) && ! file_exists($dest)) |
|
531 | + if (file_exists($src) && !file_exists($dest)) |
|
532 | 532 | { |
533 | 533 | require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; |
534 | 534 | dol_mkdir($dirodt); |
535 | - $result=dol_copy($src,$dest,0,0); |
|
535 | + $result = dol_copy($src, $dest, 0, 0); |
|
536 | 536 | if ($result < 0) |
537 | 537 | { |
538 | 538 | $langs->load("errors"); |
539 | - $this->error=$langs->trans('ErrorFailToCopyFile',$src,$dest); |
|
539 | + $this->error = $langs->trans('ErrorFailToCopyFile', $src, $dest); |
|
540 | 540 | return 0; |
541 | 541 | } |
542 | 542 | } |
543 | 543 | |
544 | 544 | $sql = array(); |
545 | 545 | |
546 | - return $this->_init($sql,$options); |
|
546 | + return $this->_init($sql, $options); |
|
547 | 547 | } |
548 | 548 | } |
@@ -269,12 +269,16 @@ discard block |
||
269 | 269 | 't.libelle'=>"ThirdPartyType",'ce.code'=>"Staff","cfj.libelle"=>"JuridicalStatus",'s.fk_prospectlevel'=>'ProspectLevel', |
270 | 270 | 'st.code'=>'ProspectStatus','payterm.libelle'=>'PaymentConditions','paymode.libelle'=>'PaymentMode' |
271 | 271 | ); |
272 | - if (! empty($conf->global->SOCIETE_USEPREFIX)) $this->export_fields_array[$r]['s.prefix']='Prefix'; |
|
272 | + if (! empty($conf->global->SOCIETE_USEPREFIX)) { |
|
273 | + $this->export_fields_array[$r]['s.prefix']='Prefix'; |
|
274 | + } |
|
273 | 275 | // Add multicompany field |
274 | 276 | if (! empty($conf->global->MULTICOMPANY_ENTITY_IN_EXPORT_IF_SHARED)) |
275 | 277 | { |
276 | 278 | $nbofallowedentities=count(explode(',',getEntity('societe'))); // If project are shared, nb will be > 1 |
277 | - if (! empty($conf->multicompany->enabled) && $nbofallowedentities > 1) $this->export_fields_array[$r]+=array('s.entity'=>'Entity'); |
|
279 | + if (! empty($conf->multicompany->enabled) && $nbofallowedentities > 1) { |
|
280 | + $this->export_fields_array[$r]+=array('s.entity'=>'Entity'); |
|
281 | + } |
|
278 | 282 | } |
279 | 283 | $keyforselect='societe'; $keyforelement='company'; $keyforaliasextra='extra'; |
280 | 284 | include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; |
@@ -359,7 +363,9 @@ discard block |
||
359 | 363 | $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'socpeople as c'; |
360 | 364 | $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'societe as s ON c.fk_soc = s.rowid'; |
361 | 365 | $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'societe_extrafields as extrasoc ON s.rowid = extrasoc.fk_object'; |
362 | - if (is_object($user) && 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'; |
|
366 | + if (is_object($user) && empty($user->rights->societe->client->voir)) { |
|
367 | + $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid'; |
|
368 | + } |
|
363 | 369 | $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_departements as d ON c.fk_departement = d.rowid'; |
364 | 370 | $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as co ON c.fk_pays = co.rowid'; |
365 | 371 | $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'socpeople_extrafields as extra ON extra.fk_object = c.rowid'; |
@@ -397,11 +403,13 @@ discard block |
||
397 | 403 | // Add extra fields |
398 | 404 | $sql="SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'societe' AND entity IN (0,".$conf->entity.")"; |
399 | 405 | $resql=$this->db->query($sql); |
400 | - if ($resql) // This can fail when class is used on old database (during migration for example) |
|
406 | + if ($resql) { |
|
407 | + // This can fail when class is used on old database (during migration for example) |
|
401 | 408 | { |
402 | 409 | while ($obj=$this->db->fetch_object($resql)) |
403 | 410 | { |
404 | 411 | $fieldname='extra.'.$obj->name; |
412 | + } |
|
405 | 413 | $fieldlabel=ucfirst($obj->label); |
406 | 414 | $this->import_fields_array[$r][$fieldname]=$fieldlabel.($obj->fieldrequired?'*':''); |
407 | 415 | } |
@@ -447,11 +455,13 @@ discard block |
||
447 | 455 | // Add extra fields |
448 | 456 | $sql="SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'socpeople' AND entity IN (0,".$conf->entity.")"; |
449 | 457 | $resql=$this->db->query($sql); |
450 | - if ($resql) // This can fail when class is used on old database (during migration for example) |
|
458 | + if ($resql) { |
|
459 | + // This can fail when class is used on old database (during migration for example) |
|
451 | 460 | { |
452 | 461 | while ($obj=$this->db->fetch_object($resql)) |
453 | 462 | { |
454 | 463 | $fieldname='extra.'.$obj->name; |
464 | + } |
|
455 | 465 | $fieldlabel=ucfirst($obj->label); |
456 | 466 | $this->import_fields_array[$r][$fieldname]=$fieldlabel.($obj->fieldrequired?'*':''); |
457 | 467 | } |
@@ -33,73 +33,73 @@ |
||
33 | 33 | class modBookmark extends DolibarrModules |
34 | 34 | { |
35 | 35 | |
36 | - /** |
|
37 | - * Constructor. Define names, constants, directories, boxes, permissions |
|
38 | - * |
|
39 | - * @param DoliDB $db Database handler |
|
40 | - */ |
|
41 | - function __construct($db) |
|
42 | - { |
|
43 | - $this->db = $db; |
|
44 | - $this->numero = 330; |
|
45 | - |
|
46 | - $this->family = "technic"; |
|
47 | - // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) |
|
48 | - $this->name = preg_replace('/^mod/i','',get_class($this)); |
|
49 | - $this->description = "Gestion des Bookmarks"; |
|
50 | - |
|
51 | - // Possible values for version are: 'development', 'experimental', 'dolibarr' or version |
|
52 | - $this->version = 'dolibarr'; |
|
53 | - |
|
54 | - $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); |
|
55 | - $this->picto='bookmark'; |
|
56 | - |
|
57 | - // Data directories to create when module is enabled |
|
58 | - $this->dirs = array(); |
|
59 | - |
|
60 | - // Dependancies |
|
61 | - $this->depends = array(); |
|
62 | - $this->requiredby = array(); |
|
63 | - $this->langfiles = array("bookmarks"); |
|
64 | - |
|
65 | - // Config pages |
|
66 | - $this->config_page_url = array('bookmark.php@bookmarks'); |
|
67 | - |
|
68 | - // Constants |
|
69 | - $this->const = array(); |
|
70 | - |
|
71 | - // Boxes |
|
72 | - $this->boxes = array(0=>array('file'=>'box_bookmarks.php','enabledbydefaulton'=>'Home')); |
|
73 | - |
|
74 | - // Permissions |
|
75 | - $this->rights = array(); |
|
76 | - $this->rights_class = 'bookmark'; |
|
77 | - $r=0; |
|
78 | - |
|
79 | - $r++; |
|
80 | - $this->rights[$r][0] = 331; // id de la permission |
|
81 | - $this->rights[$r][1] = 'Lire les bookmarks'; // libelle de la permission |
|
82 | - $this->rights[$r][2] = 'r'; // type de la permission (deprecie a ce jour) |
|
83 | - $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut |
|
84 | - $this->rights[$r][4] = 'lire'; |
|
85 | - |
|
86 | - $r++; |
|
87 | - $this->rights[$r][0] = 332; // id de la permission |
|
88 | - $this->rights[$r][1] = 'Creer/modifier les bookmarks'; // libelle de la permission |
|
89 | - $this->rights[$r][2] = 'r'; // type de la permission (deprecie a ce jour) |
|
90 | - $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut |
|
91 | - $this->rights[$r][4] = 'creer'; |
|
92 | - |
|
93 | - $r++; |
|
94 | - $this->rights[$r][0] = 333; // id de la permission |
|
95 | - $this->rights[$r][1] = 'Supprimer les bookmarks'; // libelle de la permission |
|
96 | - $this->rights[$r][2] = 'r'; // type de la permission (d�pr�ci� � ce jour) |
|
97 | - $this->rights[$r][3] = 0; // La permission est-elle une permission par d�faut |
|
98 | - $this->rights[$r][4] = 'supprimer'; |
|
99 | - |
|
100 | - |
|
101 | - // Menus |
|
102 | - //------- |
|
103 | - $this->menu = 1; // This module add menu entries. They are coded into menu manager. |
|
104 | - } |
|
36 | + /** |
|
37 | + * Constructor. Define names, constants, directories, boxes, permissions |
|
38 | + * |
|
39 | + * @param DoliDB $db Database handler |
|
40 | + */ |
|
41 | + function __construct($db) |
|
42 | + { |
|
43 | + $this->db = $db; |
|
44 | + $this->numero = 330; |
|
45 | + |
|
46 | + $this->family = "technic"; |
|
47 | + // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) |
|
48 | + $this->name = preg_replace('/^mod/i','',get_class($this)); |
|
49 | + $this->description = "Gestion des Bookmarks"; |
|
50 | + |
|
51 | + // Possible values for version are: 'development', 'experimental', 'dolibarr' or version |
|
52 | + $this->version = 'dolibarr'; |
|
53 | + |
|
54 | + $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); |
|
55 | + $this->picto='bookmark'; |
|
56 | + |
|
57 | + // Data directories to create when module is enabled |
|
58 | + $this->dirs = array(); |
|
59 | + |
|
60 | + // Dependancies |
|
61 | + $this->depends = array(); |
|
62 | + $this->requiredby = array(); |
|
63 | + $this->langfiles = array("bookmarks"); |
|
64 | + |
|
65 | + // Config pages |
|
66 | + $this->config_page_url = array('bookmark.php@bookmarks'); |
|
67 | + |
|
68 | + // Constants |
|
69 | + $this->const = array(); |
|
70 | + |
|
71 | + // Boxes |
|
72 | + $this->boxes = array(0=>array('file'=>'box_bookmarks.php','enabledbydefaulton'=>'Home')); |
|
73 | + |
|
74 | + // Permissions |
|
75 | + $this->rights = array(); |
|
76 | + $this->rights_class = 'bookmark'; |
|
77 | + $r=0; |
|
78 | + |
|
79 | + $r++; |
|
80 | + $this->rights[$r][0] = 331; // id de la permission |
|
81 | + $this->rights[$r][1] = 'Lire les bookmarks'; // libelle de la permission |
|
82 | + $this->rights[$r][2] = 'r'; // type de la permission (deprecie a ce jour) |
|
83 | + $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut |
|
84 | + $this->rights[$r][4] = 'lire'; |
|
85 | + |
|
86 | + $r++; |
|
87 | + $this->rights[$r][0] = 332; // id de la permission |
|
88 | + $this->rights[$r][1] = 'Creer/modifier les bookmarks'; // libelle de la permission |
|
89 | + $this->rights[$r][2] = 'r'; // type de la permission (deprecie a ce jour) |
|
90 | + $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut |
|
91 | + $this->rights[$r][4] = 'creer'; |
|
92 | + |
|
93 | + $r++; |
|
94 | + $this->rights[$r][0] = 333; // id de la permission |
|
95 | + $this->rights[$r][1] = 'Supprimer les bookmarks'; // libelle de la permission |
|
96 | + $this->rights[$r][2] = 'r'; // type de la permission (d�pr�ci� � ce jour) |
|
97 | + $this->rights[$r][3] = 0; // La permission est-elle une permission par d�faut |
|
98 | + $this->rights[$r][4] = 'supprimer'; |
|
99 | + |
|
100 | + |
|
101 | + // Menus |
|
102 | + //------- |
|
103 | + $this->menu = 1; // This module add menu entries. They are coded into menu manager. |
|
104 | + } |
|
105 | 105 | } |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | * \brief Fichier de description et activation du module Bookmarks |
25 | 25 | */ |
26 | 26 | |
27 | -include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php'; |
|
27 | +include_once DOL_DOCUMENT_ROOT.'/core/modules/DolibarrModules.class.php'; |
|
28 | 28 | |
29 | 29 | |
30 | 30 | /** |
@@ -45,14 +45,14 @@ discard block |
||
45 | 45 | |
46 | 46 | $this->family = "technic"; |
47 | 47 | // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) |
48 | - $this->name = preg_replace('/^mod/i','',get_class($this)); |
|
48 | + $this->name = preg_replace('/^mod/i', '', get_class($this)); |
|
49 | 49 | $this->description = "Gestion des Bookmarks"; |
50 | 50 | |
51 | 51 | // Possible values for version are: 'development', 'experimental', 'dolibarr' or version |
52 | 52 | $this->version = 'dolibarr'; |
53 | 53 | |
54 | 54 | $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); |
55 | - $this->picto='bookmark'; |
|
55 | + $this->picto = 'bookmark'; |
|
56 | 56 | |
57 | 57 | // Data directories to create when module is enabled |
58 | 58 | $this->dirs = array(); |
@@ -69,12 +69,12 @@ discard block |
||
69 | 69 | $this->const = array(); |
70 | 70 | |
71 | 71 | // Boxes |
72 | - $this->boxes = array(0=>array('file'=>'box_bookmarks.php','enabledbydefaulton'=>'Home')); |
|
72 | + $this->boxes = array(0=>array('file'=>'box_bookmarks.php', 'enabledbydefaulton'=>'Home')); |
|
73 | 73 | |
74 | 74 | // Permissions |
75 | 75 | $this->rights = array(); |
76 | 76 | $this->rights_class = 'bookmark'; |
77 | - $r=0; |
|
77 | + $r = 0; |
|
78 | 78 | |
79 | 79 | $r++; |
80 | 80 | $this->rights[$r][0] = 331; // id de la permission |
@@ -100,6 +100,6 @@ discard block |
||
100 | 100 | |
101 | 101 | // Menus |
102 | 102 | //------- |
103 | - $this->menu = 1; // This module add menu entries. They are coded into menu manager. |
|
103 | + $this->menu = 1; // This module add menu entries. They are coded into menu manager. |
|
104 | 104 | } |
105 | 105 | } |
@@ -34,91 +34,91 @@ discard block |
||
34 | 34 | class modBarcode extends DolibarrModules |
35 | 35 | { |
36 | 36 | |
37 | - /** |
|
38 | - * Constructor. Define names, constants, directories, boxes, permissions |
|
39 | - * |
|
40 | - * @param DoliDB $db Database handler |
|
41 | - */ |
|
42 | - function __construct($db) |
|
43 | - { |
|
44 | - $this->db = $db; |
|
45 | - $this->numero = 55; |
|
46 | - |
|
47 | - $this->family = "technic"; |
|
48 | - // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) |
|
49 | - $this->name = preg_replace('/^mod/i','',get_class($this)); |
|
50 | - $this->description = "Gestion des codes barres"; |
|
51 | - // Possible values for version are: 'development', 'experimental', 'dolibarr' or version |
|
52 | - $this->version = 'dolibarr'; |
|
53 | - $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); |
|
54 | - $this->picto='barcode'; |
|
55 | - |
|
56 | - // Data directories to create when module is enabled |
|
57 | - $this->dirs = array("/barcode/temp"); |
|
58 | - |
|
59 | - // Dependencies |
|
60 | - $this->depends = array(); // May be used for product or service or third party module |
|
61 | - $this->requiredby = array(); |
|
62 | - |
|
63 | - // Config pages |
|
64 | - $this->config_page_url = array("barcode.php"); |
|
65 | - |
|
66 | - // Constants |
|
67 | - // Example: $this->const=array(0=>array('MYMODULE_MYNEWCONST1','chaine','myvalue','This is a constant to add',0), |
|
68 | - // 1=>array('MYMODULE_MYNEWCONST2','chaine','myvalue','This is another constant to add',0) ); |
|
69 | - $this->const = array(); |
|
70 | - //$this->const[0] = array('BARCODE_LABEL_LEFT_TEXT','chaine','%BARCODE%','Print barcode on left side of label',1); |
|
71 | - //$this->const[1] = array('BARCODE_LABEL_RIGHT_TEXT','chaine','%LOGO%','Print Company logo on right side',1); |
|
72 | - //$this->const[2] = array('BARCODE_LABEL_HEADER_TEXT','chaine','My header','Print header text on label',1); |
|
73 | - //$this->const[3] = array('BARCODE_LABEL_FOOTER_TEXT','chaine','My footer','Print footer text on label',1); |
|
74 | - |
|
75 | - // Boxes |
|
76 | - $this->boxes = array(); |
|
77 | - |
|
78 | - // Permissions |
|
79 | - $this->rights = array(); |
|
80 | - $this->rights_class = 'barcode'; |
|
81 | - |
|
82 | - $this->rights[1][0] = 300; // id de la permission |
|
83 | - $this->rights[1][1] = 'Read barcodes'; // libelle de la permission |
|
84 | - $this->rights[1][2] = 'r'; // type de la permission (deprecie a ce jour) |
|
85 | - $this->rights[1][3] = 1; // La permission est-elle une permission par defaut |
|
86 | - $this->rights[1][4] = 'lire_advance'; |
|
87 | - |
|
88 | - $this->rights[2][0] = 301; // id de la permission |
|
89 | - $this->rights[2][1] = 'Create/modify barcodes'; // libelle de la permission |
|
90 | - $this->rights[2][2] = 'w'; // type de la permission (deprecie a ce jour) |
|
91 | - $this->rights[2][3] = 0; // La permission est-elle une permission par defaut |
|
92 | - $this->rights[2][4] = 'creer_advance'; |
|
37 | + /** |
|
38 | + * Constructor. Define names, constants, directories, boxes, permissions |
|
39 | + * |
|
40 | + * @param DoliDB $db Database handler |
|
41 | + */ |
|
42 | + function __construct($db) |
|
43 | + { |
|
44 | + $this->db = $db; |
|
45 | + $this->numero = 55; |
|
46 | + |
|
47 | + $this->family = "technic"; |
|
48 | + // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) |
|
49 | + $this->name = preg_replace('/^mod/i','',get_class($this)); |
|
50 | + $this->description = "Gestion des codes barres"; |
|
51 | + // Possible values for version are: 'development', 'experimental', 'dolibarr' or version |
|
52 | + $this->version = 'dolibarr'; |
|
53 | + $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); |
|
54 | + $this->picto='barcode'; |
|
55 | + |
|
56 | + // Data directories to create when module is enabled |
|
57 | + $this->dirs = array("/barcode/temp"); |
|
58 | + |
|
59 | + // Dependencies |
|
60 | + $this->depends = array(); // May be used for product or service or third party module |
|
61 | + $this->requiredby = array(); |
|
62 | + |
|
63 | + // Config pages |
|
64 | + $this->config_page_url = array("barcode.php"); |
|
65 | + |
|
66 | + // Constants |
|
67 | + // Example: $this->const=array(0=>array('MYMODULE_MYNEWCONST1','chaine','myvalue','This is a constant to add',0), |
|
68 | + // 1=>array('MYMODULE_MYNEWCONST2','chaine','myvalue','This is another constant to add',0) ); |
|
69 | + $this->const = array(); |
|
70 | + //$this->const[0] = array('BARCODE_LABEL_LEFT_TEXT','chaine','%BARCODE%','Print barcode on left side of label',1); |
|
71 | + //$this->const[1] = array('BARCODE_LABEL_RIGHT_TEXT','chaine','%LOGO%','Print Company logo on right side',1); |
|
72 | + //$this->const[2] = array('BARCODE_LABEL_HEADER_TEXT','chaine','My header','Print header text on label',1); |
|
73 | + //$this->const[3] = array('BARCODE_LABEL_FOOTER_TEXT','chaine','My footer','Print footer text on label',1); |
|
74 | + |
|
75 | + // Boxes |
|
76 | + $this->boxes = array(); |
|
77 | + |
|
78 | + // Permissions |
|
79 | + $this->rights = array(); |
|
80 | + $this->rights_class = 'barcode'; |
|
81 | + |
|
82 | + $this->rights[1][0] = 300; // id de la permission |
|
83 | + $this->rights[1][1] = 'Read barcodes'; // libelle de la permission |
|
84 | + $this->rights[1][2] = 'r'; // type de la permission (deprecie a ce jour) |
|
85 | + $this->rights[1][3] = 1; // La permission est-elle une permission par defaut |
|
86 | + $this->rights[1][4] = 'lire_advance'; |
|
87 | + |
|
88 | + $this->rights[2][0] = 301; // id de la permission |
|
89 | + $this->rights[2][1] = 'Create/modify barcodes'; // libelle de la permission |
|
90 | + $this->rights[2][2] = 'w'; // type de la permission (deprecie a ce jour) |
|
91 | + $this->rights[2][3] = 0; // La permission est-elle une permission par defaut |
|
92 | + $this->rights[2][4] = 'creer_advance'; |
|
93 | 93 | |
94 | 94 | // Main menu entries |
95 | 95 | $r=0; |
96 | 96 | $this->menu[$r]=array( 'fk_menu'=>'fk_mainmenu=tools', // Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode |
97 | - 'mainmenu'=>'tools', |
|
98 | - 'leftmenu'=>'barcodeprint', |
|
99 | - 'type'=>'left', // This is a Left menu entry |
|
100 | - 'titre'=>'BarCodePrintsheet', |
|
101 | - 'url'=>'/barcode/printsheet.php?mainmenu=tools&leftmenu=barcodeprint', |
|
102 | - 'langs'=>'products', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. |
|
103 | - 'position'=>200, |
|
104 | - 'enabled'=>'$conf->barcode->enabled', // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected. |
|
105 | - 'perms'=>'($conf->global->MAIN_USE_ADVANCED_PERMS && $user->rights->barcode->lire_advance) || (! $conf->global->MAIN_USE_ADVANCED_PERMS)', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules |
|
106 | - 'target'=>'', |
|
107 | - 'user'=>2); // 0=Menu for internal users, 1=external users, 2=both |
|
108 | - $r++; |
|
109 | - |
|
110 | - $this->menu[$r]=array( 'fk_menu'=>'fk_mainmenu=home,fk_leftmenu=admintools', // Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode |
|
111 | - 'type'=>'left', // This is a Left menu entry |
|
112 | - 'titre'=>'MassBarcodeInit', |
|
113 | - 'url'=>'/barcode/codeinit.php?mainmenu=home&leftmenu=admintools', |
|
114 | - 'langs'=>'products', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. |
|
115 | - 'position'=>300, |
|
116 | - 'enabled'=>'$conf->barcode->enabled && preg_match(\'/^(admintools|all)/\',$leftmenu)', // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected. |
|
117 | - 'perms'=>'($conf->global->MAIN_USE_ADVANCED_PERMS && $user->rights->barcode->creer_advance) || (! $conf->global->MAIN_USE_ADVANCED_PERMS)', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules |
|
118 | - 'target'=>'', |
|
119 | - 'user'=>0); // 0=Menu for internal users, 1=external users, 2=both |
|
120 | - $r++; |
|
121 | - } |
|
97 | + 'mainmenu'=>'tools', |
|
98 | + 'leftmenu'=>'barcodeprint', |
|
99 | + 'type'=>'left', // This is a Left menu entry |
|
100 | + 'titre'=>'BarCodePrintsheet', |
|
101 | + 'url'=>'/barcode/printsheet.php?mainmenu=tools&leftmenu=barcodeprint', |
|
102 | + 'langs'=>'products', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. |
|
103 | + 'position'=>200, |
|
104 | + 'enabled'=>'$conf->barcode->enabled', // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected. |
|
105 | + 'perms'=>'($conf->global->MAIN_USE_ADVANCED_PERMS && $user->rights->barcode->lire_advance) || (! $conf->global->MAIN_USE_ADVANCED_PERMS)', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules |
|
106 | + 'target'=>'', |
|
107 | + 'user'=>2); // 0=Menu for internal users, 1=external users, 2=both |
|
108 | + $r++; |
|
109 | + |
|
110 | + $this->menu[$r]=array( 'fk_menu'=>'fk_mainmenu=home,fk_leftmenu=admintools', // Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode |
|
111 | + 'type'=>'left', // This is a Left menu entry |
|
112 | + 'titre'=>'MassBarcodeInit', |
|
113 | + 'url'=>'/barcode/codeinit.php?mainmenu=home&leftmenu=admintools', |
|
114 | + 'langs'=>'products', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. |
|
115 | + 'position'=>300, |
|
116 | + 'enabled'=>'$conf->barcode->enabled && preg_match(\'/^(admintools|all)/\',$leftmenu)', // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected. |
|
117 | + 'perms'=>'($conf->global->MAIN_USE_ADVANCED_PERMS && $user->rights->barcode->creer_advance) || (! $conf->global->MAIN_USE_ADVANCED_PERMS)', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules |
|
118 | + 'target'=>'', |
|
119 | + 'user'=>0); // 0=Menu for internal users, 1=external users, 2=both |
|
120 | + $r++; |
|
121 | + } |
|
122 | 122 | |
123 | 123 | |
124 | 124 | /** |
@@ -127,24 +127,24 @@ discard block |
||
127 | 127 | * It also creates data directories. |
128 | 128 | * |
129 | 129 | * @param string $options Options when enabling module ('', 'noboxes') |
130 | - * @return int 1 if OK, 0 if KO |
|
131 | - */ |
|
132 | - function init($options='') |
|
133 | - { |
|
134 | - // Permissions |
|
135 | - $this->remove($options); |
|
136 | - |
|
137 | - $sql = array( |
|
138 | - array('sql'=>"INSERT INTO ".MAIN_DB_PREFIX."c_barcode_type (code, libelle, coder, example, entity) VALUES ('EAN8', 'EAN8', 0, '1234567', __ENTITY__)",'ignoreerror'=>1), |
|
139 | - array('sql'=>"INSERT INTO ".MAIN_DB_PREFIX."c_barcode_type (code, libelle, coder, example, entity) VALUES ('EAN13', 'EAN13', 0, '123456789012', __ENTITY__)",'ignoreerror'=>1), |
|
140 | - array('sql'=>"INSERT INTO ".MAIN_DB_PREFIX."c_barcode_type (code, libelle, coder, example, entity) VALUES ('UPC', 'UPC', 0, '123456789012', __ENTITY__)",'ignoreerror'=>1), |
|
141 | - array('sql'=>"INSERT INTO ".MAIN_DB_PREFIX."c_barcode_type (code, libelle, coder, example, entity) VALUES ('ISBN', 'ISBN', 0, '123456789', __ENTITY__)",'ignoreerror'=>1), |
|
142 | - array('sql'=>"INSERT INTO ".MAIN_DB_PREFIX."c_barcode_type (code, libelle, coder, example, entity) VALUES ('C39', 'Code 39', 0, '1234567890', __ENTITY__)",'ignoreerror'=>1), |
|
143 | - array('sql'=>"INSERT INTO ".MAIN_DB_PREFIX."c_barcode_type (code, libelle, coder, example, entity) VALUES ('C128', 'Code 128', 0, 'ABCD1234567890', __ENTITY__)",'ignoreerror'=>1), |
|
144 | - array('sql'=>"INSERT INTO ".MAIN_DB_PREFIX."c_barcode_type (code, libelle, coder, example, entity) VALUES ('DATAMATRIX', 'Datamatrix', 0, '1234567xyz', __ENTITY__)",'ignoreerror'=>1), |
|
145 | - array('sql'=>"INSERT INTO ".MAIN_DB_PREFIX."c_barcode_type (code, libelle, coder, example, entity) VALUES ('QRCODE', 'Qr Code', 0, 'www.dolibarr.org', __ENTITY__)",'ignoreerror'=>1) |
|
146 | - ); |
|
147 | - |
|
148 | - return $this->_init($sql, $options); |
|
149 | - } |
|
130 | + * @return int 1 if OK, 0 if KO |
|
131 | + */ |
|
132 | + function init($options='') |
|
133 | + { |
|
134 | + // Permissions |
|
135 | + $this->remove($options); |
|
136 | + |
|
137 | + $sql = array( |
|
138 | + array('sql'=>"INSERT INTO ".MAIN_DB_PREFIX."c_barcode_type (code, libelle, coder, example, entity) VALUES ('EAN8', 'EAN8', 0, '1234567', __ENTITY__)",'ignoreerror'=>1), |
|
139 | + array('sql'=>"INSERT INTO ".MAIN_DB_PREFIX."c_barcode_type (code, libelle, coder, example, entity) VALUES ('EAN13', 'EAN13', 0, '123456789012', __ENTITY__)",'ignoreerror'=>1), |
|
140 | + array('sql'=>"INSERT INTO ".MAIN_DB_PREFIX."c_barcode_type (code, libelle, coder, example, entity) VALUES ('UPC', 'UPC', 0, '123456789012', __ENTITY__)",'ignoreerror'=>1), |
|
141 | + array('sql'=>"INSERT INTO ".MAIN_DB_PREFIX."c_barcode_type (code, libelle, coder, example, entity) VALUES ('ISBN', 'ISBN', 0, '123456789', __ENTITY__)",'ignoreerror'=>1), |
|
142 | + array('sql'=>"INSERT INTO ".MAIN_DB_PREFIX."c_barcode_type (code, libelle, coder, example, entity) VALUES ('C39', 'Code 39', 0, '1234567890', __ENTITY__)",'ignoreerror'=>1), |
|
143 | + array('sql'=>"INSERT INTO ".MAIN_DB_PREFIX."c_barcode_type (code, libelle, coder, example, entity) VALUES ('C128', 'Code 128', 0, 'ABCD1234567890', __ENTITY__)",'ignoreerror'=>1), |
|
144 | + array('sql'=>"INSERT INTO ".MAIN_DB_PREFIX."c_barcode_type (code, libelle, coder, example, entity) VALUES ('DATAMATRIX', 'Datamatrix', 0, '1234567xyz', __ENTITY__)",'ignoreerror'=>1), |
|
145 | + array('sql'=>"INSERT INTO ".MAIN_DB_PREFIX."c_barcode_type (code, libelle, coder, example, entity) VALUES ('QRCODE', 'Qr Code', 0, 'www.dolibarr.org', __ENTITY__)",'ignoreerror'=>1) |
|
146 | + ); |
|
147 | + |
|
148 | + return $this->_init($sql, $options); |
|
149 | + } |
|
150 | 150 | } |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | * \brief Fichier de description et activation du module Barcode |
27 | 27 | */ |
28 | 28 | |
29 | -include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php'; |
|
29 | +include_once DOL_DOCUMENT_ROOT.'/core/modules/DolibarrModules.class.php'; |
|
30 | 30 | |
31 | 31 | /** |
32 | 32 | * Class to describe Barcode |
@@ -46,18 +46,18 @@ discard block |
||
46 | 46 | |
47 | 47 | $this->family = "technic"; |
48 | 48 | // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) |
49 | - $this->name = preg_replace('/^mod/i','',get_class($this)); |
|
49 | + $this->name = preg_replace('/^mod/i', '', get_class($this)); |
|
50 | 50 | $this->description = "Gestion des codes barres"; |
51 | 51 | // Possible values for version are: 'development', 'experimental', 'dolibarr' or version |
52 | 52 | $this->version = 'dolibarr'; |
53 | 53 | $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); |
54 | - $this->picto='barcode'; |
|
54 | + $this->picto = 'barcode'; |
|
55 | 55 | |
56 | 56 | // Data directories to create when module is enabled |
57 | 57 | $this->dirs = array("/barcode/temp"); |
58 | 58 | |
59 | 59 | // Dependencies |
60 | - $this->depends = array(); // May be used for product or service or third party module |
|
60 | + $this->depends = array(); // May be used for product or service or third party module |
|
61 | 61 | $this->requiredby = array(); |
62 | 62 | |
63 | 63 | // Config pages |
@@ -92,31 +92,31 @@ discard block |
||
92 | 92 | $this->rights[2][4] = 'creer_advance'; |
93 | 93 | |
94 | 94 | // Main menu entries |
95 | - $r=0; |
|
96 | - $this->menu[$r]=array( 'fk_menu'=>'fk_mainmenu=tools', // Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode |
|
95 | + $r = 0; |
|
96 | + $this->menu[$r] = array('fk_menu'=>'fk_mainmenu=tools', // Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode |
|
97 | 97 | 'mainmenu'=>'tools', |
98 | 98 | 'leftmenu'=>'barcodeprint', |
99 | - 'type'=>'left', // This is a Left menu entry |
|
99 | + 'type'=>'left', // This is a Left menu entry |
|
100 | 100 | 'titre'=>'BarCodePrintsheet', |
101 | 101 | 'url'=>'/barcode/printsheet.php?mainmenu=tools&leftmenu=barcodeprint', |
102 | - 'langs'=>'products', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. |
|
102 | + 'langs'=>'products', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. |
|
103 | 103 | 'position'=>200, |
104 | - 'enabled'=>'$conf->barcode->enabled', // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected. |
|
105 | - 'perms'=>'($conf->global->MAIN_USE_ADVANCED_PERMS && $user->rights->barcode->lire_advance) || (! $conf->global->MAIN_USE_ADVANCED_PERMS)', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules |
|
104 | + 'enabled'=>'$conf->barcode->enabled', // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected. |
|
105 | + 'perms'=>'($conf->global->MAIN_USE_ADVANCED_PERMS && $user->rights->barcode->lire_advance) || (! $conf->global->MAIN_USE_ADVANCED_PERMS)', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules |
|
106 | 106 | 'target'=>'', |
107 | - 'user'=>2); // 0=Menu for internal users, 1=external users, 2=both |
|
107 | + 'user'=>2); // 0=Menu for internal users, 1=external users, 2=both |
|
108 | 108 | $r++; |
109 | 109 | |
110 | - $this->menu[$r]=array( 'fk_menu'=>'fk_mainmenu=home,fk_leftmenu=admintools', // Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode |
|
111 | - 'type'=>'left', // This is a Left menu entry |
|
110 | + $this->menu[$r] = array('fk_menu'=>'fk_mainmenu=home,fk_leftmenu=admintools', // Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode |
|
111 | + 'type'=>'left', // This is a Left menu entry |
|
112 | 112 | 'titre'=>'MassBarcodeInit', |
113 | 113 | 'url'=>'/barcode/codeinit.php?mainmenu=home&leftmenu=admintools', |
114 | - 'langs'=>'products', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. |
|
114 | + 'langs'=>'products', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. |
|
115 | 115 | 'position'=>300, |
116 | - 'enabled'=>'$conf->barcode->enabled && preg_match(\'/^(admintools|all)/\',$leftmenu)', // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected. |
|
117 | - 'perms'=>'($conf->global->MAIN_USE_ADVANCED_PERMS && $user->rights->barcode->creer_advance) || (! $conf->global->MAIN_USE_ADVANCED_PERMS)', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules |
|
116 | + 'enabled'=>'$conf->barcode->enabled && preg_match(\'/^(admintools|all)/\',$leftmenu)', // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected. |
|
117 | + 'perms'=>'($conf->global->MAIN_USE_ADVANCED_PERMS && $user->rights->barcode->creer_advance) || (! $conf->global->MAIN_USE_ADVANCED_PERMS)', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules |
|
118 | 118 | 'target'=>'', |
119 | - 'user'=>0); // 0=Menu for internal users, 1=external users, 2=both |
|
119 | + 'user'=>0); // 0=Menu for internal users, 1=external users, 2=both |
|
120 | 120 | $r++; |
121 | 121 | } |
122 | 122 | |
@@ -129,20 +129,20 @@ discard block |
||
129 | 129 | * @param string $options Options when enabling module ('', 'noboxes') |
130 | 130 | * @return int 1 if OK, 0 if KO |
131 | 131 | */ |
132 | - function init($options='') |
|
132 | + function init($options = '') |
|
133 | 133 | { |
134 | 134 | // Permissions |
135 | 135 | $this->remove($options); |
136 | 136 | |
137 | 137 | $sql = array( |
138 | - array('sql'=>"INSERT INTO ".MAIN_DB_PREFIX."c_barcode_type (code, libelle, coder, example, entity) VALUES ('EAN8', 'EAN8', 0, '1234567', __ENTITY__)",'ignoreerror'=>1), |
|
139 | - array('sql'=>"INSERT INTO ".MAIN_DB_PREFIX."c_barcode_type (code, libelle, coder, example, entity) VALUES ('EAN13', 'EAN13', 0, '123456789012', __ENTITY__)",'ignoreerror'=>1), |
|
140 | - array('sql'=>"INSERT INTO ".MAIN_DB_PREFIX."c_barcode_type (code, libelle, coder, example, entity) VALUES ('UPC', 'UPC', 0, '123456789012', __ENTITY__)",'ignoreerror'=>1), |
|
141 | - array('sql'=>"INSERT INTO ".MAIN_DB_PREFIX."c_barcode_type (code, libelle, coder, example, entity) VALUES ('ISBN', 'ISBN', 0, '123456789', __ENTITY__)",'ignoreerror'=>1), |
|
142 | - array('sql'=>"INSERT INTO ".MAIN_DB_PREFIX."c_barcode_type (code, libelle, coder, example, entity) VALUES ('C39', 'Code 39', 0, '1234567890', __ENTITY__)",'ignoreerror'=>1), |
|
143 | - array('sql'=>"INSERT INTO ".MAIN_DB_PREFIX."c_barcode_type (code, libelle, coder, example, entity) VALUES ('C128', 'Code 128', 0, 'ABCD1234567890', __ENTITY__)",'ignoreerror'=>1), |
|
144 | - array('sql'=>"INSERT INTO ".MAIN_DB_PREFIX."c_barcode_type (code, libelle, coder, example, entity) VALUES ('DATAMATRIX', 'Datamatrix', 0, '1234567xyz', __ENTITY__)",'ignoreerror'=>1), |
|
145 | - array('sql'=>"INSERT INTO ".MAIN_DB_PREFIX."c_barcode_type (code, libelle, coder, example, entity) VALUES ('QRCODE', 'Qr Code', 0, 'www.dolibarr.org', __ENTITY__)",'ignoreerror'=>1) |
|
138 | + array('sql'=>"INSERT INTO ".MAIN_DB_PREFIX."c_barcode_type (code, libelle, coder, example, entity) VALUES ('EAN8', 'EAN8', 0, '1234567', __ENTITY__)", 'ignoreerror'=>1), |
|
139 | + array('sql'=>"INSERT INTO ".MAIN_DB_PREFIX."c_barcode_type (code, libelle, coder, example, entity) VALUES ('EAN13', 'EAN13', 0, '123456789012', __ENTITY__)", 'ignoreerror'=>1), |
|
140 | + array('sql'=>"INSERT INTO ".MAIN_DB_PREFIX."c_barcode_type (code, libelle, coder, example, entity) VALUES ('UPC', 'UPC', 0, '123456789012', __ENTITY__)", 'ignoreerror'=>1), |
|
141 | + array('sql'=>"INSERT INTO ".MAIN_DB_PREFIX."c_barcode_type (code, libelle, coder, example, entity) VALUES ('ISBN', 'ISBN', 0, '123456789', __ENTITY__)", 'ignoreerror'=>1), |
|
142 | + array('sql'=>"INSERT INTO ".MAIN_DB_PREFIX."c_barcode_type (code, libelle, coder, example, entity) VALUES ('C39', 'Code 39', 0, '1234567890', __ENTITY__)", 'ignoreerror'=>1), |
|
143 | + array('sql'=>"INSERT INTO ".MAIN_DB_PREFIX."c_barcode_type (code, libelle, coder, example, entity) VALUES ('C128', 'Code 128', 0, 'ABCD1234567890', __ENTITY__)", 'ignoreerror'=>1), |
|
144 | + array('sql'=>"INSERT INTO ".MAIN_DB_PREFIX."c_barcode_type (code, libelle, coder, example, entity) VALUES ('DATAMATRIX', 'Datamatrix', 0, '1234567xyz', __ENTITY__)", 'ignoreerror'=>1), |
|
145 | + array('sql'=>"INSERT INTO ".MAIN_DB_PREFIX."c_barcode_type (code, libelle, coder, example, entity) VALUES ('QRCODE', 'Qr Code', 0, 'www.dolibarr.org', __ENTITY__)", 'ignoreerror'=>1) |
|
146 | 146 | ); |
147 | 147 | |
148 | 148 | return $this->_init($sql, $options); |
@@ -42,12 +42,12 @@ discard block |
||
42 | 42 | */ |
43 | 43 | public $db; |
44 | 44 | |
45 | - /** |
|
45 | + /** |
|
46 | 46 | * @var string model name |
47 | 47 | */ |
48 | 48 | public $name; |
49 | 49 | |
50 | - /** |
|
50 | + /** |
|
51 | 51 | * @var string model description (short text) |
52 | 52 | */ |
53 | 53 | public $description; |
@@ -59,132 +59,132 @@ discard block |
||
59 | 59 | |
60 | 60 | /** |
61 | 61 | * @var array() Minimum version of PHP required by module. |
62 | - * e.g.: PHP ≥ 5.4 = array(5, 4) |
|
62 | + * e.g.: PHP ≥ 5.4 = array(5, 4) |
|
63 | 63 | */ |
64 | - public $phpmin = array(5, 4); |
|
64 | + public $phpmin = array(5, 4); |
|
65 | 65 | |
66 | - /** |
|
66 | + /** |
|
67 | 67 | * Dolibarr version of the loaded document |
68 | 68 | * @public string |
69 | 69 | */ |
70 | - public $version = 'dolibarr'; |
|
70 | + public $version = 'dolibarr'; |
|
71 | 71 | |
72 | - /** |
|
72 | + /** |
|
73 | 73 | * @var int page_largeur |
74 | 74 | */ |
75 | 75 | public $page_largeur; |
76 | 76 | |
77 | - /** |
|
77 | + /** |
|
78 | 78 | * @var int page_hauteur |
79 | 79 | */ |
80 | 80 | public $page_hauteur; |
81 | 81 | |
82 | - /** |
|
82 | + /** |
|
83 | 83 | * @var array format |
84 | 84 | */ |
85 | 85 | public $format; |
86 | 86 | |
87 | - /** |
|
87 | + /** |
|
88 | 88 | * @var int marge_gauche |
89 | 89 | */ |
90 | - public $marge_gauche; |
|
90 | + public $marge_gauche; |
|
91 | 91 | |
92 | - /** |
|
92 | + /** |
|
93 | 93 | * @var int marge_droite |
94 | 94 | */ |
95 | - public $marge_droite; |
|
95 | + public $marge_droite; |
|
96 | 96 | |
97 | - /** |
|
97 | + /** |
|
98 | 98 | * @var int marge_haute |
99 | 99 | */ |
100 | - public $marge_haute; |
|
100 | + public $marge_haute; |
|
101 | 101 | |
102 | - /** |
|
102 | + /** |
|
103 | 103 | * @var int marge_basse |
104 | 104 | */ |
105 | - public $marge_basse; |
|
106 | - |
|
107 | - /** |
|
108 | - * Issuer |
|
109 | - * @var Company object that emits |
|
110 | - */ |
|
111 | - public $emetteur; |
|
112 | - |
|
113 | - |
|
114 | - |
|
115 | - /** |
|
116 | - * Constructor |
|
117 | - * |
|
118 | - * @param DoliDB $db Database handler |
|
119 | - */ |
|
120 | - function __construct($db) |
|
121 | - { |
|
122 | - global $conf, $langs, $mysoc; |
|
123 | - |
|
124 | - // Load translation files required by the page |
|
125 | - $langs->loadLangs(array("main", "bills")); |
|
126 | - |
|
127 | - $this->db = $db; |
|
128 | - $this->name = "canelle"; |
|
129 | - $this->description = $langs->trans('SuppliersInvoiceModel'); |
|
130 | - |
|
131 | - // Dimension page pour format A4 |
|
132 | - $this->type = 'pdf'; |
|
133 | - $formatarray=pdf_getFormat(); |
|
134 | - $this->page_largeur = $formatarray['width']; |
|
135 | - $this->page_hauteur = $formatarray['height']; |
|
136 | - $this->format = array($this->page_largeur,$this->page_hauteur); |
|
137 | - $this->marge_gauche=isset($conf->global->MAIN_PDF_MARGIN_LEFT)?$conf->global->MAIN_PDF_MARGIN_LEFT:10; |
|
138 | - $this->marge_droite=isset($conf->global->MAIN_PDF_MARGIN_RIGHT)?$conf->global->MAIN_PDF_MARGIN_RIGHT:10; |
|
139 | - $this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10; |
|
140 | - $this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10; |
|
141 | - |
|
142 | - $this->option_logo = 1; // Affiche logo |
|
143 | - $this->option_tva = 1; // Gere option tva FACTURE_TVAOPTION |
|
144 | - $this->option_modereg = 1; // Affiche mode reglement |
|
145 | - $this->option_condreg = 1; // Affiche conditions reglement |
|
146 | - $this->option_codeproduitservice = 1; // Affiche code produit-service |
|
147 | - $this->option_multilang = 1; // Dispo en plusieurs langues |
|
148 | - |
|
149 | - $this->franchise=!$mysoc->tva_assuj; |
|
105 | + public $marge_basse; |
|
106 | + |
|
107 | + /** |
|
108 | + * Issuer |
|
109 | + * @var Company object that emits |
|
110 | + */ |
|
111 | + public $emetteur; |
|
112 | + |
|
113 | + |
|
114 | + |
|
115 | + /** |
|
116 | + * Constructor |
|
117 | + * |
|
118 | + * @param DoliDB $db Database handler |
|
119 | + */ |
|
120 | + function __construct($db) |
|
121 | + { |
|
122 | + global $conf, $langs, $mysoc; |
|
123 | + |
|
124 | + // Load translation files required by the page |
|
125 | + $langs->loadLangs(array("main", "bills")); |
|
126 | + |
|
127 | + $this->db = $db; |
|
128 | + $this->name = "canelle"; |
|
129 | + $this->description = $langs->trans('SuppliersInvoiceModel'); |
|
130 | + |
|
131 | + // Dimension page pour format A4 |
|
132 | + $this->type = 'pdf'; |
|
133 | + $formatarray=pdf_getFormat(); |
|
134 | + $this->page_largeur = $formatarray['width']; |
|
135 | + $this->page_hauteur = $formatarray['height']; |
|
136 | + $this->format = array($this->page_largeur,$this->page_hauteur); |
|
137 | + $this->marge_gauche=isset($conf->global->MAIN_PDF_MARGIN_LEFT)?$conf->global->MAIN_PDF_MARGIN_LEFT:10; |
|
138 | + $this->marge_droite=isset($conf->global->MAIN_PDF_MARGIN_RIGHT)?$conf->global->MAIN_PDF_MARGIN_RIGHT:10; |
|
139 | + $this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10; |
|
140 | + $this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10; |
|
141 | + |
|
142 | + $this->option_logo = 1; // Affiche logo |
|
143 | + $this->option_tva = 1; // Gere option tva FACTURE_TVAOPTION |
|
144 | + $this->option_modereg = 1; // Affiche mode reglement |
|
145 | + $this->option_condreg = 1; // Affiche conditions reglement |
|
146 | + $this->option_codeproduitservice = 1; // Affiche code produit-service |
|
147 | + $this->option_multilang = 1; // Dispo en plusieurs langues |
|
148 | + |
|
149 | + $this->franchise=!$mysoc->tva_assuj; |
|
150 | 150 | |
151 | 151 | // Defini position des colonnes |
152 | - $this->posxdesc=$this->marge_gauche+1; |
|
153 | - $this->posxtva=112; |
|
154 | - $this->posxup=126; |
|
155 | - $this->posxqty=145; |
|
156 | - $this->posxdiscount=162; |
|
157 | - $this->postotalht=174; |
|
158 | - |
|
159 | - if($conf->global->PRODUCT_USE_UNITS) { |
|
160 | - $this->posxtva=99; |
|
161 | - $this->posxup=114; |
|
162 | - $this->posxqty=130; |
|
163 | - $this->posxunit=147; |
|
164 | - } |
|
165 | - //if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) $this->posxtva=$this->posxup; |
|
166 | - $this->posxpicture=$this->posxtva - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH)?20:$conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH); // width of images |
|
167 | - if ($this->page_largeur < 210) // To work with US executive format |
|
168 | - { |
|
169 | - $this->posxpicture-=20; |
|
170 | - $this->posxtva-=20; |
|
171 | - $this->posxup-=20; |
|
172 | - $this->posxqty-=20; |
|
173 | - $this->posxunit-=20; |
|
174 | - $this->posxdiscount-=20; |
|
175 | - $this->postotalht-=20; |
|
176 | - } |
|
152 | + $this->posxdesc=$this->marge_gauche+1; |
|
153 | + $this->posxtva=112; |
|
154 | + $this->posxup=126; |
|
155 | + $this->posxqty=145; |
|
156 | + $this->posxdiscount=162; |
|
157 | + $this->postotalht=174; |
|
158 | + |
|
159 | + if($conf->global->PRODUCT_USE_UNITS) { |
|
160 | + $this->posxtva=99; |
|
161 | + $this->posxup=114; |
|
162 | + $this->posxqty=130; |
|
163 | + $this->posxunit=147; |
|
164 | + } |
|
165 | + //if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) $this->posxtva=$this->posxup; |
|
166 | + $this->posxpicture=$this->posxtva - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH)?20:$conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH); // width of images |
|
167 | + if ($this->page_largeur < 210) // To work with US executive format |
|
168 | + { |
|
169 | + $this->posxpicture-=20; |
|
170 | + $this->posxtva-=20; |
|
171 | + $this->posxup-=20; |
|
172 | + $this->posxqty-=20; |
|
173 | + $this->posxunit-=20; |
|
174 | + $this->posxdiscount-=20; |
|
175 | + $this->postotalht-=20; |
|
176 | + } |
|
177 | 177 | |
178 | - $this->tva=array(); |
|
178 | + $this->tva=array(); |
|
179 | 179 | $this->localtax1=array(); |
180 | 180 | $this->localtax2=array(); |
181 | - $this->atleastoneratenotnull=0; |
|
182 | - $this->atleastonediscount=0; |
|
183 | - } |
|
181 | + $this->atleastoneratenotnull=0; |
|
182 | + $this->atleastonediscount=0; |
|
183 | + } |
|
184 | 184 | |
185 | 185 | |
186 | 186 | // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps |
187 | - /** |
|
187 | + /** |
|
188 | 188 | * Function to build pdf onto disk |
189 | 189 | * |
190 | 190 | * @param FactureFournisseur $object Id of object to generate |
@@ -195,77 +195,77 @@ discard block |
||
195 | 195 | * @param int $hideref Do not show ref |
196 | 196 | * @return int 1=OK, 0=KO |
197 | 197 | */ |
198 | - function write_file($object, $outputlangs='', $srctemplatepath='', $hidedetails=0, $hidedesc=0, $hideref=0) |
|
199 | - { |
|
198 | + function write_file($object, $outputlangs='', $srctemplatepath='', $hidedetails=0, $hidedesc=0, $hideref=0) |
|
199 | + { |
|
200 | 200 | // phpcs:enable |
201 | - global $user,$langs,$conf,$mysoc,$hookmanager,$nblignes; |
|
201 | + global $user,$langs,$conf,$mysoc,$hookmanager,$nblignes; |
|
202 | 202 | |
203 | - // Get source company |
|
204 | - if (! is_object($object->thirdparty)) $object->fetch_thirdparty(); |
|
205 | - if (! is_object($object->thirdparty)) $object->thirdparty=$mysoc; // If fetch_thirdparty fails, object has no socid (specimen) |
|
206 | - $this->emetteur=$object->thirdparty; |
|
207 | - if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2); // By default, if was not defined |
|
203 | + // Get source company |
|
204 | + if (! is_object($object->thirdparty)) $object->fetch_thirdparty(); |
|
205 | + if (! is_object($object->thirdparty)) $object->thirdparty=$mysoc; // If fetch_thirdparty fails, object has no socid (specimen) |
|
206 | + $this->emetteur=$object->thirdparty; |
|
207 | + if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2); // By default, if was not defined |
|
208 | 208 | |
209 | - if (! is_object($outputlangs)) $outputlangs=$langs; |
|
210 | - // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO |
|
211 | - if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1'; |
|
209 | + if (! is_object($outputlangs)) $outputlangs=$langs; |
|
210 | + // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO |
|
211 | + if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1'; |
|
212 | 212 | |
213 | - // Load translation files required by the page |
|
214 | - $outputlangs->loadLangs(array("main", "dict", "companies", "bills", "products")); |
|
213 | + // Load translation files required by the page |
|
214 | + $outputlangs->loadLangs(array("main", "dict", "companies", "bills", "products")); |
|
215 | 215 | |
216 | - if ($conf->fournisseur->facture->dir_output) |
|
217 | - { |
|
218 | - $object->fetch_thirdparty(); |
|
216 | + if ($conf->fournisseur->facture->dir_output) |
|
217 | + { |
|
218 | + $object->fetch_thirdparty(); |
|
219 | 219 | |
220 | - $deja_regle = $object->getSommePaiement(); |
|
220 | + $deja_regle = $object->getSommePaiement(); |
|
221 | 221 | //$amount_credit_notes_included = $object->getSumCreditNotesUsed(); |
222 | 222 | //$amount_deposits_included = $object->getSumDepositsUsed(); |
223 | 223 | |
224 | - // Definition of $dir and $file |
|
225 | - if ($object->specimen) |
|
226 | - { |
|
227 | - $dir = $conf->fournisseur->facture->dir_output; |
|
228 | - $file = $dir . "/SPECIMEN.pdf"; |
|
229 | - } |
|
230 | - else |
|
231 | - { |
|
232 | - $objectref = dol_sanitizeFileName($object->ref); |
|
233 | - $objectrefsupplier = dol_sanitizeFileName($object->ref_supplier); |
|
224 | + // Definition of $dir and $file |
|
225 | + if ($object->specimen) |
|
226 | + { |
|
227 | + $dir = $conf->fournisseur->facture->dir_output; |
|
228 | + $file = $dir . "/SPECIMEN.pdf"; |
|
229 | + } |
|
230 | + else |
|
231 | + { |
|
232 | + $objectref = dol_sanitizeFileName($object->ref); |
|
233 | + $objectrefsupplier = dol_sanitizeFileName($object->ref_supplier); |
|
234 | 234 | $dir = $conf->fournisseur->facture->dir_output.'/'.get_exdir($object->id,2,0,0,$object,'invoice_supplier').$objectref; |
235 | - $file = $dir . "/" . $objectref . ".pdf"; |
|
236 | - if (! empty($conf->global->SUPPLIER_REF_IN_NAME)) $file = $dir . "/" . $objectref . ($objectrefsupplier?"_".$objectrefsupplier:"").".pdf"; |
|
237 | - } |
|
235 | + $file = $dir . "/" . $objectref . ".pdf"; |
|
236 | + if (! empty($conf->global->SUPPLIER_REF_IN_NAME)) $file = $dir . "/" . $objectref . ($objectrefsupplier?"_".$objectrefsupplier:"").".pdf"; |
|
237 | + } |
|
238 | 238 | |
239 | - if (! file_exists($dir)) |
|
240 | - { |
|
241 | - if (dol_mkdir($dir) < 0) |
|
242 | - { |
|
243 | - $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir); |
|
244 | - return 0; |
|
245 | - } |
|
246 | - } |
|
239 | + if (! file_exists($dir)) |
|
240 | + { |
|
241 | + if (dol_mkdir($dir) < 0) |
|
242 | + { |
|
243 | + $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir); |
|
244 | + return 0; |
|
245 | + } |
|
246 | + } |
|
247 | 247 | |
248 | - if (file_exists($dir)) |
|
249 | - { |
|
250 | - // Add pdfgeneration hook |
|
251 | - if (! is_object($hookmanager)) |
|
252 | - { |
|
253 | - include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; |
|
254 | - $hookmanager=new HookManager($this->db); |
|
255 | - } |
|
256 | - $hookmanager->initHooks(array('pdfgeneration')); |
|
257 | - $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs); |
|
258 | - global $action; |
|
259 | - $reshook=$hookmanager->executeHooks('beforePDFCreation',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks |
|
260 | - |
|
261 | - $nblignes = count($object->lines); |
|
248 | + if (file_exists($dir)) |
|
249 | + { |
|
250 | + // Add pdfgeneration hook |
|
251 | + if (! is_object($hookmanager)) |
|
252 | + { |
|
253 | + include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; |
|
254 | + $hookmanager=new HookManager($this->db); |
|
255 | + } |
|
256 | + $hookmanager->initHooks(array('pdfgeneration')); |
|
257 | + $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs); |
|
258 | + global $action; |
|
259 | + $reshook=$hookmanager->executeHooks('beforePDFCreation',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks |
|
260 | + |
|
261 | + $nblignes = count($object->lines); |
|
262 | 262 | |
263 | 263 | $pdf=pdf_getInstance($this->format); |
264 | 264 | $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance |
265 | 265 | $heightforinfotot = 50; // Height reserved to output the info and total part |
266 | - $heightforfreetext= (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT)?$conf->global->MAIN_PDF_FREETEXT_HEIGHT:5); // Height reserved to output the free text on last page |
|
267 | - $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin) |
|
268 | - if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS >0) $heightforfooter+= 6; |
|
266 | + $heightforfreetext= (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT)?$conf->global->MAIN_PDF_FREETEXT_HEIGHT:5); // Height reserved to output the free text on last page |
|
267 | + $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin) |
|
268 | + if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS >0) $heightforfooter+= 6; |
|
269 | 269 | $pdf->SetAutoPageBreak(1,0); |
270 | 270 | |
271 | 271 | if (class_exists('TCPDF')) |
@@ -281,20 +281,20 @@ discard block |
||
281 | 281 | $tplidx = $pdf->importPage(1); |
282 | 282 | } |
283 | 283 | |
284 | - $pdf->Open(); |
|
285 | - $pagenb=0; |
|
286 | - $pdf->SetDrawColor(128,128,128); |
|
284 | + $pdf->Open(); |
|
285 | + $pagenb=0; |
|
286 | + $pdf->SetDrawColor(128,128,128); |
|
287 | 287 | |
288 | - $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref)); |
|
289 | - $pdf->SetSubject($outputlangs->transnoentities("Invoice")); |
|
290 | - $pdf->SetCreator("Dolibarr ".DOL_VERSION); |
|
291 | - $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs))); |
|
292 | - $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("Order")." ".$outputlangs->convToOutputCharset($object->thirdparty->name)); |
|
293 | - if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); |
|
288 | + $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref)); |
|
289 | + $pdf->SetSubject($outputlangs->transnoentities("Invoice")); |
|
290 | + $pdf->SetCreator("Dolibarr ".DOL_VERSION); |
|
291 | + $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs))); |
|
292 | + $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("Order")." ".$outputlangs->convToOutputCharset($object->thirdparty->name)); |
|
293 | + if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); |
|
294 | 294 | |
295 | - $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right |
|
295 | + $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right |
|
296 | 296 | |
297 | - // Positionne $this->atleastonediscount si on a au moins une remise |
|
297 | + // Positionne $this->atleastonediscount si on a au moins une remise |
|
298 | 298 | for ($i = 0 ; $i < $nblignes ; $i++) |
299 | 299 | { |
300 | 300 | if ($object->lines[$i]->remise_percent) |
@@ -302,755 +302,755 @@ discard block |
||
302 | 302 | $this->atleastonediscount++; |
303 | 303 | } |
304 | 304 | } |
305 | - if (empty($this->atleastonediscount) && empty($conf->global->PRODUCT_USE_UNITS)) |
|
306 | - { |
|
307 | - $this->posxpicture+=($this->postotalht - $this->posxdiscount); |
|
308 | - $this->posxtva+=($this->postotalht - $this->posxdiscount); |
|
309 | - $this->posxup+=($this->postotalht - $this->posxdiscount); |
|
310 | - $this->posxqty+=($this->postotalht - $this->posxdiscount); |
|
311 | - $this->posxdiscount+=($this->postotalht - $this->posxdiscount); |
|
312 | - //$this->postotalht; |
|
313 | - } |
|
305 | + if (empty($this->atleastonediscount) && empty($conf->global->PRODUCT_USE_UNITS)) |
|
306 | + { |
|
307 | + $this->posxpicture+=($this->postotalht - $this->posxdiscount); |
|
308 | + $this->posxtva+=($this->postotalht - $this->posxdiscount); |
|
309 | + $this->posxup+=($this->postotalht - $this->posxdiscount); |
|
310 | + $this->posxqty+=($this->postotalht - $this->posxdiscount); |
|
311 | + $this->posxdiscount+=($this->postotalht - $this->posxdiscount); |
|
312 | + //$this->postotalht; |
|
313 | + } |
|
314 | 314 | |
315 | 315 | // New page |
316 | - $pdf->AddPage(); |
|
317 | - if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
|
318 | - $pagenb++; |
|
319 | - $top_shift = $this->_pagehead($pdf, $object, 1, $outputlangs); |
|
320 | - $pdf->SetFont('','', $default_font_size - 1); |
|
321 | - $pdf->MultiCell(0, 3, ''); // Set interline to 3 |
|
322 | - $pdf->SetTextColor(0,0,0); |
|
323 | - |
|
324 | - $tab_top = 90+$top_shift; |
|
325 | - $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?42+$top_shift:10); |
|
326 | - |
|
327 | - // Incoterm |
|
328 | - if ($conf->incoterm->enabled) |
|
329 | - { |
|
330 | - $desc_incoterms = $object->getIncotermsForPDF(); |
|
331 | - if ($desc_incoterms) |
|
332 | - { |
|
333 | - $tab_top -= 2; |
|
334 | - |
|
335 | - $pdf->SetFont('','', $default_font_size - 1); |
|
336 | - $pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top-1, dol_htmlentitiesbr($desc_incoterms), 0, 1); |
|
337 | - $nexY = $pdf->GetY(); |
|
338 | - $height_incoterms=$nexY-$tab_top; |
|
339 | - |
|
340 | - // Rect prend une longueur en 3eme param |
|
341 | - $pdf->SetDrawColor(192,192,192); |
|
342 | - $pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_incoterms+1); |
|
343 | - |
|
344 | - $tab_top = $nexY+6; |
|
345 | - } |
|
346 | - } |
|
347 | - |
|
348 | - // Affiche notes |
|
349 | - if (! empty($object->note_public)) |
|
350 | - { |
|
351 | - $tab_top -= 2; |
|
352 | - |
|
353 | - $pdf->SetFont('','', $default_font_size - 1); |
|
354 | - $pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top-1, dol_htmlentitiesbr($object->note_public), 0, 1); |
|
355 | - $nexY = $pdf->GetY(); |
|
356 | - $height_note=$nexY-$tab_top; |
|
357 | - |
|
358 | - // Rect prend une longueur en 3eme param |
|
359 | - $pdf->SetDrawColor(192,192,192); |
|
360 | - $pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+1); |
|
361 | - |
|
362 | - $tab_top = $nexY+6; |
|
363 | - } |
|
364 | - |
|
365 | - $iniY = $tab_top + 7; |
|
366 | - $curY = $tab_top + 7; |
|
367 | - $nexY = $tab_top + 7; |
|
368 | - |
|
369 | - // Loop on each lines |
|
370 | - for ($i = 0 ; $i < $nblignes ; $i++) |
|
371 | - { |
|
372 | - $curY = $nexY; |
|
373 | - $pdf->SetFont('','', $default_font_size - 1); // Into loop to work with multipage |
|
374 | - $pdf->SetTextColor(0,0,0); |
|
375 | - |
|
376 | - $pdf->setTopMargin($tab_top_newpage); |
|
377 | - $pdf->setPageOrientation('', 1, $heightforfooter+$heightforfreetext+$heightforinfotot); // The only function to edit the bottom margin of current page to set it. |
|
378 | - $pageposbefore=$pdf->getPage(); |
|
379 | - |
|
380 | - // Description of product line |
|
381 | - $curX = $this->posxdesc-1; |
|
382 | - $showpricebeforepagebreak=1; |
|
383 | - |
|
384 | - $pdf->startTransaction(); |
|
385 | - pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxtva-$curX,3,$curX,$curY,$hideref,$hidedesc,1); |
|
386 | - $pageposafter=$pdf->getPage(); |
|
387 | - if ($pageposafter > $pageposbefore) // There is a pagebreak |
|
388 | - { |
|
389 | - $pdf->rollbackTransaction(true); |
|
390 | - $pageposafter=$pageposbefore; |
|
391 | - //print $pageposafter.'-'.$pageposbefore;exit; |
|
392 | - $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it. |
|
393 | - pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxtva-$curX,4,$curX,$curY,$hideref,$hidedesc,1); |
|
394 | - $posyafter=$pdf->GetY(); |
|
395 | - if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))) // There is no space left for total+free text |
|
396 | - { |
|
397 | - if ($i == ($nblignes-1)) // No more lines, and no space left to show total, so we create a new page |
|
398 | - { |
|
399 | - $pdf->AddPage('','',true); |
|
400 | - if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
|
401 | - if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); |
|
402 | - $pdf->setPage($pageposafter+1); |
|
403 | - } |
|
404 | - } |
|
405 | - else |
|
406 | - { |
|
407 | - // We found a page break |
|
408 | - $showpricebeforepagebreak=0; |
|
409 | - } |
|
410 | - } |
|
411 | - else // No pagebreak |
|
412 | - { |
|
413 | - $pdf->commitTransaction(); |
|
414 | - } |
|
415 | - |
|
416 | - $nexY = $pdf->GetY(); |
|
316 | + $pdf->AddPage(); |
|
317 | + if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
|
318 | + $pagenb++; |
|
319 | + $top_shift = $this->_pagehead($pdf, $object, 1, $outputlangs); |
|
320 | + $pdf->SetFont('','', $default_font_size - 1); |
|
321 | + $pdf->MultiCell(0, 3, ''); // Set interline to 3 |
|
322 | + $pdf->SetTextColor(0,0,0); |
|
323 | + |
|
324 | + $tab_top = 90+$top_shift; |
|
325 | + $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?42+$top_shift:10); |
|
326 | + |
|
327 | + // Incoterm |
|
328 | + if ($conf->incoterm->enabled) |
|
329 | + { |
|
330 | + $desc_incoterms = $object->getIncotermsForPDF(); |
|
331 | + if ($desc_incoterms) |
|
332 | + { |
|
333 | + $tab_top -= 2; |
|
334 | + |
|
335 | + $pdf->SetFont('','', $default_font_size - 1); |
|
336 | + $pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top-1, dol_htmlentitiesbr($desc_incoterms), 0, 1); |
|
337 | + $nexY = $pdf->GetY(); |
|
338 | + $height_incoterms=$nexY-$tab_top; |
|
339 | + |
|
340 | + // Rect prend une longueur en 3eme param |
|
341 | + $pdf->SetDrawColor(192,192,192); |
|
342 | + $pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_incoterms+1); |
|
343 | + |
|
344 | + $tab_top = $nexY+6; |
|
345 | + } |
|
346 | + } |
|
347 | + |
|
348 | + // Affiche notes |
|
349 | + if (! empty($object->note_public)) |
|
350 | + { |
|
351 | + $tab_top -= 2; |
|
352 | + |
|
353 | + $pdf->SetFont('','', $default_font_size - 1); |
|
354 | + $pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top-1, dol_htmlentitiesbr($object->note_public), 0, 1); |
|
355 | + $nexY = $pdf->GetY(); |
|
356 | + $height_note=$nexY-$tab_top; |
|
357 | + |
|
358 | + // Rect prend une longueur en 3eme param |
|
359 | + $pdf->SetDrawColor(192,192,192); |
|
360 | + $pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+1); |
|
361 | + |
|
362 | + $tab_top = $nexY+6; |
|
363 | + } |
|
364 | + |
|
365 | + $iniY = $tab_top + 7; |
|
366 | + $curY = $tab_top + 7; |
|
367 | + $nexY = $tab_top + 7; |
|
368 | + |
|
369 | + // Loop on each lines |
|
370 | + for ($i = 0 ; $i < $nblignes ; $i++) |
|
371 | + { |
|
372 | + $curY = $nexY; |
|
373 | + $pdf->SetFont('','', $default_font_size - 1); // Into loop to work with multipage |
|
374 | + $pdf->SetTextColor(0,0,0); |
|
375 | + |
|
376 | + $pdf->setTopMargin($tab_top_newpage); |
|
377 | + $pdf->setPageOrientation('', 1, $heightforfooter+$heightforfreetext+$heightforinfotot); // The only function to edit the bottom margin of current page to set it. |
|
378 | + $pageposbefore=$pdf->getPage(); |
|
379 | + |
|
380 | + // Description of product line |
|
381 | + $curX = $this->posxdesc-1; |
|
382 | + $showpricebeforepagebreak=1; |
|
383 | + |
|
384 | + $pdf->startTransaction(); |
|
385 | + pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxtva-$curX,3,$curX,$curY,$hideref,$hidedesc,1); |
|
417 | 386 | $pageposafter=$pdf->getPage(); |
418 | - $pdf->setPage($pageposbefore); |
|
419 | - $pdf->setTopMargin($this->marge_haute); |
|
420 | - $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. |
|
387 | + if ($pageposafter > $pageposbefore) // There is a pagebreak |
|
388 | + { |
|
389 | + $pdf->rollbackTransaction(true); |
|
390 | + $pageposafter=$pageposbefore; |
|
391 | + //print $pageposafter.'-'.$pageposbefore;exit; |
|
392 | + $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it. |
|
393 | + pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxtva-$curX,4,$curX,$curY,$hideref,$hidedesc,1); |
|
394 | + $posyafter=$pdf->GetY(); |
|
395 | + if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))) // There is no space left for total+free text |
|
396 | + { |
|
397 | + if ($i == ($nblignes-1)) // No more lines, and no space left to show total, so we create a new page |
|
398 | + { |
|
399 | + $pdf->AddPage('','',true); |
|
400 | + if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
|
401 | + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); |
|
402 | + $pdf->setPage($pageposafter+1); |
|
403 | + } |
|
404 | + } |
|
405 | + else |
|
406 | + { |
|
407 | + // We found a page break |
|
408 | + $showpricebeforepagebreak=0; |
|
409 | + } |
|
410 | + } |
|
411 | + else // No pagebreak |
|
412 | + { |
|
413 | + $pdf->commitTransaction(); |
|
414 | + } |
|
421 | 415 | |
422 | - // We suppose that a too long description is moved completely on next page |
|
423 | - if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) { |
|
424 | - $pdf->setPage($pageposafter); $curY = $tab_top_newpage; |
|
425 | - } |
|
416 | + $nexY = $pdf->GetY(); |
|
417 | + $pageposafter=$pdf->getPage(); |
|
418 | + $pdf->setPage($pageposbefore); |
|
419 | + $pdf->setTopMargin($this->marge_haute); |
|
420 | + $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. |
|
421 | + |
|
422 | + // We suppose that a too long description is moved completely on next page |
|
423 | + if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) { |
|
424 | + $pdf->setPage($pageposafter); $curY = $tab_top_newpage; |
|
425 | + } |
|
426 | 426 | |
427 | - $pdf->SetFont('','', $default_font_size - 1); // On repositionne la police par defaut |
|
427 | + $pdf->SetFont('','', $default_font_size - 1); // On repositionne la police par defaut |
|
428 | 428 | |
429 | - // VAT Rate |
|
429 | + // VAT Rate |
|
430 | 430 | if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) |
431 | 431 | { |
432 | - $vat_rate = pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails); |
|
432 | + $vat_rate = pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails); |
|
433 | 433 | $pdf->SetXY($this->posxtva, $curY); |
434 | - $pdf->MultiCell($this->posxup-$this->posxtva-1, 3, $vat_rate, 0, 'R'); |
|
434 | + $pdf->MultiCell($this->posxup-$this->posxtva-1, 3, $vat_rate, 0, 'R'); |
|
435 | 435 | } |
436 | 436 | |
437 | - // Unit price before discount |
|
438 | - $up_excl_tax = pdf_getlineupexcltax($object, $i, $outputlangs, $hidedetails); |
|
439 | - $pdf->SetXY($this->posxup, $curY); |
|
440 | - $pdf->MultiCell($this->posxqty-$this->posxup-0.8, 3, $up_excl_tax, 0, 'R', 0); |
|
441 | - |
|
442 | - // Unit price before discount |
|
443 | - $up_excl_tax = pdf_getlineupexcltax($object, $i, $outputlangs, $hidedetails); |
|
444 | - $pdf->SetXY($this->posxup, $curY); |
|
445 | - $pdf->MultiCell($this->posxqty-$this->posxup-0.8, 3, $up_excl_tax, 0, 'R', 0); |
|
446 | - |
|
447 | - // Quantity |
|
448 | - $qty = pdf_getlineqty($object, $i, $outputlangs, $hidedetails); |
|
449 | - $pdf->SetXY($this->posxqty, $curY); |
|
450 | - // Enough for 6 chars |
|
451 | - if($conf->global->PRODUCT_USE_UNITS) |
|
452 | - { |
|
453 | - $pdf->MultiCell($this->posxunit-$this->posxqty-0.8, 4, $qty, 0, 'R'); |
|
454 | - } |
|
455 | - else |
|
456 | - { |
|
457 | - $pdf->MultiCell($this->posxdiscount-$this->posxqty-0.8, 4, $qty, 0, 'R'); |
|
458 | - } |
|
459 | - |
|
460 | - // Unit |
|
461 | - if($conf->global->PRODUCT_USE_UNITS) |
|
462 | - { |
|
463 | - $unit = pdf_getlineunit($object, $i, $outputlangs, $hidedetails, $hookmanager); |
|
464 | - $pdf->SetXY($this->posxunit, $curY); |
|
465 | - $pdf->MultiCell($this->posxdiscount-$this->posxunit-0.8, 4, $unit, 0, 'L'); |
|
466 | - } |
|
467 | - |
|
468 | - // Discount on line |
|
469 | - $pdf->SetXY($this->posxdiscount, $curY); |
|
470 | - if ($object->lines[$i]->remise_percent) |
|
471 | - { |
|
472 | - $remise_percent = pdf_getlineremisepercent($object, $i, $outputlangs, $hidedetails); |
|
473 | - $pdf->MultiCell($this->postotalht-$this->posxdiscount-1, 3, $remise_percent."%", 0, 'R'); |
|
474 | - } |
|
475 | - |
|
476 | - // Total HT line |
|
437 | + // Unit price before discount |
|
438 | + $up_excl_tax = pdf_getlineupexcltax($object, $i, $outputlangs, $hidedetails); |
|
439 | + $pdf->SetXY($this->posxup, $curY); |
|
440 | + $pdf->MultiCell($this->posxqty-$this->posxup-0.8, 3, $up_excl_tax, 0, 'R', 0); |
|
441 | + |
|
442 | + // Unit price before discount |
|
443 | + $up_excl_tax = pdf_getlineupexcltax($object, $i, $outputlangs, $hidedetails); |
|
444 | + $pdf->SetXY($this->posxup, $curY); |
|
445 | + $pdf->MultiCell($this->posxqty-$this->posxup-0.8, 3, $up_excl_tax, 0, 'R', 0); |
|
446 | + |
|
447 | + // Quantity |
|
448 | + $qty = pdf_getlineqty($object, $i, $outputlangs, $hidedetails); |
|
449 | + $pdf->SetXY($this->posxqty, $curY); |
|
450 | + // Enough for 6 chars |
|
451 | + if($conf->global->PRODUCT_USE_UNITS) |
|
452 | + { |
|
453 | + $pdf->MultiCell($this->posxunit-$this->posxqty-0.8, 4, $qty, 0, 'R'); |
|
454 | + } |
|
455 | + else |
|
456 | + { |
|
457 | + $pdf->MultiCell($this->posxdiscount-$this->posxqty-0.8, 4, $qty, 0, 'R'); |
|
458 | + } |
|
459 | + |
|
460 | + // Unit |
|
461 | + if($conf->global->PRODUCT_USE_UNITS) |
|
462 | + { |
|
463 | + $unit = pdf_getlineunit($object, $i, $outputlangs, $hidedetails, $hookmanager); |
|
464 | + $pdf->SetXY($this->posxunit, $curY); |
|
465 | + $pdf->MultiCell($this->posxdiscount-$this->posxunit-0.8, 4, $unit, 0, 'L'); |
|
466 | + } |
|
467 | + |
|
468 | + // Discount on line |
|
469 | + $pdf->SetXY($this->posxdiscount, $curY); |
|
470 | + if ($object->lines[$i]->remise_percent) |
|
471 | + { |
|
472 | + $remise_percent = pdf_getlineremisepercent($object, $i, $outputlangs, $hidedetails); |
|
473 | + $pdf->MultiCell($this->postotalht-$this->posxdiscount-1, 3, $remise_percent."%", 0, 'R'); |
|
474 | + } |
|
475 | + |
|
476 | + // Total HT line |
|
477 | 477 | $total_excl_tax = pdf_getlinetotalexcltax($object, $i, $outputlangs); |
478 | 478 | $pdf->SetXY($this->postotalht, $curY); |
479 | 479 | $pdf->MultiCell($this->page_largeur-$this->marge_droite-$this->postotalht, 3, $total_excl_tax, 0, 'R', 0); |
480 | 480 | |
481 | - // Collecte des totaux par valeur de tva dans $this->tva["taux"]=total_tva |
|
482 | - if ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) $tvaligne=$object->lines[$i]->multicurrency_total_tva; |
|
483 | - else $tvaligne=$object->lines[$i]->total_tva; |
|
484 | - |
|
485 | - $localtax1ligne=$object->lines[$i]->total_localtax1; |
|
486 | - $localtax2ligne=$object->lines[$i]->total_localtax2; |
|
487 | - |
|
488 | - if (! empty($object->remise_percent)) $tvaligne-=($tvaligne*$object->remise_percent)/100; |
|
489 | - |
|
490 | - $vatrate=(string) $object->lines[$i]->tva_tx; |
|
491 | - $localtax1rate=(string) $object->lines[$i]->localtax1_tx; |
|
492 | - $localtax2rate=(string) $object->lines[$i]->localtax2_tx; |
|
493 | - |
|
494 | - if (($object->lines[$i]->info_bits & 0x01) == 0x01) $vatrate.='*'; |
|
495 | - if (empty($this->tva[$vatrate])) $this->tva[$vatrate]=0; |
|
496 | - if (empty($this->localtax1[$localtax1rate])) $this->localtax1[$localtax1rate]=0; |
|
497 | - if (empty($this->localtax2[$localtax2rate])) $this->localtax2[$localtax2rate]=0; |
|
498 | - $this->tva[$vatrate] += $tvaligne; |
|
499 | - $this->localtax1[$localtax1rate]+=$localtax1ligne; |
|
500 | - $this->localtax2[$localtax2rate]+=$localtax2ligne; |
|
501 | - |
|
502 | - // Add line |
|
503 | - if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1)) |
|
504 | - { |
|
505 | - $pdf->setPage($pageposafter); |
|
506 | - $pdf->SetLineStyle(array('dash'=>'1,1','color'=>array(80,80,80))); |
|
507 | - //$pdf->SetDrawColor(190,190,200); |
|
508 | - $pdf->line($this->marge_gauche, $nexY+1, $this->page_largeur - $this->marge_droite, $nexY+1); |
|
509 | - $pdf->SetLineStyle(array('dash'=>0)); |
|
510 | - } |
|
511 | - |
|
512 | - $nexY+=2; // Passe espace entre les lignes |
|
513 | - |
|
514 | - // Detect if some page were added automatically and output _tableau for past pages |
|
515 | - while ($pagenb < $pageposafter) |
|
516 | - { |
|
517 | - $pdf->setPage($pagenb); |
|
518 | - if ($pagenb == 1) |
|
519 | - { |
|
520 | - $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1, $object->multicurrency_code); |
|
521 | - } |
|
522 | - else |
|
523 | - { |
|
524 | - $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code); |
|
525 | - } |
|
526 | - $this->_pagefoot($pdf,$object,$outputlangs,1); |
|
527 | - $pagenb++; |
|
528 | - $pdf->setPage($pagenb); |
|
529 | - $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. |
|
530 | - if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); |
|
531 | - } |
|
532 | - if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak) |
|
533 | - { |
|
534 | - if ($pagenb == 1) |
|
535 | - { |
|
536 | - $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1, $object->multicurrency_code); |
|
537 | - } |
|
538 | - else |
|
539 | - { |
|
540 | - $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code); |
|
541 | - } |
|
542 | - $this->_pagefoot($pdf,$object,$outputlangs,1); |
|
543 | - // New page |
|
544 | - $pdf->AddPage(); |
|
545 | - if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
|
546 | - $pagenb++; |
|
547 | - if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); |
|
548 | - } |
|
549 | - } |
|
550 | - |
|
551 | - // Show square |
|
552 | - if ($pagenb == 1) |
|
553 | - { |
|
554 | - $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0, $object->multicurrency_code); |
|
555 | - $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; |
|
556 | - } |
|
557 | - else |
|
558 | - { |
|
559 | - $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0, $object->multicurrency_code); |
|
560 | - $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; |
|
561 | - } |
|
562 | - |
|
563 | - // Affiche zone totaux |
|
564 | - $posy=$this->_tableau_tot($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs); |
|
565 | - |
|
566 | - $amount_credit_notes_included=0; |
|
567 | - $amount_deposits_included=0; |
|
568 | - |
|
569 | - if ($deja_regle || $amount_credit_notes_included || $amount_deposits_included) |
|
570 | - { |
|
571 | - $posy=$this->_tableau_versements($pdf, $object, $posy, $outputlangs); |
|
572 | - } |
|
573 | - |
|
574 | - // Pied de page |
|
575 | - $this->_pagefoot($pdf, $object, $outputlangs); |
|
576 | - if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages(); |
|
577 | - |
|
578 | - $pdf->Close(); |
|
579 | - |
|
580 | - $pdf->Output($file,'F'); |
|
581 | - |
|
582 | - // Add pdfgeneration hook |
|
583 | - $hookmanager->initHooks(array('pdfgeneration')); |
|
584 | - $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs); |
|
585 | - global $action; |
|
586 | - $reshook=$hookmanager->executeHooks('afterPDFCreation',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks |
|
587 | - |
|
588 | - if (! empty($conf->global->MAIN_UMASK)) |
|
589 | - @chmod($file, octdec($conf->global->MAIN_UMASK)); |
|
590 | - |
|
591 | - $this->result = array('fullpath'=>$file); |
|
592 | - |
|
593 | - return 1; // Pas d'erreur |
|
594 | - } |
|
595 | - else |
|
596 | - { |
|
597 | - $this->error=$langs->trans("ErrorCanNotCreateDir",$dir); |
|
598 | - return 0; |
|
599 | - } |
|
600 | - } |
|
601 | - else |
|
602 | - { |
|
603 | - $this->error=$langs->trans("ErrorConstantNotDefined","SUPPLIER_OUTPUTDIR"); |
|
604 | - return 0; |
|
605 | - } |
|
606 | - } |
|
481 | + // Collecte des totaux par valeur de tva dans $this->tva["taux"]=total_tva |
|
482 | + if ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) $tvaligne=$object->lines[$i]->multicurrency_total_tva; |
|
483 | + else $tvaligne=$object->lines[$i]->total_tva; |
|
484 | + |
|
485 | + $localtax1ligne=$object->lines[$i]->total_localtax1; |
|
486 | + $localtax2ligne=$object->lines[$i]->total_localtax2; |
|
487 | + |
|
488 | + if (! empty($object->remise_percent)) $tvaligne-=($tvaligne*$object->remise_percent)/100; |
|
489 | + |
|
490 | + $vatrate=(string) $object->lines[$i]->tva_tx; |
|
491 | + $localtax1rate=(string) $object->lines[$i]->localtax1_tx; |
|
492 | + $localtax2rate=(string) $object->lines[$i]->localtax2_tx; |
|
493 | + |
|
494 | + if (($object->lines[$i]->info_bits & 0x01) == 0x01) $vatrate.='*'; |
|
495 | + if (empty($this->tva[$vatrate])) $this->tva[$vatrate]=0; |
|
496 | + if (empty($this->localtax1[$localtax1rate])) $this->localtax1[$localtax1rate]=0; |
|
497 | + if (empty($this->localtax2[$localtax2rate])) $this->localtax2[$localtax2rate]=0; |
|
498 | + $this->tva[$vatrate] += $tvaligne; |
|
499 | + $this->localtax1[$localtax1rate]+=$localtax1ligne; |
|
500 | + $this->localtax2[$localtax2rate]+=$localtax2ligne; |
|
501 | + |
|
502 | + // Add line |
|
503 | + if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1)) |
|
504 | + { |
|
505 | + $pdf->setPage($pageposafter); |
|
506 | + $pdf->SetLineStyle(array('dash'=>'1,1','color'=>array(80,80,80))); |
|
507 | + //$pdf->SetDrawColor(190,190,200); |
|
508 | + $pdf->line($this->marge_gauche, $nexY+1, $this->page_largeur - $this->marge_droite, $nexY+1); |
|
509 | + $pdf->SetLineStyle(array('dash'=>0)); |
|
510 | + } |
|
511 | + |
|
512 | + $nexY+=2; // Passe espace entre les lignes |
|
513 | + |
|
514 | + // Detect if some page were added automatically and output _tableau for past pages |
|
515 | + while ($pagenb < $pageposafter) |
|
516 | + { |
|
517 | + $pdf->setPage($pagenb); |
|
518 | + if ($pagenb == 1) |
|
519 | + { |
|
520 | + $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1, $object->multicurrency_code); |
|
521 | + } |
|
522 | + else |
|
523 | + { |
|
524 | + $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code); |
|
525 | + } |
|
526 | + $this->_pagefoot($pdf,$object,$outputlangs,1); |
|
527 | + $pagenb++; |
|
528 | + $pdf->setPage($pagenb); |
|
529 | + $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. |
|
530 | + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); |
|
531 | + } |
|
532 | + if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak) |
|
533 | + { |
|
534 | + if ($pagenb == 1) |
|
535 | + { |
|
536 | + $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1, $object->multicurrency_code); |
|
537 | + } |
|
538 | + else |
|
539 | + { |
|
540 | + $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code); |
|
541 | + } |
|
542 | + $this->_pagefoot($pdf,$object,$outputlangs,1); |
|
543 | + // New page |
|
544 | + $pdf->AddPage(); |
|
545 | + if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
|
546 | + $pagenb++; |
|
547 | + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); |
|
548 | + } |
|
549 | + } |
|
550 | + |
|
551 | + // Show square |
|
552 | + if ($pagenb == 1) |
|
553 | + { |
|
554 | + $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0, $object->multicurrency_code); |
|
555 | + $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; |
|
556 | + } |
|
557 | + else |
|
558 | + { |
|
559 | + $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0, $object->multicurrency_code); |
|
560 | + $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; |
|
561 | + } |
|
562 | + |
|
563 | + // Affiche zone totaux |
|
564 | + $posy=$this->_tableau_tot($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs); |
|
565 | + |
|
566 | + $amount_credit_notes_included=0; |
|
567 | + $amount_deposits_included=0; |
|
568 | + |
|
569 | + if ($deja_regle || $amount_credit_notes_included || $amount_deposits_included) |
|
570 | + { |
|
571 | + $posy=$this->_tableau_versements($pdf, $object, $posy, $outputlangs); |
|
572 | + } |
|
573 | + |
|
574 | + // Pied de page |
|
575 | + $this->_pagefoot($pdf, $object, $outputlangs); |
|
576 | + if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages(); |
|
577 | + |
|
578 | + $pdf->Close(); |
|
579 | + |
|
580 | + $pdf->Output($file,'F'); |
|
581 | + |
|
582 | + // Add pdfgeneration hook |
|
583 | + $hookmanager->initHooks(array('pdfgeneration')); |
|
584 | + $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs); |
|
585 | + global $action; |
|
586 | + $reshook=$hookmanager->executeHooks('afterPDFCreation',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks |
|
587 | + |
|
588 | + if (! empty($conf->global->MAIN_UMASK)) |
|
589 | + @chmod($file, octdec($conf->global->MAIN_UMASK)); |
|
590 | + |
|
591 | + $this->result = array('fullpath'=>$file); |
|
592 | + |
|
593 | + return 1; // Pas d'erreur |
|
594 | + } |
|
595 | + else |
|
596 | + { |
|
597 | + $this->error=$langs->trans("ErrorCanNotCreateDir",$dir); |
|
598 | + return 0; |
|
599 | + } |
|
600 | + } |
|
601 | + else |
|
602 | + { |
|
603 | + $this->error=$langs->trans("ErrorConstantNotDefined","SUPPLIER_OUTPUTDIR"); |
|
604 | + return 0; |
|
605 | + } |
|
606 | + } |
|
607 | 607 | |
608 | 608 | // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps |
609 | - /** |
|
610 | - * Show total to pay |
|
611 | - * |
|
612 | - * @param PDF $pdf Object PDF |
|
613 | - * @param Facture $object Object invoice |
|
614 | - * @param int $deja_regle Montant deja regle |
|
615 | - * @param int $posy Position depart |
|
616 | - * @param Translate $outputlangs Objet langs |
|
617 | - * @return int Position pour suite |
|
618 | - */ |
|
619 | - function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs) |
|
620 | - { |
|
609 | + /** |
|
610 | + * Show total to pay |
|
611 | + * |
|
612 | + * @param PDF $pdf Object PDF |
|
613 | + * @param Facture $object Object invoice |
|
614 | + * @param int $deja_regle Montant deja regle |
|
615 | + * @param int $posy Position depart |
|
616 | + * @param Translate $outputlangs Objet langs |
|
617 | + * @return int Position pour suite |
|
618 | + */ |
|
619 | + function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs) |
|
620 | + { |
|
621 | 621 | // phpcs:enable |
622 | - global $conf,$mysoc; |
|
622 | + global $conf,$mysoc; |
|
623 | 623 | |
624 | 624 | $default_font_size = pdf_getPDFFontSize($outputlangs); |
625 | 625 | |
626 | 626 | $tab2_top = $posy; |
627 | - $tab2_hl = 4; |
|
628 | - $pdf->SetFont('','', $default_font_size - 1); |
|
627 | + $tab2_hl = 4; |
|
628 | + $pdf->SetFont('','', $default_font_size - 1); |
|
629 | 629 | |
630 | - $pdf->SetXY($this->marge_gauche, $tab2_top + 0); |
|
631 | - // If France, show VAT mention if not applicable |
|
632 | - if ($this->emetteur->country_code == 'FR' && $this->franchise == 1) |
|
633 | - { |
|
634 | - $pdf->MultiCell(100, $tab2_hl, $outputlangs->transnoentities("VATIsNotUsedForInvoice"), 0, 'L', 0); |
|
635 | - } |
|
630 | + $pdf->SetXY($this->marge_gauche, $tab2_top + 0); |
|
631 | + // If France, show VAT mention if not applicable |
|
632 | + if ($this->emetteur->country_code == 'FR' && $this->franchise == 1) |
|
633 | + { |
|
634 | + $pdf->MultiCell(100, $tab2_hl, $outputlangs->transnoentities("VATIsNotUsedForInvoice"), 0, 'L', 0); |
|
635 | + } |
|
636 | 636 | |
637 | - // Tableau total |
|
638 | - $col1x = 120; $col2x = 170; |
|
639 | - if ($this->page_largeur < 210) // To work with US executive format |
|
640 | - { |
|
641 | - $col2x-=20; |
|
642 | - } |
|
643 | - $largcol2 = ($this->page_largeur - $this->marge_droite - $col2x); |
|
637 | + // Tableau total |
|
638 | + $col1x = 120; $col2x = 170; |
|
639 | + if ($this->page_largeur < 210) // To work with US executive format |
|
640 | + { |
|
641 | + $col2x-=20; |
|
642 | + } |
|
643 | + $largcol2 = ($this->page_largeur - $this->marge_droite - $col2x); |
|
644 | 644 | |
645 | - $index=0; |
|
645 | + $index=0; |
|
646 | 646 | |
647 | - // Total HT |
|
648 | - $pdf->SetFillColor(255,255,255); |
|
649 | - $pdf->SetXY($col1x, $tab2_top + 0); |
|
650 | - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT"), 0, 'L', 1); |
|
647 | + // Total HT |
|
648 | + $pdf->SetFillColor(255,255,255); |
|
649 | + $pdf->SetXY($col1x, $tab2_top + 0); |
|
650 | + $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT"), 0, 'L', 1); |
|
651 | 651 | |
652 | - $total_ht = (($conf->multicurrency->enabled && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ht : $object->total_ht); |
|
653 | - $pdf->SetXY($col2x, $tab2_top + 0); |
|
654 | - $pdf->MultiCell($largcol2, $tab2_hl, price($total_ht + $object->remise), 0, 'R', 1); |
|
652 | + $total_ht = (($conf->multicurrency->enabled && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ht : $object->total_ht); |
|
653 | + $pdf->SetXY($col2x, $tab2_top + 0); |
|
654 | + $pdf->MultiCell($largcol2, $tab2_hl, price($total_ht + $object->remise), 0, 'R', 1); |
|
655 | 655 | |
656 | - // Show VAT by rates and total |
|
657 | - $pdf->SetFillColor(248,248,248); |
|
656 | + // Show VAT by rates and total |
|
657 | + $pdf->SetFillColor(248,248,248); |
|
658 | 658 | |
659 | - foreach( $this->tva as $tvakey => $tvaval ) |
|
660 | - { |
|
661 | - if ($tvakey > 0) // On affiche pas taux 0 |
|
662 | - { |
|
663 | - $this->atleastoneratenotnull++; |
|
659 | + foreach( $this->tva as $tvakey => $tvaval ) |
|
660 | + { |
|
661 | + if ($tvakey > 0) // On affiche pas taux 0 |
|
662 | + { |
|
663 | + $this->atleastoneratenotnull++; |
|
664 | 664 | |
665 | - $index++; |
|
666 | - $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); |
|
665 | + $index++; |
|
666 | + $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); |
|
667 | 667 | |
668 | - $tvacompl=''; |
|
668 | + $tvacompl=''; |
|
669 | 669 | |
670 | - if (preg_match('/\*/',$tvakey)) |
|
671 | - { |
|
672 | - $tvakey=str_replace('*','',$tvakey); |
|
673 | - $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; |
|
674 | - } |
|
670 | + if (preg_match('/\*/',$tvakey)) |
|
671 | + { |
|
672 | + $tvakey=str_replace('*','',$tvakey); |
|
673 | + $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; |
|
674 | + } |
|
675 | 675 | |
676 | - $totalvat =$outputlangs->transcountrynoentities("TotalVAT",$mysoc->country_code).' '; |
|
677 | - $totalvat.=vatrate($tvakey,1).$tvacompl; |
|
678 | - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1); |
|
676 | + $totalvat =$outputlangs->transcountrynoentities("TotalVAT",$mysoc->country_code).' '; |
|
677 | + $totalvat.=vatrate($tvakey,1).$tvacompl; |
|
678 | + $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1); |
|
679 | 679 | |
680 | - $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); |
|
681 | - $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval), 0, 'R', 1); |
|
682 | - } |
|
683 | - } |
|
684 | - if (! $this->atleastoneratenotnull) // If no vat at all |
|
685 | - { |
|
686 | - $index++; |
|
687 | - $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); |
|
688 | - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transcountrynoentities("TotalVAT", $mysoc->country_code), 0, 'L', 1); |
|
689 | - $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); |
|
690 | - $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_tva), 0, 'R', 1); |
|
691 | - |
|
692 | - // Total LocalTax1 |
|
693 | - if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on' && $object->total_localtax1>0) |
|
694 | - { |
|
695 | - $index++; |
|
696 | - $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); |
|
697 | - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transcountrynoentities("TotalLT1",$mysoc->country_code), 0, 'L', 1); |
|
698 | - $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); |
|
699 | - $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_localtax1), 0, 'R', 1); |
|
700 | - } |
|
680 | + $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); |
|
681 | + $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval), 0, 'R', 1); |
|
682 | + } |
|
683 | + } |
|
684 | + if (! $this->atleastoneratenotnull) // If no vat at all |
|
685 | + { |
|
686 | + $index++; |
|
687 | + $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); |
|
688 | + $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transcountrynoentities("TotalVAT", $mysoc->country_code), 0, 'L', 1); |
|
689 | + $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); |
|
690 | + $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_tva), 0, 'R', 1); |
|
691 | + |
|
692 | + // Total LocalTax1 |
|
693 | + if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on' && $object->total_localtax1>0) |
|
694 | + { |
|
695 | + $index++; |
|
696 | + $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); |
|
697 | + $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transcountrynoentities("TotalLT1",$mysoc->country_code), 0, 'L', 1); |
|
698 | + $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); |
|
699 | + $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_localtax1), 0, 'R', 1); |
|
700 | + } |
|
701 | + |
|
702 | + // Total LocalTax2 |
|
703 | + if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on' && $object->total_localtax2>0) |
|
704 | + { |
|
705 | + $index++; |
|
706 | + $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); |
|
707 | + $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transcountrynoentities("TotalLT2",$mysoc->country_code), 0, 'L', 1); |
|
708 | + $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); |
|
709 | + $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_localtax2), 0, 'R', 1); |
|
710 | + } |
|
711 | + } |
|
712 | + else |
|
713 | + { |
|
714 | + //if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on') |
|
715 | + //{ |
|
716 | + //Local tax 1 |
|
717 | + foreach( $this->localtax1 as $tvakey => $tvaval ) |
|
718 | + { |
|
719 | + if ($tvakey != 0) // On affiche pas taux 0 |
|
720 | + { |
|
721 | + //$this->atleastoneratenotnull++; |
|
722 | + |
|
723 | + $index++; |
|
724 | + $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); |
|
725 | + |
|
726 | + $tvacompl=''; |
|
727 | + if (preg_match('/\*/',$tvakey)) |
|
728 | + { |
|
729 | + $tvakey=str_replace('*','',$tvakey); |
|
730 | + $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; |
|
731 | + } |
|
732 | + $totalvat = $outputlangs->transcountrynoentities("TotalLT1",$mysoc->country_code).' '; |
|
733 | + $totalvat.= vatrate(abs($tvakey),1).$tvacompl; |
|
734 | + $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1); |
|
735 | + |
|
736 | + $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); |
|
737 | + $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval), 0, 'R', 1); |
|
738 | + } |
|
739 | + } |
|
740 | + //} |
|
701 | 741 | |
702 | - // Total LocalTax2 |
|
703 | - if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on' && $object->total_localtax2>0) |
|
704 | - { |
|
705 | - $index++; |
|
706 | - $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); |
|
707 | - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transcountrynoentities("TotalLT2",$mysoc->country_code), 0, 'L', 1); |
|
708 | - $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); |
|
709 | - $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_localtax2), 0, 'R', 1); |
|
710 | - } |
|
711 | - } |
|
712 | - else |
|
713 | - { |
|
714 | - //if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on') |
|
715 | - //{ |
|
716 | - //Local tax 1 |
|
717 | - foreach( $this->localtax1 as $tvakey => $tvaval ) |
|
718 | - { |
|
719 | - if ($tvakey != 0) // On affiche pas taux 0 |
|
720 | - { |
|
721 | - //$this->atleastoneratenotnull++; |
|
722 | - |
|
723 | - $index++; |
|
724 | - $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); |
|
725 | - |
|
726 | - $tvacompl=''; |
|
727 | - if (preg_match('/\*/',$tvakey)) |
|
728 | - { |
|
729 | - $tvakey=str_replace('*','',$tvakey); |
|
730 | - $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; |
|
731 | - } |
|
732 | - $totalvat = $outputlangs->transcountrynoentities("TotalLT1",$mysoc->country_code).' '; |
|
733 | - $totalvat.= vatrate(abs($tvakey),1).$tvacompl; |
|
734 | - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1); |
|
735 | - |
|
736 | - $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); |
|
737 | - $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval), 0, 'R', 1); |
|
738 | - } |
|
739 | - } |
|
740 | - //} |
|
741 | - |
|
742 | - //if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on') |
|
743 | - //{ |
|
744 | - //Local tax 2 |
|
745 | - foreach( $this->localtax2 as $tvakey => $tvaval ) |
|
746 | - { |
|
747 | - if ($tvakey != 0) // On affiche pas taux 0 |
|
748 | - { |
|
749 | - //$this->atleastoneratenotnull++; |
|
750 | - |
|
751 | - $index++; |
|
752 | - $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); |
|
753 | - |
|
754 | - $tvacompl=''; |
|
755 | - if (preg_match('/\*/',$tvakey)) |
|
756 | - { |
|
757 | - $tvakey=str_replace('*','',$tvakey); |
|
758 | - $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; |
|
759 | - } |
|
760 | - $totalvat = $outputlangs->transcountrynoentities("TotalLT2",$mysoc->country_code).' '; |
|
761 | - $totalvat.= vatrate(abs($tvakey),1).$tvacompl; |
|
762 | - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1); |
|
763 | - |
|
764 | - $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); |
|
765 | - $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval), 0, 'R', 1); |
|
766 | - } |
|
767 | - } |
|
768 | - //} |
|
769 | - } |
|
742 | + //if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on') |
|
743 | + //{ |
|
744 | + //Local tax 2 |
|
745 | + foreach( $this->localtax2 as $tvakey => $tvaval ) |
|
746 | + { |
|
747 | + if ($tvakey != 0) // On affiche pas taux 0 |
|
748 | + { |
|
749 | + //$this->atleastoneratenotnull++; |
|
750 | + |
|
751 | + $index++; |
|
752 | + $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); |
|
753 | + |
|
754 | + $tvacompl=''; |
|
755 | + if (preg_match('/\*/',$tvakey)) |
|
756 | + { |
|
757 | + $tvakey=str_replace('*','',$tvakey); |
|
758 | + $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; |
|
759 | + } |
|
760 | + $totalvat = $outputlangs->transcountrynoentities("TotalLT2",$mysoc->country_code).' '; |
|
761 | + $totalvat.= vatrate(abs($tvakey),1).$tvacompl; |
|
762 | + $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1); |
|
763 | + |
|
764 | + $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); |
|
765 | + $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval), 0, 'R', 1); |
|
766 | + } |
|
767 | + } |
|
768 | + //} |
|
769 | + } |
|
770 | 770 | |
771 | - $useborder=0; |
|
771 | + $useborder=0; |
|
772 | 772 | |
773 | - // Total TTC |
|
774 | - $index++; |
|
775 | - $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); |
|
776 | - $pdf->SetTextColor(0,0,60); |
|
777 | - $pdf->SetFillColor(224,224,224); |
|
778 | - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC"), $useborder, 'L', 1); |
|
773 | + // Total TTC |
|
774 | + $index++; |
|
775 | + $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); |
|
776 | + $pdf->SetTextColor(0,0,60); |
|
777 | + $pdf->SetFillColor(224,224,224); |
|
778 | + $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC"), $useborder, 'L', 1); |
|
779 | 779 | |
780 | - $total_ttc = ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ttc : $object->total_ttc; |
|
781 | - $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); |
|
782 | - $pdf->MultiCell($largcol2, $tab2_hl, price($total_ttc), $useborder, 'R', 1); |
|
780 | + $total_ttc = ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ttc : $object->total_ttc; |
|
781 | + $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); |
|
782 | + $pdf->MultiCell($largcol2, $tab2_hl, price($total_ttc), $useborder, 'R', 1); |
|
783 | 783 | |
784 | - $creditnoteamount=0; |
|
785 | - $depositsamount=0; |
|
786 | - //$creditnoteamount=$object->getSumCreditNotesUsed(); |
|
787 | - //$depositsamount=$object->getSumDepositsUsed(); |
|
788 | - //print "x".$creditnoteamount."-".$depositsamount;exit; |
|
789 | - $resteapayer = price2num($total_ttc - $deja_regle - $creditnoteamount - $depositsamount, 'MT'); |
|
790 | - if (! empty($object->paye)) $resteapayer=0; |
|
784 | + $creditnoteamount=0; |
|
785 | + $depositsamount=0; |
|
786 | + //$creditnoteamount=$object->getSumCreditNotesUsed(); |
|
787 | + //$depositsamount=$object->getSumDepositsUsed(); |
|
788 | + //print "x".$creditnoteamount."-".$depositsamount;exit; |
|
789 | + $resteapayer = price2num($total_ttc - $deja_regle - $creditnoteamount - $depositsamount, 'MT'); |
|
790 | + if (! empty($object->paye)) $resteapayer=0; |
|
791 | 791 | |
792 | - if ($deja_regle > 0) |
|
793 | - { |
|
794 | - $index++; |
|
792 | + if ($deja_regle > 0) |
|
793 | + { |
|
794 | + $index++; |
|
795 | 795 | |
796 | - $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); |
|
797 | - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("AlreadyPaid"), 0, 'L', 0); |
|
796 | + $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); |
|
797 | + $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("AlreadyPaid"), 0, 'L', 0); |
|
798 | 798 | |
799 | - $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); |
|
800 | - $pdf->MultiCell($largcol2, $tab2_hl, price($deja_regle), 0, 'R', 0); |
|
799 | + $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); |
|
800 | + $pdf->MultiCell($largcol2, $tab2_hl, price($deja_regle), 0, 'R', 0); |
|
801 | 801 | |
802 | - $index++; |
|
803 | - $pdf->SetTextColor(0,0,60); |
|
804 | - $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); |
|
805 | - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("RemainderToPay"), $useborder, 'L', 1); |
|
802 | + $index++; |
|
803 | + $pdf->SetTextColor(0,0,60); |
|
804 | + $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); |
|
805 | + $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("RemainderToPay"), $useborder, 'L', 1); |
|
806 | 806 | |
807 | - $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); |
|
808 | - $pdf->MultiCell($largcol2, $tab2_hl, price($resteapayer), $useborder, 'R', 1); |
|
809 | - $pdf->SetFont('','', $default_font_size - 1); |
|
810 | - $pdf->SetTextColor(0,0,0); |
|
811 | - } |
|
807 | + $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); |
|
808 | + $pdf->MultiCell($largcol2, $tab2_hl, price($resteapayer), $useborder, 'R', 1); |
|
809 | + $pdf->SetFont('','', $default_font_size - 1); |
|
810 | + $pdf->SetTextColor(0,0,0); |
|
811 | + } |
|
812 | 812 | |
813 | - $index++; |
|
814 | - return ($tab2_top + ($tab2_hl * $index)); |
|
815 | - } |
|
816 | - |
|
817 | - /** |
|
818 | - * Show table for lines |
|
819 | - * |
|
820 | - * @param PDF $pdf Object PDF |
|
821 | - * @param string $tab_top Top position of table |
|
822 | - * @param string $tab_height Height of table (rectangle) |
|
823 | - * @param int $nexY Y (not used) |
|
824 | - * @param Translate $outputlangs Langs object |
|
825 | - * @param int $hidetop Hide top bar of array |
|
826 | - * @param int $hidebottom Hide bottom bar of array |
|
827 | - * @param string $currency Currency code |
|
828 | - * @return void |
|
829 | - */ |
|
830 | - function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0, $currency='') |
|
831 | - { |
|
832 | - global $conf; |
|
833 | - |
|
834 | - // Force to disable hidetop and hidebottom |
|
835 | - $hidebottom=0; |
|
836 | - if ($hidetop) $hidetop=-1; |
|
837 | - |
|
838 | - $currency = !empty($currency) ? $currency : $conf->currency; |
|
839 | - $default_font_size = pdf_getPDFFontSize($outputlangs); |
|
813 | + $index++; |
|
814 | + return ($tab2_top + ($tab2_hl * $index)); |
|
815 | + } |
|
816 | + |
|
817 | + /** |
|
818 | + * Show table for lines |
|
819 | + * |
|
820 | + * @param PDF $pdf Object PDF |
|
821 | + * @param string $tab_top Top position of table |
|
822 | + * @param string $tab_height Height of table (rectangle) |
|
823 | + * @param int $nexY Y (not used) |
|
824 | + * @param Translate $outputlangs Langs object |
|
825 | + * @param int $hidetop Hide top bar of array |
|
826 | + * @param int $hidebottom Hide bottom bar of array |
|
827 | + * @param string $currency Currency code |
|
828 | + * @return void |
|
829 | + */ |
|
830 | + function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0, $currency='') |
|
831 | + { |
|
832 | + global $conf; |
|
833 | + |
|
834 | + // Force to disable hidetop and hidebottom |
|
835 | + $hidebottom=0; |
|
836 | + if ($hidetop) $hidetop=-1; |
|
837 | + |
|
838 | + $currency = !empty($currency) ? $currency : $conf->currency; |
|
839 | + $default_font_size = pdf_getPDFFontSize($outputlangs); |
|
840 | 840 | |
841 | 841 | // Amount in (at tab_top - 1) |
842 | - $pdf->SetTextColor(0,0,0); |
|
843 | - $pdf->SetFont('','',$default_font_size - 2); |
|
842 | + $pdf->SetTextColor(0,0,0); |
|
843 | + $pdf->SetFont('','',$default_font_size - 2); |
|
844 | 844 | |
845 | - if (empty($hidetop)) |
|
846 | - { |
|
847 | - $titre = $outputlangs->transnoentities("AmountInCurrency",$outputlangs->transnoentitiesnoconv("Currency".$currency)); |
|
848 | - $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top-4); |
|
849 | - $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre); |
|
845 | + if (empty($hidetop)) |
|
846 | + { |
|
847 | + $titre = $outputlangs->transnoentities("AmountInCurrency",$outputlangs->transnoentitiesnoconv("Currency".$currency)); |
|
848 | + $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top-4); |
|
849 | + $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre); |
|
850 | 850 | |
851 | - //$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR='230,230,230'; |
|
852 | - if (! empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_droite-$this->marge_gauche, 5, 'F', null, explode(',',$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)); |
|
853 | - } |
|
851 | + //$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR='230,230,230'; |
|
852 | + if (! empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_droite-$this->marge_gauche, 5, 'F', null, explode(',',$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)); |
|
853 | + } |
|
854 | 854 | |
855 | - $pdf->SetDrawColor(128,128,128); |
|
856 | - $pdf->SetFont('','', $default_font_size - 1); |
|
855 | + $pdf->SetDrawColor(128,128,128); |
|
856 | + $pdf->SetFont('','', $default_font_size - 1); |
|
857 | 857 | |
858 | - // Output Rect |
|
859 | - $this->printRect($pdf,$this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height, $hidetop, $hidebottom); // Rect prend une longueur en 3eme param et 4eme param |
|
858 | + // Output Rect |
|
859 | + $this->printRect($pdf,$this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height, $hidetop, $hidebottom); // Rect prend une longueur en 3eme param et 4eme param |
|
860 | 860 | |
861 | - if (empty($hidetop)) |
|
862 | - { |
|
863 | - $pdf->line($this->marge_gauche, $tab_top+5, $this->page_largeur-$this->marge_droite, $tab_top+5); // line prend une position y en 2eme param et 4eme param |
|
861 | + if (empty($hidetop)) |
|
862 | + { |
|
863 | + $pdf->line($this->marge_gauche, $tab_top+5, $this->page_largeur-$this->marge_droite, $tab_top+5); // line prend une position y en 2eme param et 4eme param |
|
864 | 864 | |
865 | - $pdf->SetXY($this->posxdesc-1, $tab_top+1); |
|
866 | - $pdf->MultiCell(108,2, $outputlangs->transnoentities("Designation"),'','L'); |
|
867 | - } |
|
865 | + $pdf->SetXY($this->posxdesc-1, $tab_top+1); |
|
866 | + $pdf->MultiCell(108,2, $outputlangs->transnoentities("Designation"),'','L'); |
|
867 | + } |
|
868 | 868 | |
869 | 869 | if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) |
870 | 870 | { |
871 | - $pdf->line($this->posxtva-1, $tab_top, $this->posxtva-1, $tab_top + $tab_height); |
|
872 | - if (empty($hidetop)) |
|
873 | - { |
|
874 | - $pdf->SetXY($this->posxtva-3, $tab_top+1); |
|
875 | - $pdf->MultiCell($this->posxup-$this->posxtva+3,2, $outputlangs->transnoentities("VAT"),'','C'); |
|
876 | - } |
|
871 | + $pdf->line($this->posxtva-1, $tab_top, $this->posxtva-1, $tab_top + $tab_height); |
|
872 | + if (empty($hidetop)) |
|
873 | + { |
|
874 | + $pdf->SetXY($this->posxtva-3, $tab_top+1); |
|
875 | + $pdf->MultiCell($this->posxup-$this->posxtva+3,2, $outputlangs->transnoentities("VAT"),'','C'); |
|
876 | + } |
|
877 | 877 | } |
878 | 878 | |
879 | - $pdf->line($this->posxup-1, $tab_top, $this->posxup-1, $tab_top + $tab_height); |
|
880 | - if (empty($hidetop)) |
|
881 | - { |
|
882 | - $pdf->SetXY($this->posxup-1, $tab_top+1); |
|
883 | - $pdf->MultiCell($this->posxqty-$this->posxup-1,2, $outputlangs->transnoentities("PriceUHT"),'','C'); |
|
884 | - } |
|
879 | + $pdf->line($this->posxup-1, $tab_top, $this->posxup-1, $tab_top + $tab_height); |
|
880 | + if (empty($hidetop)) |
|
881 | + { |
|
882 | + $pdf->SetXY($this->posxup-1, $tab_top+1); |
|
883 | + $pdf->MultiCell($this->posxqty-$this->posxup-1,2, $outputlangs->transnoentities("PriceUHT"),'','C'); |
|
884 | + } |
|
885 | 885 | |
886 | - $pdf->line($this->posxqty-1, $tab_top, $this->posxqty-1, $tab_top + $tab_height); |
|
887 | - if (empty($hidetop)) |
|
888 | - { |
|
889 | - $pdf->SetXY($this->posxqty-1, $tab_top+1); |
|
890 | - if($conf->global->PRODUCT_USE_UNITS) |
|
891 | - { |
|
892 | - $pdf->MultiCell($this->posxunit-$this->posxqty-1,2, $outputlangs->transnoentities("Qty"),'','C'); |
|
893 | - } |
|
894 | - else |
|
895 | - { |
|
896 | - $pdf->MultiCell($this->posxdiscount-$this->posxqty-1,2, $outputlangs->transnoentities("Qty"),'','C'); |
|
897 | - } |
|
898 | - } |
|
886 | + $pdf->line($this->posxqty-1, $tab_top, $this->posxqty-1, $tab_top + $tab_height); |
|
887 | + if (empty($hidetop)) |
|
888 | + { |
|
889 | + $pdf->SetXY($this->posxqty-1, $tab_top+1); |
|
890 | + if($conf->global->PRODUCT_USE_UNITS) |
|
891 | + { |
|
892 | + $pdf->MultiCell($this->posxunit-$this->posxqty-1,2, $outputlangs->transnoentities("Qty"),'','C'); |
|
893 | + } |
|
894 | + else |
|
895 | + { |
|
896 | + $pdf->MultiCell($this->posxdiscount-$this->posxqty-1,2, $outputlangs->transnoentities("Qty"),'','C'); |
|
897 | + } |
|
898 | + } |
|
899 | 899 | |
900 | - if($conf->global->PRODUCT_USE_UNITS) { |
|
901 | - $pdf->line($this->posxunit - 1, $tab_top, $this->posxunit - 1, $tab_top + $tab_height); |
|
902 | - if (empty($hidetop)) { |
|
903 | - $pdf->SetXY($this->posxunit - 1, $tab_top + 1); |
|
904 | - $pdf->MultiCell($this->posxdiscount - $this->posxunit - 1, 2, $outputlangs->transnoentities("Unit"), '', |
|
905 | - 'C'); |
|
906 | - } |
|
907 | - } |
|
900 | + if($conf->global->PRODUCT_USE_UNITS) { |
|
901 | + $pdf->line($this->posxunit - 1, $tab_top, $this->posxunit - 1, $tab_top + $tab_height); |
|
902 | + if (empty($hidetop)) { |
|
903 | + $pdf->SetXY($this->posxunit - 1, $tab_top + 1); |
|
904 | + $pdf->MultiCell($this->posxdiscount - $this->posxunit - 1, 2, $outputlangs->transnoentities("Unit"), '', |
|
905 | + 'C'); |
|
906 | + } |
|
907 | + } |
|
908 | 908 | |
909 | - $pdf->line($this->posxdiscount-1, $tab_top, $this->posxdiscount-1, $tab_top + $tab_height); |
|
910 | - if (empty($hidetop)) |
|
911 | - { |
|
912 | - if ($this->atleastonediscount) |
|
913 | - { |
|
914 | - $pdf->SetXY($this->posxdiscount-1, $tab_top+1); |
|
915 | - $pdf->MultiCell($this->postotalht-$this->posxdiscount+1,2, $outputlangs->transnoentities("ReductionShort"),'','C'); |
|
916 | - } |
|
917 | - } |
|
909 | + $pdf->line($this->posxdiscount-1, $tab_top, $this->posxdiscount-1, $tab_top + $tab_height); |
|
910 | + if (empty($hidetop)) |
|
911 | + { |
|
912 | + if ($this->atleastonediscount) |
|
913 | + { |
|
914 | + $pdf->SetXY($this->posxdiscount-1, $tab_top+1); |
|
915 | + $pdf->MultiCell($this->postotalht-$this->posxdiscount+1,2, $outputlangs->transnoentities("ReductionShort"),'','C'); |
|
916 | + } |
|
917 | + } |
|
918 | 918 | |
919 | - if ($this->atleastonediscount) |
|
920 | - { |
|
921 | - $pdf->line($this->postotalht, $tab_top, $this->postotalht, $tab_top + $tab_height); |
|
922 | - } |
|
923 | - if (empty($hidetop)) |
|
924 | - { |
|
925 | - $pdf->SetXY($this->postotalht-1, $tab_top+1); |
|
926 | - $pdf->MultiCell(30,2, $outputlangs->transnoentities("TotalHTShort"),'','C'); |
|
927 | - } |
|
928 | - } |
|
919 | + if ($this->atleastonediscount) |
|
920 | + { |
|
921 | + $pdf->line($this->postotalht, $tab_top, $this->postotalht, $tab_top + $tab_height); |
|
922 | + } |
|
923 | + if (empty($hidetop)) |
|
924 | + { |
|
925 | + $pdf->SetXY($this->postotalht-1, $tab_top+1); |
|
926 | + $pdf->MultiCell(30,2, $outputlangs->transnoentities("TotalHTShort"),'','C'); |
|
927 | + } |
|
928 | + } |
|
929 | 929 | |
930 | 930 | // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps |
931 | - /** |
|
932 | - * Show payments table |
|
933 | - * |
|
934 | - * @param PDF $pdf Object PDF |
|
935 | - * @param FactureFournisseur $object Object invoice |
|
936 | - * @param int $posy Position y in PDF |
|
937 | - * @param Translate $outputlangs Object langs for output |
|
938 | - * @return int <0 if KO, >0 if OK |
|
939 | - */ |
|
940 | - function _tableau_versements(&$pdf, $object, $posy, $outputlangs) |
|
941 | - { |
|
931 | + /** |
|
932 | + * Show payments table |
|
933 | + * |
|
934 | + * @param PDF $pdf Object PDF |
|
935 | + * @param FactureFournisseur $object Object invoice |
|
936 | + * @param int $posy Position y in PDF |
|
937 | + * @param Translate $outputlangs Object langs for output |
|
938 | + * @return int <0 if KO, >0 if OK |
|
939 | + */ |
|
940 | + function _tableau_versements(&$pdf, $object, $posy, $outputlangs) |
|
941 | + { |
|
942 | 942 | // phpcs:enable |
943 | - global $conf; |
|
943 | + global $conf; |
|
944 | 944 | |
945 | - $sign=1; |
|
946 | - if ($object->type == 2 && ! empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign=-1; |
|
945 | + $sign=1; |
|
946 | + if ($object->type == 2 && ! empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign=-1; |
|
947 | 947 | |
948 | - $tab3_posx = 120; |
|
949 | - $tab3_top = $posy + 8; |
|
950 | - $tab3_width = 80; |
|
951 | - $tab3_height = 4; |
|
952 | - if ($this->page_largeur < 210) // To work with US executive format |
|
953 | - { |
|
954 | - $tab3_posx -= 20; |
|
955 | - } |
|
948 | + $tab3_posx = 120; |
|
949 | + $tab3_top = $posy + 8; |
|
950 | + $tab3_width = 80; |
|
951 | + $tab3_height = 4; |
|
952 | + if ($this->page_largeur < 210) // To work with US executive format |
|
953 | + { |
|
954 | + $tab3_posx -= 20; |
|
955 | + } |
|
956 | 956 | |
957 | - $default_font_size = pdf_getPDFFontSize($outputlangs); |
|
957 | + $default_font_size = pdf_getPDFFontSize($outputlangs); |
|
958 | 958 | |
959 | - $pdf->SetFont('','', $default_font_size - 3); |
|
960 | - $pdf->SetXY($tab3_posx, $tab3_top - 4); |
|
961 | - $pdf->MultiCell(60, 3, $outputlangs->transnoentities("PaymentsAlreadyDone"), 0, 'L', 0); |
|
959 | + $pdf->SetFont('','', $default_font_size - 3); |
|
960 | + $pdf->SetXY($tab3_posx, $tab3_top - 4); |
|
961 | + $pdf->MultiCell(60, 3, $outputlangs->transnoentities("PaymentsAlreadyDone"), 0, 'L', 0); |
|
962 | 962 | |
963 | - $pdf->line($tab3_posx, $tab3_top, $tab3_posx+$tab3_width, $tab3_top); |
|
963 | + $pdf->line($tab3_posx, $tab3_top, $tab3_posx+$tab3_width, $tab3_top); |
|
964 | 964 | |
965 | - $pdf->SetFont('','', $default_font_size - 4); |
|
966 | - $pdf->SetXY($tab3_posx, $tab3_top); |
|
967 | - $pdf->MultiCell(20, 3, $outputlangs->transnoentities("Payment"), 0, 'L', 0); |
|
968 | - $pdf->SetXY($tab3_posx+21, $tab3_top); |
|
969 | - $pdf->MultiCell(20, 3, $outputlangs->transnoentities("Amount"), 0, 'L', 0); |
|
970 | - $pdf->SetXY($tab3_posx+40, $tab3_top); |
|
971 | - $pdf->MultiCell(20, 3, $outputlangs->transnoentities("Type"), 0, 'L', 0); |
|
972 | - $pdf->SetXY($tab3_posx+58, $tab3_top); |
|
973 | - $pdf->MultiCell(20, 3, $outputlangs->transnoentities("Num"), 0, 'L', 0); |
|
965 | + $pdf->SetFont('','', $default_font_size - 4); |
|
966 | + $pdf->SetXY($tab3_posx, $tab3_top); |
|
967 | + $pdf->MultiCell(20, 3, $outputlangs->transnoentities("Payment"), 0, 'L', 0); |
|
968 | + $pdf->SetXY($tab3_posx+21, $tab3_top); |
|
969 | + $pdf->MultiCell(20, 3, $outputlangs->transnoentities("Amount"), 0, 'L', 0); |
|
970 | + $pdf->SetXY($tab3_posx+40, $tab3_top); |
|
971 | + $pdf->MultiCell(20, 3, $outputlangs->transnoentities("Type"), 0, 'L', 0); |
|
972 | + $pdf->SetXY($tab3_posx+58, $tab3_top); |
|
973 | + $pdf->MultiCell(20, 3, $outputlangs->transnoentities("Num"), 0, 'L', 0); |
|
974 | 974 | |
975 | - $pdf->line($tab3_posx, $tab3_top-1+$tab3_height, $tab3_posx+$tab3_width, $tab3_top-1+$tab3_height); |
|
975 | + $pdf->line($tab3_posx, $tab3_top-1+$tab3_height, $tab3_posx+$tab3_width, $tab3_top-1+$tab3_height); |
|
976 | 976 | |
977 | - $y=0; |
|
977 | + $y=0; |
|
978 | 978 | |
979 | - $pdf->SetFont('','', $default_font_size - 4); |
|
979 | + $pdf->SetFont('','', $default_font_size - 4); |
|
980 | 980 | |
981 | - // Loop on each deposits and credit notes included |
|
982 | - // |
|
981 | + // Loop on each deposits and credit notes included |
|
982 | + // |
|
983 | 983 | |
984 | - // Loop on each payment |
|
985 | - $sql = "SELECT p.datep as date, p.fk_paiement as type, p.num_paiement as num, pf.amount as amount, pf.multicurrency_amount,"; |
|
986 | - $sql.= " cp.code"; |
|
987 | - $sql.= " FROM ".MAIN_DB_PREFIX."paiementfourn_facturefourn as pf, ".MAIN_DB_PREFIX."paiementfourn as p"; |
|
988 | - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as cp ON p.fk_paiement = cp.id"; |
|
989 | - $sql.= " WHERE pf.fk_paiementfourn = p.rowid and pf.fk_facturefourn = ".$object->id; |
|
990 | - $sql.= " ORDER BY p.datep"; |
|
991 | - $resql=$this->db->query($sql); |
|
992 | - if ($resql) |
|
993 | - { |
|
994 | - $num = $this->db->num_rows($resql); |
|
995 | - $i=0; |
|
996 | - while ($i < $num) { |
|
997 | - $y+=3; |
|
998 | - $row = $this->db->fetch_object($resql); |
|
999 | - |
|
1000 | - $pdf->SetXY($tab3_posx, $tab3_top+$y); |
|
1001 | - $pdf->MultiCell(20, 3, dol_print_date($this->db->jdate($row->date),'day',false,$outputlangs,true), 0, 'L', 0); |
|
1002 | - $pdf->SetXY($tab3_posx+21, $tab3_top+$y); |
|
1003 | - $pdf->MultiCell(20, 3, price($sign * (($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? $row->multicurrency_amount : $row->amount)), 0, 'L', 0); |
|
1004 | - $pdf->SetXY($tab3_posx+40, $tab3_top+$y); |
|
1005 | - $oper = $outputlangs->transnoentitiesnoconv("PaymentTypeShort" . $row->code); |
|
1006 | - |
|
1007 | - $pdf->MultiCell(20, 3, $oper, 0, 'L', 0); |
|
1008 | - $pdf->SetXY($tab3_posx+58, $tab3_top+$y); |
|
1009 | - $pdf->MultiCell(30, 3, $row->num, 0, 'L', 0); |
|
1010 | - |
|
1011 | - $pdf->line($tab3_posx, $tab3_top+$y+3, $tab3_posx+$tab3_width, $tab3_top+$y+3); |
|
1012 | - |
|
1013 | - $i++; |
|
1014 | - } |
|
1015 | - } |
|
1016 | - else |
|
1017 | - { |
|
1018 | - $this->error=$this->db->lasterror(); |
|
1019 | - return -1; |
|
1020 | - } |
|
1021 | - } |
|
984 | + // Loop on each payment |
|
985 | + $sql = "SELECT p.datep as date, p.fk_paiement as type, p.num_paiement as num, pf.amount as amount, pf.multicurrency_amount,"; |
|
986 | + $sql.= " cp.code"; |
|
987 | + $sql.= " FROM ".MAIN_DB_PREFIX."paiementfourn_facturefourn as pf, ".MAIN_DB_PREFIX."paiementfourn as p"; |
|
988 | + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as cp ON p.fk_paiement = cp.id"; |
|
989 | + $sql.= " WHERE pf.fk_paiementfourn = p.rowid and pf.fk_facturefourn = ".$object->id; |
|
990 | + $sql.= " ORDER BY p.datep"; |
|
991 | + $resql=$this->db->query($sql); |
|
992 | + if ($resql) |
|
993 | + { |
|
994 | + $num = $this->db->num_rows($resql); |
|
995 | + $i=0; |
|
996 | + while ($i < $num) { |
|
997 | + $y+=3; |
|
998 | + $row = $this->db->fetch_object($resql); |
|
999 | + |
|
1000 | + $pdf->SetXY($tab3_posx, $tab3_top+$y); |
|
1001 | + $pdf->MultiCell(20, 3, dol_print_date($this->db->jdate($row->date),'day',false,$outputlangs,true), 0, 'L', 0); |
|
1002 | + $pdf->SetXY($tab3_posx+21, $tab3_top+$y); |
|
1003 | + $pdf->MultiCell(20, 3, price($sign * (($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? $row->multicurrency_amount : $row->amount)), 0, 'L', 0); |
|
1004 | + $pdf->SetXY($tab3_posx+40, $tab3_top+$y); |
|
1005 | + $oper = $outputlangs->transnoentitiesnoconv("PaymentTypeShort" . $row->code); |
|
1006 | + |
|
1007 | + $pdf->MultiCell(20, 3, $oper, 0, 'L', 0); |
|
1008 | + $pdf->SetXY($tab3_posx+58, $tab3_top+$y); |
|
1009 | + $pdf->MultiCell(30, 3, $row->num, 0, 'L', 0); |
|
1010 | + |
|
1011 | + $pdf->line($tab3_posx, $tab3_top+$y+3, $tab3_posx+$tab3_width, $tab3_top+$y+3); |
|
1012 | + |
|
1013 | + $i++; |
|
1014 | + } |
|
1015 | + } |
|
1016 | + else |
|
1017 | + { |
|
1018 | + $this->error=$this->db->lasterror(); |
|
1019 | + return -1; |
|
1020 | + } |
|
1021 | + } |
|
1022 | 1022 | |
1023 | - /** |
|
1024 | - * Show top header of page. |
|
1025 | - * |
|
1026 | - * @param PDF $pdf Object PDF |
|
1027 | - * @param FactureFournisseur $object Object to show |
|
1028 | - * @param int $showaddress 0=no, 1=yes |
|
1029 | - * @param Translate $outputlangs Object lang for output |
|
1030 | - * @return void |
|
1031 | - */ |
|
1032 | - function _pagehead(&$pdf, $object, $showaddress, $outputlangs) |
|
1033 | - { |
|
1034 | - global $langs, $conf, $mysoc; |
|
1023 | + /** |
|
1024 | + * Show top header of page. |
|
1025 | + * |
|
1026 | + * @param PDF $pdf Object PDF |
|
1027 | + * @param FactureFournisseur $object Object to show |
|
1028 | + * @param int $showaddress 0=no, 1=yes |
|
1029 | + * @param Translate $outputlangs Object lang for output |
|
1030 | + * @return void |
|
1031 | + */ |
|
1032 | + function _pagehead(&$pdf, $object, $showaddress, $outputlangs) |
|
1033 | + { |
|
1034 | + global $langs, $conf, $mysoc; |
|
1035 | 1035 | |
1036 | - // Load translation files required by the page |
|
1037 | - $outputlangs->loadLangs(array("main", "orders", "companies", "bills")); |
|
1036 | + // Load translation files required by the page |
|
1037 | + $outputlangs->loadLangs(array("main", "orders", "companies", "bills")); |
|
1038 | 1038 | |
1039 | - $default_font_size = pdf_getPDFFontSize($outputlangs); |
|
1039 | + $default_font_size = pdf_getPDFFontSize($outputlangs); |
|
1040 | 1040 | |
1041 | - // Do not add the BACKGROUND as this is for suppliers |
|
1042 | - //pdf_pagehead($pdf,$outputlangs,$this->page_hauteur); |
|
1041 | + // Do not add the BACKGROUND as this is for suppliers |
|
1042 | + //pdf_pagehead($pdf,$outputlangs,$this->page_hauteur); |
|
1043 | 1043 | |
1044 | - $pdf->SetTextColor(0,0,60); |
|
1045 | - $pdf->SetFont('','B', $default_font_size + 3); |
|
1044 | + $pdf->SetTextColor(0,0,60); |
|
1045 | + $pdf->SetFont('','B', $default_font_size + 3); |
|
1046 | 1046 | |
1047 | - $posy=$this->marge_haute; |
|
1048 | - $posx=$this->page_largeur-$this->marge_droite-100; |
|
1047 | + $posy=$this->marge_haute; |
|
1048 | + $posx=$this->page_largeur-$this->marge_droite-100; |
|
1049 | 1049 | |
1050 | - $pdf->SetXY($this->marge_gauche,$posy); |
|
1050 | + $pdf->SetXY($this->marge_gauche,$posy); |
|
1051 | 1051 | |
1052 | - // Logo |
|
1053 | - /* |
|
1052 | + // Logo |
|
1053 | + /* |
|
1054 | 1054 | $logo=$conf->mycompany->dir_output.'/logos/'.$mysoc->logo; |
1055 | 1055 | if ($mysoc->logo) |
1056 | 1056 | { |
@@ -1069,183 +1069,183 @@ discard block |
||
1069 | 1069 | } |
1070 | 1070 | else |
1071 | 1071 | {*/ |
1072 | - $text=$this->emetteur->name; |
|
1073 | - $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L'); |
|
1074 | - //} |
|
1075 | - |
|
1076 | - $pdf->SetFont('','B', $default_font_size + 3); |
|
1077 | - $pdf->SetXY($posx,$posy); |
|
1078 | - $pdf->SetTextColor(0,0,60); |
|
1079 | - $pdf->MultiCell(100, 3, $outputlangs->transnoentities("SupplierInvoice")." ".$outputlangs->convToOutputCharset($object->ref), '', 'R'); |
|
1080 | - $posy+=1; |
|
1081 | - |
|
1082 | - if ($object->ref_supplier) |
|
1083 | - { |
|
1084 | - $posy+=4; |
|
1085 | - $pdf->SetFont('','B', $default_font_size); |
|
1086 | - $pdf->SetXY($posx,$posy); |
|
1087 | - $pdf->SetTextColor(0,0,60); |
|
1088 | - $pdf->MultiCell(100, 4, $outputlangs->transnoentities("RefSupplier")." : " . $object->ref_supplier, '', 'R'); |
|
1089 | - $posy+=1; |
|
1090 | - } |
|
1091 | - |
|
1092 | - $pdf->SetFont('','', $default_font_size - 1); |
|
1093 | - |
|
1094 | - if (! empty($conf->global->PDF_SHOW_PROJECT)) |
|
1095 | - { |
|
1096 | - $object->fetch_projet(); |
|
1097 | - if (! empty($object->project->ref)) |
|
1098 | - { |
|
1099 | - $posy+=4; |
|
1100 | - $pdf->SetXY($posx,$posy); |
|
1101 | - $langs->load("projects"); |
|
1102 | - $pdf->SetTextColor(0,0,60); |
|
1103 | - $pdf->MultiCell(100, 3, $outputlangs->transnoentities("Project")." : " . (empty($object->project->ref)?'':$object->projet->ref), '', 'R'); |
|
1104 | - } |
|
1105 | - } |
|
1106 | - |
|
1107 | - if ($object->date) |
|
1108 | - { |
|
1109 | - $posy+=4; |
|
1110 | - $pdf->SetXY($posx,$posy); |
|
1111 | - $pdf->SetTextColor(0,0,60); |
|
1112 | - $pdf->MultiCell(100, 4, $outputlangs->transnoentities("Date")." : " . dol_print_date($object->date,"day",false,$outputlangs,true), '', 'R'); |
|
1113 | - } |
|
1114 | - else |
|
1115 | - { |
|
1116 | - $posy+=4; |
|
1117 | - $pdf->SetXY($posx,$posy); |
|
1118 | - $pdf->SetTextColor(255,0,0); |
|
1119 | - $pdf->MultiCell(100, 4, strtolower($outputlangs->transnoentities("OrderToProcess")), '', 'R'); |
|
1120 | - } |
|
1121 | - |
|
1122 | - if ($object->thirdparty->code_fournisseur) |
|
1123 | - { |
|
1124 | - $posy+=4; |
|
1125 | - $pdf->SetXY($posx,$posy); |
|
1126 | - $pdf->SetTextColor(0,0,60); |
|
1127 | - $pdf->MultiCell(100, 3, $outputlangs->transnoentities("SupplierCode")." : " . $outputlangs->transnoentities($object->thirdparty->code_fournisseur), '', 'R'); |
|
1128 | - } |
|
1072 | + $text=$this->emetteur->name; |
|
1073 | + $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L'); |
|
1074 | + //} |
|
1129 | 1075 | |
1130 | - $posy+=1; |
|
1131 | - $pdf->SetTextColor(0,0,60); |
|
1076 | + $pdf->SetFont('','B', $default_font_size + 3); |
|
1077 | + $pdf->SetXY($posx,$posy); |
|
1078 | + $pdf->SetTextColor(0,0,60); |
|
1079 | + $pdf->MultiCell(100, 3, $outputlangs->transnoentities("SupplierInvoice")." ".$outputlangs->convToOutputCharset($object->ref), '', 'R'); |
|
1080 | + $posy+=1; |
|
1132 | 1081 | |
1133 | - $top_shift = 0; |
|
1134 | - // Show list of linked objects |
|
1135 | - $current_y = $pdf->getY(); |
|
1136 | - $posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3, 'R', $default_font_size); |
|
1137 | - if ($current_y < $pdf->getY()) |
|
1138 | - { |
|
1139 | - $top_shift = $pdf->getY() - $current_y; |
|
1140 | - } |
|
1141 | - |
|
1142 | - if ($showaddress) |
|
1143 | - { |
|
1144 | - // Sender properties |
|
1145 | - $carac_emetteur=''; |
|
1146 | - // Add internal contact of proposal if defined |
|
1147 | - $arrayidcontact=$object->getIdContact('internal','SALESREPFOLL'); |
|
1148 | - if (count($arrayidcontact) > 0) |
|
1149 | - { |
|
1150 | - $object->fetch_user($arrayidcontact[0]); |
|
1151 | - $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n"; |
|
1152 | - } |
|
1153 | - |
|
1154 | - $carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'source', $object); |
|
1155 | - |
|
1156 | - // Show sender |
|
1157 | - $posy=42+$top_shift; |
|
1158 | - $posx=$this->marge_gauche; |
|
1159 | - if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->page_largeur-$this->marge_droite-80; |
|
1160 | - $hautcadre=40; |
|
1161 | - |
|
1162 | - // Show sender frame |
|
1163 | - $pdf->SetTextColor(0,0,0); |
|
1164 | - $pdf->SetFont('','', $default_font_size - 2); |
|
1165 | - $pdf->SetXY($posx,$posy-5); |
|
1166 | - $pdf->MultiCell(66,5, $outputlangs->transnoentities("BillFrom").":", 0, 'L'); |
|
1167 | - $pdf->SetXY($posx,$posy); |
|
1168 | - $pdf->SetFillColor(230,230,230); |
|
1169 | - $pdf->MultiCell(82, $hautcadre, "", 0, 'R', 1); |
|
1170 | - $pdf->SetTextColor(0,0,60); |
|
1171 | - |
|
1172 | - // Show sender name |
|
1173 | - $pdf->SetXY($posx+2,$posy+3); |
|
1174 | - $pdf->SetFont('','B', $default_font_size); |
|
1175 | - $pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L'); |
|
1176 | - $posy=$pdf->getY(); |
|
1177 | - |
|
1178 | - // Show sender information |
|
1179 | - $pdf->SetXY($posx+2,$posy); |
|
1180 | - $pdf->SetFont('','', $default_font_size - 1); |
|
1181 | - $pdf->MultiCell(80, 4, $carac_emetteur, 0, 'L'); |
|
1182 | - |
|
1183 | - |
|
1184 | - |
|
1185 | - // If BILLING contact defined on invoice, we use it |
|
1186 | - $usecontact=false; |
|
1187 | - $arrayidcontact=$object->getIdContact('internal','BILLING'); |
|
1188 | - if (count($arrayidcontact) > 0) |
|
1189 | - { |
|
1190 | - $usecontact=true; |
|
1191 | - $result=$object->fetch_contact($arrayidcontact[0]); |
|
1192 | - } |
|
1193 | - |
|
1194 | - //Recipient name |
|
1195 | - // On peut utiliser le nom de la societe du contact |
|
1196 | - if ($usecontact && !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) { |
|
1197 | - $thirdparty = $object->contact; |
|
1198 | - } else { |
|
1199 | - $thirdparty = $mysoc; |
|
1200 | - } |
|
1082 | + if ($object->ref_supplier) |
|
1083 | + { |
|
1084 | + $posy+=4; |
|
1085 | + $pdf->SetFont('','B', $default_font_size); |
|
1086 | + $pdf->SetXY($posx,$posy); |
|
1087 | + $pdf->SetTextColor(0,0,60); |
|
1088 | + $pdf->MultiCell(100, 4, $outputlangs->transnoentities("RefSupplier")." : " . $object->ref_supplier, '', 'R'); |
|
1089 | + $posy+=1; |
|
1090 | + } |
|
1201 | 1091 | |
1202 | - $carac_client_name= pdfBuildThirdpartyName($thirdparty, $outputlangs); |
|
1092 | + $pdf->SetFont('','', $default_font_size - 1); |
|
1203 | 1093 | |
1204 | - $carac_client=pdf_build_address($outputlangs,$this->emetteur,$mysoc,((!empty($object->contact))?$object->contact:null),$usecontact,'target',$object); |
|
1094 | + if (! empty($conf->global->PDF_SHOW_PROJECT)) |
|
1095 | + { |
|
1096 | + $object->fetch_projet(); |
|
1097 | + if (! empty($object->project->ref)) |
|
1098 | + { |
|
1099 | + $posy+=4; |
|
1100 | + $pdf->SetXY($posx,$posy); |
|
1101 | + $langs->load("projects"); |
|
1102 | + $pdf->SetTextColor(0,0,60); |
|
1103 | + $pdf->MultiCell(100, 3, $outputlangs->transnoentities("Project")." : " . (empty($object->project->ref)?'':$object->projet->ref), '', 'R'); |
|
1104 | + } |
|
1105 | + } |
|
1205 | 1106 | |
1206 | - // Show recipient |
|
1207 | - $widthrecbox=100; |
|
1208 | - if ($this->page_largeur < 210) $widthrecbox=84; // To work with US executive format |
|
1209 | - $posy=42+$top_shift; |
|
1210 | - $posx=$this->page_largeur-$this->marge_droite-$widthrecbox; |
|
1211 | - if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->marge_gauche; |
|
1107 | + if ($object->date) |
|
1108 | + { |
|
1109 | + $posy+=4; |
|
1110 | + $pdf->SetXY($posx,$posy); |
|
1111 | + $pdf->SetTextColor(0,0,60); |
|
1112 | + $pdf->MultiCell(100, 4, $outputlangs->transnoentities("Date")." : " . dol_print_date($object->date,"day",false,$outputlangs,true), '', 'R'); |
|
1113 | + } |
|
1114 | + else |
|
1115 | + { |
|
1116 | + $posy+=4; |
|
1117 | + $pdf->SetXY($posx,$posy); |
|
1118 | + $pdf->SetTextColor(255,0,0); |
|
1119 | + $pdf->MultiCell(100, 4, strtolower($outputlangs->transnoentities("OrderToProcess")), '', 'R'); |
|
1120 | + } |
|
1212 | 1121 | |
1213 | - // Show recipient frame |
|
1214 | - $pdf->SetTextColor(0,0,0); |
|
1215 | - $pdf->SetFont('','', $default_font_size - 2); |
|
1216 | - $pdf->SetXY($posx+2,$posy-5); |
|
1217 | - $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("BillTo").":",0,'L'); |
|
1218 | - $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre); |
|
1122 | + if ($object->thirdparty->code_fournisseur) |
|
1123 | + { |
|
1124 | + $posy+=4; |
|
1125 | + $pdf->SetXY($posx,$posy); |
|
1126 | + $pdf->SetTextColor(0,0,60); |
|
1127 | + $pdf->MultiCell(100, 3, $outputlangs->transnoentities("SupplierCode")." : " . $outputlangs->transnoentities($object->thirdparty->code_fournisseur), '', 'R'); |
|
1128 | + } |
|
1219 | 1129 | |
1220 | - // Show recipient name |
|
1221 | - $pdf->SetXY($posx+2,$posy+3); |
|
1222 | - $pdf->SetFont('','B', $default_font_size); |
|
1223 | - $pdf->MultiCell($widthrecbox, 4, $carac_client_name, 0, 'L'); |
|
1130 | + $posy+=1; |
|
1131 | + $pdf->SetTextColor(0,0,60); |
|
1224 | 1132 | |
1225 | - $posy = $pdf->getY(); |
|
1133 | + $top_shift = 0; |
|
1134 | + // Show list of linked objects |
|
1135 | + $current_y = $pdf->getY(); |
|
1136 | + $posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3, 'R', $default_font_size); |
|
1137 | + if ($current_y < $pdf->getY()) |
|
1138 | + { |
|
1139 | + $top_shift = $pdf->getY() - $current_y; |
|
1140 | + } |
|
1226 | 1141 | |
1227 | - // Show recipient information |
|
1228 | - $pdf->SetFont('','', $default_font_size - 1); |
|
1229 | - $pdf->SetXY($posx+2,$posy); |
|
1230 | - $pdf->MultiCell($widthrecbox, 4, $carac_client, 0, 'L'); |
|
1231 | - } |
|
1142 | + if ($showaddress) |
|
1143 | + { |
|
1144 | + // Sender properties |
|
1145 | + $carac_emetteur=''; |
|
1146 | + // Add internal contact of proposal if defined |
|
1147 | + $arrayidcontact=$object->getIdContact('internal','SALESREPFOLL'); |
|
1148 | + if (count($arrayidcontact) > 0) |
|
1149 | + { |
|
1150 | + $object->fetch_user($arrayidcontact[0]); |
|
1151 | + $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n"; |
|
1152 | + } |
|
1153 | + |
|
1154 | + $carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'source', $object); |
|
1155 | + |
|
1156 | + // Show sender |
|
1157 | + $posy=42+$top_shift; |
|
1158 | + $posx=$this->marge_gauche; |
|
1159 | + if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->page_largeur-$this->marge_droite-80; |
|
1160 | + $hautcadre=40; |
|
1161 | + |
|
1162 | + // Show sender frame |
|
1163 | + $pdf->SetTextColor(0,0,0); |
|
1164 | + $pdf->SetFont('','', $default_font_size - 2); |
|
1165 | + $pdf->SetXY($posx,$posy-5); |
|
1166 | + $pdf->MultiCell(66,5, $outputlangs->transnoentities("BillFrom").":", 0, 'L'); |
|
1167 | + $pdf->SetXY($posx,$posy); |
|
1168 | + $pdf->SetFillColor(230,230,230); |
|
1169 | + $pdf->MultiCell(82, $hautcadre, "", 0, 'R', 1); |
|
1170 | + $pdf->SetTextColor(0,0,60); |
|
1171 | + |
|
1172 | + // Show sender name |
|
1173 | + $pdf->SetXY($posx+2,$posy+3); |
|
1174 | + $pdf->SetFont('','B', $default_font_size); |
|
1175 | + $pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L'); |
|
1176 | + $posy=$pdf->getY(); |
|
1177 | + |
|
1178 | + // Show sender information |
|
1179 | + $pdf->SetXY($posx+2,$posy); |
|
1180 | + $pdf->SetFont('','', $default_font_size - 1); |
|
1181 | + $pdf->MultiCell(80, 4, $carac_emetteur, 0, 'L'); |
|
1182 | + |
|
1183 | + |
|
1184 | + |
|
1185 | + // If BILLING contact defined on invoice, we use it |
|
1186 | + $usecontact=false; |
|
1187 | + $arrayidcontact=$object->getIdContact('internal','BILLING'); |
|
1188 | + if (count($arrayidcontact) > 0) |
|
1189 | + { |
|
1190 | + $usecontact=true; |
|
1191 | + $result=$object->fetch_contact($arrayidcontact[0]); |
|
1192 | + } |
|
1193 | + |
|
1194 | + //Recipient name |
|
1195 | + // On peut utiliser le nom de la societe du contact |
|
1196 | + if ($usecontact && !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) { |
|
1197 | + $thirdparty = $object->contact; |
|
1198 | + } else { |
|
1199 | + $thirdparty = $mysoc; |
|
1200 | + } |
|
1201 | + |
|
1202 | + $carac_client_name= pdfBuildThirdpartyName($thirdparty, $outputlangs); |
|
1203 | + |
|
1204 | + $carac_client=pdf_build_address($outputlangs,$this->emetteur,$mysoc,((!empty($object->contact))?$object->contact:null),$usecontact,'target',$object); |
|
1205 | + |
|
1206 | + // Show recipient |
|
1207 | + $widthrecbox=100; |
|
1208 | + if ($this->page_largeur < 210) $widthrecbox=84; // To work with US executive format |
|
1209 | + $posy=42+$top_shift; |
|
1210 | + $posx=$this->page_largeur-$this->marge_droite-$widthrecbox; |
|
1211 | + if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->marge_gauche; |
|
1212 | + |
|
1213 | + // Show recipient frame |
|
1214 | + $pdf->SetTextColor(0,0,0); |
|
1215 | + $pdf->SetFont('','', $default_font_size - 2); |
|
1216 | + $pdf->SetXY($posx+2,$posy-5); |
|
1217 | + $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("BillTo").":",0,'L'); |
|
1218 | + $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre); |
|
1219 | + |
|
1220 | + // Show recipient name |
|
1221 | + $pdf->SetXY($posx+2,$posy+3); |
|
1222 | + $pdf->SetFont('','B', $default_font_size); |
|
1223 | + $pdf->MultiCell($widthrecbox, 4, $carac_client_name, 0, 'L'); |
|
1224 | + |
|
1225 | + $posy = $pdf->getY(); |
|
1226 | + |
|
1227 | + // Show recipient information |
|
1228 | + $pdf->SetFont('','', $default_font_size - 1); |
|
1229 | + $pdf->SetXY($posx+2,$posy); |
|
1230 | + $pdf->MultiCell($widthrecbox, 4, $carac_client, 0, 'L'); |
|
1231 | + } |
|
1232 | 1232 | |
1233 | - return $top_shift; |
|
1234 | - } |
|
1233 | + return $top_shift; |
|
1234 | + } |
|
1235 | 1235 | |
1236 | - /** |
|
1237 | - * Show footer of page. Need this->emetteur object |
|
1236 | + /** |
|
1237 | + * Show footer of page. Need this->emetteur object |
|
1238 | 1238 | * |
1239 | - * @param PDF $pdf PDF |
|
1240 | - * @param FactureFournisseur $object Object to show |
|
1241 | - * @param Translate $outputlangs Object lang for output |
|
1242 | - * @param int $hidefreetext 1=Hide free text |
|
1243 | - * @return int Return height of bottom margin including footer text |
|
1244 | - */ |
|
1245 | - function _pagefoot(&$pdf, $object, $outputlangs,$hidefreetext=0) |
|
1246 | - { |
|
1247 | - global $conf; |
|
1248 | - $showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS; |
|
1249 | - return pdf_pagefoot($pdf,$outputlangs,'SUPPLIER_INVOICE_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object,$showdetails,$hidefreetext); |
|
1250 | - } |
|
1239 | + * @param PDF $pdf PDF |
|
1240 | + * @param FactureFournisseur $object Object to show |
|
1241 | + * @param Translate $outputlangs Object lang for output |
|
1242 | + * @param int $hidefreetext 1=Hide free text |
|
1243 | + * @return int Return height of bottom margin including footer text |
|
1244 | + */ |
|
1245 | + function _pagefoot(&$pdf, $object, $outputlangs,$hidefreetext=0) |
|
1246 | + { |
|
1247 | + global $conf; |
|
1248 | + $showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS; |
|
1249 | + return pdf_pagefoot($pdf,$outputlangs,'SUPPLIER_INVOICE_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object,$showdetails,$hidefreetext); |
|
1250 | + } |
|
1251 | 1251 | } |
@@ -130,56 +130,56 @@ discard block |
||
130 | 130 | |
131 | 131 | // Dimension page pour format A4 |
132 | 132 | $this->type = 'pdf'; |
133 | - $formatarray=pdf_getFormat(); |
|
133 | + $formatarray = pdf_getFormat(); |
|
134 | 134 | $this->page_largeur = $formatarray['width']; |
135 | 135 | $this->page_hauteur = $formatarray['height']; |
136 | - $this->format = array($this->page_largeur,$this->page_hauteur); |
|
137 | - $this->marge_gauche=isset($conf->global->MAIN_PDF_MARGIN_LEFT)?$conf->global->MAIN_PDF_MARGIN_LEFT:10; |
|
138 | - $this->marge_droite=isset($conf->global->MAIN_PDF_MARGIN_RIGHT)?$conf->global->MAIN_PDF_MARGIN_RIGHT:10; |
|
139 | - $this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10; |
|
140 | - $this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10; |
|
136 | + $this->format = array($this->page_largeur, $this->page_hauteur); |
|
137 | + $this->marge_gauche = isset($conf->global->MAIN_PDF_MARGIN_LEFT) ? $conf->global->MAIN_PDF_MARGIN_LEFT : 10; |
|
138 | + $this->marge_droite = isset($conf->global->MAIN_PDF_MARGIN_RIGHT) ? $conf->global->MAIN_PDF_MARGIN_RIGHT : 10; |
|
139 | + $this->marge_haute = isset($conf->global->MAIN_PDF_MARGIN_TOP) ? $conf->global->MAIN_PDF_MARGIN_TOP : 10; |
|
140 | + $this->marge_basse = isset($conf->global->MAIN_PDF_MARGIN_BOTTOM) ? $conf->global->MAIN_PDF_MARGIN_BOTTOM : 10; |
|
141 | 141 | |
142 | - $this->option_logo = 1; // Affiche logo |
|
143 | - $this->option_tva = 1; // Gere option tva FACTURE_TVAOPTION |
|
144 | - $this->option_modereg = 1; // Affiche mode reglement |
|
145 | - $this->option_condreg = 1; // Affiche conditions reglement |
|
146 | - $this->option_codeproduitservice = 1; // Affiche code produit-service |
|
147 | - $this->option_multilang = 1; // Dispo en plusieurs langues |
|
142 | + $this->option_logo = 1; // Affiche logo |
|
143 | + $this->option_tva = 1; // Gere option tva FACTURE_TVAOPTION |
|
144 | + $this->option_modereg = 1; // Affiche mode reglement |
|
145 | + $this->option_condreg = 1; // Affiche conditions reglement |
|
146 | + $this->option_codeproduitservice = 1; // Affiche code produit-service |
|
147 | + $this->option_multilang = 1; // Dispo en plusieurs langues |
|
148 | 148 | |
149 | - $this->franchise=!$mysoc->tva_assuj; |
|
149 | + $this->franchise = !$mysoc->tva_assuj; |
|
150 | 150 | |
151 | 151 | // Defini position des colonnes |
152 | - $this->posxdesc=$this->marge_gauche+1; |
|
153 | - $this->posxtva=112; |
|
154 | - $this->posxup=126; |
|
155 | - $this->posxqty=145; |
|
156 | - $this->posxdiscount=162; |
|
157 | - $this->postotalht=174; |
|
158 | - |
|
159 | - if($conf->global->PRODUCT_USE_UNITS) { |
|
160 | - $this->posxtva=99; |
|
161 | - $this->posxup=114; |
|
162 | - $this->posxqty=130; |
|
163 | - $this->posxunit=147; |
|
152 | + $this->posxdesc = $this->marge_gauche + 1; |
|
153 | + $this->posxtva = 112; |
|
154 | + $this->posxup = 126; |
|
155 | + $this->posxqty = 145; |
|
156 | + $this->posxdiscount = 162; |
|
157 | + $this->postotalht = 174; |
|
158 | + |
|
159 | + if ($conf->global->PRODUCT_USE_UNITS) { |
|
160 | + $this->posxtva = 99; |
|
161 | + $this->posxup = 114; |
|
162 | + $this->posxqty = 130; |
|
163 | + $this->posxunit = 147; |
|
164 | 164 | } |
165 | 165 | //if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) $this->posxtva=$this->posxup; |
166 | - $this->posxpicture=$this->posxtva - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH)?20:$conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH); // width of images |
|
166 | + $this->posxpicture = $this->posxtva - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH) ? 20 : $conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH); // width of images |
|
167 | 167 | if ($this->page_largeur < 210) // To work with US executive format |
168 | 168 | { |
169 | - $this->posxpicture-=20; |
|
170 | - $this->posxtva-=20; |
|
171 | - $this->posxup-=20; |
|
172 | - $this->posxqty-=20; |
|
173 | - $this->posxunit-=20; |
|
174 | - $this->posxdiscount-=20; |
|
175 | - $this->postotalht-=20; |
|
169 | + $this->posxpicture -= 20; |
|
170 | + $this->posxtva -= 20; |
|
171 | + $this->posxup -= 20; |
|
172 | + $this->posxqty -= 20; |
|
173 | + $this->posxunit -= 20; |
|
174 | + $this->posxdiscount -= 20; |
|
175 | + $this->postotalht -= 20; |
|
176 | 176 | } |
177 | 177 | |
178 | - $this->tva=array(); |
|
179 | - $this->localtax1=array(); |
|
180 | - $this->localtax2=array(); |
|
181 | - $this->atleastoneratenotnull=0; |
|
182 | - $this->atleastonediscount=0; |
|
178 | + $this->tva = array(); |
|
179 | + $this->localtax1 = array(); |
|
180 | + $this->localtax2 = array(); |
|
181 | + $this->atleastoneratenotnull = 0; |
|
182 | + $this->atleastonediscount = 0; |
|
183 | 183 | } |
184 | 184 | |
185 | 185 | |
@@ -195,20 +195,20 @@ discard block |
||
195 | 195 | * @param int $hideref Do not show ref |
196 | 196 | * @return int 1=OK, 0=KO |
197 | 197 | */ |
198 | - function write_file($object, $outputlangs='', $srctemplatepath='', $hidedetails=0, $hidedesc=0, $hideref=0) |
|
198 | + function write_file($object, $outputlangs = '', $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0) |
|
199 | 199 | { |
200 | 200 | // phpcs:enable |
201 | - global $user,$langs,$conf,$mysoc,$hookmanager,$nblignes; |
|
201 | + global $user, $langs, $conf, $mysoc, $hookmanager, $nblignes; |
|
202 | 202 | |
203 | 203 | // Get source company |
204 | - if (! is_object($object->thirdparty)) $object->fetch_thirdparty(); |
|
205 | - if (! is_object($object->thirdparty)) $object->thirdparty=$mysoc; // If fetch_thirdparty fails, object has no socid (specimen) |
|
206 | - $this->emetteur=$object->thirdparty; |
|
207 | - if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2); // By default, if was not defined |
|
204 | + if (!is_object($object->thirdparty)) $object->fetch_thirdparty(); |
|
205 | + if (!is_object($object->thirdparty)) $object->thirdparty = $mysoc; // If fetch_thirdparty fails, object has no socid (specimen) |
|
206 | + $this->emetteur = $object->thirdparty; |
|
207 | + if (!$this->emetteur->country_code) $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default, if was not defined |
|
208 | 208 | |
209 | - if (! is_object($outputlangs)) $outputlangs=$langs; |
|
209 | + if (!is_object($outputlangs)) $outputlangs = $langs; |
|
210 | 210 | // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO |
211 | - if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1'; |
|
211 | + if (!empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output = 'ISO-8859-1'; |
|
212 | 212 | |
213 | 213 | // Load translation files required by the page |
214 | 214 | $outputlangs->loadLangs(array("main", "dict", "companies", "bills", "products")); |
@@ -225,22 +225,22 @@ discard block |
||
225 | 225 | if ($object->specimen) |
226 | 226 | { |
227 | 227 | $dir = $conf->fournisseur->facture->dir_output; |
228 | - $file = $dir . "/SPECIMEN.pdf"; |
|
228 | + $file = $dir."/SPECIMEN.pdf"; |
|
229 | 229 | } |
230 | 230 | else |
231 | 231 | { |
232 | 232 | $objectref = dol_sanitizeFileName($object->ref); |
233 | 233 | $objectrefsupplier = dol_sanitizeFileName($object->ref_supplier); |
234 | - $dir = $conf->fournisseur->facture->dir_output.'/'.get_exdir($object->id,2,0,0,$object,'invoice_supplier').$objectref; |
|
235 | - $file = $dir . "/" . $objectref . ".pdf"; |
|
236 | - if (! empty($conf->global->SUPPLIER_REF_IN_NAME)) $file = $dir . "/" . $objectref . ($objectrefsupplier?"_".$objectrefsupplier:"").".pdf"; |
|
234 | + $dir = $conf->fournisseur->facture->dir_output.'/'.get_exdir($object->id, 2, 0, 0, $object, 'invoice_supplier').$objectref; |
|
235 | + $file = $dir."/".$objectref.".pdf"; |
|
236 | + if (!empty($conf->global->SUPPLIER_REF_IN_NAME)) $file = $dir."/".$objectref.($objectrefsupplier ? "_".$objectrefsupplier : "").".pdf"; |
|
237 | 237 | } |
238 | 238 | |
239 | - if (! file_exists($dir)) |
|
239 | + if (!file_exists($dir)) |
|
240 | 240 | { |
241 | 241 | if (dol_mkdir($dir) < 0) |
242 | 242 | { |
243 | - $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir); |
|
243 | + $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir); |
|
244 | 244 | return 0; |
245 | 245 | } |
246 | 246 | } |
@@ -248,25 +248,25 @@ discard block |
||
248 | 248 | if (file_exists($dir)) |
249 | 249 | { |
250 | 250 | // Add pdfgeneration hook |
251 | - if (! is_object($hookmanager)) |
|
251 | + if (!is_object($hookmanager)) |
|
252 | 252 | { |
253 | 253 | include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; |
254 | - $hookmanager=new HookManager($this->db); |
|
254 | + $hookmanager = new HookManager($this->db); |
|
255 | 255 | } |
256 | 256 | $hookmanager->initHooks(array('pdfgeneration')); |
257 | - $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs); |
|
257 | + $parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs); |
|
258 | 258 | global $action; |
259 | - $reshook=$hookmanager->executeHooks('beforePDFCreation',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks |
|
259 | + $reshook = $hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks |
|
260 | 260 | |
261 | 261 | $nblignes = count($object->lines); |
262 | 262 | |
263 | - $pdf=pdf_getInstance($this->format); |
|
264 | - $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance |
|
265 | - $heightforinfotot = 50; // Height reserved to output the info and total part |
|
266 | - $heightforfreetext= (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT)?$conf->global->MAIN_PDF_FREETEXT_HEIGHT:5); // Height reserved to output the free text on last page |
|
267 | - $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin) |
|
268 | - if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS >0) $heightforfooter+= 6; |
|
269 | - $pdf->SetAutoPageBreak(1,0); |
|
263 | + $pdf = pdf_getInstance($this->format); |
|
264 | + $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance |
|
265 | + $heightforinfotot = 50; // Height reserved to output the info and total part |
|
266 | + $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5); // Height reserved to output the free text on last page |
|
267 | + $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin) |
|
268 | + if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS > 0) $heightforfooter += 6; |
|
269 | + $pdf->SetAutoPageBreak(1, 0); |
|
270 | 270 | |
271 | 271 | if (class_exists('TCPDF')) |
272 | 272 | { |
@@ -275,27 +275,27 @@ discard block |
||
275 | 275 | } |
276 | 276 | $pdf->SetFont(pdf_getPDFFont($outputlangs)); |
277 | 277 | // Set path to the background PDF File |
278 | - if (! empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) |
|
278 | + if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) |
|
279 | 279 | { |
280 | 280 | $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND); |
281 | 281 | $tplidx = $pdf->importPage(1); |
282 | 282 | } |
283 | 283 | |
284 | 284 | $pdf->Open(); |
285 | - $pagenb=0; |
|
286 | - $pdf->SetDrawColor(128,128,128); |
|
285 | + $pagenb = 0; |
|
286 | + $pdf->SetDrawColor(128, 128, 128); |
|
287 | 287 | |
288 | 288 | $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref)); |
289 | 289 | $pdf->SetSubject($outputlangs->transnoentities("Invoice")); |
290 | 290 | $pdf->SetCreator("Dolibarr ".DOL_VERSION); |
291 | 291 | $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs))); |
292 | 292 | $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("Order")." ".$outputlangs->convToOutputCharset($object->thirdparty->name)); |
293 | - if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); |
|
293 | + if (!empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); |
|
294 | 294 | |
295 | - $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right |
|
295 | + $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right |
|
296 | 296 | |
297 | 297 | // Positionne $this->atleastonediscount si on a au moins une remise |
298 | - for ($i = 0 ; $i < $nblignes ; $i++) |
|
298 | + for ($i = 0; $i < $nblignes; $i++) |
|
299 | 299 | { |
300 | 300 | if ($object->lines[$i]->remise_percent) |
301 | 301 | { |
@@ -304,25 +304,25 @@ discard block |
||
304 | 304 | } |
305 | 305 | if (empty($this->atleastonediscount) && empty($conf->global->PRODUCT_USE_UNITS)) |
306 | 306 | { |
307 | - $this->posxpicture+=($this->postotalht - $this->posxdiscount); |
|
308 | - $this->posxtva+=($this->postotalht - $this->posxdiscount); |
|
309 | - $this->posxup+=($this->postotalht - $this->posxdiscount); |
|
310 | - $this->posxqty+=($this->postotalht - $this->posxdiscount); |
|
311 | - $this->posxdiscount+=($this->postotalht - $this->posxdiscount); |
|
307 | + $this->posxpicture += ($this->postotalht - $this->posxdiscount); |
|
308 | + $this->posxtva += ($this->postotalht - $this->posxdiscount); |
|
309 | + $this->posxup += ($this->postotalht - $this->posxdiscount); |
|
310 | + $this->posxqty += ($this->postotalht - $this->posxdiscount); |
|
311 | + $this->posxdiscount += ($this->postotalht - $this->posxdiscount); |
|
312 | 312 | //$this->postotalht; |
313 | 313 | } |
314 | 314 | |
315 | 315 | // New page |
316 | 316 | $pdf->AddPage(); |
317 | - if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
|
317 | + if (!empty($tplidx)) $pdf->useTemplate($tplidx); |
|
318 | 318 | $pagenb++; |
319 | 319 | $top_shift = $this->_pagehead($pdf, $object, 1, $outputlangs); |
320 | - $pdf->SetFont('','', $default_font_size - 1); |
|
321 | - $pdf->MultiCell(0, 3, ''); // Set interline to 3 |
|
322 | - $pdf->SetTextColor(0,0,0); |
|
320 | + $pdf->SetFont('', '', $default_font_size - 1); |
|
321 | + $pdf->MultiCell(0, 3, ''); // Set interline to 3 |
|
322 | + $pdf->SetTextColor(0, 0, 0); |
|
323 | 323 | |
324 | - $tab_top = 90+$top_shift; |
|
325 | - $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?42+$top_shift:10); |
|
324 | + $tab_top = 90 + $top_shift; |
|
325 | + $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 + $top_shift : 10); |
|
326 | 326 | |
327 | 327 | // Incoterm |
328 | 328 | if ($conf->incoterm->enabled) |
@@ -332,34 +332,34 @@ discard block |
||
332 | 332 | { |
333 | 333 | $tab_top -= 2; |
334 | 334 | |
335 | - $pdf->SetFont('','', $default_font_size - 1); |
|
336 | - $pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top-1, dol_htmlentitiesbr($desc_incoterms), 0, 1); |
|
335 | + $pdf->SetFont('', '', $default_font_size - 1); |
|
336 | + $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1, dol_htmlentitiesbr($desc_incoterms), 0, 1); |
|
337 | 337 | $nexY = $pdf->GetY(); |
338 | - $height_incoterms=$nexY-$tab_top; |
|
338 | + $height_incoterms = $nexY - $tab_top; |
|
339 | 339 | |
340 | 340 | // Rect prend une longueur en 3eme param |
341 | - $pdf->SetDrawColor(192,192,192); |
|
342 | - $pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_incoterms+1); |
|
341 | + $pdf->SetDrawColor(192, 192, 192); |
|
342 | + $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_incoterms + 1); |
|
343 | 343 | |
344 | - $tab_top = $nexY+6; |
|
344 | + $tab_top = $nexY + 6; |
|
345 | 345 | } |
346 | 346 | } |
347 | 347 | |
348 | 348 | // Affiche notes |
349 | - if (! empty($object->note_public)) |
|
349 | + if (!empty($object->note_public)) |
|
350 | 350 | { |
351 | 351 | $tab_top -= 2; |
352 | 352 | |
353 | - $pdf->SetFont('','', $default_font_size - 1); |
|
354 | - $pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top-1, dol_htmlentitiesbr($object->note_public), 0, 1); |
|
353 | + $pdf->SetFont('', '', $default_font_size - 1); |
|
354 | + $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1, dol_htmlentitiesbr($object->note_public), 0, 1); |
|
355 | 355 | $nexY = $pdf->GetY(); |
356 | - $height_note=$nexY-$tab_top; |
|
356 | + $height_note = $nexY - $tab_top; |
|
357 | 357 | |
358 | 358 | // Rect prend une longueur en 3eme param |
359 | - $pdf->SetDrawColor(192,192,192); |
|
360 | - $pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+1); |
|
359 | + $pdf->SetDrawColor(192, 192, 192); |
|
360 | + $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 1); |
|
361 | 361 | |
362 | - $tab_top = $nexY+6; |
|
362 | + $tab_top = $nexY + 6; |
|
363 | 363 | } |
364 | 364 | |
365 | 365 | $iniY = $tab_top + 7; |
@@ -367,45 +367,45 @@ discard block |
||
367 | 367 | $nexY = $tab_top + 7; |
368 | 368 | |
369 | 369 | // Loop on each lines |
370 | - for ($i = 0 ; $i < $nblignes ; $i++) |
|
370 | + for ($i = 0; $i < $nblignes; $i++) |
|
371 | 371 | { |
372 | 372 | $curY = $nexY; |
373 | - $pdf->SetFont('','', $default_font_size - 1); // Into loop to work with multipage |
|
374 | - $pdf->SetTextColor(0,0,0); |
|
373 | + $pdf->SetFont('', '', $default_font_size - 1); // Into loop to work with multipage |
|
374 | + $pdf->SetTextColor(0, 0, 0); |
|
375 | 375 | |
376 | 376 | $pdf->setTopMargin($tab_top_newpage); |
377 | - $pdf->setPageOrientation('', 1, $heightforfooter+$heightforfreetext+$heightforinfotot); // The only function to edit the bottom margin of current page to set it. |
|
378 | - $pageposbefore=$pdf->getPage(); |
|
377 | + $pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext + $heightforinfotot); // The only function to edit the bottom margin of current page to set it. |
|
378 | + $pageposbefore = $pdf->getPage(); |
|
379 | 379 | |
380 | 380 | // Description of product line |
381 | - $curX = $this->posxdesc-1; |
|
382 | - $showpricebeforepagebreak=1; |
|
381 | + $curX = $this->posxdesc - 1; |
|
382 | + $showpricebeforepagebreak = 1; |
|
383 | 383 | |
384 | 384 | $pdf->startTransaction(); |
385 | - pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxtva-$curX,3,$curX,$curY,$hideref,$hidedesc,1); |
|
386 | - $pageposafter=$pdf->getPage(); |
|
385 | + pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxtva - $curX, 3, $curX, $curY, $hideref, $hidedesc, 1); |
|
386 | + $pageposafter = $pdf->getPage(); |
|
387 | 387 | if ($pageposafter > $pageposbefore) // There is a pagebreak |
388 | 388 | { |
389 | 389 | $pdf->rollbackTransaction(true); |
390 | - $pageposafter=$pageposbefore; |
|
390 | + $pageposafter = $pageposbefore; |
|
391 | 391 | //print $pageposafter.'-'.$pageposbefore;exit; |
392 | - $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it. |
|
393 | - pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxtva-$curX,4,$curX,$curY,$hideref,$hidedesc,1); |
|
394 | - $posyafter=$pdf->GetY(); |
|
395 | - if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))) // There is no space left for total+free text |
|
392 | + $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it. |
|
393 | + pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxtva - $curX, 4, $curX, $curY, $hideref, $hidedesc, 1); |
|
394 | + $posyafter = $pdf->GetY(); |
|
395 | + if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) // There is no space left for total+free text |
|
396 | 396 | { |
397 | - if ($i == ($nblignes-1)) // No more lines, and no space left to show total, so we create a new page |
|
397 | + if ($i == ($nblignes - 1)) // No more lines, and no space left to show total, so we create a new page |
|
398 | 398 | { |
399 | - $pdf->AddPage('','',true); |
|
400 | - if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
|
399 | + $pdf->AddPage('', '', true); |
|
400 | + if (!empty($tplidx)) $pdf->useTemplate($tplidx); |
|
401 | 401 | if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); |
402 | - $pdf->setPage($pageposafter+1); |
|
402 | + $pdf->setPage($pageposafter + 1); |
|
403 | 403 | } |
404 | 404 | } |
405 | 405 | else |
406 | 406 | { |
407 | 407 | // We found a page break |
408 | - $showpricebeforepagebreak=0; |
|
408 | + $showpricebeforepagebreak = 0; |
|
409 | 409 | } |
410 | 410 | } |
411 | 411 | else // No pagebreak |
@@ -414,55 +414,55 @@ discard block |
||
414 | 414 | } |
415 | 415 | |
416 | 416 | $nexY = $pdf->GetY(); |
417 | - $pageposafter=$pdf->getPage(); |
|
417 | + $pageposafter = $pdf->getPage(); |
|
418 | 418 | $pdf->setPage($pageposbefore); |
419 | 419 | $pdf->setTopMargin($this->marge_haute); |
420 | - $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. |
|
420 | + $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. |
|
421 | 421 | |
422 | 422 | // We suppose that a too long description is moved completely on next page |
423 | 423 | if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) { |
424 | 424 | $pdf->setPage($pageposafter); $curY = $tab_top_newpage; |
425 | 425 | } |
426 | 426 | |
427 | - $pdf->SetFont('','', $default_font_size - 1); // On repositionne la police par defaut |
|
427 | + $pdf->SetFont('', '', $default_font_size - 1); // On repositionne la police par defaut |
|
428 | 428 | |
429 | 429 | // VAT Rate |
430 | 430 | if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) |
431 | 431 | { |
432 | 432 | $vat_rate = pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails); |
433 | 433 | $pdf->SetXY($this->posxtva, $curY); |
434 | - $pdf->MultiCell($this->posxup-$this->posxtva-1, 3, $vat_rate, 0, 'R'); |
|
434 | + $pdf->MultiCell($this->posxup - $this->posxtva - 1, 3, $vat_rate, 0, 'R'); |
|
435 | 435 | } |
436 | 436 | |
437 | 437 | // Unit price before discount |
438 | 438 | $up_excl_tax = pdf_getlineupexcltax($object, $i, $outputlangs, $hidedetails); |
439 | 439 | $pdf->SetXY($this->posxup, $curY); |
440 | - $pdf->MultiCell($this->posxqty-$this->posxup-0.8, 3, $up_excl_tax, 0, 'R', 0); |
|
440 | + $pdf->MultiCell($this->posxqty - $this->posxup - 0.8, 3, $up_excl_tax, 0, 'R', 0); |
|
441 | 441 | |
442 | 442 | // Unit price before discount |
443 | 443 | $up_excl_tax = pdf_getlineupexcltax($object, $i, $outputlangs, $hidedetails); |
444 | 444 | $pdf->SetXY($this->posxup, $curY); |
445 | - $pdf->MultiCell($this->posxqty-$this->posxup-0.8, 3, $up_excl_tax, 0, 'R', 0); |
|
445 | + $pdf->MultiCell($this->posxqty - $this->posxup - 0.8, 3, $up_excl_tax, 0, 'R', 0); |
|
446 | 446 | |
447 | 447 | // Quantity |
448 | 448 | $qty = pdf_getlineqty($object, $i, $outputlangs, $hidedetails); |
449 | 449 | $pdf->SetXY($this->posxqty, $curY); |
450 | 450 | // Enough for 6 chars |
451 | - if($conf->global->PRODUCT_USE_UNITS) |
|
451 | + if ($conf->global->PRODUCT_USE_UNITS) |
|
452 | 452 | { |
453 | - $pdf->MultiCell($this->posxunit-$this->posxqty-0.8, 4, $qty, 0, 'R'); |
|
453 | + $pdf->MultiCell($this->posxunit - $this->posxqty - 0.8, 4, $qty, 0, 'R'); |
|
454 | 454 | } |
455 | 455 | else |
456 | 456 | { |
457 | - $pdf->MultiCell($this->posxdiscount-$this->posxqty-0.8, 4, $qty, 0, 'R'); |
|
457 | + $pdf->MultiCell($this->posxdiscount - $this->posxqty - 0.8, 4, $qty, 0, 'R'); |
|
458 | 458 | } |
459 | 459 | |
460 | 460 | // Unit |
461 | - if($conf->global->PRODUCT_USE_UNITS) |
|
461 | + if ($conf->global->PRODUCT_USE_UNITS) |
|
462 | 462 | { |
463 | 463 | $unit = pdf_getlineunit($object, $i, $outputlangs, $hidedetails, $hookmanager); |
464 | 464 | $pdf->SetXY($this->posxunit, $curY); |
465 | - $pdf->MultiCell($this->posxdiscount-$this->posxunit-0.8, 4, $unit, 0, 'L'); |
|
465 | + $pdf->MultiCell($this->posxdiscount - $this->posxunit - 0.8, 4, $unit, 0, 'L'); |
|
466 | 466 | } |
467 | 467 | |
468 | 468 | // Discount on line |
@@ -470,46 +470,46 @@ discard block |
||
470 | 470 | if ($object->lines[$i]->remise_percent) |
471 | 471 | { |
472 | 472 | $remise_percent = pdf_getlineremisepercent($object, $i, $outputlangs, $hidedetails); |
473 | - $pdf->MultiCell($this->postotalht-$this->posxdiscount-1, 3, $remise_percent."%", 0, 'R'); |
|
473 | + $pdf->MultiCell($this->postotalht - $this->posxdiscount - 1, 3, $remise_percent."%", 0, 'R'); |
|
474 | 474 | } |
475 | 475 | |
476 | 476 | // Total HT line |
477 | 477 | $total_excl_tax = pdf_getlinetotalexcltax($object, $i, $outputlangs); |
478 | 478 | $pdf->SetXY($this->postotalht, $curY); |
479 | - $pdf->MultiCell($this->page_largeur-$this->marge_droite-$this->postotalht, 3, $total_excl_tax, 0, 'R', 0); |
|
479 | + $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->postotalht, 3, $total_excl_tax, 0, 'R', 0); |
|
480 | 480 | |
481 | 481 | // Collecte des totaux par valeur de tva dans $this->tva["taux"]=total_tva |
482 | - if ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) $tvaligne=$object->lines[$i]->multicurrency_total_tva; |
|
483 | - else $tvaligne=$object->lines[$i]->total_tva; |
|
482 | + if ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) $tvaligne = $object->lines[$i]->multicurrency_total_tva; |
|
483 | + else $tvaligne = $object->lines[$i]->total_tva; |
|
484 | 484 | |
485 | - $localtax1ligne=$object->lines[$i]->total_localtax1; |
|
486 | - $localtax2ligne=$object->lines[$i]->total_localtax2; |
|
485 | + $localtax1ligne = $object->lines[$i]->total_localtax1; |
|
486 | + $localtax2ligne = $object->lines[$i]->total_localtax2; |
|
487 | 487 | |
488 | - if (! empty($object->remise_percent)) $tvaligne-=($tvaligne*$object->remise_percent)/100; |
|
488 | + if (!empty($object->remise_percent)) $tvaligne -= ($tvaligne * $object->remise_percent) / 100; |
|
489 | 489 | |
490 | - $vatrate=(string) $object->lines[$i]->tva_tx; |
|
491 | - $localtax1rate=(string) $object->lines[$i]->localtax1_tx; |
|
492 | - $localtax2rate=(string) $object->lines[$i]->localtax2_tx; |
|
490 | + $vatrate = (string) $object->lines[$i]->tva_tx; |
|
491 | + $localtax1rate = (string) $object->lines[$i]->localtax1_tx; |
|
492 | + $localtax2rate = (string) $object->lines[$i]->localtax2_tx; |
|
493 | 493 | |
494 | - if (($object->lines[$i]->info_bits & 0x01) == 0x01) $vatrate.='*'; |
|
495 | - if (empty($this->tva[$vatrate])) $this->tva[$vatrate]=0; |
|
496 | - if (empty($this->localtax1[$localtax1rate])) $this->localtax1[$localtax1rate]=0; |
|
497 | - if (empty($this->localtax2[$localtax2rate])) $this->localtax2[$localtax2rate]=0; |
|
494 | + if (($object->lines[$i]->info_bits & 0x01) == 0x01) $vatrate .= '*'; |
|
495 | + if (empty($this->tva[$vatrate])) $this->tva[$vatrate] = 0; |
|
496 | + if (empty($this->localtax1[$localtax1rate])) $this->localtax1[$localtax1rate] = 0; |
|
497 | + if (empty($this->localtax2[$localtax2rate])) $this->localtax2[$localtax2rate] = 0; |
|
498 | 498 | $this->tva[$vatrate] += $tvaligne; |
499 | - $this->localtax1[$localtax1rate]+=$localtax1ligne; |
|
500 | - $this->localtax2[$localtax2rate]+=$localtax2ligne; |
|
499 | + $this->localtax1[$localtax1rate] += $localtax1ligne; |
|
500 | + $this->localtax2[$localtax2rate] += $localtax2ligne; |
|
501 | 501 | |
502 | 502 | // Add line |
503 | - if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1)) |
|
503 | + if (!empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1)) |
|
504 | 504 | { |
505 | 505 | $pdf->setPage($pageposafter); |
506 | - $pdf->SetLineStyle(array('dash'=>'1,1','color'=>array(80,80,80))); |
|
506 | + $pdf->SetLineStyle(array('dash'=>'1,1', 'color'=>array(80, 80, 80))); |
|
507 | 507 | //$pdf->SetDrawColor(190,190,200); |
508 | - $pdf->line($this->marge_gauche, $nexY+1, $this->page_largeur - $this->marge_droite, $nexY+1); |
|
508 | + $pdf->line($this->marge_gauche, $nexY + 1, $this->page_largeur - $this->marge_droite, $nexY + 1); |
|
509 | 509 | $pdf->SetLineStyle(array('dash'=>0)); |
510 | 510 | } |
511 | 511 | |
512 | - $nexY+=2; // Passe espace entre les lignes |
|
512 | + $nexY += 2; // Passe espace entre les lignes |
|
513 | 513 | |
514 | 514 | // Detect if some page were added automatically and output _tableau for past pages |
515 | 515 | while ($pagenb < $pageposafter) |
@@ -523,13 +523,13 @@ discard block |
||
523 | 523 | { |
524 | 524 | $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code); |
525 | 525 | } |
526 | - $this->_pagefoot($pdf,$object,$outputlangs,1); |
|
526 | + $this->_pagefoot($pdf, $object, $outputlangs, 1); |
|
527 | 527 | $pagenb++; |
528 | 528 | $pdf->setPage($pagenb); |
529 | - $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. |
|
529 | + $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. |
|
530 | 530 | if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); |
531 | 531 | } |
532 | - if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak) |
|
532 | + if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak) |
|
533 | 533 | { |
534 | 534 | if ($pagenb == 1) |
535 | 535 | { |
@@ -539,10 +539,10 @@ discard block |
||
539 | 539 | { |
540 | 540 | $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code); |
541 | 541 | } |
542 | - $this->_pagefoot($pdf,$object,$outputlangs,1); |
|
542 | + $this->_pagefoot($pdf, $object, $outputlangs, 1); |
|
543 | 543 | // New page |
544 | 544 | $pdf->AddPage(); |
545 | - if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
|
545 | + if (!empty($tplidx)) $pdf->useTemplate($tplidx); |
|
546 | 546 | $pagenb++; |
547 | 547 | if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); |
548 | 548 | } |
@@ -552,55 +552,55 @@ discard block |
||
552 | 552 | if ($pagenb == 1) |
553 | 553 | { |
554 | 554 | $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0, $object->multicurrency_code); |
555 | - $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; |
|
555 | + $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; |
|
556 | 556 | } |
557 | 557 | else |
558 | 558 | { |
559 | 559 | $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0, $object->multicurrency_code); |
560 | - $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; |
|
560 | + $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; |
|
561 | 561 | } |
562 | 562 | |
563 | 563 | // Affiche zone totaux |
564 | - $posy=$this->_tableau_tot($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs); |
|
564 | + $posy = $this->_tableau_tot($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs); |
|
565 | 565 | |
566 | - $amount_credit_notes_included=0; |
|
567 | - $amount_deposits_included=0; |
|
566 | + $amount_credit_notes_included = 0; |
|
567 | + $amount_deposits_included = 0; |
|
568 | 568 | |
569 | 569 | if ($deja_regle || $amount_credit_notes_included || $amount_deposits_included) |
570 | 570 | { |
571 | - $posy=$this->_tableau_versements($pdf, $object, $posy, $outputlangs); |
|
571 | + $posy = $this->_tableau_versements($pdf, $object, $posy, $outputlangs); |
|
572 | 572 | } |
573 | 573 | |
574 | 574 | // Pied de page |
575 | 575 | $this->_pagefoot($pdf, $object, $outputlangs); |
576 | - if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages(); |
|
576 | + if (method_exists($pdf, 'AliasNbPages')) $pdf->AliasNbPages(); |
|
577 | 577 | |
578 | 578 | $pdf->Close(); |
579 | 579 | |
580 | - $pdf->Output($file,'F'); |
|
580 | + $pdf->Output($file, 'F'); |
|
581 | 581 | |
582 | 582 | // Add pdfgeneration hook |
583 | 583 | $hookmanager->initHooks(array('pdfgeneration')); |
584 | - $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs); |
|
584 | + $parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs); |
|
585 | 585 | global $action; |
586 | - $reshook=$hookmanager->executeHooks('afterPDFCreation',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks |
|
586 | + $reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks |
|
587 | 587 | |
588 | - if (! empty($conf->global->MAIN_UMASK)) |
|
588 | + if (!empty($conf->global->MAIN_UMASK)) |
|
589 | 589 | @chmod($file, octdec($conf->global->MAIN_UMASK)); |
590 | 590 | |
591 | 591 | $this->result = array('fullpath'=>$file); |
592 | 592 | |
593 | - return 1; // Pas d'erreur |
|
593 | + return 1; // Pas d'erreur |
|
594 | 594 | } |
595 | 595 | else |
596 | 596 | { |
597 | - $this->error=$langs->trans("ErrorCanNotCreateDir",$dir); |
|
597 | + $this->error = $langs->trans("ErrorCanNotCreateDir", $dir); |
|
598 | 598 | return 0; |
599 | 599 | } |
600 | 600 | } |
601 | 601 | else |
602 | 602 | { |
603 | - $this->error=$langs->trans("ErrorConstantNotDefined","SUPPLIER_OUTPUTDIR"); |
|
603 | + $this->error = $langs->trans("ErrorConstantNotDefined", "SUPPLIER_OUTPUTDIR"); |
|
604 | 604 | return 0; |
605 | 605 | } |
606 | 606 | } |
@@ -619,13 +619,13 @@ discard block |
||
619 | 619 | function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs) |
620 | 620 | { |
621 | 621 | // phpcs:enable |
622 | - global $conf,$mysoc; |
|
622 | + global $conf, $mysoc; |
|
623 | 623 | |
624 | 624 | $default_font_size = pdf_getPDFFontSize($outputlangs); |
625 | 625 | |
626 | 626 | $tab2_top = $posy; |
627 | 627 | $tab2_hl = 4; |
628 | - $pdf->SetFont('','', $default_font_size - 1); |
|
628 | + $pdf->SetFont('', '', $default_font_size - 1); |
|
629 | 629 | |
630 | 630 | $pdf->SetXY($this->marge_gauche, $tab2_top + 0); |
631 | 631 | // If France, show VAT mention if not applicable |
@@ -638,25 +638,25 @@ discard block |
||
638 | 638 | $col1x = 120; $col2x = 170; |
639 | 639 | if ($this->page_largeur < 210) // To work with US executive format |
640 | 640 | { |
641 | - $col2x-=20; |
|
641 | + $col2x -= 20; |
|
642 | 642 | } |
643 | 643 | $largcol2 = ($this->page_largeur - $this->marge_droite - $col2x); |
644 | 644 | |
645 | - $index=0; |
|
645 | + $index = 0; |
|
646 | 646 | |
647 | 647 | // Total HT |
648 | - $pdf->SetFillColor(255,255,255); |
|
648 | + $pdf->SetFillColor(255, 255, 255); |
|
649 | 649 | $pdf->SetXY($col1x, $tab2_top + 0); |
650 | - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT"), 0, 'L', 1); |
|
650 | + $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT"), 0, 'L', 1); |
|
651 | 651 | |
652 | 652 | $total_ht = (($conf->multicurrency->enabled && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ht : $object->total_ht); |
653 | 653 | $pdf->SetXY($col2x, $tab2_top + 0); |
654 | 654 | $pdf->MultiCell($largcol2, $tab2_hl, price($total_ht + $object->remise), 0, 'R', 1); |
655 | 655 | |
656 | 656 | // Show VAT by rates and total |
657 | - $pdf->SetFillColor(248,248,248); |
|
657 | + $pdf->SetFillColor(248, 248, 248); |
|
658 | 658 | |
659 | - foreach( $this->tva as $tvakey => $tvaval ) |
|
659 | + foreach ($this->tva as $tvakey => $tvaval) |
|
660 | 660 | { |
661 | 661 | if ($tvakey > 0) // On affiche pas taux 0 |
662 | 662 | { |
@@ -665,46 +665,46 @@ discard block |
||
665 | 665 | $index++; |
666 | 666 | $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); |
667 | 667 | |
668 | - $tvacompl=''; |
|
668 | + $tvacompl = ''; |
|
669 | 669 | |
670 | - if (preg_match('/\*/',$tvakey)) |
|
670 | + if (preg_match('/\*/', $tvakey)) |
|
671 | 671 | { |
672 | - $tvakey=str_replace('*','',$tvakey); |
|
672 | + $tvakey = str_replace('*', '', $tvakey); |
|
673 | 673 | $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; |
674 | 674 | } |
675 | 675 | |
676 | - $totalvat =$outputlangs->transcountrynoentities("TotalVAT",$mysoc->country_code).' '; |
|
677 | - $totalvat.=vatrate($tvakey,1).$tvacompl; |
|
678 | - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1); |
|
676 | + $totalvat = $outputlangs->transcountrynoentities("TotalVAT", $mysoc->country_code).' '; |
|
677 | + $totalvat .= vatrate($tvakey, 1).$tvacompl; |
|
678 | + $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1); |
|
679 | 679 | |
680 | 680 | $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); |
681 | 681 | $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval), 0, 'R', 1); |
682 | 682 | } |
683 | 683 | } |
684 | - if (! $this->atleastoneratenotnull) // If no vat at all |
|
684 | + if (!$this->atleastoneratenotnull) // If no vat at all |
|
685 | 685 | { |
686 | 686 | $index++; |
687 | 687 | $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); |
688 | - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transcountrynoentities("TotalVAT", $mysoc->country_code), 0, 'L', 1); |
|
688 | + $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transcountrynoentities("TotalVAT", $mysoc->country_code), 0, 'L', 1); |
|
689 | 689 | $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); |
690 | 690 | $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_tva), 0, 'R', 1); |
691 | 691 | |
692 | 692 | // Total LocalTax1 |
693 | - if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on' && $object->total_localtax1>0) |
|
693 | + if (!empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION == 'localtax1on' && $object->total_localtax1 > 0) |
|
694 | 694 | { |
695 | 695 | $index++; |
696 | 696 | $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); |
697 | - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transcountrynoentities("TotalLT1",$mysoc->country_code), 0, 'L', 1); |
|
697 | + $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code), 0, 'L', 1); |
|
698 | 698 | $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); |
699 | 699 | $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_localtax1), 0, 'R', 1); |
700 | 700 | } |
701 | 701 | |
702 | 702 | // Total LocalTax2 |
703 | - if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on' && $object->total_localtax2>0) |
|
703 | + if (!empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION == 'localtax2on' && $object->total_localtax2 > 0) |
|
704 | 704 | { |
705 | 705 | $index++; |
706 | 706 | $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); |
707 | - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transcountrynoentities("TotalLT2",$mysoc->country_code), 0, 'L', 1); |
|
707 | + $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code), 0, 'L', 1); |
|
708 | 708 | $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); |
709 | 709 | $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_localtax2), 0, 'R', 1); |
710 | 710 | } |
@@ -714,7 +714,7 @@ discard block |
||
714 | 714 | //if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on') |
715 | 715 | //{ |
716 | 716 | //Local tax 1 |
717 | - foreach( $this->localtax1 as $tvakey => $tvaval ) |
|
717 | + foreach ($this->localtax1 as $tvakey => $tvaval) |
|
718 | 718 | { |
719 | 719 | if ($tvakey != 0) // On affiche pas taux 0 |
720 | 720 | { |
@@ -723,15 +723,15 @@ discard block |
||
723 | 723 | $index++; |
724 | 724 | $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); |
725 | 725 | |
726 | - $tvacompl=''; |
|
727 | - if (preg_match('/\*/',$tvakey)) |
|
726 | + $tvacompl = ''; |
|
727 | + if (preg_match('/\*/', $tvakey)) |
|
728 | 728 | { |
729 | - $tvakey=str_replace('*','',$tvakey); |
|
729 | + $tvakey = str_replace('*', '', $tvakey); |
|
730 | 730 | $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; |
731 | 731 | } |
732 | - $totalvat = $outputlangs->transcountrynoentities("TotalLT1",$mysoc->country_code).' '; |
|
733 | - $totalvat.= vatrate(abs($tvakey),1).$tvacompl; |
|
734 | - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1); |
|
732 | + $totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code).' '; |
|
733 | + $totalvat .= vatrate(abs($tvakey), 1).$tvacompl; |
|
734 | + $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1); |
|
735 | 735 | |
736 | 736 | $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); |
737 | 737 | $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval), 0, 'R', 1); |
@@ -742,7 +742,7 @@ discard block |
||
742 | 742 | //if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on') |
743 | 743 | //{ |
744 | 744 | //Local tax 2 |
745 | - foreach( $this->localtax2 as $tvakey => $tvaval ) |
|
745 | + foreach ($this->localtax2 as $tvakey => $tvaval) |
|
746 | 746 | { |
747 | 747 | if ($tvakey != 0) // On affiche pas taux 0 |
748 | 748 | { |
@@ -751,15 +751,15 @@ discard block |
||
751 | 751 | $index++; |
752 | 752 | $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); |
753 | 753 | |
754 | - $tvacompl=''; |
|
755 | - if (preg_match('/\*/',$tvakey)) |
|
754 | + $tvacompl = ''; |
|
755 | + if (preg_match('/\*/', $tvakey)) |
|
756 | 756 | { |
757 | - $tvakey=str_replace('*','',$tvakey); |
|
757 | + $tvakey = str_replace('*', '', $tvakey); |
|
758 | 758 | $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; |
759 | 759 | } |
760 | - $totalvat = $outputlangs->transcountrynoentities("TotalLT2",$mysoc->country_code).' '; |
|
761 | - $totalvat.= vatrate(abs($tvakey),1).$tvacompl; |
|
762 | - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1); |
|
760 | + $totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).' '; |
|
761 | + $totalvat .= vatrate(abs($tvakey), 1).$tvacompl; |
|
762 | + $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1); |
|
763 | 763 | |
764 | 764 | $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); |
765 | 765 | $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval), 0, 'R', 1); |
@@ -768,46 +768,46 @@ discard block |
||
768 | 768 | //} |
769 | 769 | } |
770 | 770 | |
771 | - $useborder=0; |
|
771 | + $useborder = 0; |
|
772 | 772 | |
773 | 773 | // Total TTC |
774 | 774 | $index++; |
775 | 775 | $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); |
776 | - $pdf->SetTextColor(0,0,60); |
|
777 | - $pdf->SetFillColor(224,224,224); |
|
778 | - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC"), $useborder, 'L', 1); |
|
776 | + $pdf->SetTextColor(0, 0, 60); |
|
777 | + $pdf->SetFillColor(224, 224, 224); |
|
778 | + $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC"), $useborder, 'L', 1); |
|
779 | 779 | |
780 | 780 | $total_ttc = ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ttc : $object->total_ttc; |
781 | 781 | $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); |
782 | 782 | $pdf->MultiCell($largcol2, $tab2_hl, price($total_ttc), $useborder, 'R', 1); |
783 | 783 | |
784 | - $creditnoteamount=0; |
|
785 | - $depositsamount=0; |
|
784 | + $creditnoteamount = 0; |
|
785 | + $depositsamount = 0; |
|
786 | 786 | //$creditnoteamount=$object->getSumCreditNotesUsed(); |
787 | 787 | //$depositsamount=$object->getSumDepositsUsed(); |
788 | 788 | //print "x".$creditnoteamount."-".$depositsamount;exit; |
789 | 789 | $resteapayer = price2num($total_ttc - $deja_regle - $creditnoteamount - $depositsamount, 'MT'); |
790 | - if (! empty($object->paye)) $resteapayer=0; |
|
790 | + if (!empty($object->paye)) $resteapayer = 0; |
|
791 | 791 | |
792 | 792 | if ($deja_regle > 0) |
793 | 793 | { |
794 | 794 | $index++; |
795 | 795 | |
796 | 796 | $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); |
797 | - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("AlreadyPaid"), 0, 'L', 0); |
|
797 | + $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("AlreadyPaid"), 0, 'L', 0); |
|
798 | 798 | |
799 | 799 | $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); |
800 | 800 | $pdf->MultiCell($largcol2, $tab2_hl, price($deja_regle), 0, 'R', 0); |
801 | 801 | |
802 | 802 | $index++; |
803 | - $pdf->SetTextColor(0,0,60); |
|
803 | + $pdf->SetTextColor(0, 0, 60); |
|
804 | 804 | $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); |
805 | - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("RemainderToPay"), $useborder, 'L', 1); |
|
805 | + $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("RemainderToPay"), $useborder, 'L', 1); |
|
806 | 806 | |
807 | 807 | $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); |
808 | 808 | $pdf->MultiCell($largcol2, $tab2_hl, price($resteapayer), $useborder, 'R', 1); |
809 | - $pdf->SetFont('','', $default_font_size - 1); |
|
810 | - $pdf->SetTextColor(0,0,0); |
|
809 | + $pdf->SetFont('', '', $default_font_size - 1); |
|
810 | + $pdf->SetTextColor(0, 0, 0); |
|
811 | 811 | } |
812 | 812 | |
813 | 813 | $index++; |
@@ -827,77 +827,77 @@ discard block |
||
827 | 827 | * @param string $currency Currency code |
828 | 828 | * @return void |
829 | 829 | */ |
830 | - function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0, $currency='') |
|
830 | + function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency = '') |
|
831 | 831 | { |
832 | 832 | global $conf; |
833 | 833 | |
834 | 834 | // Force to disable hidetop and hidebottom |
835 | - $hidebottom=0; |
|
836 | - if ($hidetop) $hidetop=-1; |
|
835 | + $hidebottom = 0; |
|
836 | + if ($hidetop) $hidetop = -1; |
|
837 | 837 | |
838 | 838 | $currency = !empty($currency) ? $currency : $conf->currency; |
839 | 839 | $default_font_size = pdf_getPDFFontSize($outputlangs); |
840 | 840 | |
841 | 841 | // Amount in (at tab_top - 1) |
842 | - $pdf->SetTextColor(0,0,0); |
|
843 | - $pdf->SetFont('','',$default_font_size - 2); |
|
842 | + $pdf->SetTextColor(0, 0, 0); |
|
843 | + $pdf->SetFont('', '', $default_font_size - 2); |
|
844 | 844 | |
845 | 845 | if (empty($hidetop)) |
846 | 846 | { |
847 | - $titre = $outputlangs->transnoentities("AmountInCurrency",$outputlangs->transnoentitiesnoconv("Currency".$currency)); |
|
848 | - $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top-4); |
|
847 | + $titre = $outputlangs->transnoentities("AmountInCurrency", $outputlangs->transnoentitiesnoconv("Currency".$currency)); |
|
848 | + $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top - 4); |
|
849 | 849 | $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre); |
850 | 850 | |
851 | 851 | //$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR='230,230,230'; |
852 | - if (! empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_droite-$this->marge_gauche, 5, 'F', null, explode(',',$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)); |
|
852 | + if (!empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_droite - $this->marge_gauche, 5, 'F', null, explode(',', $conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)); |
|
853 | 853 | } |
854 | 854 | |
855 | - $pdf->SetDrawColor(128,128,128); |
|
856 | - $pdf->SetFont('','', $default_font_size - 1); |
|
855 | + $pdf->SetDrawColor(128, 128, 128); |
|
856 | + $pdf->SetFont('', '', $default_font_size - 1); |
|
857 | 857 | |
858 | 858 | // Output Rect |
859 | - $this->printRect($pdf,$this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height, $hidetop, $hidebottom); // Rect prend une longueur en 3eme param et 4eme param |
|
859 | + $this->printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height, $hidetop, $hidebottom); // Rect prend une longueur en 3eme param et 4eme param |
|
860 | 860 | |
861 | 861 | if (empty($hidetop)) |
862 | 862 | { |
863 | - $pdf->line($this->marge_gauche, $tab_top+5, $this->page_largeur-$this->marge_droite, $tab_top+5); // line prend une position y en 2eme param et 4eme param |
|
863 | + $pdf->line($this->marge_gauche, $tab_top + 5, $this->page_largeur - $this->marge_droite, $tab_top + 5); // line prend une position y en 2eme param et 4eme param |
|
864 | 864 | |
865 | - $pdf->SetXY($this->posxdesc-1, $tab_top+1); |
|
866 | - $pdf->MultiCell(108,2, $outputlangs->transnoentities("Designation"),'','L'); |
|
865 | + $pdf->SetXY($this->posxdesc - 1, $tab_top + 1); |
|
866 | + $pdf->MultiCell(108, 2, $outputlangs->transnoentities("Designation"), '', 'L'); |
|
867 | 867 | } |
868 | 868 | |
869 | 869 | if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) |
870 | 870 | { |
871 | - $pdf->line($this->posxtva-1, $tab_top, $this->posxtva-1, $tab_top + $tab_height); |
|
871 | + $pdf->line($this->posxtva - 1, $tab_top, $this->posxtva - 1, $tab_top + $tab_height); |
|
872 | 872 | if (empty($hidetop)) |
873 | 873 | { |
874 | - $pdf->SetXY($this->posxtva-3, $tab_top+1); |
|
875 | - $pdf->MultiCell($this->posxup-$this->posxtva+3,2, $outputlangs->transnoentities("VAT"),'','C'); |
|
874 | + $pdf->SetXY($this->posxtva - 3, $tab_top + 1); |
|
875 | + $pdf->MultiCell($this->posxup - $this->posxtva + 3, 2, $outputlangs->transnoentities("VAT"), '', 'C'); |
|
876 | 876 | } |
877 | 877 | } |
878 | 878 | |
879 | - $pdf->line($this->posxup-1, $tab_top, $this->posxup-1, $tab_top + $tab_height); |
|
879 | + $pdf->line($this->posxup - 1, $tab_top, $this->posxup - 1, $tab_top + $tab_height); |
|
880 | 880 | if (empty($hidetop)) |
881 | 881 | { |
882 | - $pdf->SetXY($this->posxup-1, $tab_top+1); |
|
883 | - $pdf->MultiCell($this->posxqty-$this->posxup-1,2, $outputlangs->transnoentities("PriceUHT"),'','C'); |
|
882 | + $pdf->SetXY($this->posxup - 1, $tab_top + 1); |
|
883 | + $pdf->MultiCell($this->posxqty - $this->posxup - 1, 2, $outputlangs->transnoentities("PriceUHT"), '', 'C'); |
|
884 | 884 | } |
885 | 885 | |
886 | - $pdf->line($this->posxqty-1, $tab_top, $this->posxqty-1, $tab_top + $tab_height); |
|
886 | + $pdf->line($this->posxqty - 1, $tab_top, $this->posxqty - 1, $tab_top + $tab_height); |
|
887 | 887 | if (empty($hidetop)) |
888 | 888 | { |
889 | - $pdf->SetXY($this->posxqty-1, $tab_top+1); |
|
890 | - if($conf->global->PRODUCT_USE_UNITS) |
|
889 | + $pdf->SetXY($this->posxqty - 1, $tab_top + 1); |
|
890 | + if ($conf->global->PRODUCT_USE_UNITS) |
|
891 | 891 | { |
892 | - $pdf->MultiCell($this->posxunit-$this->posxqty-1,2, $outputlangs->transnoentities("Qty"),'','C'); |
|
892 | + $pdf->MultiCell($this->posxunit - $this->posxqty - 1, 2, $outputlangs->transnoentities("Qty"), '', 'C'); |
|
893 | 893 | } |
894 | 894 | else |
895 | 895 | { |
896 | - $pdf->MultiCell($this->posxdiscount-$this->posxqty-1,2, $outputlangs->transnoentities("Qty"),'','C'); |
|
896 | + $pdf->MultiCell($this->posxdiscount - $this->posxqty - 1, 2, $outputlangs->transnoentities("Qty"), '', 'C'); |
|
897 | 897 | } |
898 | 898 | } |
899 | 899 | |
900 | - if($conf->global->PRODUCT_USE_UNITS) { |
|
900 | + if ($conf->global->PRODUCT_USE_UNITS) { |
|
901 | 901 | $pdf->line($this->posxunit - 1, $tab_top, $this->posxunit - 1, $tab_top + $tab_height); |
902 | 902 | if (empty($hidetop)) { |
903 | 903 | $pdf->SetXY($this->posxunit - 1, $tab_top + 1); |
@@ -906,13 +906,13 @@ discard block |
||
906 | 906 | } |
907 | 907 | } |
908 | 908 | |
909 | - $pdf->line($this->posxdiscount-1, $tab_top, $this->posxdiscount-1, $tab_top + $tab_height); |
|
909 | + $pdf->line($this->posxdiscount - 1, $tab_top, $this->posxdiscount - 1, $tab_top + $tab_height); |
|
910 | 910 | if (empty($hidetop)) |
911 | 911 | { |
912 | 912 | if ($this->atleastonediscount) |
913 | 913 | { |
914 | - $pdf->SetXY($this->posxdiscount-1, $tab_top+1); |
|
915 | - $pdf->MultiCell($this->postotalht-$this->posxdiscount+1,2, $outputlangs->transnoentities("ReductionShort"),'','C'); |
|
914 | + $pdf->SetXY($this->posxdiscount - 1, $tab_top + 1); |
|
915 | + $pdf->MultiCell($this->postotalht - $this->posxdiscount + 1, 2, $outputlangs->transnoentities("ReductionShort"), '', 'C'); |
|
916 | 916 | } |
917 | 917 | } |
918 | 918 | |
@@ -922,8 +922,8 @@ discard block |
||
922 | 922 | } |
923 | 923 | if (empty($hidetop)) |
924 | 924 | { |
925 | - $pdf->SetXY($this->postotalht-1, $tab_top+1); |
|
926 | - $pdf->MultiCell(30,2, $outputlangs->transnoentities("TotalHTShort"),'','C'); |
|
925 | + $pdf->SetXY($this->postotalht - 1, $tab_top + 1); |
|
926 | + $pdf->MultiCell(30, 2, $outputlangs->transnoentities("TotalHTShort"), '', 'C'); |
|
927 | 927 | } |
928 | 928 | } |
929 | 929 | |
@@ -942,8 +942,8 @@ discard block |
||
942 | 942 | // phpcs:enable |
943 | 943 | global $conf; |
944 | 944 | |
945 | - $sign=1; |
|
946 | - if ($object->type == 2 && ! empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign=-1; |
|
945 | + $sign = 1; |
|
946 | + if ($object->type == 2 && !empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign = -1; |
|
947 | 947 | |
948 | 948 | $tab3_posx = 120; |
949 | 949 | $tab3_top = $posy + 8; |
@@ -956,66 +956,66 @@ discard block |
||
956 | 956 | |
957 | 957 | $default_font_size = pdf_getPDFFontSize($outputlangs); |
958 | 958 | |
959 | - $pdf->SetFont('','', $default_font_size - 3); |
|
959 | + $pdf->SetFont('', '', $default_font_size - 3); |
|
960 | 960 | $pdf->SetXY($tab3_posx, $tab3_top - 4); |
961 | 961 | $pdf->MultiCell(60, 3, $outputlangs->transnoentities("PaymentsAlreadyDone"), 0, 'L', 0); |
962 | 962 | |
963 | - $pdf->line($tab3_posx, $tab3_top, $tab3_posx+$tab3_width, $tab3_top); |
|
963 | + $pdf->line($tab3_posx, $tab3_top, $tab3_posx + $tab3_width, $tab3_top); |
|
964 | 964 | |
965 | - $pdf->SetFont('','', $default_font_size - 4); |
|
965 | + $pdf->SetFont('', '', $default_font_size - 4); |
|
966 | 966 | $pdf->SetXY($tab3_posx, $tab3_top); |
967 | 967 | $pdf->MultiCell(20, 3, $outputlangs->transnoentities("Payment"), 0, 'L', 0); |
968 | - $pdf->SetXY($tab3_posx+21, $tab3_top); |
|
968 | + $pdf->SetXY($tab3_posx + 21, $tab3_top); |
|
969 | 969 | $pdf->MultiCell(20, 3, $outputlangs->transnoentities("Amount"), 0, 'L', 0); |
970 | - $pdf->SetXY($tab3_posx+40, $tab3_top); |
|
970 | + $pdf->SetXY($tab3_posx + 40, $tab3_top); |
|
971 | 971 | $pdf->MultiCell(20, 3, $outputlangs->transnoentities("Type"), 0, 'L', 0); |
972 | - $pdf->SetXY($tab3_posx+58, $tab3_top); |
|
972 | + $pdf->SetXY($tab3_posx + 58, $tab3_top); |
|
973 | 973 | $pdf->MultiCell(20, 3, $outputlangs->transnoentities("Num"), 0, 'L', 0); |
974 | 974 | |
975 | - $pdf->line($tab3_posx, $tab3_top-1+$tab3_height, $tab3_posx+$tab3_width, $tab3_top-1+$tab3_height); |
|
975 | + $pdf->line($tab3_posx, $tab3_top - 1 + $tab3_height, $tab3_posx + $tab3_width, $tab3_top - 1 + $tab3_height); |
|
976 | 976 | |
977 | - $y=0; |
|
977 | + $y = 0; |
|
978 | 978 | |
979 | - $pdf->SetFont('','', $default_font_size - 4); |
|
979 | + $pdf->SetFont('', '', $default_font_size - 4); |
|
980 | 980 | |
981 | 981 | // Loop on each deposits and credit notes included |
982 | 982 | // |
983 | 983 | |
984 | 984 | // Loop on each payment |
985 | 985 | $sql = "SELECT p.datep as date, p.fk_paiement as type, p.num_paiement as num, pf.amount as amount, pf.multicurrency_amount,"; |
986 | - $sql.= " cp.code"; |
|
987 | - $sql.= " FROM ".MAIN_DB_PREFIX."paiementfourn_facturefourn as pf, ".MAIN_DB_PREFIX."paiementfourn as p"; |
|
988 | - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as cp ON p.fk_paiement = cp.id"; |
|
989 | - $sql.= " WHERE pf.fk_paiementfourn = p.rowid and pf.fk_facturefourn = ".$object->id; |
|
990 | - $sql.= " ORDER BY p.datep"; |
|
991 | - $resql=$this->db->query($sql); |
|
986 | + $sql .= " cp.code"; |
|
987 | + $sql .= " FROM ".MAIN_DB_PREFIX."paiementfourn_facturefourn as pf, ".MAIN_DB_PREFIX."paiementfourn as p"; |
|
988 | + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as cp ON p.fk_paiement = cp.id"; |
|
989 | + $sql .= " WHERE pf.fk_paiementfourn = p.rowid and pf.fk_facturefourn = ".$object->id; |
|
990 | + $sql .= " ORDER BY p.datep"; |
|
991 | + $resql = $this->db->query($sql); |
|
992 | 992 | if ($resql) |
993 | 993 | { |
994 | 994 | $num = $this->db->num_rows($resql); |
995 | - $i=0; |
|
995 | + $i = 0; |
|
996 | 996 | while ($i < $num) { |
997 | - $y+=3; |
|
997 | + $y += 3; |
|
998 | 998 | $row = $this->db->fetch_object($resql); |
999 | 999 | |
1000 | - $pdf->SetXY($tab3_posx, $tab3_top+$y); |
|
1001 | - $pdf->MultiCell(20, 3, dol_print_date($this->db->jdate($row->date),'day',false,$outputlangs,true), 0, 'L', 0); |
|
1002 | - $pdf->SetXY($tab3_posx+21, $tab3_top+$y); |
|
1000 | + $pdf->SetXY($tab3_posx, $tab3_top + $y); |
|
1001 | + $pdf->MultiCell(20, 3, dol_print_date($this->db->jdate($row->date), 'day', false, $outputlangs, true), 0, 'L', 0); |
|
1002 | + $pdf->SetXY($tab3_posx + 21, $tab3_top + $y); |
|
1003 | 1003 | $pdf->MultiCell(20, 3, price($sign * (($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? $row->multicurrency_amount : $row->amount)), 0, 'L', 0); |
1004 | - $pdf->SetXY($tab3_posx+40, $tab3_top+$y); |
|
1005 | - $oper = $outputlangs->transnoentitiesnoconv("PaymentTypeShort" . $row->code); |
|
1004 | + $pdf->SetXY($tab3_posx + 40, $tab3_top + $y); |
|
1005 | + $oper = $outputlangs->transnoentitiesnoconv("PaymentTypeShort".$row->code); |
|
1006 | 1006 | |
1007 | 1007 | $pdf->MultiCell(20, 3, $oper, 0, 'L', 0); |
1008 | - $pdf->SetXY($tab3_posx+58, $tab3_top+$y); |
|
1008 | + $pdf->SetXY($tab3_posx + 58, $tab3_top + $y); |
|
1009 | 1009 | $pdf->MultiCell(30, 3, $row->num, 0, 'L', 0); |
1010 | 1010 | |
1011 | - $pdf->line($tab3_posx, $tab3_top+$y+3, $tab3_posx+$tab3_width, $tab3_top+$y+3); |
|
1011 | + $pdf->line($tab3_posx, $tab3_top + $y + 3, $tab3_posx + $tab3_width, $tab3_top + $y + 3); |
|
1012 | 1012 | |
1013 | 1013 | $i++; |
1014 | 1014 | } |
1015 | 1015 | } |
1016 | 1016 | else |
1017 | 1017 | { |
1018 | - $this->error=$this->db->lasterror(); |
|
1018 | + $this->error = $this->db->lasterror(); |
|
1019 | 1019 | return -1; |
1020 | 1020 | } |
1021 | 1021 | } |
@@ -1041,13 +1041,13 @@ discard block |
||
1041 | 1041 | // Do not add the BACKGROUND as this is for suppliers |
1042 | 1042 | //pdf_pagehead($pdf,$outputlangs,$this->page_hauteur); |
1043 | 1043 | |
1044 | - $pdf->SetTextColor(0,0,60); |
|
1045 | - $pdf->SetFont('','B', $default_font_size + 3); |
|
1044 | + $pdf->SetTextColor(0, 0, 60); |
|
1045 | + $pdf->SetFont('', 'B', $default_font_size + 3); |
|
1046 | 1046 | |
1047 | - $posy=$this->marge_haute; |
|
1048 | - $posx=$this->page_largeur-$this->marge_droite-100; |
|
1047 | + $posy = $this->marge_haute; |
|
1048 | + $posx = $this->page_largeur - $this->marge_droite - 100; |
|
1049 | 1049 | |
1050 | - $pdf->SetXY($this->marge_gauche,$posy); |
|
1050 | + $pdf->SetXY($this->marge_gauche, $posy); |
|
1051 | 1051 | |
1052 | 1052 | // Logo |
1053 | 1053 | /* |
@@ -1069,66 +1069,66 @@ discard block |
||
1069 | 1069 | } |
1070 | 1070 | else |
1071 | 1071 | {*/ |
1072 | - $text=$this->emetteur->name; |
|
1072 | + $text = $this->emetteur->name; |
|
1073 | 1073 | $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L'); |
1074 | 1074 | //} |
1075 | 1075 | |
1076 | - $pdf->SetFont('','B', $default_font_size + 3); |
|
1077 | - $pdf->SetXY($posx,$posy); |
|
1078 | - $pdf->SetTextColor(0,0,60); |
|
1076 | + $pdf->SetFont('', 'B', $default_font_size + 3); |
|
1077 | + $pdf->SetXY($posx, $posy); |
|
1078 | + $pdf->SetTextColor(0, 0, 60); |
|
1079 | 1079 | $pdf->MultiCell(100, 3, $outputlangs->transnoentities("SupplierInvoice")." ".$outputlangs->convToOutputCharset($object->ref), '', 'R'); |
1080 | - $posy+=1; |
|
1080 | + $posy += 1; |
|
1081 | 1081 | |
1082 | 1082 | if ($object->ref_supplier) |
1083 | 1083 | { |
1084 | - $posy+=4; |
|
1085 | - $pdf->SetFont('','B', $default_font_size); |
|
1086 | - $pdf->SetXY($posx,$posy); |
|
1087 | - $pdf->SetTextColor(0,0,60); |
|
1088 | - $pdf->MultiCell(100, 4, $outputlangs->transnoentities("RefSupplier")." : " . $object->ref_supplier, '', 'R'); |
|
1089 | - $posy+=1; |
|
1084 | + $posy += 4; |
|
1085 | + $pdf->SetFont('', 'B', $default_font_size); |
|
1086 | + $pdf->SetXY($posx, $posy); |
|
1087 | + $pdf->SetTextColor(0, 0, 60); |
|
1088 | + $pdf->MultiCell(100, 4, $outputlangs->transnoentities("RefSupplier")." : ".$object->ref_supplier, '', 'R'); |
|
1089 | + $posy += 1; |
|
1090 | 1090 | } |
1091 | 1091 | |
1092 | - $pdf->SetFont('','', $default_font_size - 1); |
|
1092 | + $pdf->SetFont('', '', $default_font_size - 1); |
|
1093 | 1093 | |
1094 | - if (! empty($conf->global->PDF_SHOW_PROJECT)) |
|
1094 | + if (!empty($conf->global->PDF_SHOW_PROJECT)) |
|
1095 | 1095 | { |
1096 | 1096 | $object->fetch_projet(); |
1097 | - if (! empty($object->project->ref)) |
|
1097 | + if (!empty($object->project->ref)) |
|
1098 | 1098 | { |
1099 | - $posy+=4; |
|
1100 | - $pdf->SetXY($posx,$posy); |
|
1099 | + $posy += 4; |
|
1100 | + $pdf->SetXY($posx, $posy); |
|
1101 | 1101 | $langs->load("projects"); |
1102 | - $pdf->SetTextColor(0,0,60); |
|
1103 | - $pdf->MultiCell(100, 3, $outputlangs->transnoentities("Project")." : " . (empty($object->project->ref)?'':$object->projet->ref), '', 'R'); |
|
1102 | + $pdf->SetTextColor(0, 0, 60); |
|
1103 | + $pdf->MultiCell(100, 3, $outputlangs->transnoentities("Project")." : ".(empty($object->project->ref) ? '' : $object->projet->ref), '', 'R'); |
|
1104 | 1104 | } |
1105 | 1105 | } |
1106 | 1106 | |
1107 | 1107 | if ($object->date) |
1108 | 1108 | { |
1109 | - $posy+=4; |
|
1110 | - $pdf->SetXY($posx,$posy); |
|
1111 | - $pdf->SetTextColor(0,0,60); |
|
1112 | - $pdf->MultiCell(100, 4, $outputlangs->transnoentities("Date")." : " . dol_print_date($object->date,"day",false,$outputlangs,true), '', 'R'); |
|
1109 | + $posy += 4; |
|
1110 | + $pdf->SetXY($posx, $posy); |
|
1111 | + $pdf->SetTextColor(0, 0, 60); |
|
1112 | + $pdf->MultiCell(100, 4, $outputlangs->transnoentities("Date")." : ".dol_print_date($object->date, "day", false, $outputlangs, true), '', 'R'); |
|
1113 | 1113 | } |
1114 | 1114 | else |
1115 | 1115 | { |
1116 | - $posy+=4; |
|
1117 | - $pdf->SetXY($posx,$posy); |
|
1118 | - $pdf->SetTextColor(255,0,0); |
|
1116 | + $posy += 4; |
|
1117 | + $pdf->SetXY($posx, $posy); |
|
1118 | + $pdf->SetTextColor(255, 0, 0); |
|
1119 | 1119 | $pdf->MultiCell(100, 4, strtolower($outputlangs->transnoentities("OrderToProcess")), '', 'R'); |
1120 | 1120 | } |
1121 | 1121 | |
1122 | 1122 | if ($object->thirdparty->code_fournisseur) |
1123 | 1123 | { |
1124 | - $posy+=4; |
|
1125 | - $pdf->SetXY($posx,$posy); |
|
1126 | - $pdf->SetTextColor(0,0,60); |
|
1127 | - $pdf->MultiCell(100, 3, $outputlangs->transnoentities("SupplierCode")." : " . $outputlangs->transnoentities($object->thirdparty->code_fournisseur), '', 'R'); |
|
1124 | + $posy += 4; |
|
1125 | + $pdf->SetXY($posx, $posy); |
|
1126 | + $pdf->SetTextColor(0, 0, 60); |
|
1127 | + $pdf->MultiCell(100, 3, $outputlangs->transnoentities("SupplierCode")." : ".$outputlangs->transnoentities($object->thirdparty->code_fournisseur), '', 'R'); |
|
1128 | 1128 | } |
1129 | 1129 | |
1130 | - $posy+=1; |
|
1131 | - $pdf->SetTextColor(0,0,60); |
|
1130 | + $posy += 1; |
|
1131 | + $pdf->SetTextColor(0, 0, 60); |
|
1132 | 1132 | |
1133 | 1133 | $top_shift = 0; |
1134 | 1134 | // Show list of linked objects |
@@ -1142,53 +1142,53 @@ discard block |
||
1142 | 1142 | if ($showaddress) |
1143 | 1143 | { |
1144 | 1144 | // Sender properties |
1145 | - $carac_emetteur=''; |
|
1145 | + $carac_emetteur = ''; |
|
1146 | 1146 | // Add internal contact of proposal if defined |
1147 | - $arrayidcontact=$object->getIdContact('internal','SALESREPFOLL'); |
|
1147 | + $arrayidcontact = $object->getIdContact('internal', 'SALESREPFOLL'); |
|
1148 | 1148 | if (count($arrayidcontact) > 0) |
1149 | 1149 | { |
1150 | 1150 | $object->fetch_user($arrayidcontact[0]); |
1151 | - $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n"; |
|
1151 | + $carac_emetteur .= ($carac_emetteur ? "\n" : '').$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n"; |
|
1152 | 1152 | } |
1153 | 1153 | |
1154 | 1154 | $carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'source', $object); |
1155 | 1155 | |
1156 | 1156 | // Show sender |
1157 | - $posy=42+$top_shift; |
|
1158 | - $posx=$this->marge_gauche; |
|
1159 | - if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->page_largeur-$this->marge_droite-80; |
|
1160 | - $hautcadre=40; |
|
1157 | + $posy = 42 + $top_shift; |
|
1158 | + $posx = $this->marge_gauche; |
|
1159 | + if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx = $this->page_largeur - $this->marge_droite - 80; |
|
1160 | + $hautcadre = 40; |
|
1161 | 1161 | |
1162 | 1162 | // Show sender frame |
1163 | - $pdf->SetTextColor(0,0,0); |
|
1164 | - $pdf->SetFont('','', $default_font_size - 2); |
|
1165 | - $pdf->SetXY($posx,$posy-5); |
|
1166 | - $pdf->MultiCell(66,5, $outputlangs->transnoentities("BillFrom").":", 0, 'L'); |
|
1167 | - $pdf->SetXY($posx,$posy); |
|
1168 | - $pdf->SetFillColor(230,230,230); |
|
1163 | + $pdf->SetTextColor(0, 0, 0); |
|
1164 | + $pdf->SetFont('', '', $default_font_size - 2); |
|
1165 | + $pdf->SetXY($posx, $posy - 5); |
|
1166 | + $pdf->MultiCell(66, 5, $outputlangs->transnoentities("BillFrom").":", 0, 'L'); |
|
1167 | + $pdf->SetXY($posx, $posy); |
|
1168 | + $pdf->SetFillColor(230, 230, 230); |
|
1169 | 1169 | $pdf->MultiCell(82, $hautcadre, "", 0, 'R', 1); |
1170 | - $pdf->SetTextColor(0,0,60); |
|
1170 | + $pdf->SetTextColor(0, 0, 60); |
|
1171 | 1171 | |
1172 | 1172 | // Show sender name |
1173 | - $pdf->SetXY($posx+2,$posy+3); |
|
1174 | - $pdf->SetFont('','B', $default_font_size); |
|
1173 | + $pdf->SetXY($posx + 2, $posy + 3); |
|
1174 | + $pdf->SetFont('', 'B', $default_font_size); |
|
1175 | 1175 | $pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L'); |
1176 | - $posy=$pdf->getY(); |
|
1176 | + $posy = $pdf->getY(); |
|
1177 | 1177 | |
1178 | 1178 | // Show sender information |
1179 | - $pdf->SetXY($posx+2,$posy); |
|
1180 | - $pdf->SetFont('','', $default_font_size - 1); |
|
1179 | + $pdf->SetXY($posx + 2, $posy); |
|
1180 | + $pdf->SetFont('', '', $default_font_size - 1); |
|
1181 | 1181 | $pdf->MultiCell(80, 4, $carac_emetteur, 0, 'L'); |
1182 | 1182 | |
1183 | 1183 | |
1184 | 1184 | |
1185 | 1185 | // If BILLING contact defined on invoice, we use it |
1186 | - $usecontact=false; |
|
1187 | - $arrayidcontact=$object->getIdContact('internal','BILLING'); |
|
1186 | + $usecontact = false; |
|
1187 | + $arrayidcontact = $object->getIdContact('internal', 'BILLING'); |
|
1188 | 1188 | if (count($arrayidcontact) > 0) |
1189 | 1189 | { |
1190 | - $usecontact=true; |
|
1191 | - $result=$object->fetch_contact($arrayidcontact[0]); |
|
1190 | + $usecontact = true; |
|
1191 | + $result = $object->fetch_contact($arrayidcontact[0]); |
|
1192 | 1192 | } |
1193 | 1193 | |
1194 | 1194 | //Recipient name |
@@ -1199,34 +1199,34 @@ discard block |
||
1199 | 1199 | $thirdparty = $mysoc; |
1200 | 1200 | } |
1201 | 1201 | |
1202 | - $carac_client_name= pdfBuildThirdpartyName($thirdparty, $outputlangs); |
|
1202 | + $carac_client_name = pdfBuildThirdpartyName($thirdparty, $outputlangs); |
|
1203 | 1203 | |
1204 | - $carac_client=pdf_build_address($outputlangs,$this->emetteur,$mysoc,((!empty($object->contact))?$object->contact:null),$usecontact,'target',$object); |
|
1204 | + $carac_client = pdf_build_address($outputlangs, $this->emetteur, $mysoc, ((!empty($object->contact)) ? $object->contact : null), $usecontact, 'target', $object); |
|
1205 | 1205 | |
1206 | 1206 | // Show recipient |
1207 | - $widthrecbox=100; |
|
1208 | - if ($this->page_largeur < 210) $widthrecbox=84; // To work with US executive format |
|
1209 | - $posy=42+$top_shift; |
|
1210 | - $posx=$this->page_largeur-$this->marge_droite-$widthrecbox; |
|
1211 | - if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->marge_gauche; |
|
1207 | + $widthrecbox = 100; |
|
1208 | + if ($this->page_largeur < 210) $widthrecbox = 84; // To work with US executive format |
|
1209 | + $posy = 42 + $top_shift; |
|
1210 | + $posx = $this->page_largeur - $this->marge_droite - $widthrecbox; |
|
1211 | + if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx = $this->marge_gauche; |
|
1212 | 1212 | |
1213 | 1213 | // Show recipient frame |
1214 | - $pdf->SetTextColor(0,0,0); |
|
1215 | - $pdf->SetFont('','', $default_font_size - 2); |
|
1216 | - $pdf->SetXY($posx+2,$posy-5); |
|
1217 | - $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("BillTo").":",0,'L'); |
|
1214 | + $pdf->SetTextColor(0, 0, 0); |
|
1215 | + $pdf->SetFont('', '', $default_font_size - 2); |
|
1216 | + $pdf->SetXY($posx + 2, $posy - 5); |
|
1217 | + $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("BillTo").":", 0, 'L'); |
|
1218 | 1218 | $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre); |
1219 | 1219 | |
1220 | 1220 | // Show recipient name |
1221 | - $pdf->SetXY($posx+2,$posy+3); |
|
1222 | - $pdf->SetFont('','B', $default_font_size); |
|
1221 | + $pdf->SetXY($posx + 2, $posy + 3); |
|
1222 | + $pdf->SetFont('', 'B', $default_font_size); |
|
1223 | 1223 | $pdf->MultiCell($widthrecbox, 4, $carac_client_name, 0, 'L'); |
1224 | 1224 | |
1225 | 1225 | $posy = $pdf->getY(); |
1226 | 1226 | |
1227 | 1227 | // Show recipient information |
1228 | - $pdf->SetFont('','', $default_font_size - 1); |
|
1229 | - $pdf->SetXY($posx+2,$posy); |
|
1228 | + $pdf->SetFont('', '', $default_font_size - 1); |
|
1229 | + $pdf->SetXY($posx + 2, $posy); |
|
1230 | 1230 | $pdf->MultiCell($widthrecbox, 4, $carac_client, 0, 'L'); |
1231 | 1231 | } |
1232 | 1232 | |
@@ -1242,10 +1242,10 @@ discard block |
||
1242 | 1242 | * @param int $hidefreetext 1=Hide free text |
1243 | 1243 | * @return int Return height of bottom margin including footer text |
1244 | 1244 | */ |
1245 | - function _pagefoot(&$pdf, $object, $outputlangs,$hidefreetext=0) |
|
1245 | + function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0) |
|
1246 | 1246 | { |
1247 | 1247 | global $conf; |
1248 | - $showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS; |
|
1249 | - return pdf_pagefoot($pdf,$outputlangs,'SUPPLIER_INVOICE_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object,$showdetails,$hidefreetext); |
|
1248 | + $showdetails = $conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS; |
|
1249 | + return pdf_pagefoot($pdf, $outputlangs, 'SUPPLIER_INVOICE_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext); |
|
1250 | 1250 | } |
1251 | 1251 | } |
@@ -164,9 +164,11 @@ discard block |
||
164 | 164 | } |
165 | 165 | //if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) $this->posxtva=$this->posxup; |
166 | 166 | $this->posxpicture=$this->posxtva - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH)?20:$conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH); // width of images |
167 | - if ($this->page_largeur < 210) // To work with US executive format |
|
167 | + if ($this->page_largeur < 210) { |
|
168 | + // To work with US executive format |
|
168 | 169 | { |
169 | 170 | $this->posxpicture-=20; |
171 | + } |
|
170 | 172 | $this->posxtva-=20; |
171 | 173 | $this->posxup-=20; |
172 | 174 | $this->posxqty-=20; |
@@ -201,14 +203,26 @@ discard block |
||
201 | 203 | global $user,$langs,$conf,$mysoc,$hookmanager,$nblignes; |
202 | 204 | |
203 | 205 | // Get source company |
204 | - if (! is_object($object->thirdparty)) $object->fetch_thirdparty(); |
|
205 | - if (! is_object($object->thirdparty)) $object->thirdparty=$mysoc; // If fetch_thirdparty fails, object has no socid (specimen) |
|
206 | + if (! is_object($object->thirdparty)) { |
|
207 | + $object->fetch_thirdparty(); |
|
208 | + } |
|
209 | + if (! is_object($object->thirdparty)) { |
|
210 | + $object->thirdparty=$mysoc; |
|
211 | + } |
|
212 | + // If fetch_thirdparty fails, object has no socid (specimen) |
|
206 | 213 | $this->emetteur=$object->thirdparty; |
207 | - if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2); // By default, if was not defined |
|
214 | + if (! $this->emetteur->country_code) { |
|
215 | + $this->emetteur->country_code=substr($langs->defaultlang,-2); |
|
216 | + } |
|
217 | + // By default, if was not defined |
|
208 | 218 | |
209 | - if (! is_object($outputlangs)) $outputlangs=$langs; |
|
219 | + if (! is_object($outputlangs)) { |
|
220 | + $outputlangs=$langs; |
|
221 | + } |
|
210 | 222 | // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO |
211 | - if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1'; |
|
223 | + if (! empty($conf->global->MAIN_USE_FPDF)) { |
|
224 | + $outputlangs->charset_output='ISO-8859-1'; |
|
225 | + } |
|
212 | 226 | |
213 | 227 | // Load translation files required by the page |
214 | 228 | $outputlangs->loadLangs(array("main", "dict", "companies", "bills", "products")); |
@@ -226,14 +240,15 @@ discard block |
||
226 | 240 | { |
227 | 241 | $dir = $conf->fournisseur->facture->dir_output; |
228 | 242 | $file = $dir . "/SPECIMEN.pdf"; |
229 | - } |
|
230 | - else |
|
243 | + } else |
|
231 | 244 | { |
232 | 245 | $objectref = dol_sanitizeFileName($object->ref); |
233 | 246 | $objectrefsupplier = dol_sanitizeFileName($object->ref_supplier); |
234 | 247 | $dir = $conf->fournisseur->facture->dir_output.'/'.get_exdir($object->id,2,0,0,$object,'invoice_supplier').$objectref; |
235 | 248 | $file = $dir . "/" . $objectref . ".pdf"; |
236 | - if (! empty($conf->global->SUPPLIER_REF_IN_NAME)) $file = $dir . "/" . $objectref . ($objectrefsupplier?"_".$objectrefsupplier:"").".pdf"; |
|
249 | + if (! empty($conf->global->SUPPLIER_REF_IN_NAME)) { |
|
250 | + $file = $dir . "/" . $objectref . ($objectrefsupplier?"_".$objectrefsupplier:"").".pdf"; |
|
251 | + } |
|
237 | 252 | } |
238 | 253 | |
239 | 254 | if (! file_exists($dir)) |
@@ -265,7 +280,9 @@ discard block |
||
265 | 280 | $heightforinfotot = 50; // Height reserved to output the info and total part |
266 | 281 | $heightforfreetext= (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT)?$conf->global->MAIN_PDF_FREETEXT_HEIGHT:5); // Height reserved to output the free text on last page |
267 | 282 | $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin) |
268 | - if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS >0) $heightforfooter+= 6; |
|
283 | + if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS >0) { |
|
284 | + $heightforfooter+= 6; |
|
285 | + } |
|
269 | 286 | $pdf->SetAutoPageBreak(1,0); |
270 | 287 | |
271 | 288 | if (class_exists('TCPDF')) |
@@ -290,7 +307,9 @@ discard block |
||
290 | 307 | $pdf->SetCreator("Dolibarr ".DOL_VERSION); |
291 | 308 | $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs))); |
292 | 309 | $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("Order")." ".$outputlangs->convToOutputCharset($object->thirdparty->name)); |
293 | - if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); |
|
310 | + if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) { |
|
311 | + $pdf->SetCompression(false); |
|
312 | + } |
|
294 | 313 | |
295 | 314 | $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right |
296 | 315 | |
@@ -314,7 +333,9 @@ discard block |
||
314 | 333 | |
315 | 334 | // New page |
316 | 335 | $pdf->AddPage(); |
317 | - if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
|
336 | + if (! empty($tplidx)) { |
|
337 | + $pdf->useTemplate($tplidx); |
|
338 | + } |
|
318 | 339 | $pagenb++; |
319 | 340 | $top_shift = $this->_pagehead($pdf, $object, 1, $outputlangs); |
320 | 341 | $pdf->SetFont('','', $default_font_size - 1); |
@@ -384,31 +405,37 @@ discard block |
||
384 | 405 | $pdf->startTransaction(); |
385 | 406 | pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxtva-$curX,3,$curX,$curY,$hideref,$hidedesc,1); |
386 | 407 | $pageposafter=$pdf->getPage(); |
387 | - if ($pageposafter > $pageposbefore) // There is a pagebreak |
|
408 | + if ($pageposafter > $pageposbefore) { |
|
409 | + // There is a pagebreak |
|
388 | 410 | { |
389 | 411 | $pdf->rollbackTransaction(true); |
412 | + } |
|
390 | 413 | $pageposafter=$pageposbefore; |
391 | 414 | //print $pageposafter.'-'.$pageposbefore;exit; |
392 | 415 | $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it. |
393 | 416 | pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxtva-$curX,4,$curX,$curY,$hideref,$hidedesc,1); |
394 | 417 | $posyafter=$pdf->GetY(); |
395 | - if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))) // There is no space left for total+free text |
|
418 | + if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))) { |
|
419 | + // There is no space left for total+free text |
|
396 | 420 | { |
397 | 421 | if ($i == ($nblignes-1)) // No more lines, and no space left to show total, so we create a new page |
398 | 422 | { |
399 | 423 | $pdf->AddPage('','',true); |
400 | - if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
|
401 | - if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); |
|
424 | + } |
|
425 | + if (! empty($tplidx)) { |
|
426 | + $pdf->useTemplate($tplidx); |
|
427 | + } |
|
428 | + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) { |
|
429 | + $this->_pagehead($pdf, $object, 0, $outputlangs); |
|
430 | + } |
|
402 | 431 | $pdf->setPage($pageposafter+1); |
403 | 432 | } |
404 | - } |
|
405 | - else |
|
433 | + } else |
|
406 | 434 | { |
407 | 435 | // We found a page break |
408 | 436 | $showpricebeforepagebreak=0; |
409 | 437 | } |
410 | - } |
|
411 | - else // No pagebreak |
|
438 | + } else // No pagebreak |
|
412 | 439 | { |
413 | 440 | $pdf->commitTransaction(); |
414 | 441 | } |
@@ -451,8 +478,7 @@ discard block |
||
451 | 478 | if($conf->global->PRODUCT_USE_UNITS) |
452 | 479 | { |
453 | 480 | $pdf->MultiCell($this->posxunit-$this->posxqty-0.8, 4, $qty, 0, 'R'); |
454 | - } |
|
455 | - else |
|
481 | + } else |
|
456 | 482 | { |
457 | 483 | $pdf->MultiCell($this->posxdiscount-$this->posxqty-0.8, 4, $qty, 0, 'R'); |
458 | 484 | } |
@@ -479,22 +505,35 @@ discard block |
||
479 | 505 | $pdf->MultiCell($this->page_largeur-$this->marge_droite-$this->postotalht, 3, $total_excl_tax, 0, 'R', 0); |
480 | 506 | |
481 | 507 | // Collecte des totaux par valeur de tva dans $this->tva["taux"]=total_tva |
482 | - if ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) $tvaligne=$object->lines[$i]->multicurrency_total_tva; |
|
483 | - else $tvaligne=$object->lines[$i]->total_tva; |
|
508 | + if ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) { |
|
509 | + $tvaligne=$object->lines[$i]->multicurrency_total_tva; |
|
510 | + } else { |
|
511 | + $tvaligne=$object->lines[$i]->total_tva; |
|
512 | + } |
|
484 | 513 | |
485 | 514 | $localtax1ligne=$object->lines[$i]->total_localtax1; |
486 | 515 | $localtax2ligne=$object->lines[$i]->total_localtax2; |
487 | 516 | |
488 | - if (! empty($object->remise_percent)) $tvaligne-=($tvaligne*$object->remise_percent)/100; |
|
517 | + if (! empty($object->remise_percent)) { |
|
518 | + $tvaligne-=($tvaligne*$object->remise_percent)/100; |
|
519 | + } |
|
489 | 520 | |
490 | 521 | $vatrate=(string) $object->lines[$i]->tva_tx; |
491 | 522 | $localtax1rate=(string) $object->lines[$i]->localtax1_tx; |
492 | 523 | $localtax2rate=(string) $object->lines[$i]->localtax2_tx; |
493 | 524 | |
494 | - if (($object->lines[$i]->info_bits & 0x01) == 0x01) $vatrate.='*'; |
|
495 | - if (empty($this->tva[$vatrate])) $this->tva[$vatrate]=0; |
|
496 | - if (empty($this->localtax1[$localtax1rate])) $this->localtax1[$localtax1rate]=0; |
|
497 | - if (empty($this->localtax2[$localtax2rate])) $this->localtax2[$localtax2rate]=0; |
|
525 | + if (($object->lines[$i]->info_bits & 0x01) == 0x01) { |
|
526 | + $vatrate.='*'; |
|
527 | + } |
|
528 | + if (empty($this->tva[$vatrate])) { |
|
529 | + $this->tva[$vatrate]=0; |
|
530 | + } |
|
531 | + if (empty($this->localtax1[$localtax1rate])) { |
|
532 | + $this->localtax1[$localtax1rate]=0; |
|
533 | + } |
|
534 | + if (empty($this->localtax2[$localtax2rate])) { |
|
535 | + $this->localtax2[$localtax2rate]=0; |
|
536 | + } |
|
498 | 537 | $this->tva[$vatrate] += $tvaligne; |
499 | 538 | $this->localtax1[$localtax1rate]+=$localtax1ligne; |
500 | 539 | $this->localtax2[$localtax2rate]+=$localtax2ligne; |
@@ -518,8 +557,7 @@ discard block |
||
518 | 557 | if ($pagenb == 1) |
519 | 558 | { |
520 | 559 | $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1, $object->multicurrency_code); |
521 | - } |
|
522 | - else |
|
560 | + } else |
|
523 | 561 | { |
524 | 562 | $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code); |
525 | 563 | } |
@@ -527,24 +565,29 @@ discard block |
||
527 | 565 | $pagenb++; |
528 | 566 | $pdf->setPage($pagenb); |
529 | 567 | $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. |
530 | - if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); |
|
568 | + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) { |
|
569 | + $this->_pagehead($pdf, $object, 0, $outputlangs); |
|
570 | + } |
|
531 | 571 | } |
532 | 572 | if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak) |
533 | 573 | { |
534 | 574 | if ($pagenb == 1) |
535 | 575 | { |
536 | 576 | $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1, $object->multicurrency_code); |
537 | - } |
|
538 | - else |
|
577 | + } else |
|
539 | 578 | { |
540 | 579 | $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code); |
541 | 580 | } |
542 | 581 | $this->_pagefoot($pdf,$object,$outputlangs,1); |
543 | 582 | // New page |
544 | 583 | $pdf->AddPage(); |
545 | - if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
|
584 | + if (! empty($tplidx)) { |
|
585 | + $pdf->useTemplate($tplidx); |
|
586 | + } |
|
546 | 587 | $pagenb++; |
547 | - if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); |
|
588 | + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) { |
|
589 | + $this->_pagehead($pdf, $object, 0, $outputlangs); |
|
590 | + } |
|
548 | 591 | } |
549 | 592 | } |
550 | 593 | |
@@ -553,8 +596,7 @@ discard block |
||
553 | 596 | { |
554 | 597 | $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0, $object->multicurrency_code); |
555 | 598 | $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; |
556 | - } |
|
557 | - else |
|
599 | + } else |
|
558 | 600 | { |
559 | 601 | $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0, $object->multicurrency_code); |
560 | 602 | $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; |
@@ -573,7 +615,9 @@ discard block |
||
573 | 615 | |
574 | 616 | // Pied de page |
575 | 617 | $this->_pagefoot($pdf, $object, $outputlangs); |
576 | - if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages(); |
|
618 | + if (method_exists($pdf,'AliasNbPages')) { |
|
619 | + $pdf->AliasNbPages(); |
|
620 | + } |
|
577 | 621 | |
578 | 622 | $pdf->Close(); |
579 | 623 | |
@@ -585,20 +629,19 @@ discard block |
||
585 | 629 | global $action; |
586 | 630 | $reshook=$hookmanager->executeHooks('afterPDFCreation',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks |
587 | 631 | |
588 | - if (! empty($conf->global->MAIN_UMASK)) |
|
589 | - @chmod($file, octdec($conf->global->MAIN_UMASK)); |
|
632 | + if (! empty($conf->global->MAIN_UMASK)) { |
|
633 | + @chmod($file, octdec($conf->global->MAIN_UMASK)); |
|
634 | + } |
|
590 | 635 | |
591 | 636 | $this->result = array('fullpath'=>$file); |
592 | 637 | |
593 | 638 | return 1; // Pas d'erreur |
594 | - } |
|
595 | - else |
|
639 | + } else |
|
596 | 640 | { |
597 | 641 | $this->error=$langs->trans("ErrorCanNotCreateDir",$dir); |
598 | 642 | return 0; |
599 | 643 | } |
600 | - } |
|
601 | - else |
|
644 | + } else |
|
602 | 645 | { |
603 | 646 | $this->error=$langs->trans("ErrorConstantNotDefined","SUPPLIER_OUTPUTDIR"); |
604 | 647 | return 0; |
@@ -636,10 +679,12 @@ discard block |
||
636 | 679 | |
637 | 680 | // Tableau total |
638 | 681 | $col1x = 120; $col2x = 170; |
639 | - if ($this->page_largeur < 210) // To work with US executive format |
|
682 | + if ($this->page_largeur < 210) { |
|
683 | + // To work with US executive format |
|
640 | 684 | { |
641 | 685 | $col2x-=20; |
642 | 686 | } |
687 | + } |
|
643 | 688 | $largcol2 = ($this->page_largeur - $this->marge_droite - $col2x); |
644 | 689 | |
645 | 690 | $index=0; |
@@ -658,9 +703,11 @@ discard block |
||
658 | 703 | |
659 | 704 | foreach( $this->tva as $tvakey => $tvaval ) |
660 | 705 | { |
661 | - if ($tvakey > 0) // On affiche pas taux 0 |
|
706 | + if ($tvakey > 0) { |
|
707 | + // On affiche pas taux 0 |
|
662 | 708 | { |
663 | 709 | $this->atleastoneratenotnull++; |
710 | + } |
|
664 | 711 | |
665 | 712 | $index++; |
666 | 713 | $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); |
@@ -681,9 +728,11 @@ discard block |
||
681 | 728 | $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval), 0, 'R', 1); |
682 | 729 | } |
683 | 730 | } |
684 | - if (! $this->atleastoneratenotnull) // If no vat at all |
|
731 | + if (! $this->atleastoneratenotnull) { |
|
732 | + // If no vat at all |
|
685 | 733 | { |
686 | 734 | $index++; |
735 | + } |
|
687 | 736 | $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); |
688 | 737 | $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transcountrynoentities("TotalVAT", $mysoc->country_code), 0, 'L', 1); |
689 | 738 | $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); |
@@ -708,19 +757,20 @@ discard block |
||
708 | 757 | $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); |
709 | 758 | $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_localtax2), 0, 'R', 1); |
710 | 759 | } |
711 | - } |
|
712 | - else |
|
760 | + } else |
|
713 | 761 | { |
714 | 762 | //if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on') |
715 | 763 | //{ |
716 | 764 | //Local tax 1 |
717 | 765 | foreach( $this->localtax1 as $tvakey => $tvaval ) |
718 | 766 | { |
719 | - if ($tvakey != 0) // On affiche pas taux 0 |
|
767 | + if ($tvakey != 0) { |
|
768 | + // On affiche pas taux 0 |
|
720 | 769 | { |
721 | 770 | //$this->atleastoneratenotnull++; |
722 | 771 | |
723 | 772 | $index++; |
773 | + } |
|
724 | 774 | $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); |
725 | 775 | |
726 | 776 | $tvacompl=''; |
@@ -744,11 +794,13 @@ discard block |
||
744 | 794 | //Local tax 2 |
745 | 795 | foreach( $this->localtax2 as $tvakey => $tvaval ) |
746 | 796 | { |
747 | - if ($tvakey != 0) // On affiche pas taux 0 |
|
797 | + if ($tvakey != 0) { |
|
798 | + // On affiche pas taux 0 |
|
748 | 799 | { |
749 | 800 | //$this->atleastoneratenotnull++; |
750 | 801 | |
751 | 802 | $index++; |
803 | + } |
|
752 | 804 | $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); |
753 | 805 | |
754 | 806 | $tvacompl=''; |
@@ -787,7 +839,9 @@ discard block |
||
787 | 839 | //$depositsamount=$object->getSumDepositsUsed(); |
788 | 840 | //print "x".$creditnoteamount."-".$depositsamount;exit; |
789 | 841 | $resteapayer = price2num($total_ttc - $deja_regle - $creditnoteamount - $depositsamount, 'MT'); |
790 | - if (! empty($object->paye)) $resteapayer=0; |
|
842 | + if (! empty($object->paye)) { |
|
843 | + $resteapayer=0; |
|
844 | + } |
|
791 | 845 | |
792 | 846 | if ($deja_regle > 0) |
793 | 847 | { |
@@ -833,7 +887,9 @@ discard block |
||
833 | 887 | |
834 | 888 | // Force to disable hidetop and hidebottom |
835 | 889 | $hidebottom=0; |
836 | - if ($hidetop) $hidetop=-1; |
|
890 | + if ($hidetop) { |
|
891 | + $hidetop=-1; |
|
892 | + } |
|
837 | 893 | |
838 | 894 | $currency = !empty($currency) ? $currency : $conf->currency; |
839 | 895 | $default_font_size = pdf_getPDFFontSize($outputlangs); |
@@ -849,7 +905,9 @@ discard block |
||
849 | 905 | $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre); |
850 | 906 | |
851 | 907 | //$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR='230,230,230'; |
852 | - if (! empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_droite-$this->marge_gauche, 5, 'F', null, explode(',',$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)); |
|
908 | + if (! empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) { |
|
909 | + $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_droite-$this->marge_gauche, 5, 'F', null, explode(',',$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)); |
|
910 | + } |
|
853 | 911 | } |
854 | 912 | |
855 | 913 | $pdf->SetDrawColor(128,128,128); |
@@ -890,8 +948,7 @@ discard block |
||
890 | 948 | if($conf->global->PRODUCT_USE_UNITS) |
891 | 949 | { |
892 | 950 | $pdf->MultiCell($this->posxunit-$this->posxqty-1,2, $outputlangs->transnoentities("Qty"),'','C'); |
893 | - } |
|
894 | - else |
|
951 | + } else |
|
895 | 952 | { |
896 | 953 | $pdf->MultiCell($this->posxdiscount-$this->posxqty-1,2, $outputlangs->transnoentities("Qty"),'','C'); |
897 | 954 | } |
@@ -943,16 +1000,20 @@ discard block |
||
943 | 1000 | global $conf; |
944 | 1001 | |
945 | 1002 | $sign=1; |
946 | - if ($object->type == 2 && ! empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign=-1; |
|
1003 | + if ($object->type == 2 && ! empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) { |
|
1004 | + $sign=-1; |
|
1005 | + } |
|
947 | 1006 | |
948 | 1007 | $tab3_posx = 120; |
949 | 1008 | $tab3_top = $posy + 8; |
950 | 1009 | $tab3_width = 80; |
951 | 1010 | $tab3_height = 4; |
952 | - if ($this->page_largeur < 210) // To work with US executive format |
|
1011 | + if ($this->page_largeur < 210) { |
|
1012 | + // To work with US executive format |
|
953 | 1013 | { |
954 | 1014 | $tab3_posx -= 20; |
955 | 1015 | } |
1016 | + } |
|
956 | 1017 | |
957 | 1018 | $default_font_size = pdf_getPDFFontSize($outputlangs); |
958 | 1019 | |
@@ -1012,8 +1073,7 @@ discard block |
||
1012 | 1073 | |
1013 | 1074 | $i++; |
1014 | 1075 | } |
1015 | - } |
|
1016 | - else |
|
1076 | + } else |
|
1017 | 1077 | { |
1018 | 1078 | $this->error=$this->db->lasterror(); |
1019 | 1079 | return -1; |
@@ -1110,8 +1170,7 @@ discard block |
||
1110 | 1170 | $pdf->SetXY($posx,$posy); |
1111 | 1171 | $pdf->SetTextColor(0,0,60); |
1112 | 1172 | $pdf->MultiCell(100, 4, $outputlangs->transnoentities("Date")." : " . dol_print_date($object->date,"day",false,$outputlangs,true), '', 'R'); |
1113 | - } |
|
1114 | - else |
|
1173 | + } else |
|
1115 | 1174 | { |
1116 | 1175 | $posy+=4; |
1117 | 1176 | $pdf->SetXY($posx,$posy); |
@@ -1156,7 +1215,9 @@ discard block |
||
1156 | 1215 | // Show sender |
1157 | 1216 | $posy=42+$top_shift; |
1158 | 1217 | $posx=$this->marge_gauche; |
1159 | - if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->page_largeur-$this->marge_droite-80; |
|
1218 | + if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) { |
|
1219 | + $posx=$this->page_largeur-$this->marge_droite-80; |
|
1220 | + } |
|
1160 | 1221 | $hautcadre=40; |
1161 | 1222 | |
1162 | 1223 | // Show sender frame |
@@ -1205,10 +1266,15 @@ discard block |
||
1205 | 1266 | |
1206 | 1267 | // Show recipient |
1207 | 1268 | $widthrecbox=100; |
1208 | - if ($this->page_largeur < 210) $widthrecbox=84; // To work with US executive format |
|
1269 | + if ($this->page_largeur < 210) { |
|
1270 | + $widthrecbox=84; |
|
1271 | + } |
|
1272 | + // To work with US executive format |
|
1209 | 1273 | $posy=42+$top_shift; |
1210 | 1274 | $posx=$this->page_largeur-$this->marge_droite-$widthrecbox; |
1211 | - if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->marge_gauche; |
|
1275 | + if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) { |
|
1276 | + $posx=$this->marge_gauche; |
|
1277 | + } |
|
1212 | 1278 | |
1213 | 1279 | // Show recipient frame |
1214 | 1280 | $pdf->SetTextColor(0,0,0); |
@@ -33,34 +33,34 @@ discard block |
||
33 | 33 | */ |
34 | 34 | class mod_facture_fournisseur_cactus extends ModeleNumRefSuppliersInvoices |
35 | 35 | { |
36 | - /** |
|
36 | + /** |
|
37 | 37 | * Dolibarr version of the loaded document |
38 | 38 | * @public string |
39 | 39 | */ |
40 | - public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' |
|
40 | + public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' |
|
41 | 41 | |
42 | - /** |
|
42 | + /** |
|
43 | 43 | * @var string Error code (or message) |
44 | 44 | */ |
45 | 45 | public $error = ''; |
46 | 46 | |
47 | - /** |
|
48 | - * @var string Nom du modele |
|
49 | - * @deprecated |
|
50 | - * @see name |
|
51 | - */ |
|
52 | - public $nom='Cactus'; |
|
47 | + /** |
|
48 | + * @var string Nom du modele |
|
49 | + * @deprecated |
|
50 | + * @see name |
|
51 | + */ |
|
52 | + public $nom='Cactus'; |
|
53 | 53 | |
54 | - /** |
|
55 | - * @var string model name |
|
56 | - */ |
|
57 | - public $name='Cactus'; |
|
54 | + /** |
|
55 | + * @var string model name |
|
56 | + */ |
|
57 | + public $name='Cactus'; |
|
58 | 58 | |
59 | - public $prefixinvoice='SI'; |
|
59 | + public $prefixinvoice='SI'; |
|
60 | 60 | |
61 | - public $prefixcreditnote='SA'; |
|
61 | + public $prefixcreditnote='SA'; |
|
62 | 62 | |
63 | - public $prefixdeposit='SD'; |
|
63 | + public $prefixdeposit='SD'; |
|
64 | 64 | |
65 | 65 | |
66 | 66 | /** |
@@ -70,9 +70,9 @@ discard block |
||
70 | 70 | */ |
71 | 71 | function info() |
72 | 72 | { |
73 | - global $langs; |
|
74 | - $langs->load("bills"); |
|
75 | - return $langs->trans("CactusNumRefModelDesc1",$this->prefixinvoice,$this->prefixcreditnote,$this->prefixdeposit); |
|
73 | + global $langs; |
|
74 | + $langs->load("bills"); |
|
75 | + return $langs->trans("CactusNumRefModelDesc1",$this->prefixinvoice,$this->prefixcreditnote,$this->prefixdeposit); |
|
76 | 76 | } |
77 | 77 | |
78 | 78 | |
@@ -87,88 +87,88 @@ discard block |
||
87 | 87 | } |
88 | 88 | |
89 | 89 | |
90 | - /** |
|
91 | - * Tests if the numbers already in force in the database do not cause conflicts that would prevent this numbering. |
|
92 | - * |
|
93 | - * @return boolean false if conflict, true if ok |
|
94 | - */ |
|
95 | - function canBeActivated() |
|
96 | - { |
|
97 | - global $conf,$langs,$db; |
|
98 | - |
|
99 | - $langs->load("bills"); |
|
100 | - |
|
101 | - // Check invoice num |
|
102 | - $siyymm=''; $max=''; |
|
103 | - |
|
104 | - $posindice=8; |
|
105 | - $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; |
|
106 | - $sql.= " FROM ".MAIN_DB_PREFIX."facture_fourn"; |
|
107 | - $sql.= " WHERE ref LIKE '".$db->escape($this->prefixinvoice)."____-%'"; |
|
108 | - $sql.= " AND entity = ".$conf->entity; |
|
109 | - $resql=$db->query($sql); |
|
110 | - if ($resql) |
|
111 | - { |
|
112 | - $row = $db->fetch_row($resql); |
|
113 | - if ($row) { $siyymm = substr($row[0],0,6); $max=$row[0]; } |
|
114 | - } |
|
115 | - if ($siyymm && ! preg_match('/'.$this->prefixinvoice.'[0-9][0-9][0-9][0-9]/i',$siyymm)) |
|
116 | - { |
|
117 | - $langs->load("errors"); |
|
118 | - $this->error=$langs->trans('ErrorNumRefModel',$max); |
|
119 | - return false; |
|
120 | - } |
|
121 | - |
|
122 | - // Check credit note num |
|
123 | - $siyymm=''; |
|
124 | - |
|
125 | - $posindice=8; |
|
126 | - $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; // This is standard SQL |
|
127 | - $sql.= " FROM ".MAIN_DB_PREFIX."facture_fourn"; |
|
128 | - $sql.= " WHERE ref LIKE '".$db->escape($this->prefixcreditnote)."____-%'"; |
|
129 | - $sql.= " AND entity = ".$conf->entity; |
|
130 | - |
|
131 | - $resql=$db->query($sql); |
|
132 | - if ($resql) |
|
133 | - { |
|
134 | - $row = $db->fetch_row($resql); |
|
135 | - if ($row) { $siyymm = substr($row[0],0,6); $max=$row[0]; } |
|
136 | - } |
|
137 | - if ($siyymm && ! preg_match('/'.$this->prefixcreditnote.'[0-9][0-9][0-9][0-9]/i',$siyymm)) |
|
138 | - { |
|
139 | - $this->error=$langs->trans('ErrorNumRefModel',$max); |
|
140 | - return false; |
|
141 | - } |
|
142 | - |
|
143 | - // Check deposit num |
|
144 | - $siyymm=''; |
|
145 | - |
|
146 | - $posindice=8; |
|
147 | - $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; // This is standard SQL |
|
148 | - $sql.= " FROM ".MAIN_DB_PREFIX."facture_fourn"; |
|
149 | - $sql.= " WHERE ref LIKE '".$db->escape($this->prefixdeposit)."____-%'"; |
|
150 | - $sql.= " AND entity = ".$conf->entity; |
|
151 | - |
|
152 | - $resql=$db->query($sql); |
|
153 | - if ($resql) |
|
154 | - { |
|
155 | - $row = $db->fetch_row($resql); |
|
156 | - if ($row) { $siyymm = substr($row[0],0,6); $max=$row[0]; } |
|
157 | - } |
|
158 | - if ($siyymm && ! preg_match('/'.$this->prefixdeposit.'[0-9][0-9][0-9][0-9]/i',$siyymm)) |
|
159 | - { |
|
160 | - $this->error=$langs->trans('ErrorNumRefModel',$max); |
|
161 | - return false; |
|
162 | - } |
|
90 | + /** |
|
91 | + * Tests if the numbers already in force in the database do not cause conflicts that would prevent this numbering. |
|
92 | + * |
|
93 | + * @return boolean false if conflict, true if ok |
|
94 | + */ |
|
95 | + function canBeActivated() |
|
96 | + { |
|
97 | + global $conf,$langs,$db; |
|
98 | + |
|
99 | + $langs->load("bills"); |
|
100 | + |
|
101 | + // Check invoice num |
|
102 | + $siyymm=''; $max=''; |
|
103 | + |
|
104 | + $posindice=8; |
|
105 | + $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; |
|
106 | + $sql.= " FROM ".MAIN_DB_PREFIX."facture_fourn"; |
|
107 | + $sql.= " WHERE ref LIKE '".$db->escape($this->prefixinvoice)."____-%'"; |
|
108 | + $sql.= " AND entity = ".$conf->entity; |
|
109 | + $resql=$db->query($sql); |
|
110 | + if ($resql) |
|
111 | + { |
|
112 | + $row = $db->fetch_row($resql); |
|
113 | + if ($row) { $siyymm = substr($row[0],0,6); $max=$row[0]; } |
|
114 | + } |
|
115 | + if ($siyymm && ! preg_match('/'.$this->prefixinvoice.'[0-9][0-9][0-9][0-9]/i',$siyymm)) |
|
116 | + { |
|
117 | + $langs->load("errors"); |
|
118 | + $this->error=$langs->trans('ErrorNumRefModel',$max); |
|
119 | + return false; |
|
120 | + } |
|
121 | + |
|
122 | + // Check credit note num |
|
123 | + $siyymm=''; |
|
124 | + |
|
125 | + $posindice=8; |
|
126 | + $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; // This is standard SQL |
|
127 | + $sql.= " FROM ".MAIN_DB_PREFIX."facture_fourn"; |
|
128 | + $sql.= " WHERE ref LIKE '".$db->escape($this->prefixcreditnote)."____-%'"; |
|
129 | + $sql.= " AND entity = ".$conf->entity; |
|
130 | + |
|
131 | + $resql=$db->query($sql); |
|
132 | + if ($resql) |
|
133 | + { |
|
134 | + $row = $db->fetch_row($resql); |
|
135 | + if ($row) { $siyymm = substr($row[0],0,6); $max=$row[0]; } |
|
136 | + } |
|
137 | + if ($siyymm && ! preg_match('/'.$this->prefixcreditnote.'[0-9][0-9][0-9][0-9]/i',$siyymm)) |
|
138 | + { |
|
139 | + $this->error=$langs->trans('ErrorNumRefModel',$max); |
|
140 | + return false; |
|
141 | + } |
|
142 | + |
|
143 | + // Check deposit num |
|
144 | + $siyymm=''; |
|
145 | + |
|
146 | + $posindice=8; |
|
147 | + $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; // This is standard SQL |
|
148 | + $sql.= " FROM ".MAIN_DB_PREFIX."facture_fourn"; |
|
149 | + $sql.= " WHERE ref LIKE '".$db->escape($this->prefixdeposit)."____-%'"; |
|
150 | + $sql.= " AND entity = ".$conf->entity; |
|
151 | + |
|
152 | + $resql=$db->query($sql); |
|
153 | + if ($resql) |
|
154 | + { |
|
155 | + $row = $db->fetch_row($resql); |
|
156 | + if ($row) { $siyymm = substr($row[0],0,6); $max=$row[0]; } |
|
157 | + } |
|
158 | + if ($siyymm && ! preg_match('/'.$this->prefixdeposit.'[0-9][0-9][0-9][0-9]/i',$siyymm)) |
|
159 | + { |
|
160 | + $this->error=$langs->trans('ErrorNumRefModel',$max); |
|
161 | + return false; |
|
162 | + } |
|
163 | 163 | } |
164 | 164 | |
165 | 165 | /** |
166 | 166 | * Return next value |
167 | - * |
|
168 | - * @param Societe $objsoc Object third party |
|
169 | - * @param Object $object Object invoice |
|
167 | + * |
|
168 | + * @param Societe $objsoc Object third party |
|
169 | + * @param Object $object Object invoice |
|
170 | 170 | * @param string $mode 'next' for next value or 'last' for last value |
171 | - * @return string Value if OK, 0 if KO |
|
171 | + * @return string Value if OK, 0 if KO |
|
172 | 172 | */ |
173 | 173 | function getNextValue($objsoc,$object,$mode='next') |
174 | 174 | { |
@@ -189,63 +189,63 @@ discard block |
||
189 | 189 | dol_syslog(get_class($this)."::getNextValue", LOG_DEBUG); |
190 | 190 | if ($resql) |
191 | 191 | { |
192 | - $obj = $db->fetch_object($resql); |
|
193 | - if ($obj) $max = intval($obj->max); |
|
194 | - else $max=0; |
|
192 | + $obj = $db->fetch_object($resql); |
|
193 | + if ($obj) $max = intval($obj->max); |
|
194 | + else $max=0; |
|
195 | 195 | } |
196 | 196 | else |
197 | 197 | { |
198 | - return -1; |
|
198 | + return -1; |
|
199 | 199 | } |
200 | 200 | |
201 | 201 | if ($mode == 'last') |
202 | 202 | { |
203 | - if ($max >= (pow(10, 4) - 1)) $num=$max; // If counter > 9999, we do not format on 4 chars, we take number as it is |
|
204 | - else $num = sprintf("%04s",$max); |
|
205 | - |
|
206 | - $ref=''; |
|
207 | - $sql = "SELECT ref as ref"; |
|
208 | - $sql.= " FROM ".MAIN_DB_PREFIX."facture_fourn"; |
|
209 | - $sql.= " WHERE ref LIKE '".$prefix."____-".$num."'"; |
|
210 | - $sql.= " AND entity = ".$conf->entity; |
|
211 | - |
|
212 | - dol_syslog(get_class($this)."::getNextValue", LOG_DEBUG); |
|
213 | - $resql=$db->query($sql); |
|
214 | - if ($resql) |
|
215 | - { |
|
216 | - $obj = $db->fetch_object($resql); |
|
217 | - if ($obj) $ref = $obj->ref; |
|
218 | - } |
|
219 | - else dol_print_error($db); |
|
220 | - |
|
221 | - return $ref; |
|
203 | + if ($max >= (pow(10, 4) - 1)) $num=$max; // If counter > 9999, we do not format on 4 chars, we take number as it is |
|
204 | + else $num = sprintf("%04s",$max); |
|
205 | + |
|
206 | + $ref=''; |
|
207 | + $sql = "SELECT ref as ref"; |
|
208 | + $sql.= " FROM ".MAIN_DB_PREFIX."facture_fourn"; |
|
209 | + $sql.= " WHERE ref LIKE '".$prefix."____-".$num."'"; |
|
210 | + $sql.= " AND entity = ".$conf->entity; |
|
211 | + |
|
212 | + dol_syslog(get_class($this)."::getNextValue", LOG_DEBUG); |
|
213 | + $resql=$db->query($sql); |
|
214 | + if ($resql) |
|
215 | + { |
|
216 | + $obj = $db->fetch_object($resql); |
|
217 | + if ($obj) $ref = $obj->ref; |
|
218 | + } |
|
219 | + else dol_print_error($db); |
|
220 | + |
|
221 | + return $ref; |
|
222 | 222 | } |
223 | 223 | else if ($mode == 'next') |
224 | 224 | { |
225 | - $date=$object->date; // This is invoice date (not creation date) |
|
226 | - $yymm = strftime("%y%m",$date); |
|
225 | + $date=$object->date; // This is invoice date (not creation date) |
|
226 | + $yymm = strftime("%y%m",$date); |
|
227 | 227 | |
228 | - if ($max >= (pow(10, 4) - 1)) $num=$max+1; // If counter > 9999, we do not format on 4 chars, we take number as it is |
|
229 | - else $num = sprintf("%04s",$max+1); |
|
228 | + if ($max >= (pow(10, 4) - 1)) $num=$max+1; // If counter > 9999, we do not format on 4 chars, we take number as it is |
|
229 | + else $num = sprintf("%04s",$max+1); |
|
230 | 230 | |
231 | - dol_syslog(get_class($this)."::getNextValue return ".$prefix.$yymm."-".$num); |
|
232 | - return $prefix.$yymm."-".$num; |
|
231 | + dol_syslog(get_class($this)."::getNextValue return ".$prefix.$yymm."-".$num); |
|
232 | + return $prefix.$yymm."-".$num; |
|
233 | 233 | } |
234 | 234 | else dol_print_error('','Bad parameter for getNextValue'); |
235 | 235 | } |
236 | 236 | |
237 | 237 | |
238 | 238 | /** |
239 | - * Return next free value |
|
240 | - * |
|
239 | + * Return next free value |
|
240 | + * |
|
241 | 241 | * @param Societe $objsoc Object third party |
242 | 242 | * @param string $objforref Object for number to search |
243 | 243 | * @param string $mode 'next' for next value or 'last' for last value |
244 | 244 | * @return string Next free value |
245 | 245 | */ |
246 | - function getNumRef($objsoc,$objforref,$mode='next') |
|
247 | - { |
|
248 | - return $this->getNextValue($objsoc,$objforref,$mode); |
|
249 | - } |
|
246 | + function getNumRef($objsoc,$objforref,$mode='next') |
|
247 | + { |
|
248 | + return $this->getNextValue($objsoc,$objforref,$mode); |
|
249 | + } |
|
250 | 250 | } |
251 | 251 |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | * \brief File containing class for the numbering module Cactus |
26 | 26 | */ |
27 | 27 | |
28 | -require_once DOL_DOCUMENT_ROOT .'/core/modules/supplier_invoice/modules_facturefournisseur.php'; |
|
28 | +require_once DOL_DOCUMENT_ROOT.'/core/modules/supplier_invoice/modules_facturefournisseur.php'; |
|
29 | 29 | |
30 | 30 | |
31 | 31 | /** |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | * Dolibarr version of the loaded document |
38 | 38 | * @public string |
39 | 39 | */ |
40 | - public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' |
|
40 | + public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' |
|
41 | 41 | |
42 | 42 | /** |
43 | 43 | * @var string Error code (or message) |
@@ -49,18 +49,18 @@ discard block |
||
49 | 49 | * @deprecated |
50 | 50 | * @see name |
51 | 51 | */ |
52 | - public $nom='Cactus'; |
|
52 | + public $nom = 'Cactus'; |
|
53 | 53 | |
54 | 54 | /** |
55 | 55 | * @var string model name |
56 | 56 | */ |
57 | - public $name='Cactus'; |
|
57 | + public $name = 'Cactus'; |
|
58 | 58 | |
59 | - public $prefixinvoice='SI'; |
|
59 | + public $prefixinvoice = 'SI'; |
|
60 | 60 | |
61 | - public $prefixcreditnote='SA'; |
|
61 | + public $prefixcreditnote = 'SA'; |
|
62 | 62 | |
63 | - public $prefixdeposit='SD'; |
|
63 | + public $prefixdeposit = 'SD'; |
|
64 | 64 | |
65 | 65 | |
66 | 66 | /** |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | { |
73 | 73 | global $langs; |
74 | 74 | $langs->load("bills"); |
75 | - return $langs->trans("CactusNumRefModelDesc1",$this->prefixinvoice,$this->prefixcreditnote,$this->prefixdeposit); |
|
75 | + return $langs->trans("CactusNumRefModelDesc1", $this->prefixinvoice, $this->prefixcreditnote, $this->prefixdeposit); |
|
76 | 76 | } |
77 | 77 | |
78 | 78 | |
@@ -94,70 +94,70 @@ discard block |
||
94 | 94 | */ |
95 | 95 | function canBeActivated() |
96 | 96 | { |
97 | - global $conf,$langs,$db; |
|
97 | + global $conf, $langs, $db; |
|
98 | 98 | |
99 | 99 | $langs->load("bills"); |
100 | 100 | |
101 | 101 | // Check invoice num |
102 | - $siyymm=''; $max=''; |
|
102 | + $siyymm = ''; $max = ''; |
|
103 | 103 | |
104 | - $posindice=8; |
|
104 | + $posindice = 8; |
|
105 | 105 | $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; |
106 | - $sql.= " FROM ".MAIN_DB_PREFIX."facture_fourn"; |
|
107 | - $sql.= " WHERE ref LIKE '".$db->escape($this->prefixinvoice)."____-%'"; |
|
108 | - $sql.= " AND entity = ".$conf->entity; |
|
109 | - $resql=$db->query($sql); |
|
106 | + $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn"; |
|
107 | + $sql .= " WHERE ref LIKE '".$db->escape($this->prefixinvoice)."____-%'"; |
|
108 | + $sql .= " AND entity = ".$conf->entity; |
|
109 | + $resql = $db->query($sql); |
|
110 | 110 | if ($resql) |
111 | 111 | { |
112 | 112 | $row = $db->fetch_row($resql); |
113 | - if ($row) { $siyymm = substr($row[0],0,6); $max=$row[0]; } |
|
113 | + if ($row) { $siyymm = substr($row[0], 0, 6); $max = $row[0]; } |
|
114 | 114 | } |
115 | - if ($siyymm && ! preg_match('/'.$this->prefixinvoice.'[0-9][0-9][0-9][0-9]/i',$siyymm)) |
|
115 | + if ($siyymm && !preg_match('/'.$this->prefixinvoice.'[0-9][0-9][0-9][0-9]/i', $siyymm)) |
|
116 | 116 | { |
117 | 117 | $langs->load("errors"); |
118 | - $this->error=$langs->trans('ErrorNumRefModel',$max); |
|
118 | + $this->error = $langs->trans('ErrorNumRefModel', $max); |
|
119 | 119 | return false; |
120 | 120 | } |
121 | 121 | |
122 | 122 | // Check credit note num |
123 | - $siyymm=''; |
|
123 | + $siyymm = ''; |
|
124 | 124 | |
125 | - $posindice=8; |
|
126 | - $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; // This is standard SQL |
|
127 | - $sql.= " FROM ".MAIN_DB_PREFIX."facture_fourn"; |
|
128 | - $sql.= " WHERE ref LIKE '".$db->escape($this->prefixcreditnote)."____-%'"; |
|
129 | - $sql.= " AND entity = ".$conf->entity; |
|
125 | + $posindice = 8; |
|
126 | + $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; // This is standard SQL |
|
127 | + $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn"; |
|
128 | + $sql .= " WHERE ref LIKE '".$db->escape($this->prefixcreditnote)."____-%'"; |
|
129 | + $sql .= " AND entity = ".$conf->entity; |
|
130 | 130 | |
131 | - $resql=$db->query($sql); |
|
131 | + $resql = $db->query($sql); |
|
132 | 132 | if ($resql) |
133 | 133 | { |
134 | 134 | $row = $db->fetch_row($resql); |
135 | - if ($row) { $siyymm = substr($row[0],0,6); $max=$row[0]; } |
|
135 | + if ($row) { $siyymm = substr($row[0], 0, 6); $max = $row[0]; } |
|
136 | 136 | } |
137 | - if ($siyymm && ! preg_match('/'.$this->prefixcreditnote.'[0-9][0-9][0-9][0-9]/i',$siyymm)) |
|
137 | + if ($siyymm && !preg_match('/'.$this->prefixcreditnote.'[0-9][0-9][0-9][0-9]/i', $siyymm)) |
|
138 | 138 | { |
139 | - $this->error=$langs->trans('ErrorNumRefModel',$max); |
|
139 | + $this->error = $langs->trans('ErrorNumRefModel', $max); |
|
140 | 140 | return false; |
141 | 141 | } |
142 | 142 | |
143 | 143 | // Check deposit num |
144 | - $siyymm=''; |
|
144 | + $siyymm = ''; |
|
145 | 145 | |
146 | - $posindice=8; |
|
147 | - $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; // This is standard SQL |
|
148 | - $sql.= " FROM ".MAIN_DB_PREFIX."facture_fourn"; |
|
149 | - $sql.= " WHERE ref LIKE '".$db->escape($this->prefixdeposit)."____-%'"; |
|
150 | - $sql.= " AND entity = ".$conf->entity; |
|
146 | + $posindice = 8; |
|
147 | + $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; // This is standard SQL |
|
148 | + $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn"; |
|
149 | + $sql .= " WHERE ref LIKE '".$db->escape($this->prefixdeposit)."____-%'"; |
|
150 | + $sql .= " AND entity = ".$conf->entity; |
|
151 | 151 | |
152 | - $resql=$db->query($sql); |
|
152 | + $resql = $db->query($sql); |
|
153 | 153 | if ($resql) |
154 | 154 | { |
155 | 155 | $row = $db->fetch_row($resql); |
156 | - if ($row) { $siyymm = substr($row[0],0,6); $max=$row[0]; } |
|
156 | + if ($row) { $siyymm = substr($row[0], 0, 6); $max = $row[0]; } |
|
157 | 157 | } |
158 | - if ($siyymm && ! preg_match('/'.$this->prefixdeposit.'[0-9][0-9][0-9][0-9]/i',$siyymm)) |
|
158 | + if ($siyymm && !preg_match('/'.$this->prefixdeposit.'[0-9][0-9][0-9][0-9]/i', $siyymm)) |
|
159 | 159 | { |
160 | - $this->error=$langs->trans('ErrorNumRefModel',$max); |
|
160 | + $this->error = $langs->trans('ErrorNumRefModel', $max); |
|
161 | 161 | return false; |
162 | 162 | } |
163 | 163 | } |
@@ -170,28 +170,28 @@ discard block |
||
170 | 170 | * @param string $mode 'next' for next value or 'last' for last value |
171 | 171 | * @return string Value if OK, 0 if KO |
172 | 172 | */ |
173 | - function getNextValue($objsoc,$object,$mode='next') |
|
173 | + function getNextValue($objsoc, $object, $mode = 'next') |
|
174 | 174 | { |
175 | - global $db,$conf; |
|
175 | + global $db, $conf; |
|
176 | 176 | |
177 | - if ($object->type == 2) $prefix=$this->prefixcreditnote; |
|
178 | - else if ($facture->type == 3) $prefix=$this->prefixdeposit; |
|
179 | - else $prefix=$this->prefixinvoice; |
|
177 | + if ($object->type == 2) $prefix = $this->prefixcreditnote; |
|
178 | + else if ($facture->type == 3) $prefix = $this->prefixdeposit; |
|
179 | + else $prefix = $this->prefixinvoice; |
|
180 | 180 | |
181 | 181 | // D'abord on recupere la valeur max |
182 | - $posindice=8; |
|
183 | - $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; // This is standard SQL |
|
184 | - $sql.= " FROM ".MAIN_DB_PREFIX."facture_fourn"; |
|
185 | - $sql.= " WHERE ref LIKE '".$prefix."____-%'"; |
|
186 | - $sql.= " AND entity = ".$conf->entity; |
|
182 | + $posindice = 8; |
|
183 | + $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; // This is standard SQL |
|
184 | + $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn"; |
|
185 | + $sql .= " WHERE ref LIKE '".$prefix."____-%'"; |
|
186 | + $sql .= " AND entity = ".$conf->entity; |
|
187 | 187 | |
188 | - $resql=$db->query($sql); |
|
188 | + $resql = $db->query($sql); |
|
189 | 189 | dol_syslog(get_class($this)."::getNextValue", LOG_DEBUG); |
190 | 190 | if ($resql) |
191 | 191 | { |
192 | 192 | $obj = $db->fetch_object($resql); |
193 | 193 | if ($obj) $max = intval($obj->max); |
194 | - else $max=0; |
|
194 | + else $max = 0; |
|
195 | 195 | } |
196 | 196 | else |
197 | 197 | { |
@@ -200,17 +200,17 @@ discard block |
||
200 | 200 | |
201 | 201 | if ($mode == 'last') |
202 | 202 | { |
203 | - if ($max >= (pow(10, 4) - 1)) $num=$max; // If counter > 9999, we do not format on 4 chars, we take number as it is |
|
204 | - else $num = sprintf("%04s",$max); |
|
203 | + if ($max >= (pow(10, 4) - 1)) $num = $max; // If counter > 9999, we do not format on 4 chars, we take number as it is |
|
204 | + else $num = sprintf("%04s", $max); |
|
205 | 205 | |
206 | - $ref=''; |
|
206 | + $ref = ''; |
|
207 | 207 | $sql = "SELECT ref as ref"; |
208 | - $sql.= " FROM ".MAIN_DB_PREFIX."facture_fourn"; |
|
209 | - $sql.= " WHERE ref LIKE '".$prefix."____-".$num."'"; |
|
210 | - $sql.= " AND entity = ".$conf->entity; |
|
208 | + $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn"; |
|
209 | + $sql .= " WHERE ref LIKE '".$prefix."____-".$num."'"; |
|
210 | + $sql .= " AND entity = ".$conf->entity; |
|
211 | 211 | |
212 | 212 | dol_syslog(get_class($this)."::getNextValue", LOG_DEBUG); |
213 | - $resql=$db->query($sql); |
|
213 | + $resql = $db->query($sql); |
|
214 | 214 | if ($resql) |
215 | 215 | { |
216 | 216 | $obj = $db->fetch_object($resql); |
@@ -222,16 +222,16 @@ discard block |
||
222 | 222 | } |
223 | 223 | else if ($mode == 'next') |
224 | 224 | { |
225 | - $date=$object->date; // This is invoice date (not creation date) |
|
226 | - $yymm = strftime("%y%m",$date); |
|
225 | + $date = $object->date; // This is invoice date (not creation date) |
|
226 | + $yymm = strftime("%y%m", $date); |
|
227 | 227 | |
228 | - if ($max >= (pow(10, 4) - 1)) $num=$max+1; // If counter > 9999, we do not format on 4 chars, we take number as it is |
|
229 | - else $num = sprintf("%04s",$max+1); |
|
228 | + if ($max >= (pow(10, 4) - 1)) $num = $max + 1; // If counter > 9999, we do not format on 4 chars, we take number as it is |
|
229 | + else $num = sprintf("%04s", $max + 1); |
|
230 | 230 | |
231 | 231 | dol_syslog(get_class($this)."::getNextValue return ".$prefix.$yymm."-".$num); |
232 | 232 | return $prefix.$yymm."-".$num; |
233 | 233 | } |
234 | - else dol_print_error('','Bad parameter for getNextValue'); |
|
234 | + else dol_print_error('', 'Bad parameter for getNextValue'); |
|
235 | 235 | } |
236 | 236 | |
237 | 237 | |
@@ -243,9 +243,9 @@ discard block |
||
243 | 243 | * @param string $mode 'next' for next value or 'last' for last value |
244 | 244 | * @return string Next free value |
245 | 245 | */ |
246 | - function getNumRef($objsoc,$objforref,$mode='next') |
|
246 | + function getNumRef($objsoc, $objforref, $mode = 'next') |
|
247 | 247 | { |
248 | - return $this->getNextValue($objsoc,$objforref,$mode); |
|
248 | + return $this->getNextValue($objsoc, $objforref, $mode); |
|
249 | 249 | } |
250 | 250 | } |
251 | 251 |
@@ -174,9 +174,13 @@ discard block |
||
174 | 174 | { |
175 | 175 | global $db,$conf; |
176 | 176 | |
177 | - if ($object->type == 2) $prefix=$this->prefixcreditnote; |
|
178 | - else if ($facture->type == 3) $prefix=$this->prefixdeposit; |
|
179 | - else $prefix=$this->prefixinvoice; |
|
177 | + if ($object->type == 2) { |
|
178 | + $prefix=$this->prefixcreditnote; |
|
179 | + } else if ($facture->type == 3) { |
|
180 | + $prefix=$this->prefixdeposit; |
|
181 | + } else { |
|
182 | + $prefix=$this->prefixinvoice; |
|
183 | + } |
|
180 | 184 | |
181 | 185 | // D'abord on recupere la valeur max |
182 | 186 | $posindice=8; |
@@ -190,18 +194,25 @@ discard block |
||
190 | 194 | if ($resql) |
191 | 195 | { |
192 | 196 | $obj = $db->fetch_object($resql); |
193 | - if ($obj) $max = intval($obj->max); |
|
194 | - else $max=0; |
|
195 | - } |
|
196 | - else |
|
197 | + if ($obj) { |
|
198 | + $max = intval($obj->max); |
|
199 | + } else { |
|
200 | + $max=0; |
|
201 | + } |
|
202 | + } else |
|
197 | 203 | { |
198 | 204 | return -1; |
199 | 205 | } |
200 | 206 | |
201 | 207 | if ($mode == 'last') |
202 | 208 | { |
203 | - if ($max >= (pow(10, 4) - 1)) $num=$max; // If counter > 9999, we do not format on 4 chars, we take number as it is |
|
204 | - else $num = sprintf("%04s",$max); |
|
209 | + if ($max >= (pow(10, 4) - 1)) { |
|
210 | + $num=$max; |
|
211 | + } |
|
212 | + // If counter > 9999, we do not format on 4 chars, we take number as it is |
|
213 | + else { |
|
214 | + $num = sprintf("%04s",$max); |
|
215 | + } |
|
205 | 216 | |
206 | 217 | $ref=''; |
207 | 218 | $sql = "SELECT ref as ref"; |
@@ -214,24 +225,32 @@ discard block |
||
214 | 225 | if ($resql) |
215 | 226 | { |
216 | 227 | $obj = $db->fetch_object($resql); |
217 | - if ($obj) $ref = $obj->ref; |
|
228 | + if ($obj) { |
|
229 | + $ref = $obj->ref; |
|
230 | + } |
|
231 | + } else { |
|
232 | + dol_print_error($db); |
|
218 | 233 | } |
219 | - else dol_print_error($db); |
|
220 | 234 | |
221 | 235 | return $ref; |
222 | - } |
|
223 | - else if ($mode == 'next') |
|
236 | + } else if ($mode == 'next') |
|
224 | 237 | { |
225 | 238 | $date=$object->date; // This is invoice date (not creation date) |
226 | 239 | $yymm = strftime("%y%m",$date); |
227 | 240 | |
228 | - if ($max >= (pow(10, 4) - 1)) $num=$max+1; // If counter > 9999, we do not format on 4 chars, we take number as it is |
|
229 | - else $num = sprintf("%04s",$max+1); |
|
241 | + if ($max >= (pow(10, 4) - 1)) { |
|
242 | + $num=$max+1; |
|
243 | + } |
|
244 | + // If counter > 9999, we do not format on 4 chars, we take number as it is |
|
245 | + else { |
|
246 | + $num = sprintf("%04s",$max+1); |
|
247 | + } |
|
230 | 248 | |
231 | 249 | dol_syslog(get_class($this)."::getNextValue return ".$prefix.$yymm."-".$num); |
232 | 250 | return $prefix.$yymm."-".$num; |
251 | + } else { |
|
252 | + dol_print_error('','Bad parameter for getNextValue'); |
|
233 | 253 | } |
234 | - else dol_print_error('','Bad parameter for getNextValue'); |
|
235 | 254 | } |
236 | 255 | |
237 | 256 |
@@ -36,28 +36,28 @@ discard block |
||
36 | 36 | */ |
37 | 37 | class mod_facture_fournisseur_tulip extends ModeleNumRefSuppliersInvoices |
38 | 38 | { |
39 | - /** |
|
39 | + /** |
|
40 | 40 | * Dolibarr version of the loaded document |
41 | 41 | * @public string |
42 | 42 | */ |
43 | - public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' |
|
43 | + public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' |
|
44 | 44 | |
45 | - /** |
|
45 | + /** |
|
46 | 46 | * @var string Error code (or message) |
47 | 47 | */ |
48 | 48 | public $error = ''; |
49 | 49 | |
50 | - /** |
|
51 | - * @var string Nom du modele |
|
52 | - * @deprecated |
|
53 | - * @see name |
|
54 | - */ |
|
55 | - public $nom='Tulip'; |
|
50 | + /** |
|
51 | + * @var string Nom du modele |
|
52 | + * @deprecated |
|
53 | + * @see name |
|
54 | + */ |
|
55 | + public $nom='Tulip'; |
|
56 | 56 | |
57 | - /** |
|
58 | - * @var string model name |
|
59 | - */ |
|
60 | - public $name='Tulip'; |
|
57 | + /** |
|
58 | + * @var string model name |
|
59 | + */ |
|
60 | + public $name='Tulip'; |
|
61 | 61 | |
62 | 62 | |
63 | 63 | /** |
@@ -65,63 +65,63 @@ discard block |
||
65 | 65 | * |
66 | 66 | * @return string Description Text |
67 | 67 | */ |
68 | - function info() |
|
68 | + function info() |
|
69 | 69 | { |
70 | - global $conf, $langs; |
|
70 | + global $conf, $langs; |
|
71 | 71 | |
72 | - // Load translation files required by the page |
|
72 | + // Load translation files required by the page |
|
73 | 73 | $langs->loadLangs(array("bills","admin")); |
74 | 74 | |
75 | - $form = new Form($this->db); |
|
75 | + $form = new Form($this->db); |
|
76 | 76 | |
77 | - $texte = $langs->trans('GenericNumRefModelDesc')."<br>\n"; |
|
78 | - $texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">'; |
|
79 | - $texte.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
80 | - $texte.= '<input type="hidden" name="action" value="updateMask">'; |
|
81 | - $texte.= '<input type="hidden" name="maskconstinvoice" value="SUPPLIER_INVOICE_TULIP_MASK">'; |
|
77 | + $texte = $langs->trans('GenericNumRefModelDesc')."<br>\n"; |
|
78 | + $texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">'; |
|
79 | + $texte.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
80 | + $texte.= '<input type="hidden" name="action" value="updateMask">'; |
|
81 | + $texte.= '<input type="hidden" name="maskconstinvoice" value="SUPPLIER_INVOICE_TULIP_MASK">'; |
|
82 | 82 | $texte.= '<input type="hidden" name="maskconstreplacement" value="SUPPLIER_REPLACEMENT_TULIP_MASK">'; |
83 | 83 | $texte.= '<input type="hidden" name="maskconstcredit" value="SUPPLIER_CREDIT_TULIP_MASK">'; |
84 | - $texte.= '<input type="hidden" name="maskconstdeposit" value="SUPPLIER_DEPOSIT_TULIP_MASK">'; |
|
85 | - $texte.= '<table class="nobordernopadding" width="100%">'; |
|
84 | + $texte.= '<input type="hidden" name="maskconstdeposit" value="SUPPLIER_DEPOSIT_TULIP_MASK">'; |
|
85 | + $texte.= '<table class="nobordernopadding" width="100%">'; |
|
86 | 86 | |
87 | - $tooltip=$langs->trans("GenericMaskCodes",$langs->transnoentities("Invoice"),$langs->transnoentities("Invoice")); |
|
88 | - $tooltip.=$langs->trans("GenericMaskCodes2"); |
|
89 | - $tooltip.=$langs->trans("GenericMaskCodes3"); |
|
90 | - $tooltip.=$langs->trans("GenericMaskCodes4a",$langs->transnoentities("Invoice"),$langs->transnoentities("Invoice")); |
|
91 | - $tooltip.=$langs->trans("GenericMaskCodes5"); |
|
87 | + $tooltip=$langs->trans("GenericMaskCodes",$langs->transnoentities("Invoice"),$langs->transnoentities("Invoice")); |
|
88 | + $tooltip.=$langs->trans("GenericMaskCodes2"); |
|
89 | + $tooltip.=$langs->trans("GenericMaskCodes3"); |
|
90 | + $tooltip.=$langs->trans("GenericMaskCodes4a",$langs->transnoentities("Invoice"),$langs->transnoentities("Invoice")); |
|
91 | + $tooltip.=$langs->trans("GenericMaskCodes5"); |
|
92 | 92 | |
93 | - // Parametrage du prefix |
|
94 | - $texte.= '<tr><td>'.$langs->trans("Mask").' ('.$langs->trans("InvoiceStandard").')'; |
|
95 | - $texte.= ':</td>'; |
|
96 | - $texte.= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="maskinvoice" value="'.$conf->global->SUPPLIER_INVOICE_TULIP_MASK.'">',$tooltip,1,1).'</td>'; |
|
93 | + // Parametrage du prefix |
|
94 | + $texte.= '<tr><td>'.$langs->trans("Mask").' ('.$langs->trans("InvoiceStandard").')'; |
|
95 | + $texte.= ':</td>'; |
|
96 | + $texte.= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="maskinvoice" value="'.$conf->global->SUPPLIER_INVOICE_TULIP_MASK.'">',$tooltip,1,1).'</td>'; |
|
97 | 97 | |
98 | - $texte.= '<td align="left" rowspan="2"> <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>'; |
|
98 | + $texte.= '<td align="left" rowspan="2"> <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>'; |
|
99 | 99 | |
100 | - $texte.= '</tr>'; |
|
100 | + $texte.= '</tr>'; |
|
101 | 101 | |
102 | - // Parametrage du prefix des avoirs |
|
103 | - $texte.= '<tr><td>'.$langs->trans("Mask").' ('.$langs->trans("InvoiceAvoir").'):</td>'; |
|
104 | - $texte.= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="maskcredit" value="'.$conf->global->SUPPLIER_CREDIT_TULIP_MASK.'">',$tooltip,1,1).'</td>'; |
|
105 | - $texte.= '</tr>'; |
|
102 | + // Parametrage du prefix des avoirs |
|
103 | + $texte.= '<tr><td>'.$langs->trans("Mask").' ('.$langs->trans("InvoiceAvoir").'):</td>'; |
|
104 | + $texte.= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="maskcredit" value="'.$conf->global->SUPPLIER_CREDIT_TULIP_MASK.'">',$tooltip,1,1).'</td>'; |
|
105 | + $texte.= '</tr>'; |
|
106 | 106 | |
107 | - if ($conf->global->MAIN_FEATURE_LEVEL >= 2) |
|
108 | - { |
|
109 | - // Parametrage du prefix des replacement |
|
110 | - $texte.= '<tr><td>'.$langs->trans("Mask").' ('.$langs->trans("InvoiceReplacement").'):</td>'; |
|
111 | - $texte.= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="maskreplacement" value="'.$conf->global->SUPPLIER_REPLACEMENT_TULIP_MASK.'">',$tooltip,1,1).'</td>'; |
|
112 | - $texte.= '</tr>'; |
|
107 | + if ($conf->global->MAIN_FEATURE_LEVEL >= 2) |
|
108 | + { |
|
109 | + // Parametrage du prefix des replacement |
|
110 | + $texte.= '<tr><td>'.$langs->trans("Mask").' ('.$langs->trans("InvoiceReplacement").'):</td>'; |
|
111 | + $texte.= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="maskreplacement" value="'.$conf->global->SUPPLIER_REPLACEMENT_TULIP_MASK.'">',$tooltip,1,1).'</td>'; |
|
112 | + $texte.= '</tr>'; |
|
113 | 113 | |
114 | 114 | |
115 | - // Parametrage du prefix des acomptes |
|
116 | - $texte.= '<tr><td>'.$langs->trans("Mask").' ('.$langs->trans("InvoiceDeposit").'):</td>'; |
|
117 | - $texte.= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="maskdeposit" value="'.$conf->global->SUPPLIER_DEPOSIT_TULIP_MASK.'">',$tooltip,1,1).'</td>'; |
|
118 | - $texte.= '</tr>'; |
|
119 | - } |
|
115 | + // Parametrage du prefix des acomptes |
|
116 | + $texte.= '<tr><td>'.$langs->trans("Mask").' ('.$langs->trans("InvoiceDeposit").'):</td>'; |
|
117 | + $texte.= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="maskdeposit" value="'.$conf->global->SUPPLIER_DEPOSIT_TULIP_MASK.'">',$tooltip,1,1).'</td>'; |
|
118 | + $texte.= '</tr>'; |
|
119 | + } |
|
120 | 120 | |
121 | - $texte.= '</table>'; |
|
122 | - $texte.= '</form>'; |
|
121 | + $texte.= '</table>'; |
|
122 | + $texte.= '</form>'; |
|
123 | 123 | |
124 | - return $texte; |
|
124 | + return $texte; |
|
125 | 125 | } |
126 | 126 | |
127 | 127 | /** |
@@ -131,70 +131,70 @@ discard block |
||
131 | 131 | */ |
132 | 132 | function getExample() |
133 | 133 | { |
134 | - global $conf,$langs,$mysoc; |
|
135 | - |
|
136 | - $old_code_client=$mysoc->code_client; |
|
137 | - $mysoc->code_client='CCCCCCCCCC'; |
|
138 | - $numExample = $this->getNextValue($mysoc,''); |
|
139 | - $mysoc->code_client=$old_code_client; |
|
140 | - |
|
141 | - if (! $numExample) |
|
142 | - { |
|
143 | - $numExample = $langs->trans('NotConfigured'); |
|
144 | - } |
|
145 | - return $numExample; |
|
134 | + global $conf,$langs,$mysoc; |
|
135 | + |
|
136 | + $old_code_client=$mysoc->code_client; |
|
137 | + $mysoc->code_client='CCCCCCCCCC'; |
|
138 | + $numExample = $this->getNextValue($mysoc,''); |
|
139 | + $mysoc->code_client=$old_code_client; |
|
140 | + |
|
141 | + if (! $numExample) |
|
142 | + { |
|
143 | + $numExample = $langs->trans('NotConfigured'); |
|
144 | + } |
|
145 | + return $numExample; |
|
146 | 146 | } |
147 | 147 | |
148 | - /** |
|
149 | - * Return next value |
|
150 | - * |
|
151 | - * @param Societe $objsoc Object third party |
|
152 | - * @param Object $object Object invoice |
|
148 | + /** |
|
149 | + * Return next value |
|
150 | + * |
|
151 | + * @param Societe $objsoc Object third party |
|
152 | + * @param Object $object Object invoice |
|
153 | 153 | * @param string $mode 'next' for next value or 'last' for last value |
154 | 154 | * @return string Value if OK, 0 if KO |
155 | - */ |
|
155 | + */ |
|
156 | 156 | function getNextValue($objsoc,$object,$mode='next') |
157 | 157 | { |
158 | - global $db,$conf; |
|
159 | - |
|
160 | - require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php'; |
|
161 | - |
|
162 | - // Get Mask value |
|
163 | - $mask = ''; |
|
164 | - if (is_object($object) && $object->type == 1) |
|
165 | - { |
|
166 | - $mask=$conf->global->SUPPLIER_REPLACEMENT_TULIP_MASK; |
|
167 | - if (! $mask) |
|
168 | - { |
|
169 | - $mask=$conf->global->SUPPLIER_INVOICE_TULIP_MASK; |
|
170 | - } |
|
171 | - } |
|
172 | - else if (is_object($object) && $object->type == 2) $mask=$conf->global->SUPPLIER_CREDIT_TULIP_MASK; |
|
173 | - else if (is_object($object) && $object->type == 3) $mask=$conf->global->SUPPLIER_DEPOSIT_TULIP_MASK; |
|
174 | - else $mask=$conf->global->SUPPLIER_INVOICE_TULIP_MASK; |
|
175 | - if (! $mask) |
|
176 | - { |
|
177 | - $this->error='NotConfigured'; |
|
178 | - return 0; |
|
179 | - } |
|
180 | - |
|
181 | - // Supplier invoices take invoice date instead of creation date for the mask |
|
182 | - $numFinal=get_next_value($db,$mask,'facture_fourn','ref','',$objsoc,$object->date); |
|
183 | - |
|
184 | - return $numFinal; |
|
185 | - } |
|
158 | + global $db,$conf; |
|
159 | + |
|
160 | + require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php'; |
|
161 | + |
|
162 | + // Get Mask value |
|
163 | + $mask = ''; |
|
164 | + if (is_object($object) && $object->type == 1) |
|
165 | + { |
|
166 | + $mask=$conf->global->SUPPLIER_REPLACEMENT_TULIP_MASK; |
|
167 | + if (! $mask) |
|
168 | + { |
|
169 | + $mask=$conf->global->SUPPLIER_INVOICE_TULIP_MASK; |
|
170 | + } |
|
171 | + } |
|
172 | + else if (is_object($object) && $object->type == 2) $mask=$conf->global->SUPPLIER_CREDIT_TULIP_MASK; |
|
173 | + else if (is_object($object) && $object->type == 3) $mask=$conf->global->SUPPLIER_DEPOSIT_TULIP_MASK; |
|
174 | + else $mask=$conf->global->SUPPLIER_INVOICE_TULIP_MASK; |
|
175 | + if (! $mask) |
|
176 | + { |
|
177 | + $this->error='NotConfigured'; |
|
178 | + return 0; |
|
179 | + } |
|
180 | + |
|
181 | + // Supplier invoices take invoice date instead of creation date for the mask |
|
182 | + $numFinal=get_next_value($db,$mask,'facture_fourn','ref','',$objsoc,$object->date); |
|
183 | + |
|
184 | + return $numFinal; |
|
185 | + } |
|
186 | 186 | |
187 | 187 | /** |
188 | - * Return next free value |
|
189 | - * |
|
188 | + * Return next free value |
|
189 | + * |
|
190 | 190 | * @param Societe $objsoc Object third party |
191 | 191 | * @param string $objforref Object for number to search |
192 | 192 | * @param string $mode 'next' for next value or 'last' for last value |
193 | 193 | * @return string Next free value |
194 | 194 | */ |
195 | - function getNumRef($objsoc,$objforref,$mode='next') |
|
196 | - { |
|
197 | - return $this->getNextValue($objsoc,$objforref,$mode); |
|
198 | - } |
|
195 | + function getNumRef($objsoc,$objforref,$mode='next') |
|
196 | + { |
|
197 | + return $this->getNextValue($objsoc,$objforref,$mode); |
|
198 | + } |
|
199 | 199 | } |
200 | 200 |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | * \brief File containing the Tulip Class of numbering models of suppliers invoices references |
28 | 28 | */ |
29 | 29 | |
30 | -require_once DOL_DOCUMENT_ROOT .'/core/modules/supplier_invoice/modules_facturefournisseur.php'; |
|
30 | +require_once DOL_DOCUMENT_ROOT.'/core/modules/supplier_invoice/modules_facturefournisseur.php'; |
|
31 | 31 | |
32 | 32 | |
33 | 33 | /** |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | * Dolibarr version of the loaded document |
41 | 41 | * @public string |
42 | 42 | */ |
43 | - public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' |
|
43 | + public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' |
|
44 | 44 | |
45 | 45 | /** |
46 | 46 | * @var string Error code (or message) |
@@ -52,12 +52,12 @@ discard block |
||
52 | 52 | * @deprecated |
53 | 53 | * @see name |
54 | 54 | */ |
55 | - public $nom='Tulip'; |
|
55 | + public $nom = 'Tulip'; |
|
56 | 56 | |
57 | 57 | /** |
58 | 58 | * @var string model name |
59 | 59 | */ |
60 | - public $name='Tulip'; |
|
60 | + public $name = 'Tulip'; |
|
61 | 61 | |
62 | 62 | |
63 | 63 | /** |
@@ -70,56 +70,56 @@ discard block |
||
70 | 70 | global $conf, $langs; |
71 | 71 | |
72 | 72 | // Load translation files required by the page |
73 | - $langs->loadLangs(array("bills","admin")); |
|
73 | + $langs->loadLangs(array("bills", "admin")); |
|
74 | 74 | |
75 | 75 | $form = new Form($this->db); |
76 | 76 | |
77 | 77 | $texte = $langs->trans('GenericNumRefModelDesc')."<br>\n"; |
78 | - $texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">'; |
|
79 | - $texte.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
80 | - $texte.= '<input type="hidden" name="action" value="updateMask">'; |
|
81 | - $texte.= '<input type="hidden" name="maskconstinvoice" value="SUPPLIER_INVOICE_TULIP_MASK">'; |
|
82 | - $texte.= '<input type="hidden" name="maskconstreplacement" value="SUPPLIER_REPLACEMENT_TULIP_MASK">'; |
|
83 | - $texte.= '<input type="hidden" name="maskconstcredit" value="SUPPLIER_CREDIT_TULIP_MASK">'; |
|
84 | - $texte.= '<input type="hidden" name="maskconstdeposit" value="SUPPLIER_DEPOSIT_TULIP_MASK">'; |
|
85 | - $texte.= '<table class="nobordernopadding" width="100%">'; |
|
86 | - |
|
87 | - $tooltip=$langs->trans("GenericMaskCodes",$langs->transnoentities("Invoice"),$langs->transnoentities("Invoice")); |
|
88 | - $tooltip.=$langs->trans("GenericMaskCodes2"); |
|
89 | - $tooltip.=$langs->trans("GenericMaskCodes3"); |
|
90 | - $tooltip.=$langs->trans("GenericMaskCodes4a",$langs->transnoentities("Invoice"),$langs->transnoentities("Invoice")); |
|
91 | - $tooltip.=$langs->trans("GenericMaskCodes5"); |
|
78 | + $texte .= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">'; |
|
79 | + $texte .= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
80 | + $texte .= '<input type="hidden" name="action" value="updateMask">'; |
|
81 | + $texte .= '<input type="hidden" name="maskconstinvoice" value="SUPPLIER_INVOICE_TULIP_MASK">'; |
|
82 | + $texte .= '<input type="hidden" name="maskconstreplacement" value="SUPPLIER_REPLACEMENT_TULIP_MASK">'; |
|
83 | + $texte .= '<input type="hidden" name="maskconstcredit" value="SUPPLIER_CREDIT_TULIP_MASK">'; |
|
84 | + $texte .= '<input type="hidden" name="maskconstdeposit" value="SUPPLIER_DEPOSIT_TULIP_MASK">'; |
|
85 | + $texte .= '<table class="nobordernopadding" width="100%">'; |
|
86 | + |
|
87 | + $tooltip = $langs->trans("GenericMaskCodes", $langs->transnoentities("Invoice"), $langs->transnoentities("Invoice")); |
|
88 | + $tooltip .= $langs->trans("GenericMaskCodes2"); |
|
89 | + $tooltip .= $langs->trans("GenericMaskCodes3"); |
|
90 | + $tooltip .= $langs->trans("GenericMaskCodes4a", $langs->transnoentities("Invoice"), $langs->transnoentities("Invoice")); |
|
91 | + $tooltip .= $langs->trans("GenericMaskCodes5"); |
|
92 | 92 | |
93 | 93 | // Parametrage du prefix |
94 | - $texte.= '<tr><td>'.$langs->trans("Mask").' ('.$langs->trans("InvoiceStandard").')'; |
|
95 | - $texte.= ':</td>'; |
|
96 | - $texte.= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="maskinvoice" value="'.$conf->global->SUPPLIER_INVOICE_TULIP_MASK.'">',$tooltip,1,1).'</td>'; |
|
94 | + $texte .= '<tr><td>'.$langs->trans("Mask").' ('.$langs->trans("InvoiceStandard").')'; |
|
95 | + $texte .= ':</td>'; |
|
96 | + $texte .= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="maskinvoice" value="'.$conf->global->SUPPLIER_INVOICE_TULIP_MASK.'">', $tooltip, 1, 1).'</td>'; |
|
97 | 97 | |
98 | - $texte.= '<td align="left" rowspan="2"> <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>'; |
|
98 | + $texte .= '<td align="left" rowspan="2"> <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>'; |
|
99 | 99 | |
100 | - $texte.= '</tr>'; |
|
100 | + $texte .= '</tr>'; |
|
101 | 101 | |
102 | 102 | // Parametrage du prefix des avoirs |
103 | - $texte.= '<tr><td>'.$langs->trans("Mask").' ('.$langs->trans("InvoiceAvoir").'):</td>'; |
|
104 | - $texte.= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="maskcredit" value="'.$conf->global->SUPPLIER_CREDIT_TULIP_MASK.'">',$tooltip,1,1).'</td>'; |
|
105 | - $texte.= '</tr>'; |
|
103 | + $texte .= '<tr><td>'.$langs->trans("Mask").' ('.$langs->trans("InvoiceAvoir").'):</td>'; |
|
104 | + $texte .= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="maskcredit" value="'.$conf->global->SUPPLIER_CREDIT_TULIP_MASK.'">', $tooltip, 1, 1).'</td>'; |
|
105 | + $texte .= '</tr>'; |
|
106 | 106 | |
107 | 107 | if ($conf->global->MAIN_FEATURE_LEVEL >= 2) |
108 | 108 | { |
109 | 109 | // Parametrage du prefix des replacement |
110 | - $texte.= '<tr><td>'.$langs->trans("Mask").' ('.$langs->trans("InvoiceReplacement").'):</td>'; |
|
111 | - $texte.= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="maskreplacement" value="'.$conf->global->SUPPLIER_REPLACEMENT_TULIP_MASK.'">',$tooltip,1,1).'</td>'; |
|
112 | - $texte.= '</tr>'; |
|
110 | + $texte .= '<tr><td>'.$langs->trans("Mask").' ('.$langs->trans("InvoiceReplacement").'):</td>'; |
|
111 | + $texte .= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="maskreplacement" value="'.$conf->global->SUPPLIER_REPLACEMENT_TULIP_MASK.'">', $tooltip, 1, 1).'</td>'; |
|
112 | + $texte .= '</tr>'; |
|
113 | 113 | |
114 | 114 | |
115 | 115 | // Parametrage du prefix des acomptes |
116 | - $texte.= '<tr><td>'.$langs->trans("Mask").' ('.$langs->trans("InvoiceDeposit").'):</td>'; |
|
117 | - $texte.= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="maskdeposit" value="'.$conf->global->SUPPLIER_DEPOSIT_TULIP_MASK.'">',$tooltip,1,1).'</td>'; |
|
118 | - $texte.= '</tr>'; |
|
116 | + $texte .= '<tr><td>'.$langs->trans("Mask").' ('.$langs->trans("InvoiceDeposit").'):</td>'; |
|
117 | + $texte .= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="maskdeposit" value="'.$conf->global->SUPPLIER_DEPOSIT_TULIP_MASK.'">', $tooltip, 1, 1).'</td>'; |
|
118 | + $texte .= '</tr>'; |
|
119 | 119 | } |
120 | 120 | |
121 | - $texte.= '</table>'; |
|
122 | - $texte.= '</form>'; |
|
121 | + $texte .= '</table>'; |
|
122 | + $texte .= '</form>'; |
|
123 | 123 | |
124 | 124 | return $texte; |
125 | 125 | } |
@@ -131,14 +131,14 @@ discard block |
||
131 | 131 | */ |
132 | 132 | function getExample() |
133 | 133 | { |
134 | - global $conf,$langs,$mysoc; |
|
134 | + global $conf, $langs, $mysoc; |
|
135 | 135 | |
136 | - $old_code_client=$mysoc->code_client; |
|
137 | - $mysoc->code_client='CCCCCCCCCC'; |
|
138 | - $numExample = $this->getNextValue($mysoc,''); |
|
139 | - $mysoc->code_client=$old_code_client; |
|
136 | + $old_code_client = $mysoc->code_client; |
|
137 | + $mysoc->code_client = 'CCCCCCCCCC'; |
|
138 | + $numExample = $this->getNextValue($mysoc, ''); |
|
139 | + $mysoc->code_client = $old_code_client; |
|
140 | 140 | |
141 | - if (! $numExample) |
|
141 | + if (!$numExample) |
|
142 | 142 | { |
143 | 143 | $numExample = $langs->trans('NotConfigured'); |
144 | 144 | } |
@@ -153,33 +153,33 @@ discard block |
||
153 | 153 | * @param string $mode 'next' for next value or 'last' for last value |
154 | 154 | * @return string Value if OK, 0 if KO |
155 | 155 | */ |
156 | - function getNextValue($objsoc,$object,$mode='next') |
|
156 | + function getNextValue($objsoc, $object, $mode = 'next') |
|
157 | 157 | { |
158 | - global $db,$conf; |
|
158 | + global $db, $conf; |
|
159 | 159 | |
160 | - require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php'; |
|
160 | + require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; |
|
161 | 161 | |
162 | 162 | // Get Mask value |
163 | 163 | $mask = ''; |
164 | 164 | if (is_object($object) && $object->type == 1) |
165 | 165 | { |
166 | - $mask=$conf->global->SUPPLIER_REPLACEMENT_TULIP_MASK; |
|
167 | - if (! $mask) |
|
166 | + $mask = $conf->global->SUPPLIER_REPLACEMENT_TULIP_MASK; |
|
167 | + if (!$mask) |
|
168 | 168 | { |
169 | - $mask=$conf->global->SUPPLIER_INVOICE_TULIP_MASK; |
|
169 | + $mask = $conf->global->SUPPLIER_INVOICE_TULIP_MASK; |
|
170 | 170 | } |
171 | 171 | } |
172 | - else if (is_object($object) && $object->type == 2) $mask=$conf->global->SUPPLIER_CREDIT_TULIP_MASK; |
|
173 | - else if (is_object($object) && $object->type == 3) $mask=$conf->global->SUPPLIER_DEPOSIT_TULIP_MASK; |
|
174 | - else $mask=$conf->global->SUPPLIER_INVOICE_TULIP_MASK; |
|
175 | - if (! $mask) |
|
172 | + else if (is_object($object) && $object->type == 2) $mask = $conf->global->SUPPLIER_CREDIT_TULIP_MASK; |
|
173 | + else if (is_object($object) && $object->type == 3) $mask = $conf->global->SUPPLIER_DEPOSIT_TULIP_MASK; |
|
174 | + else $mask = $conf->global->SUPPLIER_INVOICE_TULIP_MASK; |
|
175 | + if (!$mask) |
|
176 | 176 | { |
177 | - $this->error='NotConfigured'; |
|
177 | + $this->error = 'NotConfigured'; |
|
178 | 178 | return 0; |
179 | 179 | } |
180 | 180 | |
181 | 181 | // Supplier invoices take invoice date instead of creation date for the mask |
182 | - $numFinal=get_next_value($db,$mask,'facture_fourn','ref','',$objsoc,$object->date); |
|
182 | + $numFinal = get_next_value($db, $mask, 'facture_fourn', 'ref', '', $objsoc, $object->date); |
|
183 | 183 | |
184 | 184 | return $numFinal; |
185 | 185 | } |
@@ -192,9 +192,9 @@ discard block |
||
192 | 192 | * @param string $mode 'next' for next value or 'last' for last value |
193 | 193 | * @return string Next free value |
194 | 194 | */ |
195 | - function getNumRef($objsoc,$objforref,$mode='next') |
|
195 | + function getNumRef($objsoc, $objforref, $mode = 'next') |
|
196 | 196 | { |
197 | - return $this->getNextValue($objsoc,$objforref,$mode); |
|
197 | + return $this->getNextValue($objsoc, $objforref, $mode); |
|
198 | 198 | } |
199 | 199 | } |
200 | 200 |
@@ -168,10 +168,13 @@ |
||
168 | 168 | { |
169 | 169 | $mask=$conf->global->SUPPLIER_INVOICE_TULIP_MASK; |
170 | 170 | } |
171 | + } else if (is_object($object) && $object->type == 2) { |
|
172 | + $mask=$conf->global->SUPPLIER_CREDIT_TULIP_MASK; |
|
173 | + } else if (is_object($object) && $object->type == 3) { |
|
174 | + $mask=$conf->global->SUPPLIER_DEPOSIT_TULIP_MASK; |
|
175 | + } else { |
|
176 | + $mask=$conf->global->SUPPLIER_INVOICE_TULIP_MASK; |
|
171 | 177 | } |
172 | - else if (is_object($object) && $object->type == 2) $mask=$conf->global->SUPPLIER_CREDIT_TULIP_MASK; |
|
173 | - else if (is_object($object) && $object->type == 3) $mask=$conf->global->SUPPLIER_DEPOSIT_TULIP_MASK; |
|
174 | - else $mask=$conf->global->SUPPLIER_INVOICE_TULIP_MASK; |
|
175 | 178 | if (! $mask) |
176 | 179 | { |
177 | 180 | $this->error='NotConfigured'; |
@@ -34,33 +34,33 @@ discard block |
||
34 | 34 | */ |
35 | 35 | abstract class ModelePDFSuppliersInvoices extends CommonDocGenerator |
36 | 36 | { |
37 | - /** |
|
38 | - * @var string Error code (or message) |
|
39 | - */ |
|
40 | - public $error=''; |
|
37 | + /** |
|
38 | + * @var string Error code (or message) |
|
39 | + */ |
|
40 | + public $error=''; |
|
41 | 41 | |
42 | 42 | |
43 | 43 | // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps |
44 | - /** |
|
45 | - * Return list of active generation models |
|
46 | - * |
|
44 | + /** |
|
45 | + * Return list of active generation models |
|
46 | + * |
|
47 | 47 | * @param DoliDB $db Database handler |
48 | 48 | * @param integer $maxfilenamelength Max length of value to show |
49 | 49 | * @return array List of numbers |
50 | - */ |
|
51 | - static function liste_modeles($db, $maxfilenamelength=0) |
|
52 | - { |
|
50 | + */ |
|
51 | + static function liste_modeles($db, $maxfilenamelength=0) |
|
52 | + { |
|
53 | 53 | // phpcs:enable |
54 | - global $conf; |
|
54 | + global $conf; |
|
55 | 55 | |
56 | - $type = 'invoice_supplier'; |
|
57 | - $list = array(); |
|
56 | + $type = 'invoice_supplier'; |
|
57 | + $list = array(); |
|
58 | 58 | |
59 | - include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; |
|
60 | - $list = getListOfModels($db, $type, $maxfilenamelength); |
|
59 | + include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; |
|
60 | + $list = getListOfModels($db, $type, $maxfilenamelength); |
|
61 | 61 | |
62 | - return $list; |
|
63 | - } |
|
62 | + return $list; |
|
63 | + } |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | /** |
@@ -68,50 +68,50 @@ discard block |
||
68 | 68 | */ |
69 | 69 | abstract class ModeleNumRefSuppliersInvoices |
70 | 70 | { |
71 | - /** |
|
72 | - * @var string Error code (or message) |
|
73 | - */ |
|
74 | - public $error=''; |
|
75 | - |
|
76 | - /** Return if a model can be used or not |
|
77 | - * |
|
78 | - * @return boolean true if model can be used |
|
79 | - */ |
|
80 | - function isEnabled() |
|
81 | - { |
|
82 | - return true; |
|
83 | - } |
|
84 | - |
|
85 | - /** Returns the default description of the model numbering |
|
86 | - * |
|
87 | - * @return string Description Text |
|
88 | - */ |
|
89 | - function info() |
|
90 | - { |
|
91 | - global $langs; |
|
92 | - $langs->load("invoices"); |
|
93 | - return $langs->trans("NoDescription"); |
|
94 | - } |
|
95 | - |
|
96 | - /** Returns a numbering example |
|
97 | - * |
|
98 | - * @return string Example |
|
99 | - */ |
|
100 | - function getExample() |
|
101 | - { |
|
102 | - global $langs; |
|
103 | - $langs->load("invoices"); |
|
104 | - return $langs->trans("NoExample"); |
|
105 | - } |
|
106 | - |
|
107 | - /** Tests if the numbers already in force in the database do not cause conflicts that would prevent this numbering. |
|
108 | - * |
|
109 | - * @return boolean false if conflict, true if ok |
|
110 | - */ |
|
111 | - function canBeActivated() |
|
112 | - { |
|
113 | - return true; |
|
114 | - } |
|
71 | + /** |
|
72 | + * @var string Error code (or message) |
|
73 | + */ |
|
74 | + public $error=''; |
|
75 | + |
|
76 | + /** Return if a model can be used or not |
|
77 | + * |
|
78 | + * @return boolean true if model can be used |
|
79 | + */ |
|
80 | + function isEnabled() |
|
81 | + { |
|
82 | + return true; |
|
83 | + } |
|
84 | + |
|
85 | + /** Returns the default description of the model numbering |
|
86 | + * |
|
87 | + * @return string Description Text |
|
88 | + */ |
|
89 | + function info() |
|
90 | + { |
|
91 | + global $langs; |
|
92 | + $langs->load("invoices"); |
|
93 | + return $langs->trans("NoDescription"); |
|
94 | + } |
|
95 | + |
|
96 | + /** Returns a numbering example |
|
97 | + * |
|
98 | + * @return string Example |
|
99 | + */ |
|
100 | + function getExample() |
|
101 | + { |
|
102 | + global $langs; |
|
103 | + $langs->load("invoices"); |
|
104 | + return $langs->trans("NoExample"); |
|
105 | + } |
|
106 | + |
|
107 | + /** Tests if the numbers already in force in the database do not cause conflicts that would prevent this numbering. |
|
108 | + * |
|
109 | + * @return boolean false if conflict, true if ok |
|
110 | + */ |
|
111 | + function canBeActivated() |
|
112 | + { |
|
113 | + return true; |
|
114 | + } |
|
115 | 115 | |
116 | 116 | /** Returns next value assigned |
117 | 117 | * |
@@ -121,24 +121,24 @@ discard block |
||
121 | 121 | * @return string Value if OK, 0 if KO |
122 | 122 | */ |
123 | 123 | function getNextValue($objsoc,$object,$mode) |
124 | - { |
|
125 | - global $langs; |
|
126 | - return $langs->trans("NotAvailable"); |
|
127 | - } |
|
128 | - |
|
129 | - /** Returns version of the model numbering |
|
130 | - * |
|
131 | - * @return string Value |
|
132 | - */ |
|
133 | - function getVersion() |
|
134 | - { |
|
135 | - global $langs; |
|
136 | - $langs->load("admin"); |
|
137 | - |
|
138 | - if ($this->version == 'development') return $langs->trans("VersionDevelopment"); |
|
139 | - if ($this->version == 'experimental') return $langs->trans("VersionExperimental"); |
|
140 | - if ($this->version == 'dolibarr') return DOL_VERSION; |
|
141 | - if ($this->version) return $this->version; |
|
142 | - return $langs->trans("NotAvailable"); |
|
143 | - } |
|
124 | + { |
|
125 | + global $langs; |
|
126 | + return $langs->trans("NotAvailable"); |
|
127 | + } |
|
128 | + |
|
129 | + /** Returns version of the model numbering |
|
130 | + * |
|
131 | + * @return string Value |
|
132 | + */ |
|
133 | + function getVersion() |
|
134 | + { |
|
135 | + global $langs; |
|
136 | + $langs->load("admin"); |
|
137 | + |
|
138 | + if ($this->version == 'development') return $langs->trans("VersionDevelopment"); |
|
139 | + if ($this->version == 'experimental') return $langs->trans("VersionExperimental"); |
|
140 | + if ($this->version == 'dolibarr') return DOL_VERSION; |
|
141 | + if ($this->version) return $this->version; |
|
142 | + return $langs->trans("NotAvailable"); |
|
143 | + } |
|
144 | 144 | } |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | * and parent class for supplier invoices numbering models |
27 | 27 | */ |
28 | 28 | require_once DOL_DOCUMENT_ROOT.'/core/class/commondocgenerator.class.php'; |
29 | -require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; // required for use by classes that inherit |
|
29 | +require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; // required for use by classes that inherit |
|
30 | 30 | |
31 | 31 | |
32 | 32 | /** |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | /** |
38 | 38 | * @var string Error code (or message) |
39 | 39 | */ |
40 | - public $error=''; |
|
40 | + public $error = ''; |
|
41 | 41 | |
42 | 42 | |
43 | 43 | // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | * @param integer $maxfilenamelength Max length of value to show |
49 | 49 | * @return array List of numbers |
50 | 50 | */ |
51 | - static function liste_modeles($db, $maxfilenamelength=0) |
|
51 | + static function liste_modeles($db, $maxfilenamelength = 0) |
|
52 | 52 | { |
53 | 53 | // phpcs:enable |
54 | 54 | global $conf; |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | /** |
72 | 72 | * @var string Error code (or message) |
73 | 73 | */ |
74 | - public $error=''; |
|
74 | + public $error = ''; |
|
75 | 75 | |
76 | 76 | /** Return if a model can be used or not |
77 | 77 | * |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | * @param string $mode 'next' for next value or 'last' for last value |
121 | 121 | * @return string Value if OK, 0 if KO |
122 | 122 | */ |
123 | - function getNextValue($objsoc,$object,$mode) |
|
123 | + function getNextValue($objsoc, $object, $mode) |
|
124 | 124 | { |
125 | 125 | global $langs; |
126 | 126 | return $langs->trans("NotAvailable"); |
@@ -142,10 +142,18 @@ |
||
142 | 142 | global $langs; |
143 | 143 | $langs->load("admin"); |
144 | 144 | |
145 | - if ($this->version == 'development') return $langs->trans("VersionDevelopment"); |
|
146 | - if ($this->version == 'experimental') return $langs->trans("VersionExperimental"); |
|
147 | - if ($this->version == 'dolibarr') return DOL_VERSION; |
|
148 | - if ($this->version) return $this->version; |
|
145 | + if ($this->version == 'development') { |
|
146 | + return $langs->trans("VersionDevelopment"); |
|
147 | + } |
|
148 | + if ($this->version == 'experimental') { |
|
149 | + return $langs->trans("VersionExperimental"); |
|
150 | + } |
|
151 | + if ($this->version == 'dolibarr') { |
|
152 | + return DOL_VERSION; |
|
153 | + } |
|
154 | + if ($this->version) { |
|
155 | + return $this->version; |
|
156 | + } |
|
149 | 157 | return $langs->trans("NotAvailable"); |
150 | 158 | } |
151 | 159 | } |