@@ -34,29 +34,29 @@ discard block |
||
34 | 34 | */ |
35 | 35 | function expedition_prepare_head(Expedition $object) |
36 | 36 | { |
37 | - global $langs, $conf, $user; |
|
38 | - if (! empty($conf->expedition->enabled)) $langs->load("sendings"); |
|
39 | - $langs->load("orders"); |
|
37 | + global $langs, $conf, $user; |
|
38 | + if (! empty($conf->expedition->enabled)) $langs->load("sendings"); |
|
39 | + $langs->load("orders"); |
|
40 | 40 | |
41 | - $h = 0; |
|
42 | - $head = array(); |
|
43 | - $h = 0; |
|
44 | - |
|
45 | - $head[$h][0] = DOL_URL_ROOT."/admin/confexped.php"; |
|
46 | - $head[$h][1] = $langs->trans("Setup"); |
|
47 | - $h++; |
|
48 | - |
|
49 | - $head[$h][0] = DOL_URL_ROOT."/admin/expedition.php"; |
|
50 | - $head[$h][1] = $langs->trans("Shipment"); |
|
51 | - $hselected=$h; |
|
52 | - $h++; |
|
53 | - |
|
54 | - if (! empty($conf->global->MAIN_SUBMODULE_LIVRAISON)) |
|
55 | - { |
|
56 | - $head[$h][0] = DOL_URL_ROOT."/admin/livraison.php"; |
|
57 | - $head[$h][1] = $langs->trans("Receivings"); |
|
58 | - $h++; |
|
59 | - } |
|
41 | + $h = 0; |
|
42 | + $head = array(); |
|
43 | + $h = 0; |
|
44 | + |
|
45 | + $head[$h][0] = DOL_URL_ROOT."/admin/confexped.php"; |
|
46 | + $head[$h][1] = $langs->trans("Setup"); |
|
47 | + $h++; |
|
48 | + |
|
49 | + $head[$h][0] = DOL_URL_ROOT."/admin/expedition.php"; |
|
50 | + $head[$h][1] = $langs->trans("Shipment"); |
|
51 | + $hselected=$h; |
|
52 | + $h++; |
|
53 | + |
|
54 | + if (! empty($conf->global->MAIN_SUBMODULE_LIVRAISON)) |
|
55 | + { |
|
56 | + $head[$h][0] = DOL_URL_ROOT."/admin/livraison.php"; |
|
57 | + $head[$h][1] = $langs->trans("Receivings"); |
|
58 | + $h++; |
|
59 | + } |
|
60 | 60 | |
61 | 61 | |
62 | 62 | complete_head_from_modules($conf,$langs,$object,$head,$h,'order','remove'); |
@@ -71,72 +71,72 @@ discard block |
||
71 | 71 | */ |
72 | 72 | function expedition_admin_prepare_head() |
73 | 73 | { |
74 | - global $langs, $conf, $user; |
|
75 | - $langs->load("sendings"); |
|
74 | + global $langs, $conf, $user; |
|
75 | + $langs->load("sendings"); |
|
76 | 76 | |
77 | - $h = 0; |
|
78 | - $head = array(); |
|
79 | - |
|
80 | - $head[$h][0] = DOL_URL_ROOT."/admin/confexped.php"; |
|
81 | - $head[$h][1] = $langs->trans("Setup"); |
|
82 | - $head[$h][2] = 'general'; |
|
83 | - $h++; |
|
84 | - |
|
85 | - |
|
86 | - if (! empty($conf->global->MAIN_SUBMODULE_EXPEDITION)) |
|
87 | - { |
|
88 | - $head[$h][0] = DOL_URL_ROOT."/admin/expedition.php"; |
|
89 | - $head[$h][1] = $langs->trans("Shipment"); |
|
90 | - $head[$h][2] = 'shipment'; |
|
91 | - $h++; |
|
92 | - } |
|
93 | - |
|
94 | - |
|
95 | - if (! empty($conf->global->MAIN_SUBMODULE_EXPEDITION)) |
|
96 | - { |
|
97 | - $head[$h][0] = DOL_URL_ROOT.'/admin/expedition_extrafields.php'; |
|
98 | - $head[$h][1] = $langs->trans("ExtraFields"); |
|
99 | - $head[$h][2] = 'attributes_shipment'; |
|
100 | - $h++; |
|
101 | - } |
|
102 | - |
|
103 | - if (! empty($conf->global->MAIN_SUBMODULE_EXPEDITION)) |
|
104 | - { |
|
105 | - $head[$h][0] = DOL_URL_ROOT.'/admin/expeditiondet_extrafields.php'; |
|
106 | - $head[$h][1] = $langs->trans("ExtraFieldsLines"); |
|
107 | - $head[$h][2] = 'attributeslines_shipment'; |
|
108 | - $h++; |
|
109 | - } |
|
110 | - |
|
111 | - if (! empty($conf->global->MAIN_SUBMODULE_LIVRAISON)) |
|
112 | - { |
|
113 | - $head[$h][0] = DOL_URL_ROOT."/admin/livraison.php"; |
|
114 | - $head[$h][1] = $langs->trans("Receivings"); |
|
115 | - $head[$h][2] = 'receivings'; |
|
116 | - $h++; |
|
117 | - } |
|
118 | - |
|
119 | - if (! empty($conf->global->MAIN_SUBMODULE_LIVRAISON)) |
|
120 | - { |
|
121 | - $head[$h][0] = DOL_URL_ROOT.'/admin/livraison_extrafields.php'; |
|
122 | - $head[$h][1] = $langs->trans("ExtraFields"); |
|
123 | - $head[$h][2] = 'attributes_receivings'; |
|
124 | - $h++; |
|
125 | - } |
|
126 | - |
|
127 | - if (! empty($conf->global->MAIN_SUBMODULE_LIVRAISON)) |
|
128 | - { |
|
129 | - $head[$h][0] = DOL_URL_ROOT.'/admin/livraisondet_extrafields.php'; |
|
130 | - $head[$h][1] = $langs->trans("ExtraFieldsLines"); |
|
131 | - $head[$h][2] = 'attributeslines_receivings'; |
|
132 | - $h++; |
|
133 | - } |
|
134 | - |
|
135 | - |
|
136 | - |
|
137 | - complete_head_from_modules($conf,$langs,null,$head,$h,'expedition_admin','remove'); |
|
77 | + $h = 0; |
|
78 | + $head = array(); |
|
79 | + |
|
80 | + $head[$h][0] = DOL_URL_ROOT."/admin/confexped.php"; |
|
81 | + $head[$h][1] = $langs->trans("Setup"); |
|
82 | + $head[$h][2] = 'general'; |
|
83 | + $h++; |
|
84 | + |
|
85 | + |
|
86 | + if (! empty($conf->global->MAIN_SUBMODULE_EXPEDITION)) |
|
87 | + { |
|
88 | + $head[$h][0] = DOL_URL_ROOT."/admin/expedition.php"; |
|
89 | + $head[$h][1] = $langs->trans("Shipment"); |
|
90 | + $head[$h][2] = 'shipment'; |
|
91 | + $h++; |
|
92 | + } |
|
93 | + |
|
94 | + |
|
95 | + if (! empty($conf->global->MAIN_SUBMODULE_EXPEDITION)) |
|
96 | + { |
|
97 | + $head[$h][0] = DOL_URL_ROOT.'/admin/expedition_extrafields.php'; |
|
98 | + $head[$h][1] = $langs->trans("ExtraFields"); |
|
99 | + $head[$h][2] = 'attributes_shipment'; |
|
100 | + $h++; |
|
101 | + } |
|
102 | + |
|
103 | + if (! empty($conf->global->MAIN_SUBMODULE_EXPEDITION)) |
|
104 | + { |
|
105 | + $head[$h][0] = DOL_URL_ROOT.'/admin/expeditiondet_extrafields.php'; |
|
106 | + $head[$h][1] = $langs->trans("ExtraFieldsLines"); |
|
107 | + $head[$h][2] = 'attributeslines_shipment'; |
|
108 | + $h++; |
|
109 | + } |
|
110 | + |
|
111 | + if (! empty($conf->global->MAIN_SUBMODULE_LIVRAISON)) |
|
112 | + { |
|
113 | + $head[$h][0] = DOL_URL_ROOT."/admin/livraison.php"; |
|
114 | + $head[$h][1] = $langs->trans("Receivings"); |
|
115 | + $head[$h][2] = 'receivings'; |
|
116 | + $h++; |
|
117 | + } |
|
118 | + |
|
119 | + if (! empty($conf->global->MAIN_SUBMODULE_LIVRAISON)) |
|
120 | + { |
|
121 | + $head[$h][0] = DOL_URL_ROOT.'/admin/livraison_extrafields.php'; |
|
122 | + $head[$h][1] = $langs->trans("ExtraFields"); |
|
123 | + $head[$h][2] = 'attributes_receivings'; |
|
124 | + $h++; |
|
125 | + } |
|
126 | + |
|
127 | + if (! empty($conf->global->MAIN_SUBMODULE_LIVRAISON)) |
|
128 | + { |
|
129 | + $head[$h][0] = DOL_URL_ROOT.'/admin/livraisondet_extrafields.php'; |
|
130 | + $head[$h][1] = $langs->trans("ExtraFieldsLines"); |
|
131 | + $head[$h][2] = 'attributeslines_receivings'; |
|
132 | + $h++; |
|
133 | + } |
|
134 | + |
|
135 | + |
|
136 | + |
|
137 | + complete_head_from_modules($conf,$langs,null,$head,$h,'expedition_admin','remove'); |
|
138 | 138 | |
139 | - return $head; |
|
139 | + return $head; |
|
140 | 140 | } |
141 | 141 | |
142 | 142 |
@@ -33,25 +33,25 @@ discard block |
||
33 | 33 | */ |
34 | 34 | function facturefourn_prepare_head($object) |
35 | 35 | { |
36 | - global $db, $langs, $conf; |
|
37 | - |
|
38 | - $h = 0; |
|
39 | - $head = array(); |
|
40 | - |
|
41 | - $head[$h][0] = DOL_URL_ROOT.'/fourn/facture/card.php?facid='.$object->id; |
|
42 | - $head[$h][1] = $langs->trans('Card'); |
|
43 | - $head[$h][2] = 'card'; |
|
44 | - $h++; |
|
45 | - |
|
46 | - if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) |
|
47 | - { |
|
48 | - $nbContact = count($object->liste_contact(-1,'internal')) + count($object->liste_contact(-1,'external')); |
|
49 | - $head[$h][0] = DOL_URL_ROOT.'/fourn/facture/contact.php?facid='.$object->id; |
|
50 | - $head[$h][1] = $langs->trans('ContactsAddresses'); |
|
51 | - if ($nbContact > 0) $head[$h][1].= ' <span class="badge">'.$nbContact.'</span>'; |
|
52 | - $head[$h][2] = 'contact'; |
|
53 | - $h++; |
|
54 | - } |
|
36 | + global $db, $langs, $conf; |
|
37 | + |
|
38 | + $h = 0; |
|
39 | + $head = array(); |
|
40 | + |
|
41 | + $head[$h][0] = DOL_URL_ROOT.'/fourn/facture/card.php?facid='.$object->id; |
|
42 | + $head[$h][1] = $langs->trans('Card'); |
|
43 | + $head[$h][2] = 'card'; |
|
44 | + $h++; |
|
45 | + |
|
46 | + if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) |
|
47 | + { |
|
48 | + $nbContact = count($object->liste_contact(-1,'internal')) + count($object->liste_contact(-1,'external')); |
|
49 | + $head[$h][0] = DOL_URL_ROOT.'/fourn/facture/contact.php?facid='.$object->id; |
|
50 | + $head[$h][1] = $langs->trans('ContactsAddresses'); |
|
51 | + if ($nbContact > 0) $head[$h][1].= ' <span class="badge">'.$nbContact.'</span>'; |
|
52 | + $head[$h][2] = 'contact'; |
|
53 | + $h++; |
|
54 | + } |
|
55 | 55 | |
56 | 56 | // Show more tabs from modules |
57 | 57 | // Entries must be declared in modules descriptor with line |
@@ -61,31 +61,31 @@ discard block |
||
61 | 61 | |
62 | 62 | if (empty($conf->global->MAIN_DISABLE_NOTES_TAB)) |
63 | 63 | { |
64 | - $nbNote = 0; |
|
64 | + $nbNote = 0; |
|
65 | 65 | if(!empty($object->note_private)) $nbNote++; |
66 | - if(!empty($object->note_public)) $nbNote++; |
|
67 | - $head[$h][0] = DOL_URL_ROOT.'/fourn/facture/note.php?facid='.$object->id; |
|
68 | - $head[$h][1] = $langs->trans('Notes'); |
|
69 | - if ($nbNote > 0) $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>'; |
|
70 | - $head[$h][2] = 'note'; |
|
71 | - $h++; |
|
66 | + if(!empty($object->note_public)) $nbNote++; |
|
67 | + $head[$h][0] = DOL_URL_ROOT.'/fourn/facture/note.php?facid='.$object->id; |
|
68 | + $head[$h][1] = $langs->trans('Notes'); |
|
69 | + if ($nbNote > 0) $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>'; |
|
70 | + $head[$h][2] = 'note'; |
|
71 | + $h++; |
|
72 | 72 | } |
73 | 73 | |
74 | - require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; |
|
74 | + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; |
|
75 | 75 | require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php'; |
76 | - $upload_dir = $conf->fournisseur->facture->dir_output.'/'.get_exdir($object->id,2,0,0,$object,'invoice_supplier').$object->ref; |
|
77 | - $nbFiles = count(dol_dir_list($upload_dir,'files',0,'','(\.meta|_preview.*\.png)$')); |
|
76 | + $upload_dir = $conf->fournisseur->facture->dir_output.'/'.get_exdir($object->id,2,0,0,$object,'invoice_supplier').$object->ref; |
|
77 | + $nbFiles = count(dol_dir_list($upload_dir,'files',0,'','(\.meta|_preview.*\.png)$')); |
|
78 | 78 | $nbLinks=Link::count($db, $object->element, $object->id); |
79 | - $head[$h][0] = DOL_URL_ROOT.'/fourn/facture/document.php?facid='.$object->id; |
|
80 | - $head[$h][1] = $langs->trans('Documents'); |
|
81 | - if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>'; |
|
82 | - $head[$h][2] = 'documents'; |
|
83 | - $h++; |
|
79 | + $head[$h][0] = DOL_URL_ROOT.'/fourn/facture/document.php?facid='.$object->id; |
|
80 | + $head[$h][1] = $langs->trans('Documents'); |
|
81 | + if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>'; |
|
82 | + $head[$h][2] = 'documents'; |
|
83 | + $h++; |
|
84 | 84 | |
85 | - $head[$h][0] = DOL_URL_ROOT.'/fourn/facture/info.php?facid='.$object->id; |
|
86 | - $head[$h][1] = $langs->trans('Info'); |
|
87 | - $head[$h][2] = 'info'; |
|
88 | - $h++; |
|
85 | + $head[$h][0] = DOL_URL_ROOT.'/fourn/facture/info.php?facid='.$object->id; |
|
86 | + $head[$h][1] = $langs->trans('Info'); |
|
87 | + $head[$h][2] = 'info'; |
|
88 | + $h++; |
|
89 | 89 | |
90 | 90 | complete_head_from_modules($conf,$langs,$object,$head,$h,'supplier_invoice','remove'); |
91 | 91 | |
@@ -101,36 +101,36 @@ discard block |
||
101 | 101 | */ |
102 | 102 | function ordersupplier_prepare_head($object) |
103 | 103 | { |
104 | - global $db, $langs, $conf, $user; |
|
105 | - |
|
106 | - $h = 0; |
|
107 | - $head = array(); |
|
108 | - |
|
109 | - $head[$h][0] = DOL_URL_ROOT.'/fourn/commande/card.php?id='.$object->id; |
|
110 | - $head[$h][1] = $langs->trans("OrderCard"); |
|
111 | - $head[$h][2] = 'card'; |
|
112 | - $h++; |
|
113 | - |
|
114 | - if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) |
|
115 | - { |
|
116 | - $nbContact = count($object->liste_contact(-1,'internal')) + count($object->liste_contact(-1,'external')); |
|
117 | - $head[$h][0] = DOL_URL_ROOT.'/fourn/commande/contact.php?id='.$object->id; |
|
118 | - $head[$h][1] = $langs->trans('ContactsAddresses'); |
|
119 | - if ($nbContact > 0) $head[$h][1].= ' <span class="badge">'.$nbContact.'</span>'; |
|
120 | - $head[$h][2] = 'contact'; |
|
121 | - $h++; |
|
122 | - } |
|
123 | - |
|
124 | - if (! empty($conf->stock->enabled) && (! empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER) || !empty($conf->global->STOCK_CALCULATE_ON_RECEPTION) || !empty($conf->global->STOCK_CALCULATE_ON_RECEPTION_CLOSE))) |
|
125 | - { |
|
126 | - $langs->load("stocks"); |
|
127 | - $head[$h][0] = DOL_URL_ROOT.'/fourn/commande/dispatch.php?id='.$object->id; |
|
128 | - $head[$h][1] = $langs->trans("OrderDispatch"); |
|
129 | - $head[$h][2] = 'dispatch'; |
|
130 | - $h++; |
|
131 | - } |
|
132 | - |
|
133 | - // Show more tabs from modules |
|
104 | + global $db, $langs, $conf, $user; |
|
105 | + |
|
106 | + $h = 0; |
|
107 | + $head = array(); |
|
108 | + |
|
109 | + $head[$h][0] = DOL_URL_ROOT.'/fourn/commande/card.php?id='.$object->id; |
|
110 | + $head[$h][1] = $langs->trans("OrderCard"); |
|
111 | + $head[$h][2] = 'card'; |
|
112 | + $h++; |
|
113 | + |
|
114 | + if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) |
|
115 | + { |
|
116 | + $nbContact = count($object->liste_contact(-1,'internal')) + count($object->liste_contact(-1,'external')); |
|
117 | + $head[$h][0] = DOL_URL_ROOT.'/fourn/commande/contact.php?id='.$object->id; |
|
118 | + $head[$h][1] = $langs->trans('ContactsAddresses'); |
|
119 | + if ($nbContact > 0) $head[$h][1].= ' <span class="badge">'.$nbContact.'</span>'; |
|
120 | + $head[$h][2] = 'contact'; |
|
121 | + $h++; |
|
122 | + } |
|
123 | + |
|
124 | + if (! empty($conf->stock->enabled) && (! empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER) || !empty($conf->global->STOCK_CALCULATE_ON_RECEPTION) || !empty($conf->global->STOCK_CALCULATE_ON_RECEPTION_CLOSE))) |
|
125 | + { |
|
126 | + $langs->load("stocks"); |
|
127 | + $head[$h][0] = DOL_URL_ROOT.'/fourn/commande/dispatch.php?id='.$object->id; |
|
128 | + $head[$h][1] = $langs->trans("OrderDispatch"); |
|
129 | + $head[$h][2] = 'dispatch'; |
|
130 | + $h++; |
|
131 | + } |
|
132 | + |
|
133 | + // Show more tabs from modules |
|
134 | 134 | // Entries must be declared in modules descriptor with line |
135 | 135 | // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab |
136 | 136 | // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab |
@@ -138,38 +138,38 @@ discard block |
||
138 | 138 | |
139 | 139 | if (empty($conf->global->MAIN_DISABLE_NOTES_TAB)) |
140 | 140 | { |
141 | - $nbNote = 0; |
|
141 | + $nbNote = 0; |
|
142 | 142 | if(!empty($object->note_private)) $nbNote++; |
143 | - if(!empty($object->note_public)) $nbNote++; |
|
144 | - $head[$h][0] = DOL_URL_ROOT.'/fourn/commande/note.php?id='.$object->id; |
|
145 | - $head[$h][1] = $langs->trans("Notes"); |
|
146 | - if ($nbNote > 0) $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>'; |
|
147 | - $head[$h][2] = 'note'; |
|
148 | - $h++; |
|
143 | + if(!empty($object->note_public)) $nbNote++; |
|
144 | + $head[$h][0] = DOL_URL_ROOT.'/fourn/commande/note.php?id='.$object->id; |
|
145 | + $head[$h][1] = $langs->trans("Notes"); |
|
146 | + if ($nbNote > 0) $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>'; |
|
147 | + $head[$h][2] = 'note'; |
|
148 | + $h++; |
|
149 | 149 | } |
150 | 150 | |
151 | - require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; |
|
151 | + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; |
|
152 | 152 | require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php'; |
153 | - $upload_dir = $conf->fournisseur->dir_output . "/commande/" . dol_sanitizeFileName($object->ref); |
|
154 | - $nbFiles = count(dol_dir_list($upload_dir,'files',0,'','(\.meta|_preview.*\.png)$')); |
|
153 | + $upload_dir = $conf->fournisseur->dir_output . "/commande/" . dol_sanitizeFileName($object->ref); |
|
154 | + $nbFiles = count(dol_dir_list($upload_dir,'files',0,'','(\.meta|_preview.*\.png)$')); |
|
155 | 155 | $nbLinks=Link::count($db, $object->element, $object->id); |
156 | - $head[$h][0] = DOL_URL_ROOT.'/fourn/commande/document.php?id='.$object->id; |
|
157 | - $head[$h][1] = $langs->trans('Documents'); |
|
158 | - if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>'; |
|
159 | - $head[$h][2] = 'documents'; |
|
160 | - $h++; |
|
161 | - |
|
162 | - $head[$h][0] = DOL_URL_ROOT.'/fourn/commande/info.php?id='.$object->id; |
|
163 | - $head[$h][1].= $langs->trans("Events"); |
|
164 | - if (! empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read) )) |
|
165 | - { |
|
166 | - $head[$h][1].= '/'; |
|
167 | - $head[$h][1].= $langs->trans("Agenda"); |
|
168 | - } |
|
169 | - $head[$h][2] = 'info'; |
|
170 | - $h++; |
|
171 | - complete_head_from_modules($conf,$langs,$object,$head,$h,'supplier_order', 'remove'); |
|
172 | - return $head; |
|
156 | + $head[$h][0] = DOL_URL_ROOT.'/fourn/commande/document.php?id='.$object->id; |
|
157 | + $head[$h][1] = $langs->trans('Documents'); |
|
158 | + if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>'; |
|
159 | + $head[$h][2] = 'documents'; |
|
160 | + $h++; |
|
161 | + |
|
162 | + $head[$h][0] = DOL_URL_ROOT.'/fourn/commande/info.php?id='.$object->id; |
|
163 | + $head[$h][1].= $langs->trans("Events"); |
|
164 | + if (! empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read) )) |
|
165 | + { |
|
166 | + $head[$h][1].= '/'; |
|
167 | + $head[$h][1].= $langs->trans("Agenda"); |
|
168 | + } |
|
169 | + $head[$h][2] = 'info'; |
|
170 | + $h++; |
|
171 | + complete_head_from_modules($conf,$langs,$object,$head,$h,'supplier_order', 'remove'); |
|
172 | + return $head; |
|
173 | 173 | } |
174 | 174 | |
175 | 175 | /** |
@@ -179,53 +179,53 @@ discard block |
||
179 | 179 | */ |
180 | 180 | function supplierorder_admin_prepare_head() |
181 | 181 | { |
182 | - global $langs, $conf, $user; |
|
182 | + global $langs, $conf, $user; |
|
183 | 183 | |
184 | - $h = 0; |
|
185 | - $head = array(); |
|
184 | + $h = 0; |
|
185 | + $head = array(); |
|
186 | 186 | |
187 | - $head[$h][0] = DOL_URL_ROOT."/admin/supplier_order.php"; |
|
188 | - $head[$h][1] = $langs->trans("SupplierOrder"); |
|
189 | - $head[$h][2] = 'order'; |
|
190 | - $h++; |
|
187 | + $head[$h][0] = DOL_URL_ROOT."/admin/supplier_order.php"; |
|
188 | + $head[$h][1] = $langs->trans("SupplierOrder"); |
|
189 | + $head[$h][2] = 'order'; |
|
190 | + $h++; |
|
191 | 191 | |
192 | - $head[$h][0] = DOL_URL_ROOT."/admin/supplier_invoice.php"; |
|
193 | - $head[$h][1] = $langs->trans("SuppliersInvoice"); |
|
194 | - $head[$h][2] = 'invoice'; |
|
195 | - $h++; |
|
192 | + $head[$h][0] = DOL_URL_ROOT."/admin/supplier_invoice.php"; |
|
193 | + $head[$h][1] = $langs->trans("SuppliersInvoice"); |
|
194 | + $head[$h][2] = 'invoice'; |
|
195 | + $h++; |
|
196 | 196 | |
197 | - $head[$h][0] = DOL_URL_ROOT."/admin/supplier_payment.php"; |
|
198 | - $head[$h][1] = $langs->trans("SuppliersPayment"); |
|
199 | - $head[$h][2] = 'supplierpayment'; |
|
200 | - $h++; |
|
197 | + $head[$h][0] = DOL_URL_ROOT."/admin/supplier_payment.php"; |
|
198 | + $head[$h][1] = $langs->trans("SuppliersPayment"); |
|
199 | + $head[$h][2] = 'supplierpayment'; |
|
200 | + $h++; |
|
201 | 201 | |
202 | - complete_head_from_modules($conf,$langs,null,$head,$h,'supplierorder_admin'); |
|
202 | + complete_head_from_modules($conf,$langs,null,$head,$h,'supplierorder_admin'); |
|
203 | 203 | |
204 | - $head[$h][0] = DOL_URL_ROOT.'/admin/supplierorder_extrafields.php'; |
|
205 | - $head[$h][1] = $langs->trans("ExtraFieldsSupplierOrders"); |
|
206 | - $head[$h][2] = 'supplierorder'; |
|
207 | - $h++; |
|
204 | + $head[$h][0] = DOL_URL_ROOT.'/admin/supplierorder_extrafields.php'; |
|
205 | + $head[$h][1] = $langs->trans("ExtraFieldsSupplierOrders"); |
|
206 | + $head[$h][2] = 'supplierorder'; |
|
207 | + $h++; |
|
208 | 208 | |
209 | - $head[$h][0] = DOL_URL_ROOT.'/admin/supplierorderdet_extrafields.php'; |
|
210 | - $head[$h][1] = $langs->trans("ExtraFieldsSupplierOrdersLines"); |
|
211 | - $head[$h][2] = 'supplierorderdet'; |
|
212 | - $h++; |
|
209 | + $head[$h][0] = DOL_URL_ROOT.'/admin/supplierorderdet_extrafields.php'; |
|
210 | + $head[$h][1] = $langs->trans("ExtraFieldsSupplierOrdersLines"); |
|
211 | + $head[$h][2] = 'supplierorderdet'; |
|
212 | + $h++; |
|
213 | 213 | |
214 | 214 | |
215 | 215 | |
216 | - $head[$h][0] = DOL_URL_ROOT.'/admin/supplierinvoice_extrafields.php'; |
|
217 | - $head[$h][1] = $langs->trans("ExtraFieldsSupplierInvoices"); |
|
218 | - $head[$h][2] = 'supplierinvoice'; |
|
219 | - $h++; |
|
216 | + $head[$h][0] = DOL_URL_ROOT.'/admin/supplierinvoice_extrafields.php'; |
|
217 | + $head[$h][1] = $langs->trans("ExtraFieldsSupplierInvoices"); |
|
218 | + $head[$h][2] = 'supplierinvoice'; |
|
219 | + $h++; |
|
220 | 220 | |
221 | - $head[$h][0] = DOL_URL_ROOT.'/admin/supplierinvoicedet_extrafields.php'; |
|
222 | - $head[$h][1] = $langs->trans("ExtraFieldsSupplierInvoicesLines"); |
|
223 | - $head[$h][2] = 'supplierinvoicedet'; |
|
224 | - $h++; |
|
221 | + $head[$h][0] = DOL_URL_ROOT.'/admin/supplierinvoicedet_extrafields.php'; |
|
222 | + $head[$h][1] = $langs->trans("ExtraFieldsSupplierInvoicesLines"); |
|
223 | + $head[$h][2] = 'supplierinvoicedet'; |
|
224 | + $h++; |
|
225 | 225 | |
226 | - complete_head_from_modules($conf,$langs,null,$head,$h,'supplierorder_admin','remove'); |
|
226 | + complete_head_from_modules($conf,$langs,null,$head,$h,'supplierorder_admin','remove'); |
|
227 | 227 | |
228 | - return $head; |
|
228 | + return $head; |
|
229 | 229 | } |
230 | 230 | |
231 | 231 |
@@ -41,34 +41,34 @@ discard block |
||
41 | 41 | */ |
42 | 42 | function pdf_getFormat(Translate $outputlangs = null) |
43 | 43 | { |
44 | - global $conf,$db; |
|
45 | - |
|
46 | - // Default value if setup was not done and/or entry into c_paper_format not defined |
|
47 | - $width=210; $height=297; $unit='mm'; |
|
48 | - |
|
49 | - if (empty($conf->global->MAIN_PDF_FORMAT)) |
|
50 | - { |
|
51 | - include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; |
|
52 | - $pdfformat=dol_getDefaultFormat($outputlangs); |
|
53 | - } |
|
54 | - else $pdfformat=$conf->global->MAIN_PDF_FORMAT; |
|
55 | - |
|
56 | - $sql="SELECT code, label, width, height, unit FROM ".MAIN_DB_PREFIX."c_paper_format"; |
|
57 | - $sql.=" WHERE code = '".$pdfformat."'"; |
|
58 | - $resql=$db->query($sql); |
|
59 | - if ($resql) |
|
60 | - { |
|
61 | - $obj=$db->fetch_object($resql); |
|
62 | - if ($obj) |
|
63 | - { |
|
64 | - $width=(int) $obj->width; |
|
65 | - $height=(int) $obj->height; |
|
66 | - $unit=$obj->unit; |
|
67 | - } |
|
68 | - } |
|
69 | - |
|
70 | - //print "pdfformat=".$pdfformat." width=".$width." height=".$height." unit=".$unit; |
|
71 | - return array('width'=>$width,'height'=>$height,'unit'=>$unit); |
|
44 | + global $conf,$db; |
|
45 | + |
|
46 | + // Default value if setup was not done and/or entry into c_paper_format not defined |
|
47 | + $width=210; $height=297; $unit='mm'; |
|
48 | + |
|
49 | + if (empty($conf->global->MAIN_PDF_FORMAT)) |
|
50 | + { |
|
51 | + include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; |
|
52 | + $pdfformat=dol_getDefaultFormat($outputlangs); |
|
53 | + } |
|
54 | + else $pdfformat=$conf->global->MAIN_PDF_FORMAT; |
|
55 | + |
|
56 | + $sql="SELECT code, label, width, height, unit FROM ".MAIN_DB_PREFIX."c_paper_format"; |
|
57 | + $sql.=" WHERE code = '".$pdfformat."'"; |
|
58 | + $resql=$db->query($sql); |
|
59 | + if ($resql) |
|
60 | + { |
|
61 | + $obj=$db->fetch_object($resql); |
|
62 | + if ($obj) |
|
63 | + { |
|
64 | + $width=(int) $obj->width; |
|
65 | + $height=(int) $obj->height; |
|
66 | + $unit=$obj->unit; |
|
67 | + } |
|
68 | + } |
|
69 | + |
|
70 | + //print "pdfformat=".$pdfformat." width=".$width." height=".$height." unit=".$unit; |
|
71 | + return array('width'=>$width,'height'=>$height,'unit'=>$unit); |
|
72 | 72 | } |
73 | 73 | |
74 | 74 | /** |
@@ -81,64 +81,64 @@ discard block |
||
81 | 81 | */ |
82 | 82 | function pdf_getInstance($format='',$metric='mm',$pagetype='P') |
83 | 83 | { |
84 | - global $conf; |
|
85 | - |
|
86 | - // Define constant for TCPDF |
|
87 | - if (! defined('K_TCPDF_EXTERNAL_CONFIG')) |
|
88 | - { |
|
89 | - define('K_TCPDF_EXTERNAL_CONFIG',1); // this avoid using tcpdf_config file |
|
90 | - define('K_PATH_CACHE', DOL_DATA_ROOT.'/admin/temp/'); |
|
91 | - define('K_PATH_URL_CACHE', DOL_DATA_ROOT.'/admin/temp/'); |
|
92 | - dol_mkdir(K_PATH_CACHE); |
|
93 | - define('K_BLANK_IMAGE', '_blank.png'); |
|
94 | - define('PDF_PAGE_FORMAT', 'A4'); |
|
95 | - define('PDF_PAGE_ORIENTATION', 'P'); |
|
96 | - define('PDF_CREATOR', 'TCPDF'); |
|
97 | - define('PDF_AUTHOR', 'TCPDF'); |
|
98 | - define('PDF_HEADER_TITLE', 'TCPDF Example'); |
|
99 | - define('PDF_HEADER_STRING', "by Dolibarr ERP CRM"); |
|
100 | - define('PDF_UNIT', 'mm'); |
|
101 | - define('PDF_MARGIN_HEADER', 5); |
|
102 | - define('PDF_MARGIN_FOOTER', 10); |
|
103 | - define('PDF_MARGIN_TOP', 27); |
|
104 | - define('PDF_MARGIN_BOTTOM', 25); |
|
105 | - define('PDF_MARGIN_LEFT', 15); |
|
106 | - define('PDF_MARGIN_RIGHT', 15); |
|
107 | - define('PDF_FONT_NAME_MAIN', 'helvetica'); |
|
108 | - define('PDF_FONT_SIZE_MAIN', 10); |
|
109 | - define('PDF_FONT_NAME_DATA', 'helvetica'); |
|
110 | - define('PDF_FONT_SIZE_DATA', 8); |
|
111 | - define('PDF_FONT_MONOSPACED', 'courier'); |
|
112 | - define('PDF_IMAGE_SCALE_RATIO', 1.25); |
|
113 | - define('HEAD_MAGNIFICATION', 1.1); |
|
114 | - define('K_CELL_HEIGHT_RATIO', 1.25); |
|
115 | - define('K_TITLE_MAGNIFICATION', 1.3); |
|
116 | - define('K_SMALL_RATIO', 2/3); |
|
117 | - define('K_THAI_TOPCHARS', true); |
|
118 | - define('K_TCPDF_CALLS_IN_HTML', true); |
|
119 | - define('K_TCPDF_THROW_EXCEPTION_ERROR', false); |
|
120 | - } |
|
121 | - |
|
122 | - // Load TCPDF |
|
123 | - require_once TCPDF_PATH.'tcpdf.php'; |
|
124 | - |
|
125 | - // We need to instantiate tcpdi object (instead of tcpdf) to use merging features. But we can disable it (this will break all merge features). |
|
126 | - if (empty($conf->global->MAIN_DISABLE_TCPDI)) require_once TCPDI_PATH.'tcpdi.php'; |
|
127 | - |
|
128 | - //$arrayformat=pdf_getFormat(); |
|
129 | - //$format=array($arrayformat['width'],$arrayformat['height']); |
|
130 | - //$metric=$arrayformat['unit']; |
|
131 | - |
|
132 | - $pdfa=false; // PDF-1.3 |
|
133 | - if (! empty($conf->global->PDF_USE_1A)) $pdfa=true; // PDF1/A |
|
134 | - |
|
135 | - if (class_exists('TCPDI')) $pdf = new TCPDI($pagetype,$metric,$format,true,'UTF-8',false,$pdfa); |
|
136 | - else $pdf = new TCPDF($pagetype,$metric,$format,true,'UTF-8',false,$pdfa); |
|
137 | - |
|
138 | - // Protection and encryption of pdf |
|
139 | - if (! empty($conf->global->PDF_SECURITY_ENCRYPTION)) |
|
140 | - { |
|
141 | - /* Permission supported by TCPDF |
|
84 | + global $conf; |
|
85 | + |
|
86 | + // Define constant for TCPDF |
|
87 | + if (! defined('K_TCPDF_EXTERNAL_CONFIG')) |
|
88 | + { |
|
89 | + define('K_TCPDF_EXTERNAL_CONFIG',1); // this avoid using tcpdf_config file |
|
90 | + define('K_PATH_CACHE', DOL_DATA_ROOT.'/admin/temp/'); |
|
91 | + define('K_PATH_URL_CACHE', DOL_DATA_ROOT.'/admin/temp/'); |
|
92 | + dol_mkdir(K_PATH_CACHE); |
|
93 | + define('K_BLANK_IMAGE', '_blank.png'); |
|
94 | + define('PDF_PAGE_FORMAT', 'A4'); |
|
95 | + define('PDF_PAGE_ORIENTATION', 'P'); |
|
96 | + define('PDF_CREATOR', 'TCPDF'); |
|
97 | + define('PDF_AUTHOR', 'TCPDF'); |
|
98 | + define('PDF_HEADER_TITLE', 'TCPDF Example'); |
|
99 | + define('PDF_HEADER_STRING', "by Dolibarr ERP CRM"); |
|
100 | + define('PDF_UNIT', 'mm'); |
|
101 | + define('PDF_MARGIN_HEADER', 5); |
|
102 | + define('PDF_MARGIN_FOOTER', 10); |
|
103 | + define('PDF_MARGIN_TOP', 27); |
|
104 | + define('PDF_MARGIN_BOTTOM', 25); |
|
105 | + define('PDF_MARGIN_LEFT', 15); |
|
106 | + define('PDF_MARGIN_RIGHT', 15); |
|
107 | + define('PDF_FONT_NAME_MAIN', 'helvetica'); |
|
108 | + define('PDF_FONT_SIZE_MAIN', 10); |
|
109 | + define('PDF_FONT_NAME_DATA', 'helvetica'); |
|
110 | + define('PDF_FONT_SIZE_DATA', 8); |
|
111 | + define('PDF_FONT_MONOSPACED', 'courier'); |
|
112 | + define('PDF_IMAGE_SCALE_RATIO', 1.25); |
|
113 | + define('HEAD_MAGNIFICATION', 1.1); |
|
114 | + define('K_CELL_HEIGHT_RATIO', 1.25); |
|
115 | + define('K_TITLE_MAGNIFICATION', 1.3); |
|
116 | + define('K_SMALL_RATIO', 2/3); |
|
117 | + define('K_THAI_TOPCHARS', true); |
|
118 | + define('K_TCPDF_CALLS_IN_HTML', true); |
|
119 | + define('K_TCPDF_THROW_EXCEPTION_ERROR', false); |
|
120 | + } |
|
121 | + |
|
122 | + // Load TCPDF |
|
123 | + require_once TCPDF_PATH.'tcpdf.php'; |
|
124 | + |
|
125 | + // We need to instantiate tcpdi object (instead of tcpdf) to use merging features. But we can disable it (this will break all merge features). |
|
126 | + if (empty($conf->global->MAIN_DISABLE_TCPDI)) require_once TCPDI_PATH.'tcpdi.php'; |
|
127 | + |
|
128 | + //$arrayformat=pdf_getFormat(); |
|
129 | + //$format=array($arrayformat['width'],$arrayformat['height']); |
|
130 | + //$metric=$arrayformat['unit']; |
|
131 | + |
|
132 | + $pdfa=false; // PDF-1.3 |
|
133 | + if (! empty($conf->global->PDF_USE_1A)) $pdfa=true; // PDF1/A |
|
134 | + |
|
135 | + if (class_exists('TCPDI')) $pdf = new TCPDI($pagetype,$metric,$format,true,'UTF-8',false,$pdfa); |
|
136 | + else $pdf = new TCPDF($pagetype,$metric,$format,true,'UTF-8',false,$pdfa); |
|
137 | + |
|
138 | + // Protection and encryption of pdf |
|
139 | + if (! empty($conf->global->PDF_SECURITY_ENCRYPTION)) |
|
140 | + { |
|
141 | + /* Permission supported by TCPDF |
|
142 | 142 | - print : Print the document; |
143 | 143 | - modify : Modify the contents of the document by operations other than those controlled by 'fill-forms', 'extract' and 'assemble'; |
144 | 144 | - copy : Copy or otherwise extract text and graphics from the document; |
@@ -150,26 +150,26 @@ discard block |
||
150 | 150 | - owner : (inverted logic - only for public-key) when set permits change of encryption and enables all other permissions. |
151 | 151 | */ |
152 | 152 | |
153 | - // For TCPDF, we specify permission we want to block |
|
154 | - $pdfrights = (! empty($conf->global->PDF_SECURITY_ENCRYPTION_RIGHTS)?json_decode($conf->global->PDF_SECURITY_ENCRYPTION_RIGHTS, true):array('modify','copy')); // Json format in llx_const |
|
153 | + // For TCPDF, we specify permission we want to block |
|
154 | + $pdfrights = (! empty($conf->global->PDF_SECURITY_ENCRYPTION_RIGHTS)?json_decode($conf->global->PDF_SECURITY_ENCRYPTION_RIGHTS, true):array('modify','copy')); // Json format in llx_const |
|
155 | 155 | |
156 | - // Password for the end user |
|
157 | - $pdfuserpass = (! empty($conf->global->PDF_SECURITY_ENCRYPTION_USERPASS)?$conf->global->PDF_SECURITY_ENCRYPTION_USERPASS:''); |
|
156 | + // Password for the end user |
|
157 | + $pdfuserpass = (! empty($conf->global->PDF_SECURITY_ENCRYPTION_USERPASS)?$conf->global->PDF_SECURITY_ENCRYPTION_USERPASS:''); |
|
158 | 158 | |
159 | - // Password of the owner, created randomly if not defined |
|
160 | - $pdfownerpass = (! empty($conf->global->PDF_SECURITY_ENCRYPTION_OWNERPASS)?$conf->global->PDF_SECURITY_ENCRYPTION_OWNERPASS:null); |
|
159 | + // Password of the owner, created randomly if not defined |
|
160 | + $pdfownerpass = (! empty($conf->global->PDF_SECURITY_ENCRYPTION_OWNERPASS)?$conf->global->PDF_SECURITY_ENCRYPTION_OWNERPASS:null); |
|
161 | 161 | |
162 | - // For encryption strength: 0 = RC4 40 bit; 1 = RC4 128 bit; 2 = AES 128 bit; 3 = AES 256 bit |
|
163 | - $encstrength = (! empty($conf->global->PDF_SECURITY_ENCRYPTION_STRENGTH)?$conf->global->PDF_SECURITY_ENCRYPTION_STRENGTH:0); |
|
162 | + // For encryption strength: 0 = RC4 40 bit; 1 = RC4 128 bit; 2 = AES 128 bit; 3 = AES 256 bit |
|
163 | + $encstrength = (! empty($conf->global->PDF_SECURITY_ENCRYPTION_STRENGTH)?$conf->global->PDF_SECURITY_ENCRYPTION_STRENGTH:0); |
|
164 | 164 | |
165 | - // Array of recipients containing public-key certificates ('c') and permissions ('p'). |
|
166 | - // For example: array(array('c' => 'file://../examples/data/cert/tcpdf.crt', 'p' => array('print'))) |
|
167 | - $pubkeys = (! empty($conf->global->PDF_SECURITY_ENCRYPTION_PUBKEYS)?json_decode($conf->global->PDF_SECURITY_ENCRYPTION_PUBKEYS, true):null); // Json format in llx_const |
|
165 | + // Array of recipients containing public-key certificates ('c') and permissions ('p'). |
|
166 | + // For example: array(array('c' => 'file://../examples/data/cert/tcpdf.crt', 'p' => array('print'))) |
|
167 | + $pubkeys = (! empty($conf->global->PDF_SECURITY_ENCRYPTION_PUBKEYS)?json_decode($conf->global->PDF_SECURITY_ENCRYPTION_PUBKEYS, true):null); // Json format in llx_const |
|
168 | 168 | |
169 | - $pdf->SetProtection($pdfrights,$pdfuserpass,$pdfownerpass,$encstrength,$pubkeys); |
|
170 | - } |
|
169 | + $pdf->SetProtection($pdfrights,$pdfuserpass,$pdfownerpass,$encstrength,$pubkeys); |
|
170 | + } |
|
171 | 171 | |
172 | - return $pdf; |
|
172 | + return $pdf; |
|
173 | 173 | } |
174 | 174 | |
175 | 175 | /** |
@@ -181,15 +181,15 @@ discard block |
||
181 | 181 | */ |
182 | 182 | function pdf_getEncryption(&$pdf, $pathoffile) |
183 | 183 | { |
184 | - $isencrypted = false; |
|
184 | + $isencrypted = false; |
|
185 | 185 | |
186 | - $pdfparser = $pdf->_getPdfParser($pathoffile); |
|
187 | - $data = $pdfparser->getParsedData(); |
|
188 | - if (isset($data[0]['trailer'][1]['/Encrypt'])) { |
|
189 | - $isencrypted = true; |
|
190 | - } |
|
186 | + $pdfparser = $pdf->_getPdfParser($pathoffile); |
|
187 | + $data = $pdfparser->getParsedData(); |
|
188 | + if (isset($data[0]['trailer'][1]['/Encrypt'])) { |
|
189 | + $isencrypted = true; |
|
190 | + } |
|
191 | 191 | |
192 | - return $isencrypted; |
|
192 | + return $isencrypted; |
|
193 | 193 | } |
194 | 194 | |
195 | 195 | /** |
@@ -200,19 +200,19 @@ discard block |
||
200 | 200 | */ |
201 | 201 | function pdf_getPDFFont($outputlangs) |
202 | 202 | { |
203 | - global $conf; |
|
204 | - |
|
205 | - if (! empty($conf->global->MAIN_PDF_FORCE_FONT)) return $conf->global->MAIN_PDF_FORCE_FONT; |
|
206 | - |
|
207 | - $font='Helvetica'; // By default, for FPDI, or ISO language on TCPDF |
|
208 | - if (class_exists('TCPDF')) // If TCPDF on, we can use an UTF8 one like DejaVuSans if required (slower) |
|
209 | - { |
|
210 | - if ($outputlangs->trans('FONTFORPDF')!='FONTFORPDF') |
|
211 | - { |
|
212 | - $font=$outputlangs->trans('FONTFORPDF'); |
|
213 | - } |
|
214 | - } |
|
215 | - return $font; |
|
203 | + global $conf; |
|
204 | + |
|
205 | + if (! empty($conf->global->MAIN_PDF_FORCE_FONT)) return $conf->global->MAIN_PDF_FORCE_FONT; |
|
206 | + |
|
207 | + $font='Helvetica'; // By default, for FPDI, or ISO language on TCPDF |
|
208 | + if (class_exists('TCPDF')) // If TCPDF on, we can use an UTF8 one like DejaVuSans if required (slower) |
|
209 | + { |
|
210 | + if ($outputlangs->trans('FONTFORPDF')!='FONTFORPDF') |
|
211 | + { |
|
212 | + $font=$outputlangs->trans('FONTFORPDF'); |
|
213 | + } |
|
214 | + } |
|
215 | + return $font; |
|
216 | 216 | } |
217 | 217 | |
218 | 218 | /** |
@@ -223,15 +223,15 @@ discard block |
||
223 | 223 | */ |
224 | 224 | function pdf_getPDFFontSize($outputlangs) |
225 | 225 | { |
226 | - $size=10; // By default, for FPDI or ISO language on TCPDF |
|
227 | - if (class_exists('TCPDF')) // If TCPDF on, we can use an UTF8 one like DejaVuSans if required (slower) |
|
228 | - { |
|
229 | - if ($outputlangs->trans('FONTSIZEFORPDF')!='FONTSIZEFORPDF') |
|
230 | - { |
|
231 | - $size = (int) $outputlangs->trans('FONTSIZEFORPDF'); |
|
232 | - } |
|
233 | - } |
|
234 | - return $size; |
|
226 | + $size=10; // By default, for FPDI or ISO language on TCPDF |
|
227 | + if (class_exists('TCPDF')) // If TCPDF on, we can use an UTF8 one like DejaVuSans if required (slower) |
|
228 | + { |
|
229 | + if ($outputlangs->trans('FONTSIZEFORPDF')!='FONTSIZEFORPDF') |
|
230 | + { |
|
231 | + $size = (int) $outputlangs->trans('FONTSIZEFORPDF'); |
|
232 | + } |
|
233 | + } |
|
234 | + return $size; |
|
235 | 235 | } |
236 | 236 | |
237 | 237 | |
@@ -244,18 +244,18 @@ discard block |
||
244 | 244 | */ |
245 | 245 | function pdf_getHeightForLogo($logo, $url = false) |
246 | 246 | { |
247 | - global $conf; |
|
248 | - $height=(empty($conf->global->MAIN_DOCUMENTS_LOGO_HEIGHT)?22:$conf->global->MAIN_DOCUMENTS_LOGO_HEIGHT); |
|
249 | - $maxwidth=130; |
|
250 | - include_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php'; |
|
251 | - $tmp=dol_getImageSize($logo, $url); |
|
252 | - if ($tmp['height']) |
|
253 | - { |
|
254 | - $width=round($height*$tmp['width']/$tmp['height']); |
|
255 | - if ($width > $maxwidth) $height=$height*$maxwidth/$width; |
|
256 | - } |
|
257 | - //print $tmp['width'].' '.$tmp['height'].' '.$width; exit; |
|
258 | - return $height; |
|
247 | + global $conf; |
|
248 | + $height=(empty($conf->global->MAIN_DOCUMENTS_LOGO_HEIGHT)?22:$conf->global->MAIN_DOCUMENTS_LOGO_HEIGHT); |
|
249 | + $maxwidth=130; |
|
250 | + include_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php'; |
|
251 | + $tmp=dol_getImageSize($logo, $url); |
|
252 | + if ($tmp['height']) |
|
253 | + { |
|
254 | + $width=round($height*$tmp['width']/$tmp['height']); |
|
255 | + if ($width > $maxwidth) $height=$height*$maxwidth/$width; |
|
256 | + } |
|
257 | + //print $tmp['width'].' '.$tmp['height'].' '.$width; exit; |
|
258 | + return $height; |
|
259 | 259 | } |
260 | 260 | |
261 | 261 | /** |
@@ -287,22 +287,22 @@ discard block |
||
287 | 287 | else |
288 | 288 | { |
289 | 289 | for ($page=$start_page; $page <= $end_page; ++$page) { |
290 | - $pdf->setPage($page); |
|
291 | - $tmpm=$pdf->getMargins(); |
|
292 | - $tMargin = $tmpm['top']; |
|
293 | - if ($page == $start_page) { |
|
294 | - // first page |
|
295 | - $height = $pdf->getPageHeight() - $start_y - $pdf->getBreakMargin(); |
|
296 | - } elseif ($page == $end_page) { |
|
297 | - // last page |
|
298 | - $height = $end_y - $tMargin; |
|
299 | - } else { |
|
300 | - $height = $pdf->getPageHeight() - $tMargin - $pdf->getBreakMargin(); |
|
301 | - } |
|
290 | + $pdf->setPage($page); |
|
291 | + $tmpm=$pdf->getMargins(); |
|
292 | + $tMargin = $tmpm['top']; |
|
293 | + if ($page == $start_page) { |
|
294 | + // first page |
|
295 | + $height = $pdf->getPageHeight() - $start_y - $pdf->getBreakMargin(); |
|
296 | + } elseif ($page == $end_page) { |
|
297 | + // last page |
|
298 | + $height = $end_y - $tMargin; |
|
299 | + } else { |
|
300 | + $height = $pdf->getPageHeight() - $tMargin - $pdf->getBreakMargin(); |
|
301 | + } |
|
302 | 302 | } |
303 | - } |
|
304 | - // restore previous object |
|
305 | - $pdf = $pdf->rollbackTransaction(); |
|
303 | + } |
|
304 | + // restore previous object |
|
305 | + $pdf = $pdf->rollbackTransaction(); |
|
306 | 306 | |
307 | 307 | return $height; |
308 | 308 | } |
@@ -320,21 +320,21 @@ discard block |
||
320 | 320 | { |
321 | 321 | global $conf; |
322 | 322 | |
323 | - // Recipient name |
|
324 | - $socname = ''; |
|
325 | - |
|
326 | - if ($thirdparty instanceof Societe) { |
|
327 | - $socname .= $thirdparty->name; |
|
328 | - if (($includealias || ! empty($conf->global->PDF_INCLUDE_ALIAS_IN_THIRDPARTY_NAME)) && !empty($thirdparty->name_alias)) { |
|
329 | - $socname .= "\n".$thirdparty->name_alias; |
|
330 | - } |
|
331 | - } elseif ($thirdparty instanceof Contact) { |
|
332 | - $socname = $thirdparty->socname; |
|
333 | - } else { |
|
334 | - throw new InvalidArgumentException('Parameter 1 $thirdparty is not a Societe nor Contact'); |
|
335 | - } |
|
336 | - |
|
337 | - return $outputlangs->convToOutputCharset($socname); |
|
323 | + // Recipient name |
|
324 | + $socname = ''; |
|
325 | + |
|
326 | + if ($thirdparty instanceof Societe) { |
|
327 | + $socname .= $thirdparty->name; |
|
328 | + if (($includealias || ! empty($conf->global->PDF_INCLUDE_ALIAS_IN_THIRDPARTY_NAME)) && !empty($thirdparty->name_alias)) { |
|
329 | + $socname .= "\n".$thirdparty->name_alias; |
|
330 | + } |
|
331 | + } elseif ($thirdparty instanceof Contact) { |
|
332 | + $socname = $thirdparty->socname; |
|
333 | + } else { |
|
334 | + throw new InvalidArgumentException('Parameter 1 $thirdparty is not a Societe nor Contact'); |
|
335 | + } |
|
336 | + |
|
337 | + return $outputlangs->convToOutputCharset($socname); |
|
338 | 338 | } |
339 | 339 | |
340 | 340 | |
@@ -352,240 +352,240 @@ discard block |
||
352 | 352 | */ |
353 | 353 | function pdf_build_address($outputlangs,$sourcecompany,$targetcompany='',$targetcontact='',$usecontact=0,$mode='source',$object=null) |
354 | 354 | { |
355 | - global $conf, $hookmanager; |
|
356 | - |
|
357 | - if ($mode == 'source' && ! is_object($sourcecompany)) return -1; |
|
358 | - if ($mode == 'target' && ! is_object($targetcompany)) return -1; |
|
359 | - |
|
360 | - if (! empty($sourcecompany->state_id) && empty($sourcecompany->departement)) $sourcecompany->departement=getState($sourcecompany->state_id); //TODO deprecated |
|
361 | - if (! empty($sourcecompany->state_id) && empty($sourcecompany->state)) $sourcecompany->state=getState($sourcecompany->state_id); |
|
362 | - if (! empty($sourcecompany->state_id) && !isset($sourcecompany->departement_id)) $sourcecompany->departement_id=getState($sourcecompany->state_id,'2'); |
|
363 | - if (! empty($targetcompany->state_id) && empty($targetcompany->departement)) $targetcompany->departement=getState($targetcompany->state_id); //TODO deprecated |
|
364 | - if (! empty($targetcompany->state_id) && empty($targetcompany->state)) $targetcompany->state=getState($targetcompany->state_id); |
|
365 | - if (! empty($targetcompany->state_id) && !isset($targetcompany->departement_id)) $targetcompany->departement_id=getState($targetcompany->state_id,'2'); |
|
366 | - |
|
367 | - $reshook=0; |
|
368 | - $stringaddress = ''; |
|
369 | - if (is_object($hookmanager)) |
|
370 | - { |
|
371 | - $parameters = array('sourcecompany'=>&$sourcecompany,'targetcompany'=>&$targetcompany,'targetcontact'=>$targetcontact,'outputlangs'=>$outputlangs,'mode'=>$mode,'usecontact'=>$usecontact); |
|
372 | - $action=''; |
|
373 | - $reshook = $hookmanager->executeHooks('pdf_build_address',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks |
|
374 | - $stringaddress.=$hookmanager->resPrint; |
|
375 | - } |
|
376 | - if (empty($reshook)) |
|
377 | - { |
|
378 | - if ($mode == 'source') |
|
379 | - { |
|
380 | - $withCountry = 0; |
|
381 | - if (!empty($sourcecompany->country_code) && ($targetcompany->country_code != $sourcecompany->country_code)) $withCountry = 1; |
|
382 | - |
|
383 | - $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->convToOutputCharset(dol_format_address($sourcecompany, $withCountry, "\n", $outputlangs))."\n"; |
|
384 | - |
|
385 | - if (empty($conf->global->MAIN_PDF_DISABLESOURCEDETAILS)) |
|
386 | - { |
|
387 | - // Phone |
|
388 | - if ($sourcecompany->phone) $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->transnoentities("PhoneShort").": ".$outputlangs->convToOutputCharset($sourcecompany->phone); |
|
389 | - // Fax |
|
390 | - if ($sourcecompany->fax) $stringaddress .= ($stringaddress ? ($sourcecompany->phone ? " - " : "\n") : '' ).$outputlangs->transnoentities("Fax").": ".$outputlangs->convToOutputCharset($sourcecompany->fax); |
|
391 | ||
392 | - if ($sourcecompany->email) $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->transnoentities("Email").": ".$outputlangs->convToOutputCharset($sourcecompany->email); |
|
393 | - // Web |
|
394 | - if ($sourcecompany->url) $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->transnoentities("Web").": ".$outputlangs->convToOutputCharset($sourcecompany->url); |
|
395 | - } |
|
396 | - // Intra VAT |
|
397 | - if (! empty($conf->global->MAIN_TVAINTRA_IN_SOURCE_ADDRESS)) |
|
398 | - { |
|
399 | - if ($sourcecompany->tva_intra) $stringaddress.=($stringaddress ? "\n" : '' ).$outputlangs->transnoentities("VATIntraShort").': '.$outputlangs->convToOutputCharset($sourcecompany->tva_intra); |
|
400 | - } |
|
401 | - // Professionnal Ids |
|
402 | - if (! empty($conf->global->MAIN_PROFID1_IN_SOURCE_ADDRESS) && ! empty($sourcecompany->idprof1)) |
|
403 | - { |
|
404 | - $tmp=$outputlangs->transcountrynoentities("ProfId1",$sourcecompany->country_code); |
|
405 | - if (preg_match('/\((.+)\)/',$tmp,$reg)) $tmp=$reg[1]; |
|
406 | - $stringaddress.=($stringaddress ? "\n" : '' ).$tmp.': '.$outputlangs->convToOutputCharset($sourcecompany->idprof1); |
|
407 | - } |
|
408 | - if (! empty($conf->global->MAIN_PROFID2_IN_SOURCE_ADDRESS) && ! empty($sourcecompany->idprof2)) |
|
409 | - { |
|
410 | - $tmp=$outputlangs->transcountrynoentities("ProfId2",$sourcecompany->country_code); |
|
411 | - if (preg_match('/\((.+)\)/',$tmp,$reg)) $tmp=$reg[1]; |
|
412 | - $stringaddress.=($stringaddress ? "\n" : '' ).$tmp.': '.$outputlangs->convToOutputCharset($sourcecompany->idprof2); |
|
413 | - } |
|
414 | - if (! empty($conf->global->MAIN_PROFID3_IN_SOURCE_ADDRESS) && ! empty($sourcecompany->idprof3)) |
|
415 | - { |
|
416 | - $tmp=$outputlangs->transcountrynoentities("ProfId3",$sourcecompany->country_code); |
|
417 | - if (preg_match('/\((.+)\)/',$tmp,$reg)) $tmp=$reg[1]; |
|
418 | - $stringaddress.=($stringaddress ? "\n" : '' ).$tmp.': '.$outputlangs->convToOutputCharset($sourcecompany->idprof3); |
|
419 | - } |
|
420 | - if (! empty($conf->global->MAIN_PROFID4_IN_SOURCE_ADDRESS) && ! empty($sourcecompany->idprof4)) |
|
421 | - { |
|
422 | - $tmp=$outputlangs->transcountrynoentities("ProfId4",$sourcecompany->country_code); |
|
423 | - if (preg_match('/\((.+)\)/',$tmp,$reg)) $tmp=$reg[1]; |
|
424 | - $stringaddress.=($stringaddress ? "\n" : '' ).$tmp.': '.$outputlangs->convToOutputCharset($sourcecompany->idprof4); |
|
425 | - } |
|
426 | - if (! empty($conf->global->MAIN_PROFID5_IN_SOURCE_ADDRESS) && ! empty($sourcecompany->idprof5)) |
|
427 | - { |
|
428 | - $tmp=$outputlangs->transcountrynoentities("ProfId5",$sourcecompany->country_code); |
|
429 | - if (preg_match('/\((.+)\)/',$tmp,$reg)) $tmp=$reg[1]; |
|
430 | - $stringaddress.=($stringaddress ? "\n" : '' ).$tmp.': '.$outputlangs->convToOutputCharset($sourcecompany->idprof5); |
|
431 | - } |
|
432 | - if (! empty($conf->global->MAIN_PROFID6_IN_SOURCE_ADDRESS) && ! empty($sourcecompany->idprof6)) |
|
433 | - { |
|
434 | - $tmp=$outputlangs->transcountrynoentities("ProfId6",$sourcecompany->country_code); |
|
435 | - if (preg_match('/\((.+)\)/',$tmp,$reg)) $tmp=$reg[1]; |
|
436 | - $stringaddress.=($stringaddress ? "\n" : '' ).$tmp.': '.$outputlangs->convToOutputCharset($sourcecompany->idprof6); |
|
437 | - } |
|
438 | - } |
|
439 | - |
|
440 | - if ($mode == 'target' || preg_match('/targetwithdetails/',$mode)) |
|
441 | - { |
|
442 | - if ($usecontact) |
|
443 | - { |
|
444 | - $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->convToOutputCharset($targetcontact->getFullName($outputlangs,1)); |
|
445 | - |
|
446 | - if (!empty($targetcontact->address)) { |
|
447 | - $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->convToOutputCharset(dol_format_address($targetcontact)); |
|
448 | - } else { |
|
449 | - $companytouseforaddress = $targetcompany; |
|
450 | - |
|
451 | - // Contact on a thirdparty that is a different thirdparty than the thirdparty of object |
|
452 | - if ($targetcontact->socid > 0 && $targetcontact->socid != $targetcompany->id) |
|
453 | - { |
|
454 | - $targetcontact->fetch_thirdparty(); |
|
455 | - $companytouseforaddress = $targetcontact->thirdparty; |
|
456 | - } |
|
457 | - |
|
458 | - $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->convToOutputCharset(dol_format_address($companytouseforaddress)); |
|
459 | - } |
|
460 | - // Country |
|
461 | - if (!empty($targetcontact->country_code) && $targetcontact->country_code != $sourcecompany->country_code) { |
|
462 | - $stringaddress.= ($stringaddress ? "\n" : '' ).$outputlangs->convToOutputCharset($outputlangs->transnoentitiesnoconv("Country".$targetcontact->country_code)); |
|
463 | - } |
|
464 | - else if (empty($targetcontact->country_code) && !empty($targetcompany->country_code) && ($targetcompany->country_code != $sourcecompany->country_code)) { |
|
465 | - $stringaddress.= ($stringaddress ? "\n" : '' ).$outputlangs->convToOutputCharset($outputlangs->transnoentitiesnoconv("Country".$targetcompany->country_code)); |
|
466 | - } |
|
467 | - |
|
468 | - if (! empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || preg_match('/targetwithdetails/',$mode)) |
|
469 | - { |
|
470 | - // Phone |
|
471 | - if (! empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || $mode == 'targetwithdetails' || preg_match('/targetwithdetails_phone/',$mode)) |
|
472 | - { |
|
473 | - if (! empty($targetcontact->phone_pro) || ! empty($targetcontact->phone_mobile)) $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->transnoentities("Phone").": "; |
|
474 | - if (! empty($targetcontact->phone_pro)) $stringaddress .= $outputlangs->convToOutputCharset($targetcontact->phone_pro); |
|
475 | - if (! empty($targetcontact->phone_pro) && ! empty($targetcontact->phone_mobile)) $stringaddress .= " / "; |
|
476 | - if (! empty($targetcontact->phone_mobile)) $stringaddress .= $outputlangs->convToOutputCharset($targetcontact->phone_mobile); |
|
477 | - } |
|
478 | - // Fax |
|
479 | - if (! empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || $mode == 'targetwithdetails' || preg_match('/targetwithdetails_fax/',$mode)) |
|
480 | - { |
|
355 | + global $conf, $hookmanager; |
|
356 | + |
|
357 | + if ($mode == 'source' && ! is_object($sourcecompany)) return -1; |
|
358 | + if ($mode == 'target' && ! is_object($targetcompany)) return -1; |
|
359 | + |
|
360 | + if (! empty($sourcecompany->state_id) && empty($sourcecompany->departement)) $sourcecompany->departement=getState($sourcecompany->state_id); //TODO deprecated |
|
361 | + if (! empty($sourcecompany->state_id) && empty($sourcecompany->state)) $sourcecompany->state=getState($sourcecompany->state_id); |
|
362 | + if (! empty($sourcecompany->state_id) && !isset($sourcecompany->departement_id)) $sourcecompany->departement_id=getState($sourcecompany->state_id,'2'); |
|
363 | + if (! empty($targetcompany->state_id) && empty($targetcompany->departement)) $targetcompany->departement=getState($targetcompany->state_id); //TODO deprecated |
|
364 | + if (! empty($targetcompany->state_id) && empty($targetcompany->state)) $targetcompany->state=getState($targetcompany->state_id); |
|
365 | + if (! empty($targetcompany->state_id) && !isset($targetcompany->departement_id)) $targetcompany->departement_id=getState($targetcompany->state_id,'2'); |
|
366 | + |
|
367 | + $reshook=0; |
|
368 | + $stringaddress = ''; |
|
369 | + if (is_object($hookmanager)) |
|
370 | + { |
|
371 | + $parameters = array('sourcecompany'=>&$sourcecompany,'targetcompany'=>&$targetcompany,'targetcontact'=>$targetcontact,'outputlangs'=>$outputlangs,'mode'=>$mode,'usecontact'=>$usecontact); |
|
372 | + $action=''; |
|
373 | + $reshook = $hookmanager->executeHooks('pdf_build_address',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks |
|
374 | + $stringaddress.=$hookmanager->resPrint; |
|
375 | + } |
|
376 | + if (empty($reshook)) |
|
377 | + { |
|
378 | + if ($mode == 'source') |
|
379 | + { |
|
380 | + $withCountry = 0; |
|
381 | + if (!empty($sourcecompany->country_code) && ($targetcompany->country_code != $sourcecompany->country_code)) $withCountry = 1; |
|
382 | + |
|
383 | + $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->convToOutputCharset(dol_format_address($sourcecompany, $withCountry, "\n", $outputlangs))."\n"; |
|
384 | + |
|
385 | + if (empty($conf->global->MAIN_PDF_DISABLESOURCEDETAILS)) |
|
386 | + { |
|
387 | + // Phone |
|
388 | + if ($sourcecompany->phone) $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->transnoentities("PhoneShort").": ".$outputlangs->convToOutputCharset($sourcecompany->phone); |
|
389 | + // Fax |
|
390 | + if ($sourcecompany->fax) $stringaddress .= ($stringaddress ? ($sourcecompany->phone ? " - " : "\n") : '' ).$outputlangs->transnoentities("Fax").": ".$outputlangs->convToOutputCharset($sourcecompany->fax); |
|
391 | ||
392 | + if ($sourcecompany->email) $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->transnoentities("Email").": ".$outputlangs->convToOutputCharset($sourcecompany->email); |
|
393 | + // Web |
|
394 | + if ($sourcecompany->url) $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->transnoentities("Web").": ".$outputlangs->convToOutputCharset($sourcecompany->url); |
|
395 | + } |
|
396 | + // Intra VAT |
|
397 | + if (! empty($conf->global->MAIN_TVAINTRA_IN_SOURCE_ADDRESS)) |
|
398 | + { |
|
399 | + if ($sourcecompany->tva_intra) $stringaddress.=($stringaddress ? "\n" : '' ).$outputlangs->transnoentities("VATIntraShort").': '.$outputlangs->convToOutputCharset($sourcecompany->tva_intra); |
|
400 | + } |
|
401 | + // Professionnal Ids |
|
402 | + if (! empty($conf->global->MAIN_PROFID1_IN_SOURCE_ADDRESS) && ! empty($sourcecompany->idprof1)) |
|
403 | + { |
|
404 | + $tmp=$outputlangs->transcountrynoentities("ProfId1",$sourcecompany->country_code); |
|
405 | + if (preg_match('/\((.+)\)/',$tmp,$reg)) $tmp=$reg[1]; |
|
406 | + $stringaddress.=($stringaddress ? "\n" : '' ).$tmp.': '.$outputlangs->convToOutputCharset($sourcecompany->idprof1); |
|
407 | + } |
|
408 | + if (! empty($conf->global->MAIN_PROFID2_IN_SOURCE_ADDRESS) && ! empty($sourcecompany->idprof2)) |
|
409 | + { |
|
410 | + $tmp=$outputlangs->transcountrynoentities("ProfId2",$sourcecompany->country_code); |
|
411 | + if (preg_match('/\((.+)\)/',$tmp,$reg)) $tmp=$reg[1]; |
|
412 | + $stringaddress.=($stringaddress ? "\n" : '' ).$tmp.': '.$outputlangs->convToOutputCharset($sourcecompany->idprof2); |
|
413 | + } |
|
414 | + if (! empty($conf->global->MAIN_PROFID3_IN_SOURCE_ADDRESS) && ! empty($sourcecompany->idprof3)) |
|
415 | + { |
|
416 | + $tmp=$outputlangs->transcountrynoentities("ProfId3",$sourcecompany->country_code); |
|
417 | + if (preg_match('/\((.+)\)/',$tmp,$reg)) $tmp=$reg[1]; |
|
418 | + $stringaddress.=($stringaddress ? "\n" : '' ).$tmp.': '.$outputlangs->convToOutputCharset($sourcecompany->idprof3); |
|
419 | + } |
|
420 | + if (! empty($conf->global->MAIN_PROFID4_IN_SOURCE_ADDRESS) && ! empty($sourcecompany->idprof4)) |
|
421 | + { |
|
422 | + $tmp=$outputlangs->transcountrynoentities("ProfId4",$sourcecompany->country_code); |
|
423 | + if (preg_match('/\((.+)\)/',$tmp,$reg)) $tmp=$reg[1]; |
|
424 | + $stringaddress.=($stringaddress ? "\n" : '' ).$tmp.': '.$outputlangs->convToOutputCharset($sourcecompany->idprof4); |
|
425 | + } |
|
426 | + if (! empty($conf->global->MAIN_PROFID5_IN_SOURCE_ADDRESS) && ! empty($sourcecompany->idprof5)) |
|
427 | + { |
|
428 | + $tmp=$outputlangs->transcountrynoentities("ProfId5",$sourcecompany->country_code); |
|
429 | + if (preg_match('/\((.+)\)/',$tmp,$reg)) $tmp=$reg[1]; |
|
430 | + $stringaddress.=($stringaddress ? "\n" : '' ).$tmp.': '.$outputlangs->convToOutputCharset($sourcecompany->idprof5); |
|
431 | + } |
|
432 | + if (! empty($conf->global->MAIN_PROFID6_IN_SOURCE_ADDRESS) && ! empty($sourcecompany->idprof6)) |
|
433 | + { |
|
434 | + $tmp=$outputlangs->transcountrynoentities("ProfId6",$sourcecompany->country_code); |
|
435 | + if (preg_match('/\((.+)\)/',$tmp,$reg)) $tmp=$reg[1]; |
|
436 | + $stringaddress.=($stringaddress ? "\n" : '' ).$tmp.': '.$outputlangs->convToOutputCharset($sourcecompany->idprof6); |
|
437 | + } |
|
438 | + } |
|
439 | + |
|
440 | + if ($mode == 'target' || preg_match('/targetwithdetails/',$mode)) |
|
441 | + { |
|
442 | + if ($usecontact) |
|
443 | + { |
|
444 | + $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->convToOutputCharset($targetcontact->getFullName($outputlangs,1)); |
|
445 | + |
|
446 | + if (!empty($targetcontact->address)) { |
|
447 | + $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->convToOutputCharset(dol_format_address($targetcontact)); |
|
448 | + } else { |
|
449 | + $companytouseforaddress = $targetcompany; |
|
450 | + |
|
451 | + // Contact on a thirdparty that is a different thirdparty than the thirdparty of object |
|
452 | + if ($targetcontact->socid > 0 && $targetcontact->socid != $targetcompany->id) |
|
453 | + { |
|
454 | + $targetcontact->fetch_thirdparty(); |
|
455 | + $companytouseforaddress = $targetcontact->thirdparty; |
|
456 | + } |
|
457 | + |
|
458 | + $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->convToOutputCharset(dol_format_address($companytouseforaddress)); |
|
459 | + } |
|
460 | + // Country |
|
461 | + if (!empty($targetcontact->country_code) && $targetcontact->country_code != $sourcecompany->country_code) { |
|
462 | + $stringaddress.= ($stringaddress ? "\n" : '' ).$outputlangs->convToOutputCharset($outputlangs->transnoentitiesnoconv("Country".$targetcontact->country_code)); |
|
463 | + } |
|
464 | + else if (empty($targetcontact->country_code) && !empty($targetcompany->country_code) && ($targetcompany->country_code != $sourcecompany->country_code)) { |
|
465 | + $stringaddress.= ($stringaddress ? "\n" : '' ).$outputlangs->convToOutputCharset($outputlangs->transnoentitiesnoconv("Country".$targetcompany->country_code)); |
|
466 | + } |
|
467 | + |
|
468 | + if (! empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || preg_match('/targetwithdetails/',$mode)) |
|
469 | + { |
|
470 | + // Phone |
|
471 | + if (! empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || $mode == 'targetwithdetails' || preg_match('/targetwithdetails_phone/',$mode)) |
|
472 | + { |
|
473 | + if (! empty($targetcontact->phone_pro) || ! empty($targetcontact->phone_mobile)) $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->transnoentities("Phone").": "; |
|
474 | + if (! empty($targetcontact->phone_pro)) $stringaddress .= $outputlangs->convToOutputCharset($targetcontact->phone_pro); |
|
475 | + if (! empty($targetcontact->phone_pro) && ! empty($targetcontact->phone_mobile)) $stringaddress .= " / "; |
|
476 | + if (! empty($targetcontact->phone_mobile)) $stringaddress .= $outputlangs->convToOutputCharset($targetcontact->phone_mobile); |
|
477 | + } |
|
478 | + // Fax |
|
479 | + if (! empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || $mode == 'targetwithdetails' || preg_match('/targetwithdetails_fax/',$mode)) |
|
480 | + { |
|
481 | 481 | if ($targetcontact->fax) $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->transnoentities("Fax").": ".$outputlangs->convToOutputCharset($targetcontact->fax); |
482 | - } |
|
483 | ||
484 | - if (! empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || $mode == 'targetwithdetails' || preg_match('/targetwithdetails_email/',$mode)) |
|
485 | - { |
|
482 | + } |
|
483 | ||
484 | + if (! empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || $mode == 'targetwithdetails' || preg_match('/targetwithdetails_email/',$mode)) |
|
485 | + { |
|
486 | 486 | if ($targetcontact->email) $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->transnoentities("Email").": ".$outputlangs->convToOutputCharset($targetcontact->email); |
487 | - } |
|
488 | - // Web |
|
489 | - if (! empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || $mode == 'targetwithdetails' || preg_match('/targetwithdetails_url/',$mode)) |
|
490 | - { |
|
487 | + } |
|
488 | + // Web |
|
489 | + if (! empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || $mode == 'targetwithdetails' || preg_match('/targetwithdetails_url/',$mode)) |
|
490 | + { |
|
491 | 491 | if ($targetcontact->url) $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->transnoentities("Web").": ".$outputlangs->convToOutputCharset($targetcontact->url); |
492 | - } |
|
493 | - } |
|
494 | - } |
|
495 | - else |
|
496 | - { |
|
497 | - $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->convToOutputCharset(dol_format_address($targetcompany)); |
|
498 | - // Country |
|
499 | - if (!empty($targetcompany->country_code) && $targetcompany->country_code != $sourcecompany->country_code) $stringaddress.=($stringaddress ? "\n" : '' ).$outputlangs->convToOutputCharset($outputlangs->transnoentitiesnoconv("Country".$targetcompany->country_code)); |
|
500 | - |
|
501 | - if (! empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || preg_match('/targetwithdetails/',$mode)) |
|
502 | - { |
|
503 | - // Phone |
|
504 | - if (! empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || $mode == 'targetwithdetails' || preg_match('/targetwithdetails_phone/',$mode)) |
|
505 | - { |
|
506 | - if (! empty($targetcompany->phone) || ! empty($targetcompany->phone_mobile)) $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->transnoentities("Phone").": "; |
|
507 | - if (! empty($targetcompany->phone)) $stringaddress .= $outputlangs->convToOutputCharset($targetcompany->phone); |
|
508 | - if (! empty($targetcompany->phone) && ! empty($targetcompany->phone_mobile)) $stringaddress .= " / "; |
|
509 | - if (! empty($targetcompany->phone_mobile)) $stringaddress .= $outputlangs->convToOutputCharset($targetcompany->phone_mobile); |
|
510 | - } |
|
511 | - // Fax |
|
512 | - if (! empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || $mode == 'targetwithdetails' || preg_match('/targetwithdetails_fax/',$mode)) |
|
513 | - { |
|
514 | - if ($targetcompany->fax) $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->transnoentities("Fax").": ".$outputlangs->convToOutputCharset($targetcompany->fax); |
|
515 | - } |
|
516 | ||
517 | - if (! empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || $mode == 'targetwithdetails' || preg_match('/targetwithdetails_email/',$mode)) |
|
518 | - { |
|
519 | - if ($targetcompany->email) $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->transnoentities("Email").": ".$outputlangs->convToOutputCharset($targetcompany->email); |
|
520 | - } |
|
521 | - // Web |
|
522 | - if (! empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || $mode == 'targetwithdetails' || preg_match('/targetwithdetails_url/',$mode)) |
|
523 | - { |
|
524 | - if ($targetcompany->url) $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->transnoentities("Web").": ".$outputlangs->convToOutputCharset($targetcompany->url); |
|
525 | - } |
|
526 | - } |
|
527 | - } |
|
528 | - |
|
529 | - // Intra VAT |
|
530 | - if (empty($conf->global->MAIN_TVAINTRA_NOT_IN_ADDRESS)) |
|
531 | - { |
|
532 | - if ($targetcompany->tva_intra) $stringaddress.=($stringaddress ? "\n" : '' ).$outputlangs->transnoentities("VATIntraShort").': '.$outputlangs->convToOutputCharset($targetcompany->tva_intra); |
|
533 | - } |
|
534 | - |
|
535 | - // Professionnal Ids |
|
536 | - if (! empty($conf->global->MAIN_PROFID1_IN_ADDRESS) && ! empty($targetcompany->idprof1)) |
|
537 | - { |
|
538 | - $tmp=$outputlangs->transcountrynoentities("ProfId1",$targetcompany->country_code); |
|
539 | - if (preg_match('/\((.+)\)/',$tmp,$reg)) $tmp=$reg[1]; |
|
540 | - $stringaddress.=($stringaddress ? "\n" : '' ).$tmp.': '.$outputlangs->convToOutputCharset($targetcompany->idprof1); |
|
541 | - } |
|
542 | - if (! empty($conf->global->MAIN_PROFID2_IN_ADDRESS) && ! empty($targetcompany->idprof2)) |
|
543 | - { |
|
544 | - $tmp=$outputlangs->transcountrynoentities("ProfId2",$targetcompany->country_code); |
|
545 | - if (preg_match('/\((.+)\)/',$tmp,$reg)) $tmp=$reg[1]; |
|
546 | - $stringaddress.=($stringaddress ? "\n" : '' ).$tmp.': '.$outputlangs->convToOutputCharset($targetcompany->idprof2); |
|
547 | - } |
|
548 | - if (! empty($conf->global->MAIN_PROFID3_IN_ADDRESS) && ! empty($targetcompany->idprof3)) |
|
549 | - { |
|
550 | - $tmp=$outputlangs->transcountrynoentities("ProfId3",$targetcompany->country_code); |
|
551 | - if (preg_match('/\((.+)\)/',$tmp,$reg)) $tmp=$reg[1]; |
|
552 | - $stringaddress.=($stringaddress ? "\n" : '' ).$tmp.': '.$outputlangs->convToOutputCharset($targetcompany->idprof3); |
|
553 | - } |
|
554 | - if (! empty($conf->global->MAIN_PROFID4_IN_ADDRESS) && ! empty($targetcompany->idprof4)) |
|
555 | - { |
|
556 | - $tmp=$outputlangs->transcountrynoentities("ProfId4",$targetcompany->country_code); |
|
557 | - if (preg_match('/\((.+)\)/',$tmp,$reg)) $tmp=$reg[1]; |
|
558 | - $stringaddress.=($stringaddress ? "\n" : '' ).$tmp.': '.$outputlangs->convToOutputCharset($targetcompany->idprof4); |
|
559 | - } |
|
560 | - if (! empty($conf->global->MAIN_PROFID5_IN_ADDRESS) && ! empty($targetcompany->idprof5)) |
|
561 | - { |
|
562 | - $tmp=$outputlangs->transcountrynoentities("ProfId5",$targetcompany->country_code); |
|
563 | - if (preg_match('/\((.+)\)/',$tmp,$reg)) $tmp=$reg[1]; |
|
564 | - $stringaddress.=($stringaddress ? "\n" : '' ).$tmp.': '.$outputlangs->convToOutputCharset($targetcompany->idprof5); |
|
565 | - } |
|
566 | - if (! empty($conf->global->MAIN_PROFID6_IN_ADDRESS) && ! empty($targetcompany->idprof6)) |
|
567 | - { |
|
568 | - $tmp=$outputlangs->transcountrynoentities("ProfId6",$targetcompany->country_code); |
|
569 | - if (preg_match('/\((.+)\)/',$tmp,$reg)) $tmp=$reg[1]; |
|
570 | - $stringaddress.=($stringaddress ? "\n" : '' ).$tmp.': '.$outputlangs->convToOutputCharset($targetcompany->idprof6); |
|
571 | - } |
|
572 | - |
|
573 | - // Public note |
|
574 | - if (! empty($conf->global->MAIN_PUBLIC_NOTE_IN_ADDRESS)) |
|
575 | - { |
|
576 | - if ($mode == 'source' && ! empty($sourcecompany->note_public)) |
|
577 | - { |
|
578 | - $stringaddress.=($stringaddress ? "\n" : '' ).dol_string_nohtmltag($sourcecompany->note_public); |
|
579 | - } |
|
580 | - if (($mode == 'target' || preg_match('/targetwithdetails/',$mode)) && ! empty($targetcompany->note_public)) |
|
581 | - { |
|
582 | - $stringaddress.=($stringaddress ? "\n" : '' ).dol_string_nohtmltag($targetcompany->note_public); |
|
583 | - } |
|
584 | - } |
|
585 | - } |
|
586 | - } |
|
587 | - |
|
588 | - return $stringaddress; |
|
492 | + } |
|
493 | + } |
|
494 | + } |
|
495 | + else |
|
496 | + { |
|
497 | + $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->convToOutputCharset(dol_format_address($targetcompany)); |
|
498 | + // Country |
|
499 | + if (!empty($targetcompany->country_code) && $targetcompany->country_code != $sourcecompany->country_code) $stringaddress.=($stringaddress ? "\n" : '' ).$outputlangs->convToOutputCharset($outputlangs->transnoentitiesnoconv("Country".$targetcompany->country_code)); |
|
500 | + |
|
501 | + if (! empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || preg_match('/targetwithdetails/',$mode)) |
|
502 | + { |
|
503 | + // Phone |
|
504 | + if (! empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || $mode == 'targetwithdetails' || preg_match('/targetwithdetails_phone/',$mode)) |
|
505 | + { |
|
506 | + if (! empty($targetcompany->phone) || ! empty($targetcompany->phone_mobile)) $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->transnoentities("Phone").": "; |
|
507 | + if (! empty($targetcompany->phone)) $stringaddress .= $outputlangs->convToOutputCharset($targetcompany->phone); |
|
508 | + if (! empty($targetcompany->phone) && ! empty($targetcompany->phone_mobile)) $stringaddress .= " / "; |
|
509 | + if (! empty($targetcompany->phone_mobile)) $stringaddress .= $outputlangs->convToOutputCharset($targetcompany->phone_mobile); |
|
510 | + } |
|
511 | + // Fax |
|
512 | + if (! empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || $mode == 'targetwithdetails' || preg_match('/targetwithdetails_fax/',$mode)) |
|
513 | + { |
|
514 | + if ($targetcompany->fax) $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->transnoentities("Fax").": ".$outputlangs->convToOutputCharset($targetcompany->fax); |
|
515 | + } |
|
516 | ||
517 | + if (! empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || $mode == 'targetwithdetails' || preg_match('/targetwithdetails_email/',$mode)) |
|
518 | + { |
|
519 | + if ($targetcompany->email) $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->transnoentities("Email").": ".$outputlangs->convToOutputCharset($targetcompany->email); |
|
520 | + } |
|
521 | + // Web |
|
522 | + if (! empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || $mode == 'targetwithdetails' || preg_match('/targetwithdetails_url/',$mode)) |
|
523 | + { |
|
524 | + if ($targetcompany->url) $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->transnoentities("Web").": ".$outputlangs->convToOutputCharset($targetcompany->url); |
|
525 | + } |
|
526 | + } |
|
527 | + } |
|
528 | + |
|
529 | + // Intra VAT |
|
530 | + if (empty($conf->global->MAIN_TVAINTRA_NOT_IN_ADDRESS)) |
|
531 | + { |
|
532 | + if ($targetcompany->tva_intra) $stringaddress.=($stringaddress ? "\n" : '' ).$outputlangs->transnoentities("VATIntraShort").': '.$outputlangs->convToOutputCharset($targetcompany->tva_intra); |
|
533 | + } |
|
534 | + |
|
535 | + // Professionnal Ids |
|
536 | + if (! empty($conf->global->MAIN_PROFID1_IN_ADDRESS) && ! empty($targetcompany->idprof1)) |
|
537 | + { |
|
538 | + $tmp=$outputlangs->transcountrynoentities("ProfId1",$targetcompany->country_code); |
|
539 | + if (preg_match('/\((.+)\)/',$tmp,$reg)) $tmp=$reg[1]; |
|
540 | + $stringaddress.=($stringaddress ? "\n" : '' ).$tmp.': '.$outputlangs->convToOutputCharset($targetcompany->idprof1); |
|
541 | + } |
|
542 | + if (! empty($conf->global->MAIN_PROFID2_IN_ADDRESS) && ! empty($targetcompany->idprof2)) |
|
543 | + { |
|
544 | + $tmp=$outputlangs->transcountrynoentities("ProfId2",$targetcompany->country_code); |
|
545 | + if (preg_match('/\((.+)\)/',$tmp,$reg)) $tmp=$reg[1]; |
|
546 | + $stringaddress.=($stringaddress ? "\n" : '' ).$tmp.': '.$outputlangs->convToOutputCharset($targetcompany->idprof2); |
|
547 | + } |
|
548 | + if (! empty($conf->global->MAIN_PROFID3_IN_ADDRESS) && ! empty($targetcompany->idprof3)) |
|
549 | + { |
|
550 | + $tmp=$outputlangs->transcountrynoentities("ProfId3",$targetcompany->country_code); |
|
551 | + if (preg_match('/\((.+)\)/',$tmp,$reg)) $tmp=$reg[1]; |
|
552 | + $stringaddress.=($stringaddress ? "\n" : '' ).$tmp.': '.$outputlangs->convToOutputCharset($targetcompany->idprof3); |
|
553 | + } |
|
554 | + if (! empty($conf->global->MAIN_PROFID4_IN_ADDRESS) && ! empty($targetcompany->idprof4)) |
|
555 | + { |
|
556 | + $tmp=$outputlangs->transcountrynoentities("ProfId4",$targetcompany->country_code); |
|
557 | + if (preg_match('/\((.+)\)/',$tmp,$reg)) $tmp=$reg[1]; |
|
558 | + $stringaddress.=($stringaddress ? "\n" : '' ).$tmp.': '.$outputlangs->convToOutputCharset($targetcompany->idprof4); |
|
559 | + } |
|
560 | + if (! empty($conf->global->MAIN_PROFID5_IN_ADDRESS) && ! empty($targetcompany->idprof5)) |
|
561 | + { |
|
562 | + $tmp=$outputlangs->transcountrynoentities("ProfId5",$targetcompany->country_code); |
|
563 | + if (preg_match('/\((.+)\)/',$tmp,$reg)) $tmp=$reg[1]; |
|
564 | + $stringaddress.=($stringaddress ? "\n" : '' ).$tmp.': '.$outputlangs->convToOutputCharset($targetcompany->idprof5); |
|
565 | + } |
|
566 | + if (! empty($conf->global->MAIN_PROFID6_IN_ADDRESS) && ! empty($targetcompany->idprof6)) |
|
567 | + { |
|
568 | + $tmp=$outputlangs->transcountrynoentities("ProfId6",$targetcompany->country_code); |
|
569 | + if (preg_match('/\((.+)\)/',$tmp,$reg)) $tmp=$reg[1]; |
|
570 | + $stringaddress.=($stringaddress ? "\n" : '' ).$tmp.': '.$outputlangs->convToOutputCharset($targetcompany->idprof6); |
|
571 | + } |
|
572 | + |
|
573 | + // Public note |
|
574 | + if (! empty($conf->global->MAIN_PUBLIC_NOTE_IN_ADDRESS)) |
|
575 | + { |
|
576 | + if ($mode == 'source' && ! empty($sourcecompany->note_public)) |
|
577 | + { |
|
578 | + $stringaddress.=($stringaddress ? "\n" : '' ).dol_string_nohtmltag($sourcecompany->note_public); |
|
579 | + } |
|
580 | + if (($mode == 'target' || preg_match('/targetwithdetails/',$mode)) && ! empty($targetcompany->note_public)) |
|
581 | + { |
|
582 | + $stringaddress.=($stringaddress ? "\n" : '' ).dol_string_nohtmltag($targetcompany->note_public); |
|
583 | + } |
|
584 | + } |
|
585 | + } |
|
586 | + } |
|
587 | + |
|
588 | + return $stringaddress; |
|
589 | 589 | } |
590 | 590 | |
591 | 591 | |
@@ -599,15 +599,15 @@ discard block |
||
599 | 599 | */ |
600 | 600 | function pdf_pagehead(&$pdf,$outputlangs,$page_height) |
601 | 601 | { |
602 | - global $conf; |
|
603 | - |
|
604 | - // Add a background image on document |
|
605 | - if (! empty($conf->global->MAIN_USE_BACKGROUND_ON_PDF)) // Warning, this option make TCPDF generation being crazy and some content disappeared behind the image |
|
606 | - { |
|
607 | - $pdf->SetAutoPageBreak(0,0); // Disable auto pagebreak before adding image |
|
608 | - $pdf->Image($conf->mycompany->dir_output.'/logos/'.$conf->global->MAIN_USE_BACKGROUND_ON_PDF, (isset($conf->global->MAIN_USE_BACKGROUND_ON_PDF_X)?$conf->global->MAIN_USE_BACKGROUND_ON_PDF_X:0), (isset($conf->global->MAIN_USE_BACKGROUND_ON_PDF_Y)?$conf->global->MAIN_USE_BACKGROUND_ON_PDF_Y:0), 0, $page_height); |
|
609 | - $pdf->SetAutoPageBreak(1,0); // Restore pagebreak |
|
610 | - } |
|
602 | + global $conf; |
|
603 | + |
|
604 | + // Add a background image on document |
|
605 | + if (! empty($conf->global->MAIN_USE_BACKGROUND_ON_PDF)) // Warning, this option make TCPDF generation being crazy and some content disappeared behind the image |
|
606 | + { |
|
607 | + $pdf->SetAutoPageBreak(0,0); // Disable auto pagebreak before adding image |
|
608 | + $pdf->Image($conf->mycompany->dir_output.'/logos/'.$conf->global->MAIN_USE_BACKGROUND_ON_PDF, (isset($conf->global->MAIN_USE_BACKGROUND_ON_PDF_X)?$conf->global->MAIN_USE_BACKGROUND_ON_PDF_X:0), (isset($conf->global->MAIN_USE_BACKGROUND_ON_PDF_Y)?$conf->global->MAIN_USE_BACKGROUND_ON_PDF_Y:0), 0, $page_height); |
|
609 | + $pdf->SetAutoPageBreak(1,0); // Restore pagebreak |
|
610 | + } |
|
611 | 611 | } |
612 | 612 | |
613 | 613 | |
@@ -642,38 +642,38 @@ discard block |
||
642 | 642 | */ |
643 | 643 | function pdf_watermark(&$pdf, $outputlangs, $h, $w, $unit, $text) |
644 | 644 | { |
645 | - global $langs, $mysoc, $user; |
|
646 | - |
|
647 | - // Print Draft Watermark |
|
648 | - if ($unit=='pt') $k=1; |
|
649 | - elseif ($unit=='mm') $k=72/25.4; |
|
650 | - elseif ($unit=='cm') $k=72/2.54; |
|
651 | - elseif ($unit=='in') $k=72; |
|
652 | - |
|
653 | - // Make substitution |
|
654 | - $substitutionarray=pdf_getSubstitutionArray($outputlangs, null, null); |
|
655 | - complete_substitutions_array($substitutionarray, $outputlangs, null); |
|
656 | - $text=make_substitutions($text, $substitutionarray, $outputlangs); |
|
657 | - $text=$outputlangs->convToOutputCharset($text); |
|
658 | - |
|
659 | - $savx=$pdf->getX(); $savy=$pdf->getY(); |
|
660 | - |
|
661 | - $watermark_angle=atan($h/$w)/2; |
|
662 | - $watermark_x_pos=0; |
|
663 | - $watermark_y_pos=$h/3; |
|
664 | - $watermark_x=$w/2; |
|
665 | - $watermark_y=$h/3; |
|
666 | - $pdf->SetFont('','B',40); |
|
667 | - $pdf->SetTextColor(255,192,203); |
|
668 | - //rotate |
|
669 | - $pdf->_out(sprintf('q %.5F %.5F %.5F %.5F %.2F %.2F cm 1 0 0 1 %.2F %.2F cm',cos($watermark_angle),sin($watermark_angle),-sin($watermark_angle),cos($watermark_angle),$watermark_x*$k,($h-$watermark_y)*$k,-$watermark_x*$k,-($h-$watermark_y)*$k)); |
|
670 | - //print watermark |
|
671 | - $pdf->SetXY($watermark_x_pos,$watermark_y_pos); |
|
672 | - $pdf->Cell($w-20,25,$outputlangs->convToOutputCharset($text),"",2,"C",0); |
|
673 | - //antirotate |
|
674 | - $pdf->_out('Q'); |
|
675 | - |
|
676 | - $pdf->SetXY($savx,$savy); |
|
645 | + global $langs, $mysoc, $user; |
|
646 | + |
|
647 | + // Print Draft Watermark |
|
648 | + if ($unit=='pt') $k=1; |
|
649 | + elseif ($unit=='mm') $k=72/25.4; |
|
650 | + elseif ($unit=='cm') $k=72/2.54; |
|
651 | + elseif ($unit=='in') $k=72; |
|
652 | + |
|
653 | + // Make substitution |
|
654 | + $substitutionarray=pdf_getSubstitutionArray($outputlangs, null, null); |
|
655 | + complete_substitutions_array($substitutionarray, $outputlangs, null); |
|
656 | + $text=make_substitutions($text, $substitutionarray, $outputlangs); |
|
657 | + $text=$outputlangs->convToOutputCharset($text); |
|
658 | + |
|
659 | + $savx=$pdf->getX(); $savy=$pdf->getY(); |
|
660 | + |
|
661 | + $watermark_angle=atan($h/$w)/2; |
|
662 | + $watermark_x_pos=0; |
|
663 | + $watermark_y_pos=$h/3; |
|
664 | + $watermark_x=$w/2; |
|
665 | + $watermark_y=$h/3; |
|
666 | + $pdf->SetFont('','B',40); |
|
667 | + $pdf->SetTextColor(255,192,203); |
|
668 | + //rotate |
|
669 | + $pdf->_out(sprintf('q %.5F %.5F %.5F %.5F %.2F %.2F cm 1 0 0 1 %.2F %.2F cm',cos($watermark_angle),sin($watermark_angle),-sin($watermark_angle),cos($watermark_angle),$watermark_x*$k,($h-$watermark_y)*$k,-$watermark_x*$k,-($h-$watermark_y)*$k)); |
|
670 | + //print watermark |
|
671 | + $pdf->SetXY($watermark_x_pos,$watermark_y_pos); |
|
672 | + $pdf->Cell($w-20,25,$outputlangs->convToOutputCharset($text),"",2,"C",0); |
|
673 | + //antirotate |
|
674 | + $pdf->_out('Q'); |
|
675 | + |
|
676 | + $pdf->SetXY($savx,$savy); |
|
677 | 677 | } |
678 | 678 | |
679 | 679 | |
@@ -691,167 +691,167 @@ discard block |
||
691 | 691 | */ |
692 | 692 | function pdf_bank(&$pdf,$outputlangs,$curx,$cury,$account,$onlynumber=0,$default_font_size=10) |
693 | 693 | { |
694 | - global $mysoc, $conf; |
|
695 | - |
|
696 | - require_once DOL_DOCUMENT_ROOT.'/core/class/html.formbank.class.php'; |
|
697 | - |
|
698 | - $diffsizetitle=(empty($conf->global->PDF_DIFFSIZE_TITLE)?3:$conf->global->PDF_DIFFSIZE_TITLE); |
|
699 | - $diffsizecontent=(empty($conf->global->PDF_DIFFSIZE_CONTENT)?4:$conf->global->PDF_DIFFSIZE_CONTENT); |
|
700 | - $pdf->SetXY($curx, $cury); |
|
701 | - |
|
702 | - if (empty($onlynumber)) |
|
703 | - { |
|
704 | - $pdf->SetFont('','B',$default_font_size - $diffsizetitle); |
|
705 | - $pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByTransferOnThisBankAccount').':', 0, 'L', 0); |
|
706 | - $cury+=4; |
|
707 | - } |
|
708 | - |
|
709 | - $outputlangs->load("banks"); |
|
710 | - |
|
711 | - // Use correct name of bank id according to country |
|
712 | - $bickey="BICNumber"; |
|
713 | - if ($account->getCountryCode() == 'IN') $bickey="SWIFT"; |
|
714 | - |
|
715 | - // Get format of bank account according to its country |
|
716 | - $usedetailedbban=$account->useDetailedBBAN(); |
|
717 | - |
|
718 | - //$onlynumber=0; $usedetailedbban=1; // For tests |
|
719 | - if ($usedetailedbban) |
|
720 | - { |
|
721 | - $savcurx=$curx; |
|
722 | - |
|
723 | - if (empty($onlynumber)) |
|
724 | - { |
|
725 | - $pdf->SetFont('','',$default_font_size - $diffsizecontent); |
|
726 | - $pdf->SetXY($curx, $cury); |
|
727 | - $pdf->MultiCell(100, 3, $outputlangs->transnoentities("Bank").': ' . $outputlangs->convToOutputCharset($account->bank), 0, 'L', 0); |
|
728 | - $cury+=3; |
|
729 | - } |
|
730 | - |
|
731 | - if (empty($conf->global->PDF_BANK_HIDE_NUMBER_SHOW_ONLY_BICIBAN)) // Note that some countries still need bank number, BIC/IBAN not enougth for them |
|
732 | - { |
|
733 | - // Note: |
|
734 | - // bank = code_banque (FR), sort code (GB, IR. Example: 12-34-56) |
|
735 | - // desk = code guichet (FR), used only when $usedetailedbban = 1 |
|
736 | - // number = account number |
|
737 | - // key = check control key used only when $usedetailedbban = 1 |
|
738 | - if (empty($onlynumber)) $pdf->line($curx+1, $cury+1, $curx+1, $cury+6); |
|
739 | - |
|
740 | - |
|
741 | - foreach ($account->getFieldsToShow() as $val) |
|
742 | - { |
|
743 | - $pdf->SetXY($curx, $cury+4); |
|
744 | - $pdf->SetFont('','',$default_font_size - 3); |
|
745 | - |
|
746 | - if ($val == 'BankCode') { |
|
747 | - // Bank code |
|
748 | - $tmplength = 18; |
|
749 | - $content = $account->code_banque; |
|
750 | - } elseif ($val == 'DeskCode') { |
|
751 | - // Desk |
|
752 | - $tmplength = 18; |
|
753 | - $content = $account->code_guichet; |
|
754 | - } elseif ($val == 'BankAccountNumber') { |
|
755 | - // Number |
|
756 | - $tmplength = 24; |
|
757 | - $content = $account->number; |
|
758 | - } elseif ($val == 'BankAccountNumberKey') { |
|
759 | - // Key |
|
760 | - $tmplength = 15; |
|
761 | - $content = $account->cle_rib; |
|
762 | - }elseif ($val == 'IBAN' || $val == 'BIC') { |
|
763 | - // Key |
|
764 | - $tmplength = 0; |
|
765 | - $content = ''; |
|
766 | - } else { |
|
767 | - dol_print_error($account->db, 'Unexpected value for getFieldsToShow: '.$val); |
|
768 | - break; |
|
769 | - } |
|
770 | - |
|
771 | - $pdf->MultiCell($tmplength, 3, $outputlangs->convToOutputCharset($content), 0, 'C', 0); |
|
772 | - $pdf->SetXY($curx, $cury + 1); |
|
773 | - $curx += $tmplength; |
|
774 | - $pdf->SetFont('', 'B', $default_font_size - $diffsizecontent); |
|
775 | - $pdf->MultiCell($tmplength, 3, $outputlangs->transnoentities($val), 0, 'C', 0); |
|
776 | - if (empty($onlynumber)) { |
|
777 | - $pdf->line($curx, $cury + 1, $curx, $cury + 7); |
|
778 | - } |
|
779 | - } |
|
780 | - |
|
781 | - $curx=$savcurx; |
|
782 | - $cury+=8; |
|
783 | - } |
|
784 | - } |
|
785 | - else |
|
786 | - { |
|
787 | - $pdf->SetFont('','B',$default_font_size - $diffsizecontent); |
|
788 | - $pdf->SetXY($curx, $cury); |
|
789 | - $pdf->MultiCell(100, 3, $outputlangs->transnoentities("Bank").': ' . $outputlangs->convToOutputCharset($account->bank), 0, 'L', 0); |
|
790 | - $cury+=3; |
|
791 | - |
|
792 | - $pdf->SetFont('','B',$default_font_size - $diffsizecontent); |
|
793 | - $pdf->SetXY($curx, $cury); |
|
794 | - $pdf->MultiCell(100, 3, $outputlangs->transnoentities("BankAccountNumber").': ' . $outputlangs->convToOutputCharset($account->number), 0, 'L', 0); |
|
795 | - $cury+=3; |
|
796 | - |
|
797 | - if ($diffsizecontent <= 2) $cury+=1; |
|
798 | - } |
|
799 | - |
|
800 | - $pdf->SetFont('','',$default_font_size - $diffsizecontent); |
|
801 | - |
|
802 | - if (empty($onlynumber) && ! empty($account->domiciliation)) |
|
803 | - { |
|
804 | - $pdf->SetXY($curx, $cury); |
|
805 | - $val=$outputlangs->transnoentities("Residence").': ' . $outputlangs->convToOutputCharset($account->domiciliation); |
|
806 | - $pdf->MultiCell(100, 3, $val, 0, 'L', 0); |
|
807 | - //$nboflines=dol_nboflines_bis($val,120); |
|
808 | - //$cury+=($nboflines*3)+2; |
|
809 | - $tmpy=$pdf->getStringHeight(100, $val); |
|
810 | - $cury+=$tmpy; |
|
811 | - } |
|
812 | - |
|
813 | - if (! empty($account->proprio)) |
|
814 | - { |
|
815 | - $pdf->SetXY($curx, $cury); |
|
816 | - $val=$outputlangs->transnoentities("BankAccountOwner").': ' . $outputlangs->convToOutputCharset($account->proprio); |
|
817 | - $pdf->MultiCell(100, 3, $val, 0, 'L', 0); |
|
818 | - $tmpy=$pdf->getStringHeight(100, $val); |
|
819 | - $cury+=$tmpy; |
|
820 | - $cur+=1; |
|
821 | - } |
|
822 | - |
|
823 | - else if (! $usedetailedbban) $cury+=1; |
|
824 | - |
|
825 | - // Use correct name of bank id according to country |
|
826 | - $ibankey = FormBank::getIBANLabel($account); |
|
827 | - |
|
828 | - if (! empty($account->iban)) |
|
829 | - { |
|
830 | - //Remove whitespaces to ensure we are dealing with the format we expect |
|
831 | - $ibanDisplay_temp = str_replace(' ', '', $outputlangs->convToOutputCharset($account->iban)); |
|
832 | - $ibanDisplay = ""; |
|
833 | - |
|
834 | - $nbIbanDisplay_temp = dol_strlen($ibanDisplay_temp); |
|
835 | - for ($i = 0; $i < $nbIbanDisplay_temp; $i++) |
|
836 | - { |
|
837 | - $ibanDisplay .= $ibanDisplay_temp[$i]; |
|
838 | - if($i%4 == 3 && $i > 0) $ibanDisplay .= " "; |
|
839 | - } |
|
840 | - |
|
841 | - $pdf->SetFont('','B',$default_font_size - 3); |
|
842 | - $pdf->SetXY($curx, $cury); |
|
843 | - $pdf->MultiCell(100, 3, $outputlangs->transnoentities($ibankey).': ' . $ibanDisplay, 0, 'L', 0); |
|
844 | - $cury+=3; |
|
845 | - } |
|
846 | - |
|
847 | - if (! empty($account->bic)) |
|
848 | - { |
|
849 | - $pdf->SetFont('','B',$default_font_size - 3); |
|
850 | - $pdf->SetXY($curx, $cury); |
|
851 | - $pdf->MultiCell(100, 3, $outputlangs->transnoentities($bickey).': ' . $outputlangs->convToOutputCharset($account->bic), 0, 'L', 0); |
|
852 | - } |
|
853 | - |
|
854 | - return $pdf->getY(); |
|
694 | + global $mysoc, $conf; |
|
695 | + |
|
696 | + require_once DOL_DOCUMENT_ROOT.'/core/class/html.formbank.class.php'; |
|
697 | + |
|
698 | + $diffsizetitle=(empty($conf->global->PDF_DIFFSIZE_TITLE)?3:$conf->global->PDF_DIFFSIZE_TITLE); |
|
699 | + $diffsizecontent=(empty($conf->global->PDF_DIFFSIZE_CONTENT)?4:$conf->global->PDF_DIFFSIZE_CONTENT); |
|
700 | + $pdf->SetXY($curx, $cury); |
|
701 | + |
|
702 | + if (empty($onlynumber)) |
|
703 | + { |
|
704 | + $pdf->SetFont('','B',$default_font_size - $diffsizetitle); |
|
705 | + $pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByTransferOnThisBankAccount').':', 0, 'L', 0); |
|
706 | + $cury+=4; |
|
707 | + } |
|
708 | + |
|
709 | + $outputlangs->load("banks"); |
|
710 | + |
|
711 | + // Use correct name of bank id according to country |
|
712 | + $bickey="BICNumber"; |
|
713 | + if ($account->getCountryCode() == 'IN') $bickey="SWIFT"; |
|
714 | + |
|
715 | + // Get format of bank account according to its country |
|
716 | + $usedetailedbban=$account->useDetailedBBAN(); |
|
717 | + |
|
718 | + //$onlynumber=0; $usedetailedbban=1; // For tests |
|
719 | + if ($usedetailedbban) |
|
720 | + { |
|
721 | + $savcurx=$curx; |
|
722 | + |
|
723 | + if (empty($onlynumber)) |
|
724 | + { |
|
725 | + $pdf->SetFont('','',$default_font_size - $diffsizecontent); |
|
726 | + $pdf->SetXY($curx, $cury); |
|
727 | + $pdf->MultiCell(100, 3, $outputlangs->transnoentities("Bank").': ' . $outputlangs->convToOutputCharset($account->bank), 0, 'L', 0); |
|
728 | + $cury+=3; |
|
729 | + } |
|
730 | + |
|
731 | + if (empty($conf->global->PDF_BANK_HIDE_NUMBER_SHOW_ONLY_BICIBAN)) // Note that some countries still need bank number, BIC/IBAN not enougth for them |
|
732 | + { |
|
733 | + // Note: |
|
734 | + // bank = code_banque (FR), sort code (GB, IR. Example: 12-34-56) |
|
735 | + // desk = code guichet (FR), used only when $usedetailedbban = 1 |
|
736 | + // number = account number |
|
737 | + // key = check control key used only when $usedetailedbban = 1 |
|
738 | + if (empty($onlynumber)) $pdf->line($curx+1, $cury+1, $curx+1, $cury+6); |
|
739 | + |
|
740 | + |
|
741 | + foreach ($account->getFieldsToShow() as $val) |
|
742 | + { |
|
743 | + $pdf->SetXY($curx, $cury+4); |
|
744 | + $pdf->SetFont('','',$default_font_size - 3); |
|
745 | + |
|
746 | + if ($val == 'BankCode') { |
|
747 | + // Bank code |
|
748 | + $tmplength = 18; |
|
749 | + $content = $account->code_banque; |
|
750 | + } elseif ($val == 'DeskCode') { |
|
751 | + // Desk |
|
752 | + $tmplength = 18; |
|
753 | + $content = $account->code_guichet; |
|
754 | + } elseif ($val == 'BankAccountNumber') { |
|
755 | + // Number |
|
756 | + $tmplength = 24; |
|
757 | + $content = $account->number; |
|
758 | + } elseif ($val == 'BankAccountNumberKey') { |
|
759 | + // Key |
|
760 | + $tmplength = 15; |
|
761 | + $content = $account->cle_rib; |
|
762 | + }elseif ($val == 'IBAN' || $val == 'BIC') { |
|
763 | + // Key |
|
764 | + $tmplength = 0; |
|
765 | + $content = ''; |
|
766 | + } else { |
|
767 | + dol_print_error($account->db, 'Unexpected value for getFieldsToShow: '.$val); |
|
768 | + break; |
|
769 | + } |
|
770 | + |
|
771 | + $pdf->MultiCell($tmplength, 3, $outputlangs->convToOutputCharset($content), 0, 'C', 0); |
|
772 | + $pdf->SetXY($curx, $cury + 1); |
|
773 | + $curx += $tmplength; |
|
774 | + $pdf->SetFont('', 'B', $default_font_size - $diffsizecontent); |
|
775 | + $pdf->MultiCell($tmplength, 3, $outputlangs->transnoentities($val), 0, 'C', 0); |
|
776 | + if (empty($onlynumber)) { |
|
777 | + $pdf->line($curx, $cury + 1, $curx, $cury + 7); |
|
778 | + } |
|
779 | + } |
|
780 | + |
|
781 | + $curx=$savcurx; |
|
782 | + $cury+=8; |
|
783 | + } |
|
784 | + } |
|
785 | + else |
|
786 | + { |
|
787 | + $pdf->SetFont('','B',$default_font_size - $diffsizecontent); |
|
788 | + $pdf->SetXY($curx, $cury); |
|
789 | + $pdf->MultiCell(100, 3, $outputlangs->transnoentities("Bank").': ' . $outputlangs->convToOutputCharset($account->bank), 0, 'L', 0); |
|
790 | + $cury+=3; |
|
791 | + |
|
792 | + $pdf->SetFont('','B',$default_font_size - $diffsizecontent); |
|
793 | + $pdf->SetXY($curx, $cury); |
|
794 | + $pdf->MultiCell(100, 3, $outputlangs->transnoentities("BankAccountNumber").': ' . $outputlangs->convToOutputCharset($account->number), 0, 'L', 0); |
|
795 | + $cury+=3; |
|
796 | + |
|
797 | + if ($diffsizecontent <= 2) $cury+=1; |
|
798 | + } |
|
799 | + |
|
800 | + $pdf->SetFont('','',$default_font_size - $diffsizecontent); |
|
801 | + |
|
802 | + if (empty($onlynumber) && ! empty($account->domiciliation)) |
|
803 | + { |
|
804 | + $pdf->SetXY($curx, $cury); |
|
805 | + $val=$outputlangs->transnoentities("Residence").': ' . $outputlangs->convToOutputCharset($account->domiciliation); |
|
806 | + $pdf->MultiCell(100, 3, $val, 0, 'L', 0); |
|
807 | + //$nboflines=dol_nboflines_bis($val,120); |
|
808 | + //$cury+=($nboflines*3)+2; |
|
809 | + $tmpy=$pdf->getStringHeight(100, $val); |
|
810 | + $cury+=$tmpy; |
|
811 | + } |
|
812 | + |
|
813 | + if (! empty($account->proprio)) |
|
814 | + { |
|
815 | + $pdf->SetXY($curx, $cury); |
|
816 | + $val=$outputlangs->transnoentities("BankAccountOwner").': ' . $outputlangs->convToOutputCharset($account->proprio); |
|
817 | + $pdf->MultiCell(100, 3, $val, 0, 'L', 0); |
|
818 | + $tmpy=$pdf->getStringHeight(100, $val); |
|
819 | + $cury+=$tmpy; |
|
820 | + $cur+=1; |
|
821 | + } |
|
822 | + |
|
823 | + else if (! $usedetailedbban) $cury+=1; |
|
824 | + |
|
825 | + // Use correct name of bank id according to country |
|
826 | + $ibankey = FormBank::getIBANLabel($account); |
|
827 | + |
|
828 | + if (! empty($account->iban)) |
|
829 | + { |
|
830 | + //Remove whitespaces to ensure we are dealing with the format we expect |
|
831 | + $ibanDisplay_temp = str_replace(' ', '', $outputlangs->convToOutputCharset($account->iban)); |
|
832 | + $ibanDisplay = ""; |
|
833 | + |
|
834 | + $nbIbanDisplay_temp = dol_strlen($ibanDisplay_temp); |
|
835 | + for ($i = 0; $i < $nbIbanDisplay_temp; $i++) |
|
836 | + { |
|
837 | + $ibanDisplay .= $ibanDisplay_temp[$i]; |
|
838 | + if($i%4 == 3 && $i > 0) $ibanDisplay .= " "; |
|
839 | + } |
|
840 | + |
|
841 | + $pdf->SetFont('','B',$default_font_size - 3); |
|
842 | + $pdf->SetXY($curx, $cury); |
|
843 | + $pdf->MultiCell(100, 3, $outputlangs->transnoentities($ibankey).': ' . $ibanDisplay, 0, 'L', 0); |
|
844 | + $cury+=3; |
|
845 | + } |
|
846 | + |
|
847 | + if (! empty($account->bic)) |
|
848 | + { |
|
849 | + $pdf->SetFont('','B',$default_font_size - 3); |
|
850 | + $pdf->SetXY($curx, $cury); |
|
851 | + $pdf->MultiCell(100, 3, $outputlangs->transnoentities($bickey).': ' . $outputlangs->convToOutputCharset($account->bic), 0, 'L', 0); |
|
852 | + } |
|
853 | + |
|
854 | + return $pdf->getY(); |
|
855 | 855 | } |
856 | 856 | |
857 | 857 | /** |
@@ -871,235 +871,235 @@ discard block |
||
871 | 871 | */ |
872 | 872 | function pdf_pagefoot(&$pdf,$outputlangs,$paramfreetext,$fromcompany,$marge_basse,$marge_gauche,$page_hauteur,$object,$showdetails=0,$hidefreetext=0) |
873 | 873 | { |
874 | - global $conf,$user,$mysoc; |
|
875 | - |
|
876 | - $outputlangs->load("dict"); |
|
877 | - $line=''; |
|
878 | - |
|
879 | - $dims=$pdf->getPageDimensions(); |
|
880 | - |
|
881 | - // Line of free text |
|
882 | - if (empty($hidefreetext) && ! empty($conf->global->$paramfreetext)) |
|
883 | - { |
|
884 | - $substitutionarray=pdf_getSubstitutionArray($outputlangs, null, $object); |
|
885 | - // More substitution keys |
|
886 | - $substitutionarray['__FROM_NAME__']=$fromcompany->name; |
|
887 | - $substitutionarray['__FROM_EMAIL__']=$fromcompany->email; |
|
888 | - complete_substitutions_array($substitutionarray, $outputlangs, $object); |
|
889 | - $newfreetext=make_substitutions($conf->global->$paramfreetext, $substitutionarray, $outputlangs); |
|
890 | - |
|
891 | - // Make a change into HTML code to allow to include images from medias directory. |
|
892 | - // <img alt="" src="/dolibarr_dev/htdocs/viewimage.php?modulepart=medias&entity=1&file=image/ldestailleur_166x166.jpg" style="height:166px; width:166px" /> |
|
893 | - // become |
|
894 | - // <img alt="" src="'.DOL_DATA_ROOT.'/medias/image/ldestailleur_166x166.jpg" style="height:166px; width:166px" /> |
|
895 | - $newfreetext=preg_replace('/(<img.*src=")[^\"]*viewimage\.php[^\"]*modulepart=medias[^\"]*file=([^\"]*)("[^\/]*\/>)/', '\1'.DOL_DATA_ROOT.'/medias/\2\3', $newfreetext); |
|
896 | - |
|
897 | - $line.=$outputlangs->convToOutputCharset($newfreetext); |
|
898 | - } |
|
899 | - |
|
900 | - // First line of company infos |
|
901 | - $line1=""; $line2=""; $line3=""; $line4=""; |
|
902 | - |
|
903 | - if ($showdetails == 1 || $showdetails == 3) |
|
904 | - { |
|
905 | - // Company name |
|
906 | - if ($fromcompany->name) |
|
907 | - { |
|
908 | - $line1.=($line1?" - ":"").$outputlangs->transnoentities("RegisteredOffice").": ".$fromcompany->name; |
|
909 | - } |
|
910 | - // Address |
|
911 | - if ($fromcompany->address) |
|
912 | - { |
|
913 | - $line1.=($line1?" - ":"").str_replace("\n", ", ", $fromcompany->address); |
|
914 | - } |
|
915 | - // Zip code |
|
916 | - if ($fromcompany->zip) |
|
917 | - { |
|
918 | - $line1.=($line1?" - ":"").$fromcompany->zip; |
|
919 | - } |
|
920 | - // Town |
|
921 | - if ($fromcompany->town) |
|
922 | - { |
|
923 | - $line1.=($line1?" ":"").$fromcompany->town; |
|
924 | - } |
|
925 | - // Phone |
|
926 | - if ($fromcompany->phone) |
|
927 | - { |
|
928 | - $line2.=($line2?" - ":"").$outputlangs->transnoentities("Phone").": ".$fromcompany->phone; |
|
929 | - } |
|
930 | - // Fax |
|
931 | - if ($fromcompany->fax) |
|
932 | - { |
|
933 | - $line2.=($line2?" - ":"").$outputlangs->transnoentities("Fax").": ".$fromcompany->fax; |
|
934 | - } |
|
935 | - |
|
936 | - // URL |
|
937 | - if ($fromcompany->url) |
|
938 | - { |
|
939 | - $line2.=($line2?" - ":"").$fromcompany->url; |
|
940 | - } |
|
941 | ||
942 | - if ($fromcompany->email) |
|
943 | - { |
|
944 | - $line2.=($line2?" - ":"").$fromcompany->email; |
|
945 | - } |
|
946 | - } |
|
947 | - if ($showdetails == 2 || $showdetails == 3 || ($fromcompany->country_code == 'DE')) |
|
948 | - { |
|
949 | - // Managers |
|
950 | - if ($fromcompany->managers) |
|
951 | - { |
|
952 | - $line2.=($line2?" - ":"").$fromcompany->managers; |
|
953 | - } |
|
954 | - } |
|
955 | - |
|
956 | - // Line 3 of company infos |
|
957 | - // Juridical status |
|
958 | - if ($fromcompany->forme_juridique_code) |
|
959 | - { |
|
960 | - $line3.=($line3?" - ":"").$outputlangs->convToOutputCharset(getFormeJuridiqueLabel($fromcompany->forme_juridique_code)); |
|
961 | - } |
|
962 | - // Capital |
|
963 | - if ($fromcompany->capital) |
|
964 | - { |
|
965 | - $tmpamounttoshow = price2num($fromcompany->capital); // This field is a free string |
|
966 | - if (is_numeric($tmpamounttoshow) && $tmpamounttoshow > 0) $line3.=($line3?" - ":"").$outputlangs->transnoentities("CapitalOf",price($tmpamounttoshow, 0, $outputlangs, 0, 0, 0, $conf->currency)); |
|
967 | - else $line3.=($line3?" - ":"").$outputlangs->transnoentities("CapitalOf",$tmpamounttoshow,$outputlangs); |
|
968 | - } |
|
969 | - // Prof Id 1 |
|
970 | - if ($fromcompany->idprof1 && ($fromcompany->country_code != 'FR' || ! $fromcompany->idprof2)) |
|
971 | - { |
|
972 | - $field=$outputlangs->transcountrynoentities("ProfId1",$fromcompany->country_code); |
|
973 | - if (preg_match('/\((.*)\)/i',$field,$reg)) $field=$reg[1]; |
|
974 | - $line3.=($line3?" - ":"").$field.": ".$outputlangs->convToOutputCharset($fromcompany->idprof1); |
|
975 | - } |
|
976 | - // Prof Id 2 |
|
977 | - if ($fromcompany->idprof2) |
|
978 | - { |
|
979 | - $field=$outputlangs->transcountrynoentities("ProfId2",$fromcompany->country_code); |
|
980 | - if (preg_match('/\((.*)\)/i',$field,$reg)) $field=$reg[1]; |
|
981 | - $line3.=($line3?" - ":"").$field.": ".$outputlangs->convToOutputCharset($fromcompany->idprof2); |
|
982 | - } |
|
983 | - |
|
984 | - // Line 4 of company infos |
|
985 | - // Prof Id 3 |
|
986 | - if ($fromcompany->idprof3) |
|
987 | - { |
|
988 | - $field=$outputlangs->transcountrynoentities("ProfId3",$fromcompany->country_code); |
|
989 | - if (preg_match('/\((.*)\)/i',$field,$reg)) $field=$reg[1]; |
|
990 | - $line4.=($line4?" - ":"").$field.": ".$outputlangs->convToOutputCharset($fromcompany->idprof3); |
|
991 | - } |
|
992 | - // Prof Id 4 |
|
993 | - if ($fromcompany->idprof4) |
|
994 | - { |
|
995 | - $field=$outputlangs->transcountrynoentities("ProfId4",$fromcompany->country_code); |
|
996 | - if (preg_match('/\((.*)\)/i',$field,$reg)) $field=$reg[1]; |
|
997 | - $line4.=($line4?" - ":"").$field.": ".$outputlangs->convToOutputCharset($fromcompany->idprof4); |
|
998 | - } |
|
999 | - // Prof Id 5 |
|
1000 | - if ($fromcompany->idprof5) |
|
1001 | - { |
|
1002 | - $field=$outputlangs->transcountrynoentities("ProfId5",$fromcompany->country_code); |
|
1003 | - if (preg_match('/\((.*)\)/i',$field,$reg)) $field=$reg[1]; |
|
1004 | - $line4.=($line4?" - ":"").$field.": ".$outputlangs->convToOutputCharset($fromcompany->idprof5); |
|
1005 | - } |
|
1006 | - // Prof Id 6 |
|
1007 | - if ($fromcompany->idprof6) |
|
1008 | - { |
|
1009 | - $field=$outputlangs->transcountrynoentities("ProfId6",$fromcompany->country_code); |
|
1010 | - if (preg_match('/\((.*)\)/i',$field,$reg)) $field=$reg[1]; |
|
1011 | - $line4.=($line4?" - ":"").$field.": ".$outputlangs->convToOutputCharset($fromcompany->idprof6); |
|
1012 | - } |
|
1013 | - // IntraCommunautary VAT |
|
1014 | - if ($fromcompany->tva_intra != '') |
|
1015 | - { |
|
1016 | - $line4.=($line4?" - ":"").$outputlangs->transnoentities("VATIntraShort").": ".$outputlangs->convToOutputCharset($fromcompany->tva_intra); |
|
1017 | - } |
|
1018 | - |
|
1019 | - $pdf->SetFont('','',7); |
|
1020 | - $pdf->SetDrawColor(224,224,224); |
|
1021 | - |
|
1022 | - // The start of the bottom of this page footer is positioned according to # of lines |
|
1023 | - $freetextheight=0; |
|
1024 | - if ($line) // Free text |
|
1025 | - { |
|
1026 | - //$line="sample text<br>\nfd<strong>sf</strong>sdf<br>\nghfghg<br>"; |
|
1027 | - if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) |
|
1028 | - { |
|
1029 | - $width=20000; $align='L'; // By default, ask a manual break: We use a large value 20000, to not have automatic wrap. This make user understand, he need to add CR on its text. |
|
1030 | - if (! empty($conf->global->MAIN_USE_AUTOWRAP_ON_FREETEXT)) { |
|
1031 | - $width=200; $align='C'; |
|
1032 | - } |
|
1033 | - $freetextheight=$pdf->getStringHeight($width,$line); |
|
1034 | - } |
|
1035 | - else |
|
1036 | - { |
|
874 | + global $conf,$user,$mysoc; |
|
875 | + |
|
876 | + $outputlangs->load("dict"); |
|
877 | + $line=''; |
|
878 | + |
|
879 | + $dims=$pdf->getPageDimensions(); |
|
880 | + |
|
881 | + // Line of free text |
|
882 | + if (empty($hidefreetext) && ! empty($conf->global->$paramfreetext)) |
|
883 | + { |
|
884 | + $substitutionarray=pdf_getSubstitutionArray($outputlangs, null, $object); |
|
885 | + // More substitution keys |
|
886 | + $substitutionarray['__FROM_NAME__']=$fromcompany->name; |
|
887 | + $substitutionarray['__FROM_EMAIL__']=$fromcompany->email; |
|
888 | + complete_substitutions_array($substitutionarray, $outputlangs, $object); |
|
889 | + $newfreetext=make_substitutions($conf->global->$paramfreetext, $substitutionarray, $outputlangs); |
|
890 | + |
|
891 | + // Make a change into HTML code to allow to include images from medias directory. |
|
892 | + // <img alt="" src="/dolibarr_dev/htdocs/viewimage.php?modulepart=medias&entity=1&file=image/ldestailleur_166x166.jpg" style="height:166px; width:166px" /> |
|
893 | + // become |
|
894 | + // <img alt="" src="'.DOL_DATA_ROOT.'/medias/image/ldestailleur_166x166.jpg" style="height:166px; width:166px" /> |
|
895 | + $newfreetext=preg_replace('/(<img.*src=")[^\"]*viewimage\.php[^\"]*modulepart=medias[^\"]*file=([^\"]*)("[^\/]*\/>)/', '\1'.DOL_DATA_ROOT.'/medias/\2\3', $newfreetext); |
|
896 | + |
|
897 | + $line.=$outputlangs->convToOutputCharset($newfreetext); |
|
898 | + } |
|
899 | + |
|
900 | + // First line of company infos |
|
901 | + $line1=""; $line2=""; $line3=""; $line4=""; |
|
902 | + |
|
903 | + if ($showdetails == 1 || $showdetails == 3) |
|
904 | + { |
|
905 | + // Company name |
|
906 | + if ($fromcompany->name) |
|
907 | + { |
|
908 | + $line1.=($line1?" - ":"").$outputlangs->transnoentities("RegisteredOffice").": ".$fromcompany->name; |
|
909 | + } |
|
910 | + // Address |
|
911 | + if ($fromcompany->address) |
|
912 | + { |
|
913 | + $line1.=($line1?" - ":"").str_replace("\n", ", ", $fromcompany->address); |
|
914 | + } |
|
915 | + // Zip code |
|
916 | + if ($fromcompany->zip) |
|
917 | + { |
|
918 | + $line1.=($line1?" - ":"").$fromcompany->zip; |
|
919 | + } |
|
920 | + // Town |
|
921 | + if ($fromcompany->town) |
|
922 | + { |
|
923 | + $line1.=($line1?" ":"").$fromcompany->town; |
|
924 | + } |
|
925 | + // Phone |
|
926 | + if ($fromcompany->phone) |
|
927 | + { |
|
928 | + $line2.=($line2?" - ":"").$outputlangs->transnoentities("Phone").": ".$fromcompany->phone; |
|
929 | + } |
|
930 | + // Fax |
|
931 | + if ($fromcompany->fax) |
|
932 | + { |
|
933 | + $line2.=($line2?" - ":"").$outputlangs->transnoentities("Fax").": ".$fromcompany->fax; |
|
934 | + } |
|
935 | + |
|
936 | + // URL |
|
937 | + if ($fromcompany->url) |
|
938 | + { |
|
939 | + $line2.=($line2?" - ":"").$fromcompany->url; |
|
940 | + } |
|
941 | ||
942 | + if ($fromcompany->email) |
|
943 | + { |
|
944 | + $line2.=($line2?" - ":"").$fromcompany->email; |
|
945 | + } |
|
946 | + } |
|
947 | + if ($showdetails == 2 || $showdetails == 3 || ($fromcompany->country_code == 'DE')) |
|
948 | + { |
|
949 | + // Managers |
|
950 | + if ($fromcompany->managers) |
|
951 | + { |
|
952 | + $line2.=($line2?" - ":"").$fromcompany->managers; |
|
953 | + } |
|
954 | + } |
|
955 | + |
|
956 | + // Line 3 of company infos |
|
957 | + // Juridical status |
|
958 | + if ($fromcompany->forme_juridique_code) |
|
959 | + { |
|
960 | + $line3.=($line3?" - ":"").$outputlangs->convToOutputCharset(getFormeJuridiqueLabel($fromcompany->forme_juridique_code)); |
|
961 | + } |
|
962 | + // Capital |
|
963 | + if ($fromcompany->capital) |
|
964 | + { |
|
965 | + $tmpamounttoshow = price2num($fromcompany->capital); // This field is a free string |
|
966 | + if (is_numeric($tmpamounttoshow) && $tmpamounttoshow > 0) $line3.=($line3?" - ":"").$outputlangs->transnoentities("CapitalOf",price($tmpamounttoshow, 0, $outputlangs, 0, 0, 0, $conf->currency)); |
|
967 | + else $line3.=($line3?" - ":"").$outputlangs->transnoentities("CapitalOf",$tmpamounttoshow,$outputlangs); |
|
968 | + } |
|
969 | + // Prof Id 1 |
|
970 | + if ($fromcompany->idprof1 && ($fromcompany->country_code != 'FR' || ! $fromcompany->idprof2)) |
|
971 | + { |
|
972 | + $field=$outputlangs->transcountrynoentities("ProfId1",$fromcompany->country_code); |
|
973 | + if (preg_match('/\((.*)\)/i',$field,$reg)) $field=$reg[1]; |
|
974 | + $line3.=($line3?" - ":"").$field.": ".$outputlangs->convToOutputCharset($fromcompany->idprof1); |
|
975 | + } |
|
976 | + // Prof Id 2 |
|
977 | + if ($fromcompany->idprof2) |
|
978 | + { |
|
979 | + $field=$outputlangs->transcountrynoentities("ProfId2",$fromcompany->country_code); |
|
980 | + if (preg_match('/\((.*)\)/i',$field,$reg)) $field=$reg[1]; |
|
981 | + $line3.=($line3?" - ":"").$field.": ".$outputlangs->convToOutputCharset($fromcompany->idprof2); |
|
982 | + } |
|
983 | + |
|
984 | + // Line 4 of company infos |
|
985 | + // Prof Id 3 |
|
986 | + if ($fromcompany->idprof3) |
|
987 | + { |
|
988 | + $field=$outputlangs->transcountrynoentities("ProfId3",$fromcompany->country_code); |
|
989 | + if (preg_match('/\((.*)\)/i',$field,$reg)) $field=$reg[1]; |
|
990 | + $line4.=($line4?" - ":"").$field.": ".$outputlangs->convToOutputCharset($fromcompany->idprof3); |
|
991 | + } |
|
992 | + // Prof Id 4 |
|
993 | + if ($fromcompany->idprof4) |
|
994 | + { |
|
995 | + $field=$outputlangs->transcountrynoentities("ProfId4",$fromcompany->country_code); |
|
996 | + if (preg_match('/\((.*)\)/i',$field,$reg)) $field=$reg[1]; |
|
997 | + $line4.=($line4?" - ":"").$field.": ".$outputlangs->convToOutputCharset($fromcompany->idprof4); |
|
998 | + } |
|
999 | + // Prof Id 5 |
|
1000 | + if ($fromcompany->idprof5) |
|
1001 | + { |
|
1002 | + $field=$outputlangs->transcountrynoentities("ProfId5",$fromcompany->country_code); |
|
1003 | + if (preg_match('/\((.*)\)/i',$field,$reg)) $field=$reg[1]; |
|
1004 | + $line4.=($line4?" - ":"").$field.": ".$outputlangs->convToOutputCharset($fromcompany->idprof5); |
|
1005 | + } |
|
1006 | + // Prof Id 6 |
|
1007 | + if ($fromcompany->idprof6) |
|
1008 | + { |
|
1009 | + $field=$outputlangs->transcountrynoentities("ProfId6",$fromcompany->country_code); |
|
1010 | + if (preg_match('/\((.*)\)/i',$field,$reg)) $field=$reg[1]; |
|
1011 | + $line4.=($line4?" - ":"").$field.": ".$outputlangs->convToOutputCharset($fromcompany->idprof6); |
|
1012 | + } |
|
1013 | + // IntraCommunautary VAT |
|
1014 | + if ($fromcompany->tva_intra != '') |
|
1015 | + { |
|
1016 | + $line4.=($line4?" - ":"").$outputlangs->transnoentities("VATIntraShort").": ".$outputlangs->convToOutputCharset($fromcompany->tva_intra); |
|
1017 | + } |
|
1018 | + |
|
1019 | + $pdf->SetFont('','',7); |
|
1020 | + $pdf->SetDrawColor(224,224,224); |
|
1021 | + |
|
1022 | + // The start of the bottom of this page footer is positioned according to # of lines |
|
1023 | + $freetextheight=0; |
|
1024 | + if ($line) // Free text |
|
1025 | + { |
|
1026 | + //$line="sample text<br>\nfd<strong>sf</strong>sdf<br>\nghfghg<br>"; |
|
1027 | + if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) |
|
1028 | + { |
|
1029 | + $width=20000; $align='L'; // By default, ask a manual break: We use a large value 20000, to not have automatic wrap. This make user understand, he need to add CR on its text. |
|
1030 | + if (! empty($conf->global->MAIN_USE_AUTOWRAP_ON_FREETEXT)) { |
|
1031 | + $width=200; $align='C'; |
|
1032 | + } |
|
1033 | + $freetextheight=$pdf->getStringHeight($width,$line); |
|
1034 | + } |
|
1035 | + else |
|
1036 | + { |
|
1037 | 1037 | $freetextheight=pdfGetHeightForHtmlContent($pdf,dol_htmlentitiesbr($line, 1, 'UTF-8', 0)); // New method (works for HTML content) |
1038 | 1038 | //print '<br>'.$freetextheight;exit; |
1039 | - } |
|
1040 | - } |
|
1039 | + } |
|
1040 | + } |
|
1041 | 1041 | |
1042 | - $marginwithfooter=$marge_basse + $freetextheight + (! empty($line1)?3:0) + (! empty($line2)?3:0) + (! empty($line3)?3:0) + (! empty($line4)?3:0); |
|
1043 | - $posy=$marginwithfooter+0; |
|
1042 | + $marginwithfooter=$marge_basse + $freetextheight + (! empty($line1)?3:0) + (! empty($line2)?3:0) + (! empty($line3)?3:0) + (! empty($line4)?3:0); |
|
1043 | + $posy=$marginwithfooter+0; |
|
1044 | 1044 | |
1045 | - if ($line) // Free text |
|
1046 | - { |
|
1047 | - $pdf->SetXY($dims['lm'],-$posy); |
|
1048 | - if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) // by default |
|
1049 | - { |
|
1045 | + if ($line) // Free text |
|
1046 | + { |
|
1047 | + $pdf->SetXY($dims['lm'],-$posy); |
|
1048 | + if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) // by default |
|
1049 | + { |
|
1050 | 1050 | $pdf->MultiCell(0, 3, $line, 0, $align, 0); |
1051 | - } |
|
1052 | - else |
|
1053 | - { |
|
1051 | + } |
|
1052 | + else |
|
1053 | + { |
|
1054 | 1054 | $pdf->writeHTMLCell($pdf->page_largeur - $pdf->margin_left - $pdf->margin_right, $freetextheight, $dims['lm'], $dims['hk']-$marginwithfooter, dol_htmlentitiesbr($line, 1, 'UTF-8', 0)); |
1055 | - } |
|
1056 | - $posy-=$freetextheight; |
|
1057 | - } |
|
1058 | - |
|
1059 | - $pdf->SetY(-$posy); |
|
1060 | - $pdf->line($dims['lm'], $dims['hk']-$posy, $dims['wk']-$dims['rm'], $dims['hk']-$posy); |
|
1061 | - $posy--; |
|
1062 | - |
|
1063 | - if (! empty($line1)) |
|
1064 | - { |
|
1065 | - $pdf->SetFont('','B',7); |
|
1066 | - $pdf->SetXY($dims['lm'],-$posy); |
|
1067 | - $pdf->MultiCell($dims['wk']-$dims['rm']-$dims['lm'], 2, $line1, 0, 'C', 0); |
|
1068 | - $posy-=3; |
|
1069 | - $pdf->SetFont('','',7); |
|
1070 | - } |
|
1071 | - |
|
1072 | - if (! empty($line2)) |
|
1073 | - { |
|
1074 | - $pdf->SetFont('','B',7); |
|
1075 | - $pdf->SetXY($dims['lm'],-$posy); |
|
1076 | - $pdf->MultiCell($dims['wk']-$dims['rm']-$dims['lm'], 2, $line2, 0, 'C', 0); |
|
1077 | - $posy-=3; |
|
1078 | - $pdf->SetFont('','',7); |
|
1079 | - } |
|
1080 | - |
|
1081 | - if (! empty($line3)) |
|
1082 | - { |
|
1083 | - $pdf->SetXY($dims['lm'],-$posy); |
|
1084 | - $pdf->MultiCell($dims['wk']-$dims['rm']-$dims['lm'], 2, $line3, 0, 'C', 0); |
|
1085 | - } |
|
1086 | - |
|
1087 | - if (! empty($line4)) |
|
1088 | - { |
|
1089 | - $posy-=3; |
|
1090 | - $pdf->SetXY($dims['lm'],-$posy); |
|
1091 | - $pdf->MultiCell($dims['wk']-$dims['rm']-$dims['lm'], 2, $line4, 0, 'C', 0); |
|
1092 | - } |
|
1093 | - |
|
1094 | - // Show page nb only on iso languages (so default Helvetica font) |
|
1095 | - if (strtolower(pdf_getPDFFont($outputlangs)) == 'helvetica') |
|
1096 | - { |
|
1097 | - $pdf->SetXY($dims['wk']-$dims['rm']-15, -$posy); |
|
1098 | - //print 'xxx'.$pdf->PageNo().'-'.$pdf->getAliasNbPages().'-'.$pdf->getAliasNumPage();exit; |
|
1099 | - $pdf->MultiCell(15, 2, $pdf->PageNo().'/'.$pdf->getAliasNbPages(), 0, 'R', 0); |
|
1100 | - } |
|
1101 | - |
|
1102 | - return $marginwithfooter; |
|
1055 | + } |
|
1056 | + $posy-=$freetextheight; |
|
1057 | + } |
|
1058 | + |
|
1059 | + $pdf->SetY(-$posy); |
|
1060 | + $pdf->line($dims['lm'], $dims['hk']-$posy, $dims['wk']-$dims['rm'], $dims['hk']-$posy); |
|
1061 | + $posy--; |
|
1062 | + |
|
1063 | + if (! empty($line1)) |
|
1064 | + { |
|
1065 | + $pdf->SetFont('','B',7); |
|
1066 | + $pdf->SetXY($dims['lm'],-$posy); |
|
1067 | + $pdf->MultiCell($dims['wk']-$dims['rm']-$dims['lm'], 2, $line1, 0, 'C', 0); |
|
1068 | + $posy-=3; |
|
1069 | + $pdf->SetFont('','',7); |
|
1070 | + } |
|
1071 | + |
|
1072 | + if (! empty($line2)) |
|
1073 | + { |
|
1074 | + $pdf->SetFont('','B',7); |
|
1075 | + $pdf->SetXY($dims['lm'],-$posy); |
|
1076 | + $pdf->MultiCell($dims['wk']-$dims['rm']-$dims['lm'], 2, $line2, 0, 'C', 0); |
|
1077 | + $posy-=3; |
|
1078 | + $pdf->SetFont('','',7); |
|
1079 | + } |
|
1080 | + |
|
1081 | + if (! empty($line3)) |
|
1082 | + { |
|
1083 | + $pdf->SetXY($dims['lm'],-$posy); |
|
1084 | + $pdf->MultiCell($dims['wk']-$dims['rm']-$dims['lm'], 2, $line3, 0, 'C', 0); |
|
1085 | + } |
|
1086 | + |
|
1087 | + if (! empty($line4)) |
|
1088 | + { |
|
1089 | + $posy-=3; |
|
1090 | + $pdf->SetXY($dims['lm'],-$posy); |
|
1091 | + $pdf->MultiCell($dims['wk']-$dims['rm']-$dims['lm'], 2, $line4, 0, 'C', 0); |
|
1092 | + } |
|
1093 | + |
|
1094 | + // Show page nb only on iso languages (so default Helvetica font) |
|
1095 | + if (strtolower(pdf_getPDFFont($outputlangs)) == 'helvetica') |
|
1096 | + { |
|
1097 | + $pdf->SetXY($dims['wk']-$dims['rm']-15, -$posy); |
|
1098 | + //print 'xxx'.$pdf->PageNo().'-'.$pdf->getAliasNbPages().'-'.$pdf->getAliasNumPage();exit; |
|
1099 | + $pdf->MultiCell(15, 2, $pdf->PageNo().'/'.$pdf->getAliasNbPages(), 0, 'R', 0); |
|
1100 | + } |
|
1101 | + |
|
1102 | + return $marginwithfooter; |
|
1103 | 1103 | } |
1104 | 1104 | |
1105 | 1105 | /** |
@@ -1118,25 +1118,25 @@ discard block |
||
1118 | 1118 | */ |
1119 | 1119 | function pdf_writeLinkedObjects(&$pdf,$object,$outputlangs,$posx,$posy,$w,$h,$align,$default_font_size) |
1120 | 1120 | { |
1121 | - $linkedobjects = pdf_getLinkedObjects($object,$outputlangs); |
|
1122 | - if (! empty($linkedobjects)) |
|
1123 | - { |
|
1124 | - foreach($linkedobjects as $linkedobject) |
|
1125 | - { |
|
1126 | - $reftoshow = $linkedobject["ref_title"].' : '.$linkedobject["ref_value"]; |
|
1127 | - if (! empty($linkedobject["date_value"])) |
|
1128 | - { |
|
1129 | - $reftoshow .= ' / '.$linkedobject["date_value"]; |
|
1130 | - } |
|
1131 | - |
|
1132 | - $posy+=3; |
|
1133 | - $pdf->SetXY($posx,$posy); |
|
1134 | - $pdf->SetFont('','', $default_font_size - 2); |
|
1135 | - $pdf->MultiCell($w, $h, $reftoshow, '', $align); |
|
1136 | - } |
|
1137 | - } |
|
1138 | - |
|
1139 | - return $pdf->getY(); |
|
1121 | + $linkedobjects = pdf_getLinkedObjects($object,$outputlangs); |
|
1122 | + if (! empty($linkedobjects)) |
|
1123 | + { |
|
1124 | + foreach($linkedobjects as $linkedobject) |
|
1125 | + { |
|
1126 | + $reftoshow = $linkedobject["ref_title"].' : '.$linkedobject["ref_value"]; |
|
1127 | + if (! empty($linkedobject["date_value"])) |
|
1128 | + { |
|
1129 | + $reftoshow .= ' / '.$linkedobject["date_value"]; |
|
1130 | + } |
|
1131 | + |
|
1132 | + $posy+=3; |
|
1133 | + $pdf->SetXY($posx,$posy); |
|
1134 | + $pdf->SetFont('','', $default_font_size - 2); |
|
1135 | + $pdf->MultiCell($w, $h, $reftoshow, '', $align); |
|
1136 | + } |
|
1137 | + } |
|
1138 | + |
|
1139 | + return $pdf->getY(); |
|
1140 | 1140 | } |
1141 | 1141 | |
1142 | 1142 | /** |
@@ -1157,29 +1157,29 @@ discard block |
||
1157 | 1157 | */ |
1158 | 1158 | function pdf_writelinedesc(&$pdf,$object,$i,$outputlangs,$w,$h,$posx,$posy,$hideref=0,$hidedesc=0,$issupplierline=0) |
1159 | 1159 | { |
1160 | - global $db, $conf, $langs, $hookmanager; |
|
1161 | - |
|
1162 | - $reshook=0; |
|
1163 | - $result=''; |
|
1164 | - //if (is_object($hookmanager) && ( (isset($object->lines[$i]->product_type) && $object->lines[$i]->product_type == 9 && ! empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line) ) ) |
|
1165 | - if (is_object($hookmanager)) // Old code is commented on preceding line. Reproduct this test in the pdf_xxx function if you don't want your hook to run |
|
1166 | - { |
|
1167 | - $special_code = $object->lines[$i]->special_code; |
|
1168 | - if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); |
|
1169 | - $parameters = array('pdf'=>$pdf,'i'=>$i,'outputlangs'=>$outputlangs,'w'=>$w,'h'=>$h,'posx'=>$posx,'posy'=>$posy,'hideref'=>$hideref,'hidedesc'=>$hidedesc,'issupplierline'=>$issupplierline,'special_code'=>$special_code); |
|
1170 | - $action=''; |
|
1171 | - $reshook=$hookmanager->executeHooks('pdf_writelinedesc',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks |
|
1172 | - |
|
1173 | - if (!empty($hookmanager->resPrint)) $result.=$hookmanager->resPrint; |
|
1174 | - } |
|
1175 | - if (empty($reshook)) |
|
1176 | - { |
|
1177 | - $labelproductservice=pdf_getlinedesc($object,$i,$outputlangs,$hideref,$hidedesc,$issupplierline); |
|
1178 | - // Description |
|
1179 | - $pdf->writeHTMLCell($w, $h, $posx, $posy, $outputlangs->convToOutputCharset($labelproductservice), 0, 1, false, true, 'J',true); |
|
1180 | - $result.=$labelproductservice; |
|
1181 | - } |
|
1182 | - return $result; |
|
1160 | + global $db, $conf, $langs, $hookmanager; |
|
1161 | + |
|
1162 | + $reshook=0; |
|
1163 | + $result=''; |
|
1164 | + //if (is_object($hookmanager) && ( (isset($object->lines[$i]->product_type) && $object->lines[$i]->product_type == 9 && ! empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line) ) ) |
|
1165 | + if (is_object($hookmanager)) // Old code is commented on preceding line. Reproduct this test in the pdf_xxx function if you don't want your hook to run |
|
1166 | + { |
|
1167 | + $special_code = $object->lines[$i]->special_code; |
|
1168 | + if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); |
|
1169 | + $parameters = array('pdf'=>$pdf,'i'=>$i,'outputlangs'=>$outputlangs,'w'=>$w,'h'=>$h,'posx'=>$posx,'posy'=>$posy,'hideref'=>$hideref,'hidedesc'=>$hidedesc,'issupplierline'=>$issupplierline,'special_code'=>$special_code); |
|
1170 | + $action=''; |
|
1171 | + $reshook=$hookmanager->executeHooks('pdf_writelinedesc',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks |
|
1172 | + |
|
1173 | + if (!empty($hookmanager->resPrint)) $result.=$hookmanager->resPrint; |
|
1174 | + } |
|
1175 | + if (empty($reshook)) |
|
1176 | + { |
|
1177 | + $labelproductservice=pdf_getlinedesc($object,$i,$outputlangs,$hideref,$hidedesc,$issupplierline); |
|
1178 | + // Description |
|
1179 | + $pdf->writeHTMLCell($w, $h, $posx, $posy, $outputlangs->convToOutputCharset($labelproductservice), 0, 1, false, true, 'J',true); |
|
1180 | + $result.=$labelproductservice; |
|
1181 | + } |
|
1182 | + return $result; |
|
1183 | 1183 | } |
1184 | 1184 | |
1185 | 1185 | /** |
@@ -1195,222 +1195,222 @@ discard block |
||
1195 | 1195 | */ |
1196 | 1196 | function pdf_getlinedesc($object,$i,$outputlangs,$hideref=0,$hidedesc=0,$issupplierline=0) |
1197 | 1197 | { |
1198 | - global $db, $conf, $langs; |
|
1199 | - |
|
1200 | - $idprod=(! empty($object->lines[$i]->fk_product)?$object->lines[$i]->fk_product:false); |
|
1201 | - $label=(! empty($object->lines[$i]->label)?$object->lines[$i]->label:(! empty($object->lines[$i]->product_label)?$object->lines[$i]->product_label:'')); |
|
1202 | - $desc=(! empty($object->lines[$i]->desc)?$object->lines[$i]->desc:(! empty($object->lines[$i]->description)?$object->lines[$i]->description:'')); |
|
1203 | - $ref_supplier=(! empty($object->lines[$i]->ref_supplier)?$object->lines[$i]->ref_supplier:(! empty($object->lines[$i]->ref_fourn)?$object->lines[$i]->ref_fourn:'')); // TODO Not yet saved for supplier invoices, only supplier orders |
|
1204 | - $note=(! empty($object->lines[$i]->note)?$object->lines[$i]->note:''); |
|
1205 | - $dbatch=(! empty($object->lines[$i]->detail_batch)?$object->lines[$i]->detail_batch:false); |
|
1206 | - |
|
1207 | - if ($issupplierline) |
|
1208 | - { |
|
1209 | - include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php'; |
|
1210 | - $prodser = new ProductFournisseur($db); |
|
1211 | - } |
|
1212 | - else |
|
1213 | - { |
|
1214 | - include_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; |
|
1215 | - $prodser = new Product($db); |
|
1216 | - } |
|
1217 | - |
|
1218 | - if ($idprod) |
|
1219 | - { |
|
1220 | - $prodser->fetch($idprod); |
|
1221 | - // If a predefined product and multilang and on other lang, we renamed label with label translated |
|
1222 | - if (! empty($conf->global->MAIN_MULTILANGS) && ($outputlangs->defaultlang != $langs->defaultlang)) |
|
1223 | - { |
|
1224 | - $translatealsoifmodified=(! empty($conf->global->MAIN_MULTILANG_TRANSLATE_EVEN_IF_MODIFIED)); // By default if value was modified manually, we keep it (no translation because we don't have it) |
|
1225 | - |
|
1226 | - // TODO Instead of making a compare to see if param was modified, check that content contains reference translation. If yes, add the added part to the new translation |
|
1227 | - // ($textwasmodified is replaced with $textwasmodifiedorcompleted and we add completion). |
|
1228 | - |
|
1229 | - // Set label |
|
1230 | - // If we want another language, and if label is same than default language (we did force it to a specific value), we can use translation. |
|
1231 | - //var_dump($outputlangs->defaultlang.' - '.$langs->defaultlang.' - '.$label.' - '.$prodser->label);exit; |
|
1232 | - $textwasmodified=($label == $prodser->label); |
|
1233 | - if (! empty($prodser->multilangs[$outputlangs->defaultlang]["label"]) && ($textwasmodified || $translatealsoifmodified)) $label=$prodser->multilangs[$outputlangs->defaultlang]["label"]; |
|
1234 | - |
|
1235 | - // Set desc |
|
1236 | - // Manage HTML entities description test because $prodser->description is store with htmlentities but $desc no |
|
1237 | - $textwasmodified=false; |
|
1238 | - if (!empty($desc) && dol_textishtml($desc) && !empty($prodser->description) && dol_textishtml($prodser->description)) { |
|
1239 | - $textwasmodified=(strpos(dol_html_entity_decode($desc,ENT_QUOTES | ENT_HTML401),dol_html_entity_decode($prodser->description,ENT_QUOTES | ENT_HTML401))!==false); |
|
1240 | - } else { |
|
1241 | - $textwasmodified=($desc == $prodser->description); |
|
1242 | - } |
|
1243 | - if (! empty($prodser->multilangs[$outputlangs->defaultlang]["description"]) && ($textwasmodified || $translatealsoifmodified)) $desc=$prodser->multilangs[$outputlangs->defaultlang]["description"]; |
|
1244 | - |
|
1245 | - // Set note |
|
1246 | - $textwasmodified=($note == $prodser->note); |
|
1247 | - if (! empty($prodser->multilangs[$outputlangs->defaultlang]["note"]) && ($textwasmodified || $translatealsoifmodified)) $note=$prodser->multilangs[$outputlangs->defaultlang]["note"]; |
|
1248 | - } |
|
1249 | - } |
|
1250 | - |
|
1251 | - // Description short of product line |
|
1252 | - $libelleproduitservice=$label; |
|
1253 | - |
|
1254 | - // Description long of product line |
|
1255 | - if (! empty($desc) && ($desc != $label)) |
|
1256 | - { |
|
1257 | - if ($libelleproduitservice && empty($hidedesc)) |
|
1258 | - { |
|
1259 | - $libelleproduitservice.='__N__'; |
|
1260 | - } |
|
1261 | - |
|
1262 | - if ($desc == '(CREDIT_NOTE)' && $object->lines[$i]->fk_remise_except) |
|
1263 | - { |
|
1264 | - $discount=new DiscountAbsolute($db); |
|
1265 | - $discount->fetch($object->lines[$i]->fk_remise_except); |
|
1266 | - $sourceref=!empty($discount->discount_type)?$discount->ref_invoive_supplier_source:$discount->ref_facture_source; |
|
1267 | - $libelleproduitservice=$outputlangs->transnoentitiesnoconv("DiscountFromCreditNote",$sourceref); |
|
1268 | - } |
|
1269 | - elseif ($desc == '(DEPOSIT)' && $object->lines[$i]->fk_remise_except) |
|
1270 | - { |
|
1271 | - $discount=new DiscountAbsolute($db); |
|
1272 | - $discount->fetch($object->lines[$i]->fk_remise_except); |
|
1273 | - $sourceref=!empty($discount->discount_type)?$discount->ref_invoive_supplier_source:$discount->ref_facture_source; |
|
1274 | - $libelleproduitservice=$outputlangs->transnoentitiesnoconv("DiscountFromDeposit",$sourceref); |
|
1275 | - // Add date of deposit |
|
1276 | - if (! empty($conf->global->INVOICE_ADD_DEPOSIT_DATE)) echo ' ('.dol_print_date($discount->datec,'day','',$outputlangs).')'; |
|
1277 | - } |
|
1278 | - if ($desc == '(EXCESS RECEIVED)' && $object->lines[$i]->fk_remise_except) |
|
1279 | - { |
|
1280 | - $discount=new DiscountAbsolute($db); |
|
1281 | - $discount->fetch($object->lines[$i]->fk_remise_except); |
|
1282 | - $libelleproduitservice=$outputlangs->transnoentitiesnoconv("DiscountFromExcessReceived",$discount->ref_facture_source); |
|
1283 | - } |
|
1284 | - elseif ($desc == '(EXCESS PAID)' && $object->lines[$i]->fk_remise_except) |
|
1285 | - { |
|
1286 | - $discount=new DiscountAbsolute($db); |
|
1287 | - $discount->fetch($object->lines[$i]->fk_remise_except); |
|
1288 | - $libelleproduitservice=$outputlangs->transnoentitiesnoconv("DiscountFromExcessPaid",$discount->ref_invoice_supplier_source); |
|
1289 | - } |
|
1290 | - else |
|
1291 | - { |
|
1292 | - if ($idprod) |
|
1293 | - { |
|
1294 | - if (empty($hidedesc)) |
|
1295 | - { |
|
1296 | - if (!empty($conf->global->MAIN_DOCUMENTS_DESCRIPTION_FIRST)) |
|
1297 | - { |
|
1298 | - $libelleproduitservice=$desc."\n".$libelleproduitservice; |
|
1299 | - } |
|
1300 | - else |
|
1301 | - { |
|
1302 | - $libelleproduitservice.=$desc; |
|
1303 | - } |
|
1304 | - } |
|
1305 | - } |
|
1306 | - else |
|
1307 | - { |
|
1308 | - $libelleproduitservice.=$desc; |
|
1309 | - } |
|
1310 | - } |
|
1311 | - } |
|
1312 | - |
|
1313 | - // We add ref of product (and supplier ref if defined) |
|
1314 | - $prefix_prodserv = ""; |
|
1315 | - $ref_prodserv = ""; |
|
1316 | - if (! empty($conf->global->PRODUCT_ADD_TYPE_IN_DOCUMENTS)) // In standard mode, we do not show this |
|
1317 | - { |
|
1318 | - if ($prodser->isService()) |
|
1319 | - { |
|
1320 | - $prefix_prodserv = $outputlangs->transnoentitiesnoconv("Service")." "; |
|
1321 | - } |
|
1322 | - else |
|
1323 | - { |
|
1324 | - $prefix_prodserv = $outputlangs->transnoentitiesnoconv("Product")." "; |
|
1325 | - } |
|
1326 | - } |
|
1327 | - |
|
1328 | - if (empty($hideref)) |
|
1329 | - { |
|
1330 | - if ($issupplierline) |
|
1331 | - { |
|
1332 | - if ($conf->global->PDF_HIDE_PRODUCT_REF_IN_SUPPLIER_LINES == 1) |
|
1333 | - $ref_prodserv = $ref_supplier; |
|
1334 | - elseif ($conf->global->PDF_HIDE_PRODUCT_REF_IN_SUPPLIER_LINES == 2) |
|
1335 | - $ref_prodserv = $ref_supplier. ' ('.$outputlangs->transnoentitiesnoconv("InternalRef").' '.$prodser->ref.')'; |
|
1336 | - else // Common case |
|
1337 | - { |
|
1338 | - $ref_prodserv = $prodser->ref; // Show local ref |
|
1339 | - if ($ref_supplier) $ref_prodserv.= ($prodser->ref?' (':'').$outputlangs->transnoentitiesnoconv("SupplierRef").' '.$ref_supplier.($prodser->ref?')':''); |
|
1340 | - } |
|
1341 | - } |
|
1342 | - else |
|
1343 | - { |
|
1344 | - $ref_prodserv = $prodser->ref; // Show local ref only |
|
1345 | - } |
|
1346 | - |
|
1347 | - if (! empty($libelleproduitservice) && ! empty($ref_prodserv)) $ref_prodserv .= " - "; |
|
1348 | - } |
|
1349 | - |
|
1350 | - if(!empty($ref_prodserv) && !empty($conf->global->ADD_HTML_FORMATING_INTO_DESC_DOC)){ $ref_prodserv = '<b>'.$ref_prodserv.'</b>'; } |
|
1351 | - $libelleproduitservice=$prefix_prodserv.$ref_prodserv.$libelleproduitservice; |
|
1352 | - |
|
1353 | - // Add an additional description for the category products |
|
1354 | - if (! empty($conf->global->CATEGORY_ADD_DESC_INTO_DOC) && $idprod && ! empty($conf->categorie->enabled)) |
|
1355 | - { |
|
1356 | - include_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; |
|
1357 | - $categstatic=new Categorie($db); |
|
1358 | - // recovering the list of all the categories linked to product |
|
1359 | - $tblcateg=$categstatic->containing($idprod, Categorie::TYPE_PRODUCT); |
|
1360 | - foreach ($tblcateg as $cate) |
|
1361 | - { |
|
1362 | - // Adding the descriptions if they are filled |
|
1363 | - $desccateg=$cate->add_description; |
|
1364 | - if ($desccateg) |
|
1365 | - $libelleproduitservice.='__N__'.$desccateg; |
|
1366 | - } |
|
1367 | - } |
|
1368 | - |
|
1369 | - if (! empty($object->lines[$i]->date_start) || ! empty($object->lines[$i]->date_end)) |
|
1370 | - { |
|
1371 | - $format='day'; |
|
1372 | - // Show duration if exists |
|
1373 | - if ($object->lines[$i]->date_start && $object->lines[$i]->date_end) |
|
1374 | - { |
|
1375 | - $period='('.$outputlangs->transnoentitiesnoconv('DateFromTo',dol_print_date($object->lines[$i]->date_start, $format, false, $outputlangs),dol_print_date($object->lines[$i]->date_end, $format, false, $outputlangs)).')'; |
|
1376 | - } |
|
1377 | - if ($object->lines[$i]->date_start && ! $object->lines[$i]->date_end) |
|
1378 | - { |
|
1379 | - $period='('.$outputlangs->transnoentitiesnoconv('DateFrom',dol_print_date($object->lines[$i]->date_start, $format, false, $outputlangs)).')'; |
|
1380 | - } |
|
1381 | - if (! $object->lines[$i]->date_start && $object->lines[$i]->date_end) |
|
1382 | - { |
|
1383 | - $period='('.$outputlangs->transnoentitiesnoconv('DateUntil',dol_print_date($object->lines[$i]->date_end, $format, false, $outputlangs)).')'; |
|
1384 | - } |
|
1385 | - //print '>'.$outputlangs->charset_output.','.$period; |
|
1386 | - if(!empty($conf->global->ADD_HTML_FORMATING_INTO_DESC_DOC)){ |
|
1387 | - $libelleproduitservice.= '<b style="color:#333666;" ><em>'."__N__</b> ".$period.'</em>'; |
|
1388 | - }else{ |
|
1389 | - $libelleproduitservice.="__N__".$period; |
|
1390 | - } |
|
1391 | - //print $libelleproduitservice; |
|
1392 | - } |
|
1393 | - |
|
1394 | - if ($dbatch) |
|
1395 | - { |
|
1396 | - $format='day'; |
|
1397 | - foreach ($dbatch as $detail) |
|
1398 | - { |
|
1399 | - $dte=array(); |
|
1400 | - if ($detail->eatby) $dte[]=$outputlangs->transnoentitiesnoconv('printEatby',dol_print_date($detail->eatby, $format, false, $outputlangs)); |
|
1401 | - if ($detail->sellby) $dte[]=$outputlangs->transnoentitiesnoconv('printSellby',dol_print_date($detail->sellby, $format, false, $outputlangs)); |
|
1402 | - if ($detail->batch) $dte[]=$outputlangs->transnoentitiesnoconv('printBatch',$detail->batch); |
|
1403 | - $dte[]=$outputlangs->transnoentitiesnoconv('printQty',$detail->qty); |
|
1404 | - $libelleproduitservice.= "__N__ ".implode(" - ", $dte); |
|
1405 | - } |
|
1406 | - } |
|
1407 | - |
|
1408 | - // Now we convert \n into br |
|
1409 | - if (dol_textishtml($libelleproduitservice)) $libelleproduitservice=preg_replace('/__N__/','<br>',$libelleproduitservice); |
|
1410 | - else $libelleproduitservice=preg_replace('/__N__/',"\n",$libelleproduitservice); |
|
1411 | - $libelleproduitservice=dol_htmlentitiesbr($libelleproduitservice,1); |
|
1412 | - |
|
1413 | - return $libelleproduitservice; |
|
1198 | + global $db, $conf, $langs; |
|
1199 | + |
|
1200 | + $idprod=(! empty($object->lines[$i]->fk_product)?$object->lines[$i]->fk_product:false); |
|
1201 | + $label=(! empty($object->lines[$i]->label)?$object->lines[$i]->label:(! empty($object->lines[$i]->product_label)?$object->lines[$i]->product_label:'')); |
|
1202 | + $desc=(! empty($object->lines[$i]->desc)?$object->lines[$i]->desc:(! empty($object->lines[$i]->description)?$object->lines[$i]->description:'')); |
|
1203 | + $ref_supplier=(! empty($object->lines[$i]->ref_supplier)?$object->lines[$i]->ref_supplier:(! empty($object->lines[$i]->ref_fourn)?$object->lines[$i]->ref_fourn:'')); // TODO Not yet saved for supplier invoices, only supplier orders |
|
1204 | + $note=(! empty($object->lines[$i]->note)?$object->lines[$i]->note:''); |
|
1205 | + $dbatch=(! empty($object->lines[$i]->detail_batch)?$object->lines[$i]->detail_batch:false); |
|
1206 | + |
|
1207 | + if ($issupplierline) |
|
1208 | + { |
|
1209 | + include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php'; |
|
1210 | + $prodser = new ProductFournisseur($db); |
|
1211 | + } |
|
1212 | + else |
|
1213 | + { |
|
1214 | + include_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; |
|
1215 | + $prodser = new Product($db); |
|
1216 | + } |
|
1217 | + |
|
1218 | + if ($idprod) |
|
1219 | + { |
|
1220 | + $prodser->fetch($idprod); |
|
1221 | + // If a predefined product and multilang and on other lang, we renamed label with label translated |
|
1222 | + if (! empty($conf->global->MAIN_MULTILANGS) && ($outputlangs->defaultlang != $langs->defaultlang)) |
|
1223 | + { |
|
1224 | + $translatealsoifmodified=(! empty($conf->global->MAIN_MULTILANG_TRANSLATE_EVEN_IF_MODIFIED)); // By default if value was modified manually, we keep it (no translation because we don't have it) |
|
1225 | + |
|
1226 | + // TODO Instead of making a compare to see if param was modified, check that content contains reference translation. If yes, add the added part to the new translation |
|
1227 | + // ($textwasmodified is replaced with $textwasmodifiedorcompleted and we add completion). |
|
1228 | + |
|
1229 | + // Set label |
|
1230 | + // If we want another language, and if label is same than default language (we did force it to a specific value), we can use translation. |
|
1231 | + //var_dump($outputlangs->defaultlang.' - '.$langs->defaultlang.' - '.$label.' - '.$prodser->label);exit; |
|
1232 | + $textwasmodified=($label == $prodser->label); |
|
1233 | + if (! empty($prodser->multilangs[$outputlangs->defaultlang]["label"]) && ($textwasmodified || $translatealsoifmodified)) $label=$prodser->multilangs[$outputlangs->defaultlang]["label"]; |
|
1234 | + |
|
1235 | + // Set desc |
|
1236 | + // Manage HTML entities description test because $prodser->description is store with htmlentities but $desc no |
|
1237 | + $textwasmodified=false; |
|
1238 | + if (!empty($desc) && dol_textishtml($desc) && !empty($prodser->description) && dol_textishtml($prodser->description)) { |
|
1239 | + $textwasmodified=(strpos(dol_html_entity_decode($desc,ENT_QUOTES | ENT_HTML401),dol_html_entity_decode($prodser->description,ENT_QUOTES | ENT_HTML401))!==false); |
|
1240 | + } else { |
|
1241 | + $textwasmodified=($desc == $prodser->description); |
|
1242 | + } |
|
1243 | + if (! empty($prodser->multilangs[$outputlangs->defaultlang]["description"]) && ($textwasmodified || $translatealsoifmodified)) $desc=$prodser->multilangs[$outputlangs->defaultlang]["description"]; |
|
1244 | + |
|
1245 | + // Set note |
|
1246 | + $textwasmodified=($note == $prodser->note); |
|
1247 | + if (! empty($prodser->multilangs[$outputlangs->defaultlang]["note"]) && ($textwasmodified || $translatealsoifmodified)) $note=$prodser->multilangs[$outputlangs->defaultlang]["note"]; |
|
1248 | + } |
|
1249 | + } |
|
1250 | + |
|
1251 | + // Description short of product line |
|
1252 | + $libelleproduitservice=$label; |
|
1253 | + |
|
1254 | + // Description long of product line |
|
1255 | + if (! empty($desc) && ($desc != $label)) |
|
1256 | + { |
|
1257 | + if ($libelleproduitservice && empty($hidedesc)) |
|
1258 | + { |
|
1259 | + $libelleproduitservice.='__N__'; |
|
1260 | + } |
|
1261 | + |
|
1262 | + if ($desc == '(CREDIT_NOTE)' && $object->lines[$i]->fk_remise_except) |
|
1263 | + { |
|
1264 | + $discount=new DiscountAbsolute($db); |
|
1265 | + $discount->fetch($object->lines[$i]->fk_remise_except); |
|
1266 | + $sourceref=!empty($discount->discount_type)?$discount->ref_invoive_supplier_source:$discount->ref_facture_source; |
|
1267 | + $libelleproduitservice=$outputlangs->transnoentitiesnoconv("DiscountFromCreditNote",$sourceref); |
|
1268 | + } |
|
1269 | + elseif ($desc == '(DEPOSIT)' && $object->lines[$i]->fk_remise_except) |
|
1270 | + { |
|
1271 | + $discount=new DiscountAbsolute($db); |
|
1272 | + $discount->fetch($object->lines[$i]->fk_remise_except); |
|
1273 | + $sourceref=!empty($discount->discount_type)?$discount->ref_invoive_supplier_source:$discount->ref_facture_source; |
|
1274 | + $libelleproduitservice=$outputlangs->transnoentitiesnoconv("DiscountFromDeposit",$sourceref); |
|
1275 | + // Add date of deposit |
|
1276 | + if (! empty($conf->global->INVOICE_ADD_DEPOSIT_DATE)) echo ' ('.dol_print_date($discount->datec,'day','',$outputlangs).')'; |
|
1277 | + } |
|
1278 | + if ($desc == '(EXCESS RECEIVED)' && $object->lines[$i]->fk_remise_except) |
|
1279 | + { |
|
1280 | + $discount=new DiscountAbsolute($db); |
|
1281 | + $discount->fetch($object->lines[$i]->fk_remise_except); |
|
1282 | + $libelleproduitservice=$outputlangs->transnoentitiesnoconv("DiscountFromExcessReceived",$discount->ref_facture_source); |
|
1283 | + } |
|
1284 | + elseif ($desc == '(EXCESS PAID)' && $object->lines[$i]->fk_remise_except) |
|
1285 | + { |
|
1286 | + $discount=new DiscountAbsolute($db); |
|
1287 | + $discount->fetch($object->lines[$i]->fk_remise_except); |
|
1288 | + $libelleproduitservice=$outputlangs->transnoentitiesnoconv("DiscountFromExcessPaid",$discount->ref_invoice_supplier_source); |
|
1289 | + } |
|
1290 | + else |
|
1291 | + { |
|
1292 | + if ($idprod) |
|
1293 | + { |
|
1294 | + if (empty($hidedesc)) |
|
1295 | + { |
|
1296 | + if (!empty($conf->global->MAIN_DOCUMENTS_DESCRIPTION_FIRST)) |
|
1297 | + { |
|
1298 | + $libelleproduitservice=$desc."\n".$libelleproduitservice; |
|
1299 | + } |
|
1300 | + else |
|
1301 | + { |
|
1302 | + $libelleproduitservice.=$desc; |
|
1303 | + } |
|
1304 | + } |
|
1305 | + } |
|
1306 | + else |
|
1307 | + { |
|
1308 | + $libelleproduitservice.=$desc; |
|
1309 | + } |
|
1310 | + } |
|
1311 | + } |
|
1312 | + |
|
1313 | + // We add ref of product (and supplier ref if defined) |
|
1314 | + $prefix_prodserv = ""; |
|
1315 | + $ref_prodserv = ""; |
|
1316 | + if (! empty($conf->global->PRODUCT_ADD_TYPE_IN_DOCUMENTS)) // In standard mode, we do not show this |
|
1317 | + { |
|
1318 | + if ($prodser->isService()) |
|
1319 | + { |
|
1320 | + $prefix_prodserv = $outputlangs->transnoentitiesnoconv("Service")." "; |
|
1321 | + } |
|
1322 | + else |
|
1323 | + { |
|
1324 | + $prefix_prodserv = $outputlangs->transnoentitiesnoconv("Product")." "; |
|
1325 | + } |
|
1326 | + } |
|
1327 | + |
|
1328 | + if (empty($hideref)) |
|
1329 | + { |
|
1330 | + if ($issupplierline) |
|
1331 | + { |
|
1332 | + if ($conf->global->PDF_HIDE_PRODUCT_REF_IN_SUPPLIER_LINES == 1) |
|
1333 | + $ref_prodserv = $ref_supplier; |
|
1334 | + elseif ($conf->global->PDF_HIDE_PRODUCT_REF_IN_SUPPLIER_LINES == 2) |
|
1335 | + $ref_prodserv = $ref_supplier. ' ('.$outputlangs->transnoentitiesnoconv("InternalRef").' '.$prodser->ref.')'; |
|
1336 | + else // Common case |
|
1337 | + { |
|
1338 | + $ref_prodserv = $prodser->ref; // Show local ref |
|
1339 | + if ($ref_supplier) $ref_prodserv.= ($prodser->ref?' (':'').$outputlangs->transnoentitiesnoconv("SupplierRef").' '.$ref_supplier.($prodser->ref?')':''); |
|
1340 | + } |
|
1341 | + } |
|
1342 | + else |
|
1343 | + { |
|
1344 | + $ref_prodserv = $prodser->ref; // Show local ref only |
|
1345 | + } |
|
1346 | + |
|
1347 | + if (! empty($libelleproduitservice) && ! empty($ref_prodserv)) $ref_prodserv .= " - "; |
|
1348 | + } |
|
1349 | + |
|
1350 | + if(!empty($ref_prodserv) && !empty($conf->global->ADD_HTML_FORMATING_INTO_DESC_DOC)){ $ref_prodserv = '<b>'.$ref_prodserv.'</b>'; } |
|
1351 | + $libelleproduitservice=$prefix_prodserv.$ref_prodserv.$libelleproduitservice; |
|
1352 | + |
|
1353 | + // Add an additional description for the category products |
|
1354 | + if (! empty($conf->global->CATEGORY_ADD_DESC_INTO_DOC) && $idprod && ! empty($conf->categorie->enabled)) |
|
1355 | + { |
|
1356 | + include_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; |
|
1357 | + $categstatic=new Categorie($db); |
|
1358 | + // recovering the list of all the categories linked to product |
|
1359 | + $tblcateg=$categstatic->containing($idprod, Categorie::TYPE_PRODUCT); |
|
1360 | + foreach ($tblcateg as $cate) |
|
1361 | + { |
|
1362 | + // Adding the descriptions if they are filled |
|
1363 | + $desccateg=$cate->add_description; |
|
1364 | + if ($desccateg) |
|
1365 | + $libelleproduitservice.='__N__'.$desccateg; |
|
1366 | + } |
|
1367 | + } |
|
1368 | + |
|
1369 | + if (! empty($object->lines[$i]->date_start) || ! empty($object->lines[$i]->date_end)) |
|
1370 | + { |
|
1371 | + $format='day'; |
|
1372 | + // Show duration if exists |
|
1373 | + if ($object->lines[$i]->date_start && $object->lines[$i]->date_end) |
|
1374 | + { |
|
1375 | + $period='('.$outputlangs->transnoentitiesnoconv('DateFromTo',dol_print_date($object->lines[$i]->date_start, $format, false, $outputlangs),dol_print_date($object->lines[$i]->date_end, $format, false, $outputlangs)).')'; |
|
1376 | + } |
|
1377 | + if ($object->lines[$i]->date_start && ! $object->lines[$i]->date_end) |
|
1378 | + { |
|
1379 | + $period='('.$outputlangs->transnoentitiesnoconv('DateFrom',dol_print_date($object->lines[$i]->date_start, $format, false, $outputlangs)).')'; |
|
1380 | + } |
|
1381 | + if (! $object->lines[$i]->date_start && $object->lines[$i]->date_end) |
|
1382 | + { |
|
1383 | + $period='('.$outputlangs->transnoentitiesnoconv('DateUntil',dol_print_date($object->lines[$i]->date_end, $format, false, $outputlangs)).')'; |
|
1384 | + } |
|
1385 | + //print '>'.$outputlangs->charset_output.','.$period; |
|
1386 | + if(!empty($conf->global->ADD_HTML_FORMATING_INTO_DESC_DOC)){ |
|
1387 | + $libelleproduitservice.= '<b style="color:#333666;" ><em>'."__N__</b> ".$period.'</em>'; |
|
1388 | + }else{ |
|
1389 | + $libelleproduitservice.="__N__".$period; |
|
1390 | + } |
|
1391 | + //print $libelleproduitservice; |
|
1392 | + } |
|
1393 | + |
|
1394 | + if ($dbatch) |
|
1395 | + { |
|
1396 | + $format='day'; |
|
1397 | + foreach ($dbatch as $detail) |
|
1398 | + { |
|
1399 | + $dte=array(); |
|
1400 | + if ($detail->eatby) $dte[]=$outputlangs->transnoentitiesnoconv('printEatby',dol_print_date($detail->eatby, $format, false, $outputlangs)); |
|
1401 | + if ($detail->sellby) $dte[]=$outputlangs->transnoentitiesnoconv('printSellby',dol_print_date($detail->sellby, $format, false, $outputlangs)); |
|
1402 | + if ($detail->batch) $dte[]=$outputlangs->transnoentitiesnoconv('printBatch',$detail->batch); |
|
1403 | + $dte[]=$outputlangs->transnoentitiesnoconv('printQty',$detail->qty); |
|
1404 | + $libelleproduitservice.= "__N__ ".implode(" - ", $dte); |
|
1405 | + } |
|
1406 | + } |
|
1407 | + |
|
1408 | + // Now we convert \n into br |
|
1409 | + if (dol_textishtml($libelleproduitservice)) $libelleproduitservice=preg_replace('/__N__/','<br>',$libelleproduitservice); |
|
1410 | + else $libelleproduitservice=preg_replace('/__N__/',"\n",$libelleproduitservice); |
|
1411 | + $libelleproduitservice=dol_htmlentitiesbr($libelleproduitservice,1); |
|
1412 | + |
|
1413 | + return $libelleproduitservice; |
|
1414 | 1414 | } |
1415 | 1415 | |
1416 | 1416 | /** |
@@ -1424,25 +1424,25 @@ discard block |
||
1424 | 1424 | */ |
1425 | 1425 | function pdf_getlinenum($object,$i,$outputlangs,$hidedetails=0) |
1426 | 1426 | { |
1427 | - global $hookmanager; |
|
1428 | - |
|
1429 | - $reshook=0; |
|
1430 | - $result=''; |
|
1431 | - //if (is_object($hookmanager) && ( (isset($object->lines[$i]->product_type) && $object->lines[$i]->product_type == 9 && ! empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line) ) ) |
|
1432 | - if (is_object($hookmanager)) // Old code is commented on preceding line. Reproduct this test in the pdf_xxx function if you don't want your hook to run |
|
1433 | - { |
|
1434 | - $special_code = $object->lines[$i]->special_code; |
|
1435 | - if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); |
|
1436 | - $parameters = array('i'=>$i,'outputlangs'=>$outputlangs,'hidedetails'=>$hidedetails,'special_code'=>$special_code); |
|
1437 | - $action=''; |
|
1438 | - $reshook = $hookmanager->executeHooks('pdf_getlinenum',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks |
|
1439 | - $result.=$hookmanager->resPrint; |
|
1440 | - } |
|
1441 | - if (empty($reshook)) |
|
1442 | - { |
|
1443 | - $result.=dol_htmlentitiesbr($object->lines[$i]->num); |
|
1444 | - } |
|
1445 | - return $result; |
|
1427 | + global $hookmanager; |
|
1428 | + |
|
1429 | + $reshook=0; |
|
1430 | + $result=''; |
|
1431 | + //if (is_object($hookmanager) && ( (isset($object->lines[$i]->product_type) && $object->lines[$i]->product_type == 9 && ! empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line) ) ) |
|
1432 | + if (is_object($hookmanager)) // Old code is commented on preceding line. Reproduct this test in the pdf_xxx function if you don't want your hook to run |
|
1433 | + { |
|
1434 | + $special_code = $object->lines[$i]->special_code; |
|
1435 | + if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); |
|
1436 | + $parameters = array('i'=>$i,'outputlangs'=>$outputlangs,'hidedetails'=>$hidedetails,'special_code'=>$special_code); |
|
1437 | + $action=''; |
|
1438 | + $reshook = $hookmanager->executeHooks('pdf_getlinenum',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks |
|
1439 | + $result.=$hookmanager->resPrint; |
|
1440 | + } |
|
1441 | + if (empty($reshook)) |
|
1442 | + { |
|
1443 | + $result.=dol_htmlentitiesbr($object->lines[$i]->num); |
|
1444 | + } |
|
1445 | + return $result; |
|
1446 | 1446 | } |
1447 | 1447 | |
1448 | 1448 | |
@@ -1457,25 +1457,25 @@ discard block |
||
1457 | 1457 | */ |
1458 | 1458 | function pdf_getlineref($object,$i,$outputlangs,$hidedetails=0) |
1459 | 1459 | { |
1460 | - global $hookmanager; |
|
1461 | - |
|
1462 | - $reshook=0; |
|
1463 | - $result=''; |
|
1464 | - //if (is_object($hookmanager) && ( (isset($object->lines[$i]->product_type) && $object->lines[$i]->product_type == 9 && ! empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line) ) ) |
|
1465 | - if (is_object($hookmanager)) // Old code is commented on preceding line. Reproduct this test in the pdf_xxx function if you don't want your hook to run |
|
1466 | - { |
|
1467 | - $special_code = $object->lines[$i]->special_code; |
|
1468 | - if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); |
|
1469 | - $parameters = array('i'=>$i,'outputlangs'=>$outputlangs,'hidedetails'=>$hidedetails,'special_code'=>$special_code); |
|
1470 | - $action=''; |
|
1471 | - $reshook = $hookmanager->executeHooks('pdf_getlineref',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks |
|
1472 | - $result.=$hookmanager->resPrint; |
|
1473 | - } |
|
1474 | - if (empty($reshook)) |
|
1475 | - { |
|
1476 | - $result.=dol_htmlentitiesbr($object->lines[$i]->product_ref); |
|
1477 | - } |
|
1478 | - return $result; |
|
1460 | + global $hookmanager; |
|
1461 | + |
|
1462 | + $reshook=0; |
|
1463 | + $result=''; |
|
1464 | + //if (is_object($hookmanager) && ( (isset($object->lines[$i]->product_type) && $object->lines[$i]->product_type == 9 && ! empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line) ) ) |
|
1465 | + if (is_object($hookmanager)) // Old code is commented on preceding line. Reproduct this test in the pdf_xxx function if you don't want your hook to run |
|
1466 | + { |
|
1467 | + $special_code = $object->lines[$i]->special_code; |
|
1468 | + if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); |
|
1469 | + $parameters = array('i'=>$i,'outputlangs'=>$outputlangs,'hidedetails'=>$hidedetails,'special_code'=>$special_code); |
|
1470 | + $action=''; |
|
1471 | + $reshook = $hookmanager->executeHooks('pdf_getlineref',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks |
|
1472 | + $result.=$hookmanager->resPrint; |
|
1473 | + } |
|
1474 | + if (empty($reshook)) |
|
1475 | + { |
|
1476 | + $result.=dol_htmlentitiesbr($object->lines[$i]->product_ref); |
|
1477 | + } |
|
1478 | + return $result; |
|
1479 | 1479 | } |
1480 | 1480 | |
1481 | 1481 | /** |
@@ -1489,25 +1489,25 @@ discard block |
||
1489 | 1489 | */ |
1490 | 1490 | function pdf_getlineref_supplier($object,$i,$outputlangs,$hidedetails=0) |
1491 | 1491 | { |
1492 | - global $hookmanager; |
|
1493 | - |
|
1494 | - $reshook=0; |
|
1495 | - $result=''; |
|
1496 | - //if (is_object($hookmanager) && ( (isset($object->lines[$i]->product_type) && $object->lines[$i]->product_type == 9 && ! empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line) ) ) |
|
1497 | - if (is_object($hookmanager)) // Old code is commented on preceding line. Reproduct this test in the pdf_xxx function if you don't want your hook to run |
|
1498 | - { |
|
1499 | - $special_code = $object->lines[$i]->special_code; |
|
1500 | - if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); |
|
1501 | - $parameters = array('i'=>$i,'outputlangs'=>$outputlangs,'hidedetails'=>$hidedetails,'special_code'=>$special_code); |
|
1502 | - $action=''; |
|
1503 | - $reshook = $hookmanager->executeHooks('pdf_getlineref_supplier',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks |
|
1504 | - $result.=$hookmanager->resPrint; |
|
1505 | - } |
|
1506 | - if (empty($reshook)) |
|
1507 | - { |
|
1508 | - $result.=dol_htmlentitiesbr($object->lines[$i]->ref_supplier); |
|
1509 | - } |
|
1510 | - return $result; |
|
1492 | + global $hookmanager; |
|
1493 | + |
|
1494 | + $reshook=0; |
|
1495 | + $result=''; |
|
1496 | + //if (is_object($hookmanager) && ( (isset($object->lines[$i]->product_type) && $object->lines[$i]->product_type == 9 && ! empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line) ) ) |
|
1497 | + if (is_object($hookmanager)) // Old code is commented on preceding line. Reproduct this test in the pdf_xxx function if you don't want your hook to run |
|
1498 | + { |
|
1499 | + $special_code = $object->lines[$i]->special_code; |
|
1500 | + if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); |
|
1501 | + $parameters = array('i'=>$i,'outputlangs'=>$outputlangs,'hidedetails'=>$hidedetails,'special_code'=>$special_code); |
|
1502 | + $action=''; |
|
1503 | + $reshook = $hookmanager->executeHooks('pdf_getlineref_supplier',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks |
|
1504 | + $result.=$hookmanager->resPrint; |
|
1505 | + } |
|
1506 | + if (empty($reshook)) |
|
1507 | + { |
|
1508 | + $result.=dol_htmlentitiesbr($object->lines[$i]->ref_supplier); |
|
1509 | + } |
|
1510 | + return $result; |
|
1511 | 1511 | } |
1512 | 1512 | |
1513 | 1513 | /** |
@@ -1521,52 +1521,52 @@ discard block |
||
1521 | 1521 | */ |
1522 | 1522 | function pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails=0) |
1523 | 1523 | { |
1524 | - global $conf, $hookmanager, $mysoc; |
|
1525 | - |
|
1526 | - $result=''; |
|
1527 | - $reshook=0; |
|
1528 | - //if (is_object($hookmanager) && ( (isset($object->lines[$i]->product_type) && $object->lines[$i]->product_type == 9 && ! empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line) ) ) |
|
1529 | - if (is_object($hookmanager)) // Old code is commented on preceding line. Reproduce this test in the pdf_xxx function if you don't want your hook to run |
|
1530 | - { |
|
1531 | - $special_code = $object->lines[$i]->special_code; |
|
1532 | - if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); |
|
1533 | - $parameters = array('i'=>$i,'outputlangs'=>$outputlangs,'hidedetails'=>$hidedetails,'special_code'=>$special_code); |
|
1534 | - $action=''; |
|
1535 | - $reshook = $hookmanager->executeHooks('pdf_getlinevatrate',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks |
|
1536 | - |
|
1537 | - if (!empty($hookmanager->resPrint)) $result.=$hookmanager->resPrint; |
|
1538 | - } |
|
1539 | - if (empty($reshook)) |
|
1540 | - { |
|
1541 | - if (empty($hidedetails) || $hidedetails > 1) |
|
1542 | - { |
|
1543 | - $tmpresult=''; |
|
1544 | - |
|
1545 | - $tmpresult.=vatrate($object->lines[$i]->tva_tx, 0, $object->lines[$i]->info_bits, -1); |
|
1546 | - if (empty($conf->global->MAIN_PDF_MAIN_HIDE_SECOND_TAX)) |
|
1547 | - { |
|
1548 | - if ($object->lines[$i]->total_localtax1 != 0) |
|
1549 | - { |
|
1550 | - if (preg_replace('/[\s0%]/','',$tmpresult)) $tmpresult.='/'; |
|
1551 | - else $tmpresult=''; |
|
1552 | - $tmpresult.=vatrate(abs($object->lines[$i]->localtax1_tx), 0); |
|
1553 | - } |
|
1554 | - } |
|
1555 | - if (empty($conf->global->MAIN_PDF_MAIN_HIDE_THIRD_TAX)) |
|
1556 | - { |
|
1557 | - if ($object->lines[$i]->total_localtax2 != 0) |
|
1558 | - { |
|
1559 | - if (preg_replace('/[\s0%]/','',$tmpresult)) $tmpresult.='/'; |
|
1560 | - else $tmpresult=''; |
|
1561 | - $tmpresult.=vatrate(abs($object->lines[$i]->localtax2_tx), 0); |
|
1562 | - } |
|
1563 | - } |
|
1564 | - $tmpresult.= '%'; |
|
1565 | - |
|
1566 | - $result.=$tmpresult; |
|
1567 | - } |
|
1568 | - } |
|
1569 | - return $result; |
|
1524 | + global $conf, $hookmanager, $mysoc; |
|
1525 | + |
|
1526 | + $result=''; |
|
1527 | + $reshook=0; |
|
1528 | + //if (is_object($hookmanager) && ( (isset($object->lines[$i]->product_type) && $object->lines[$i]->product_type == 9 && ! empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line) ) ) |
|
1529 | + if (is_object($hookmanager)) // Old code is commented on preceding line. Reproduce this test in the pdf_xxx function if you don't want your hook to run |
|
1530 | + { |
|
1531 | + $special_code = $object->lines[$i]->special_code; |
|
1532 | + if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); |
|
1533 | + $parameters = array('i'=>$i,'outputlangs'=>$outputlangs,'hidedetails'=>$hidedetails,'special_code'=>$special_code); |
|
1534 | + $action=''; |
|
1535 | + $reshook = $hookmanager->executeHooks('pdf_getlinevatrate',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks |
|
1536 | + |
|
1537 | + if (!empty($hookmanager->resPrint)) $result.=$hookmanager->resPrint; |
|
1538 | + } |
|
1539 | + if (empty($reshook)) |
|
1540 | + { |
|
1541 | + if (empty($hidedetails) || $hidedetails > 1) |
|
1542 | + { |
|
1543 | + $tmpresult=''; |
|
1544 | + |
|
1545 | + $tmpresult.=vatrate($object->lines[$i]->tva_tx, 0, $object->lines[$i]->info_bits, -1); |
|
1546 | + if (empty($conf->global->MAIN_PDF_MAIN_HIDE_SECOND_TAX)) |
|
1547 | + { |
|
1548 | + if ($object->lines[$i]->total_localtax1 != 0) |
|
1549 | + { |
|
1550 | + if (preg_replace('/[\s0%]/','',$tmpresult)) $tmpresult.='/'; |
|
1551 | + else $tmpresult=''; |
|
1552 | + $tmpresult.=vatrate(abs($object->lines[$i]->localtax1_tx), 0); |
|
1553 | + } |
|
1554 | + } |
|
1555 | + if (empty($conf->global->MAIN_PDF_MAIN_HIDE_THIRD_TAX)) |
|
1556 | + { |
|
1557 | + if ($object->lines[$i]->total_localtax2 != 0) |
|
1558 | + { |
|
1559 | + if (preg_replace('/[\s0%]/','',$tmpresult)) $tmpresult.='/'; |
|
1560 | + else $tmpresult=''; |
|
1561 | + $tmpresult.=vatrate(abs($object->lines[$i]->localtax2_tx), 0); |
|
1562 | + } |
|
1563 | + } |
|
1564 | + $tmpresult.= '%'; |
|
1565 | + |
|
1566 | + $result.=$tmpresult; |
|
1567 | + } |
|
1568 | + } |
|
1569 | + return $result; |
|
1570 | 1570 | } |
1571 | 1571 | |
1572 | 1572 | /** |
@@ -1580,33 +1580,33 @@ discard block |
||
1580 | 1580 | */ |
1581 | 1581 | function pdf_getlineupexcltax($object,$i,$outputlangs,$hidedetails=0) |
1582 | 1582 | { |
1583 | - global $conf, $hookmanager; |
|
1584 | - |
|
1585 | - $sign=1; |
|
1586 | - if (isset($object->type) && $object->type == 2 && ! empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign=-1; |
|
1587 | - |
|
1588 | - $result=''; |
|
1589 | - $reshook=0; |
|
1590 | - //if (is_object($hookmanager) && ( (isset($object->lines[$i]->product_type) && $object->lines[$i]->product_type == 9 && ! empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line) ) ) |
|
1591 | - if (is_object($hookmanager)) // Old code is commented on preceding line. Reproduct this test in the pdf_xxx function if you don't want your hook to run |
|
1592 | - { |
|
1593 | - $special_code = $object->lines[$i]->special_code; |
|
1594 | - if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); |
|
1595 | - $parameters = array('i'=>$i,'outputlangs'=>$outputlangs,'hidedetails'=>$hidedetails,'special_code'=>$special_code); |
|
1596 | - $action=''; |
|
1597 | - $reshook = $hookmanager->executeHooks('pdf_getlineupexcltax',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks |
|
1598 | - |
|
1599 | - if (!empty($hookmanager->resPrint)) $result.=$hookmanager->resPrint; |
|
1600 | - } |
|
1601 | - if (empty($reshook)) |
|
1602 | - { |
|
1603 | - if (empty($hidedetails) || $hidedetails > 1) |
|
1604 | - { |
|
1605 | - $subprice = ($conf->multicurrency->enabled && $object->multicurrency_tx != 1 ? $object->lines[$i]->multicurrency_subprice : $object->lines[$i]->subprice); |
|
1606 | - $result.=price($sign * $subprice, 0, $outputlangs); |
|
1607 | - } |
|
1608 | - } |
|
1609 | - return $result; |
|
1583 | + global $conf, $hookmanager; |
|
1584 | + |
|
1585 | + $sign=1; |
|
1586 | + if (isset($object->type) && $object->type == 2 && ! empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign=-1; |
|
1587 | + |
|
1588 | + $result=''; |
|
1589 | + $reshook=0; |
|
1590 | + //if (is_object($hookmanager) && ( (isset($object->lines[$i]->product_type) && $object->lines[$i]->product_type == 9 && ! empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line) ) ) |
|
1591 | + if (is_object($hookmanager)) // Old code is commented on preceding line. Reproduct this test in the pdf_xxx function if you don't want your hook to run |
|
1592 | + { |
|
1593 | + $special_code = $object->lines[$i]->special_code; |
|
1594 | + if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); |
|
1595 | + $parameters = array('i'=>$i,'outputlangs'=>$outputlangs,'hidedetails'=>$hidedetails,'special_code'=>$special_code); |
|
1596 | + $action=''; |
|
1597 | + $reshook = $hookmanager->executeHooks('pdf_getlineupexcltax',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks |
|
1598 | + |
|
1599 | + if (!empty($hookmanager->resPrint)) $result.=$hookmanager->resPrint; |
|
1600 | + } |
|
1601 | + if (empty($reshook)) |
|
1602 | + { |
|
1603 | + if (empty($hidedetails) || $hidedetails > 1) |
|
1604 | + { |
|
1605 | + $subprice = ($conf->multicurrency->enabled && $object->multicurrency_tx != 1 ? $object->lines[$i]->multicurrency_subprice : $object->lines[$i]->subprice); |
|
1606 | + $result.=price($sign * $subprice, 0, $outputlangs); |
|
1607 | + } |
|
1608 | + } |
|
1609 | + return $result; |
|
1610 | 1610 | } |
1611 | 1611 | |
1612 | 1612 | /** |
@@ -1620,29 +1620,29 @@ discard block |
||
1620 | 1620 | */ |
1621 | 1621 | function pdf_getlineupwithtax($object,$i,$outputlangs,$hidedetails=0) |
1622 | 1622 | { |
1623 | - global $hookmanager,$conf; |
|
1624 | - |
|
1625 | - $sign=1; |
|
1626 | - if (isset($object->type) && $object->type == 2 && ! empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign=-1; |
|
1627 | - |
|
1628 | - $result=''; |
|
1629 | - $reshook=0; |
|
1630 | - //if (is_object($hookmanager) && ( (isset($object->lines[$i]->product_type) && $object->lines[$i]->product_type == 9 && ! empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line) ) ) |
|
1631 | - if (is_object($hookmanager)) // Old code is commented on preceding line. Reproduct this test in the pdf_xxx function if you don't want your hook to run |
|
1632 | - { |
|
1633 | - $special_code = $object->lines[$i]->special_code; |
|
1634 | - if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); |
|
1635 | - $parameters = array('i'=>$i,'outputlangs'=>$outputlangs,'hidedetails'=>$hidedetails,'special_code'=>$special_code); |
|
1636 | - $action=''; |
|
1637 | - $reshook = $hookmanager->executeHooks('pdf_getlineupwithtax',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks |
|
1638 | - |
|
1639 | - if (!empty($hookmanager->resPrint)) $result.=$hookmanager->resPrint; |
|
1640 | - } |
|
1641 | - if (empty($reshook)) |
|
1642 | - { |
|
1643 | - if (empty($hidedetails) || $hidedetails > 1) $result.=price($sign * (($object->lines[$i]->subprice) + ($object->lines[$i]->subprice)*($object->lines[$i]->tva_tx)/100), 0, $outputlangs); |
|
1644 | - } |
|
1645 | - return $result; |
|
1623 | + global $hookmanager,$conf; |
|
1624 | + |
|
1625 | + $sign=1; |
|
1626 | + if (isset($object->type) && $object->type == 2 && ! empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign=-1; |
|
1627 | + |
|
1628 | + $result=''; |
|
1629 | + $reshook=0; |
|
1630 | + //if (is_object($hookmanager) && ( (isset($object->lines[$i]->product_type) && $object->lines[$i]->product_type == 9 && ! empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line) ) ) |
|
1631 | + if (is_object($hookmanager)) // Old code is commented on preceding line. Reproduct this test in the pdf_xxx function if you don't want your hook to run |
|
1632 | + { |
|
1633 | + $special_code = $object->lines[$i]->special_code; |
|
1634 | + if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); |
|
1635 | + $parameters = array('i'=>$i,'outputlangs'=>$outputlangs,'hidedetails'=>$hidedetails,'special_code'=>$special_code); |
|
1636 | + $action=''; |
|
1637 | + $reshook = $hookmanager->executeHooks('pdf_getlineupwithtax',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks |
|
1638 | + |
|
1639 | + if (!empty($hookmanager->resPrint)) $result.=$hookmanager->resPrint; |
|
1640 | + } |
|
1641 | + if (empty($reshook)) |
|
1642 | + { |
|
1643 | + if (empty($hidedetails) || $hidedetails > 1) $result.=price($sign * (($object->lines[$i]->subprice) + ($object->lines[$i]->subprice)*($object->lines[$i]->tva_tx)/100), 0, $outputlangs); |
|
1644 | + } |
|
1645 | + return $result; |
|
1646 | 1646 | } |
1647 | 1647 | |
1648 | 1648 | /** |
@@ -1656,27 +1656,27 @@ discard block |
||
1656 | 1656 | */ |
1657 | 1657 | function pdf_getlineqty($object,$i,$outputlangs,$hidedetails=0) |
1658 | 1658 | { |
1659 | - global $hookmanager; |
|
1660 | - |
|
1661 | - $result=''; |
|
1662 | - $reshook=0; |
|
1663 | - //if (is_object($hookmanager) && ( (isset($object->lines[$i]->product_type) && $object->lines[$i]->product_type == 9 && ! empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line) ) ) |
|
1664 | - if (is_object($hookmanager)) // Old code is commented on preceding line. Reproduct this test in the pdf_xxx function if you don't want your hook to run |
|
1665 | - { |
|
1666 | - $special_code = $object->lines[$i]->special_code; |
|
1667 | - if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); |
|
1668 | - $parameters = array('i'=>$i,'outputlangs'=>$outputlangs,'hidedetails'=>$hidedetails,'special_code'=>$special_code); |
|
1669 | - $action=''; |
|
1670 | - $reshook = $hookmanager->executeHooks('pdf_getlineqty',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks |
|
1671 | - |
|
1672 | - if(!empty($hookmanager->resPrint)) $result=$hookmanager->resPrint; |
|
1673 | - } |
|
1659 | + global $hookmanager; |
|
1660 | + |
|
1661 | + $result=''; |
|
1662 | + $reshook=0; |
|
1663 | + //if (is_object($hookmanager) && ( (isset($object->lines[$i]->product_type) && $object->lines[$i]->product_type == 9 && ! empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line) ) ) |
|
1664 | + if (is_object($hookmanager)) // Old code is commented on preceding line. Reproduct this test in the pdf_xxx function if you don't want your hook to run |
|
1665 | + { |
|
1666 | + $special_code = $object->lines[$i]->special_code; |
|
1667 | + if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); |
|
1668 | + $parameters = array('i'=>$i,'outputlangs'=>$outputlangs,'hidedetails'=>$hidedetails,'special_code'=>$special_code); |
|
1669 | + $action=''; |
|
1670 | + $reshook = $hookmanager->executeHooks('pdf_getlineqty',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks |
|
1671 | + |
|
1672 | + if(!empty($hookmanager->resPrint)) $result=$hookmanager->resPrint; |
|
1673 | + } |
|
1674 | 1674 | if (empty($reshook)) |
1675 | - { |
|
1676 | - if ($object->lines[$i]->special_code == 3) return ''; |
|
1677 | - if (empty($hidedetails) || $hidedetails > 1) $result.=$object->lines[$i]->qty; |
|
1678 | - } |
|
1679 | - return $result; |
|
1675 | + { |
|
1676 | + if ($object->lines[$i]->special_code == 3) return ''; |
|
1677 | + if (empty($hidedetails) || $hidedetails > 1) $result.=$object->lines[$i]->qty; |
|
1678 | + } |
|
1679 | + return $result; |
|
1680 | 1680 | } |
1681 | 1681 | |
1682 | 1682 | /** |
@@ -1690,27 +1690,27 @@ discard block |
||
1690 | 1690 | */ |
1691 | 1691 | function pdf_getlineqty_asked($object,$i,$outputlangs,$hidedetails=0) |
1692 | 1692 | { |
1693 | - global $hookmanager; |
|
1694 | - |
|
1695 | - $reshook=0; |
|
1696 | - $result=''; |
|
1697 | - //if (is_object($hookmanager) && ( (isset($object->lines[$i]->product_type) && $object->lines[$i]->product_type == 9 && ! empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line) ) ) |
|
1698 | - if (is_object($hookmanager)) // Old code is commented on preceding line. Reproduct this test in the pdf_xxx function if you don't want your hook to run |
|
1699 | - { |
|
1700 | - $special_code = $object->lines[$i]->special_code; |
|
1701 | - if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); |
|
1702 | - $parameters = array('i'=>$i,'outputlangs'=>$outputlangs,'hidedetails'=>$hidedetails,'special_code'=>$special_code); |
|
1703 | - $action=''; |
|
1704 | - $reshook = $hookmanager->executeHooks('pdf_getlineqty_asked',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks |
|
1705 | - |
|
1706 | - if (!empty($hookmanager->resPrint)) $result.=$hookmanager->resPrint; |
|
1707 | - } |
|
1708 | - if (empty($reshook)) |
|
1709 | - { |
|
1693 | + global $hookmanager; |
|
1694 | + |
|
1695 | + $reshook=0; |
|
1696 | + $result=''; |
|
1697 | + //if (is_object($hookmanager) && ( (isset($object->lines[$i]->product_type) && $object->lines[$i]->product_type == 9 && ! empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line) ) ) |
|
1698 | + if (is_object($hookmanager)) // Old code is commented on preceding line. Reproduct this test in the pdf_xxx function if you don't want your hook to run |
|
1699 | + { |
|
1700 | + $special_code = $object->lines[$i]->special_code; |
|
1701 | + if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); |
|
1702 | + $parameters = array('i'=>$i,'outputlangs'=>$outputlangs,'hidedetails'=>$hidedetails,'special_code'=>$special_code); |
|
1703 | + $action=''; |
|
1704 | + $reshook = $hookmanager->executeHooks('pdf_getlineqty_asked',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks |
|
1705 | + |
|
1706 | + if (!empty($hookmanager->resPrint)) $result.=$hookmanager->resPrint; |
|
1707 | + } |
|
1708 | + if (empty($reshook)) |
|
1709 | + { |
|
1710 | 1710 | if ($object->lines[$i]->special_code == 3) return ''; |
1711 | 1711 | if (empty($hidedetails) || $hidedetails > 1) $result.=$object->lines[$i]->qty_asked; |
1712 | - } |
|
1713 | - return $result; |
|
1712 | + } |
|
1713 | + return $result; |
|
1714 | 1714 | } |
1715 | 1715 | |
1716 | 1716 | /** |
@@ -1724,27 +1724,27 @@ discard block |
||
1724 | 1724 | */ |
1725 | 1725 | function pdf_getlineqty_shipped($object,$i,$outputlangs,$hidedetails=0) |
1726 | 1726 | { |
1727 | - global $hookmanager; |
|
1728 | - |
|
1729 | - $reshook=0; |
|
1730 | - $result=''; |
|
1731 | - //if (is_object($hookmanager) && ( (isset($object->lines[$i]->product_type) && $object->lines[$i]->product_type == 9 && ! empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line) ) ) |
|
1732 | - if (is_object($hookmanager)) // Old code is commented on preceding line. Reproduct this test in the pdf_xxx function if you don't want your hook to run |
|
1733 | - { |
|
1734 | - $special_code = $object->lines[$i]->special_code; |
|
1735 | - if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); |
|
1736 | - $parameters = array('i'=>$i,'outputlangs'=>$outputlangs,'hidedetails'=>$hidedetails,'special_code'=>$special_code); |
|
1737 | - $action=''; |
|
1738 | - $reshook = $hookmanager->executeHooks('pdf_getlineqty_shipped',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks |
|
1739 | - |
|
1740 | - if(!empty($hookmanager->resPrint)) $result.=$hookmanager->resPrint; |
|
1741 | - } |
|
1742 | - if (empty($reshook)) |
|
1743 | - { |
|
1727 | + global $hookmanager; |
|
1728 | + |
|
1729 | + $reshook=0; |
|
1730 | + $result=''; |
|
1731 | + //if (is_object($hookmanager) && ( (isset($object->lines[$i]->product_type) && $object->lines[$i]->product_type == 9 && ! empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line) ) ) |
|
1732 | + if (is_object($hookmanager)) // Old code is commented on preceding line. Reproduct this test in the pdf_xxx function if you don't want your hook to run |
|
1733 | + { |
|
1734 | + $special_code = $object->lines[$i]->special_code; |
|
1735 | + if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); |
|
1736 | + $parameters = array('i'=>$i,'outputlangs'=>$outputlangs,'hidedetails'=>$hidedetails,'special_code'=>$special_code); |
|
1737 | + $action=''; |
|
1738 | + $reshook = $hookmanager->executeHooks('pdf_getlineqty_shipped',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks |
|
1739 | + |
|
1740 | + if(!empty($hookmanager->resPrint)) $result.=$hookmanager->resPrint; |
|
1741 | + } |
|
1742 | + if (empty($reshook)) |
|
1743 | + { |
|
1744 | 1744 | if ($object->lines[$i]->special_code == 3) return ''; |
1745 | - if (empty($hidedetails) || $hidedetails > 1) $result.=$object->lines[$i]->qty_shipped; |
|
1746 | - } |
|
1747 | - return $result; |
|
1745 | + if (empty($hidedetails) || $hidedetails > 1) $result.=$object->lines[$i]->qty_shipped; |
|
1746 | + } |
|
1747 | + return $result; |
|
1748 | 1748 | } |
1749 | 1749 | |
1750 | 1750 | /** |
@@ -1758,27 +1758,27 @@ discard block |
||
1758 | 1758 | */ |
1759 | 1759 | function pdf_getlineqty_keeptoship($object,$i,$outputlangs,$hidedetails=0) |
1760 | 1760 | { |
1761 | - global $hookmanager; |
|
1761 | + global $hookmanager; |
|
1762 | 1762 | |
1763 | - $reshook=0; |
|
1763 | + $reshook=0; |
|
1764 | 1764 | $result=''; |
1765 | 1765 | //if (is_object($hookmanager) && ( (isset($object->lines[$i]->product_type) && $object->lines[$i]->product_type == 9 && ! empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line) ) ) |
1766 | - if (is_object($hookmanager)) // Old code is commented on preceding line. Reproduct this test in the pdf_xxx function if you don't want your hook to run |
|
1767 | - { |
|
1768 | - $special_code = $object->lines[$i]->special_code; |
|
1769 | - if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); |
|
1770 | - $parameters = array('i'=>$i,'outputlangs'=>$outputlangs,'hidedetails'=>$hidedetails,'special_code'=>$special_code); |
|
1771 | - $action=''; |
|
1772 | - $reshook = $hookmanager->executeHooks('pdf_getlineqty_keeptoship',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks |
|
1773 | - |
|
1774 | - if(!empty($hookmanager->resPrint)) $result.=$hookmanager->resPrint; |
|
1775 | - } |
|
1776 | - if (empty($reshook)) |
|
1777 | - { |
|
1766 | + if (is_object($hookmanager)) // Old code is commented on preceding line. Reproduct this test in the pdf_xxx function if you don't want your hook to run |
|
1767 | + { |
|
1768 | + $special_code = $object->lines[$i]->special_code; |
|
1769 | + if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); |
|
1770 | + $parameters = array('i'=>$i,'outputlangs'=>$outputlangs,'hidedetails'=>$hidedetails,'special_code'=>$special_code); |
|
1771 | + $action=''; |
|
1772 | + $reshook = $hookmanager->executeHooks('pdf_getlineqty_keeptoship',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks |
|
1773 | + |
|
1774 | + if(!empty($hookmanager->resPrint)) $result.=$hookmanager->resPrint; |
|
1775 | + } |
|
1776 | + if (empty($reshook)) |
|
1777 | + { |
|
1778 | 1778 | if ($object->lines[$i]->special_code == 3) return ''; |
1779 | - if (empty($hidedetails) || $hidedetails > 1) $result.=($object->lines[$i]->qty_asked - $object->lines[$i]->qty_shipped); |
|
1780 | - } |
|
1781 | - return $result; |
|
1779 | + if (empty($hidedetails) || $hidedetails > 1) $result.=($object->lines[$i]->qty_asked - $object->lines[$i]->qty_shipped); |
|
1780 | + } |
|
1781 | + return $result; |
|
1782 | 1782 | } |
1783 | 1783 | |
1784 | 1784 | /** |
@@ -1793,34 +1793,34 @@ discard block |
||
1793 | 1793 | */ |
1794 | 1794 | function pdf_getlineunit($object, $i, $outputlangs, $hidedetails = 0, $hookmanager = false) |
1795 | 1795 | { |
1796 | - global $langs; |
|
1796 | + global $langs; |
|
1797 | 1797 | |
1798 | - $reshook=0; |
|
1798 | + $reshook=0; |
|
1799 | 1799 | $result=''; |
1800 | 1800 | //if (is_object($hookmanager) && ( (isset($object->lines[$i]->product_type) && $object->lines[$i]->product_type == 9 && ! empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line) ) ) |
1801 | - if (is_object($hookmanager)) // Old code is commented on preceding line. Reproduct this test in the pdf_xxx function if you don't want your hook to run |
|
1802 | - { |
|
1803 | - $special_code = $object->lines[$i]->special_code; |
|
1804 | - if (!empty($object->lines[$i]->fk_parent_line)) { |
|
1805 | - $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); |
|
1806 | - } |
|
1807 | - $parameters = array( |
|
1808 | - 'i' => $i, |
|
1809 | - 'outputlangs' => $outputlangs, |
|
1810 | - 'hidedetails' => $hidedetails, |
|
1811 | - 'special_code' => $special_code |
|
1812 | - ); |
|
1813 | - $action = ''; |
|
1814 | - $reshook = $hookmanager->executeHooks('pdf_getlineunit', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks |
|
1815 | - |
|
1816 | - if(!empty($hookmanager->resPrint)) $result.=$hookmanager->resPrint; |
|
1817 | - } |
|
1818 | - if (empty($reshook)) |
|
1819 | - { |
|
1801 | + if (is_object($hookmanager)) // Old code is commented on preceding line. Reproduct this test in the pdf_xxx function if you don't want your hook to run |
|
1802 | + { |
|
1803 | + $special_code = $object->lines[$i]->special_code; |
|
1804 | + if (!empty($object->lines[$i]->fk_parent_line)) { |
|
1805 | + $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); |
|
1806 | + } |
|
1807 | + $parameters = array( |
|
1808 | + 'i' => $i, |
|
1809 | + 'outputlangs' => $outputlangs, |
|
1810 | + 'hidedetails' => $hidedetails, |
|
1811 | + 'special_code' => $special_code |
|
1812 | + ); |
|
1813 | + $action = ''; |
|
1814 | + $reshook = $hookmanager->executeHooks('pdf_getlineunit', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks |
|
1815 | + |
|
1816 | + if(!empty($hookmanager->resPrint)) $result.=$hookmanager->resPrint; |
|
1817 | + } |
|
1818 | + if (empty($reshook)) |
|
1819 | + { |
|
1820 | 1820 | if ($object->lines[$i]->special_code == 3) return ''; |
1821 | - if (empty($hidedetails) || $hidedetails > 1) $result.=$langs->transnoentitiesnoconv($object->lines[$i]->getLabelOfUnit('short')); |
|
1822 | - } |
|
1823 | - return $result; |
|
1821 | + if (empty($hidedetails) || $hidedetails > 1) $result.=$langs->transnoentitiesnoconv($object->lines[$i]->getLabelOfUnit('short')); |
|
1822 | + } |
|
1823 | + return $result; |
|
1824 | 1824 | } |
1825 | 1825 | |
1826 | 1826 | |
@@ -1835,29 +1835,29 @@ discard block |
||
1835 | 1835 | */ |
1836 | 1836 | function pdf_getlineremisepercent($object,$i,$outputlangs,$hidedetails=0) |
1837 | 1837 | { |
1838 | - global $hookmanager; |
|
1839 | - |
|
1840 | - include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; |
|
1841 | - |
|
1842 | - $reshook=0; |
|
1843 | - $result=''; |
|
1844 | - //if (is_object($hookmanager) && ( (isset($object->lines[$i]->product_type) && $object->lines[$i]->product_type == 9 && ! empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line) ) ) |
|
1845 | - if (is_object($hookmanager)) // Old code is commented on preceding line. Reproduct this test in the pdf_xxx function if you don't want your hook to run |
|
1846 | - { |
|
1847 | - $special_code = $object->lines[$i]->special_code; |
|
1848 | - if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); |
|
1849 | - $parameters = array('i'=>$i,'outputlangs'=>$outputlangs,'hidedetails'=>$hidedetails,'special_code'=>$special_code); |
|
1850 | - $action=''; |
|
1851 | - $reshook = $hookmanager->executeHooks('pdf_getlineremisepercent',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks |
|
1852 | - |
|
1853 | - if(!empty($hookmanager->resPrint)) $result.=$hookmanager->resPrint; |
|
1854 | - } |
|
1855 | - if (empty($reshook)) |
|
1856 | - { |
|
1838 | + global $hookmanager; |
|
1839 | + |
|
1840 | + include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; |
|
1841 | + |
|
1842 | + $reshook=0; |
|
1843 | + $result=''; |
|
1844 | + //if (is_object($hookmanager) && ( (isset($object->lines[$i]->product_type) && $object->lines[$i]->product_type == 9 && ! empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line) ) ) |
|
1845 | + if (is_object($hookmanager)) // Old code is commented on preceding line. Reproduct this test in the pdf_xxx function if you don't want your hook to run |
|
1846 | + { |
|
1847 | + $special_code = $object->lines[$i]->special_code; |
|
1848 | + if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); |
|
1849 | + $parameters = array('i'=>$i,'outputlangs'=>$outputlangs,'hidedetails'=>$hidedetails,'special_code'=>$special_code); |
|
1850 | + $action=''; |
|
1851 | + $reshook = $hookmanager->executeHooks('pdf_getlineremisepercent',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks |
|
1852 | + |
|
1853 | + if(!empty($hookmanager->resPrint)) $result.=$hookmanager->resPrint; |
|
1854 | + } |
|
1855 | + if (empty($reshook)) |
|
1856 | + { |
|
1857 | 1857 | if ($object->lines[$i]->special_code == 3) return ''; |
1858 | - if (empty($hidedetails) || $hidedetails > 1) $result.=dol_print_reduction($object->lines[$i]->remise_percent,$outputlangs); |
|
1859 | - } |
|
1860 | - return $result; |
|
1858 | + if (empty($hidedetails) || $hidedetails > 1) $result.=dol_print_reduction($object->lines[$i]->remise_percent,$outputlangs); |
|
1859 | + } |
|
1860 | + return $result; |
|
1861 | 1861 | } |
1862 | 1862 | |
1863 | 1863 | /** |
@@ -1872,41 +1872,41 @@ discard block |
||
1872 | 1872 | */ |
1873 | 1873 | function pdf_getlineprogress($object, $i, $outputlangs, $hidedetails = 0, $hookmanager = null) |
1874 | 1874 | { |
1875 | - if (empty($hookmanager)) global $hookmanager; |
|
1876 | - global $conf; |
|
1875 | + if (empty($hookmanager)) global $hookmanager; |
|
1876 | + global $conf; |
|
1877 | 1877 | |
1878 | - $reshook=0; |
|
1878 | + $reshook=0; |
|
1879 | 1879 | $result=''; |
1880 | 1880 | //if (is_object($hookmanager) && ( (isset($object->lines[$i]->product_type) && $object->lines[$i]->product_type == 9 && ! empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line) ) ) |
1881 | - if (is_object($hookmanager)) // Old code is commented on preceding line. Reproduct this test in the pdf_xxx function if you don't want your hook to run |
|
1882 | - { |
|
1883 | - $special_code = $object->lines[$i]->special_code; |
|
1884 | - if (!empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); |
|
1885 | - $parameters = array('i' => $i, 'outputlangs' => $outputlangs, 'hidedetails' => $hidedetails, 'special_code' => $special_code); |
|
1886 | - $action = ''; |
|
1887 | - $reshook = $hookmanager->executeHooks('pdf_getlineprogress', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks |
|
1888 | - |
|
1889 | - if(!empty($hookmanager->resPrint)) return $hookmanager->resPrint; |
|
1890 | - } |
|
1891 | - if (empty($reshook)) |
|
1892 | - { |
|
1893 | - if ($object->lines[$i]->special_code == 3) return ''; |
|
1894 | - if (empty($hidedetails) || $hidedetails > 1) |
|
1895 | - { |
|
1896 | - if ($conf->global->SITUATION_DISPLAY_DIFF_ON_PDF) |
|
1897 | - { |
|
1898 | - $prev_progress = 0; |
|
1899 | - if (method_exists($object, 'get_prev_progress')) |
|
1900 | - { |
|
1901 | - $prev_progress = $object->lines[$i]->get_prev_progress($object->id); |
|
1902 | - } |
|
1903 | - $result = ($object->lines[$i]->situation_percent - $prev_progress) . '%'; |
|
1904 | - } |
|
1905 | - else |
|
1906 | - $result = $object->lines[$i]->situation_percent . '%'; |
|
1907 | - } |
|
1908 | - } |
|
1909 | - return $result; |
|
1881 | + if (is_object($hookmanager)) // Old code is commented on preceding line. Reproduct this test in the pdf_xxx function if you don't want your hook to run |
|
1882 | + { |
|
1883 | + $special_code = $object->lines[$i]->special_code; |
|
1884 | + if (!empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); |
|
1885 | + $parameters = array('i' => $i, 'outputlangs' => $outputlangs, 'hidedetails' => $hidedetails, 'special_code' => $special_code); |
|
1886 | + $action = ''; |
|
1887 | + $reshook = $hookmanager->executeHooks('pdf_getlineprogress', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks |
|
1888 | + |
|
1889 | + if(!empty($hookmanager->resPrint)) return $hookmanager->resPrint; |
|
1890 | + } |
|
1891 | + if (empty($reshook)) |
|
1892 | + { |
|
1893 | + if ($object->lines[$i]->special_code == 3) return ''; |
|
1894 | + if (empty($hidedetails) || $hidedetails > 1) |
|
1895 | + { |
|
1896 | + if ($conf->global->SITUATION_DISPLAY_DIFF_ON_PDF) |
|
1897 | + { |
|
1898 | + $prev_progress = 0; |
|
1899 | + if (method_exists($object, 'get_prev_progress')) |
|
1900 | + { |
|
1901 | + $prev_progress = $object->lines[$i]->get_prev_progress($object->id); |
|
1902 | + } |
|
1903 | + $result = ($object->lines[$i]->situation_percent - $prev_progress) . '%'; |
|
1904 | + } |
|
1905 | + else |
|
1906 | + $result = $object->lines[$i]->situation_percent . '%'; |
|
1907 | + } |
|
1908 | + } |
|
1909 | + return $result; |
|
1910 | 1910 | } |
1911 | 1911 | |
1912 | 1912 | /** |
@@ -1920,49 +1920,49 @@ discard block |
||
1920 | 1920 | */ |
1921 | 1921 | function pdf_getlinetotalexcltax($object,$i,$outputlangs,$hidedetails=0) |
1922 | 1922 | { |
1923 | - global $conf, $hookmanager; |
|
1924 | - |
|
1925 | - $sign=1; |
|
1926 | - if (isset($object->type) && $object->type == 2 && ! empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign=-1; |
|
1927 | - |
|
1928 | - $reshook=0; |
|
1929 | - $result=''; |
|
1930 | - //if (is_object($hookmanager) && ( (isset($object->lines[$i]->product_type) && $object->lines[$i]->product_type == 9 && ! empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line) ) ) |
|
1931 | - if (is_object($hookmanager)) // Old code is commented on preceding line. Reproduct this test in the pdf_xxx function if you don't want your hook to run |
|
1932 | - { |
|
1933 | - $special_code = $object->lines[$i]->special_code; |
|
1934 | - if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); |
|
1935 | - $parameters = array('i'=>$i,'outputlangs'=>$outputlangs,'hidedetails'=>$hidedetails,'special_code'=>$special_code, 'sign'=>$sign); |
|
1936 | - $action=''; |
|
1937 | - $reshook = $hookmanager->executeHooks('pdf_getlinetotalexcltax',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks |
|
1938 | - |
|
1939 | - if(!empty($hookmanager->resPrint)) $result.=$hookmanager->resPrint; |
|
1940 | - } |
|
1923 | + global $conf, $hookmanager; |
|
1924 | + |
|
1925 | + $sign=1; |
|
1926 | + if (isset($object->type) && $object->type == 2 && ! empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign=-1; |
|
1927 | + |
|
1928 | + $reshook=0; |
|
1929 | + $result=''; |
|
1930 | + //if (is_object($hookmanager) && ( (isset($object->lines[$i]->product_type) && $object->lines[$i]->product_type == 9 && ! empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line) ) ) |
|
1931 | + if (is_object($hookmanager)) // Old code is commented on preceding line. Reproduct this test in the pdf_xxx function if you don't want your hook to run |
|
1932 | + { |
|
1933 | + $special_code = $object->lines[$i]->special_code; |
|
1934 | + if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); |
|
1935 | + $parameters = array('i'=>$i,'outputlangs'=>$outputlangs,'hidedetails'=>$hidedetails,'special_code'=>$special_code, 'sign'=>$sign); |
|
1936 | + $action=''; |
|
1937 | + $reshook = $hookmanager->executeHooks('pdf_getlinetotalexcltax',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks |
|
1938 | + |
|
1939 | + if(!empty($hookmanager->resPrint)) $result.=$hookmanager->resPrint; |
|
1940 | + } |
|
1941 | 1941 | if (empty($reshook)) |
1942 | 1942 | { |
1943 | - if ($object->lines[$i]->special_code == 3) |
|
1944 | - { |
|
1945 | - return $outputlangs->transnoentities("Option"); |
|
1946 | - } |
|
1943 | + if ($object->lines[$i]->special_code == 3) |
|
1944 | + { |
|
1945 | + return $outputlangs->transnoentities("Option"); |
|
1946 | + } |
|
1947 | 1947 | if (empty($hidedetails) || $hidedetails > 1) |
1948 | 1948 | { |
1949 | - $total_ht = ($conf->multicurrency->enabled && $object->multicurrency_tx != 1 ? $object->lines[$i]->multicurrency_total_ht : $object->lines[$i]->total_ht); |
|
1950 | - if ($object->lines[$i]->situation_percent > 0) |
|
1951 | - { |
|
1952 | - $prev_progress = 0; |
|
1953 | - $progress = 1; |
|
1954 | - if (method_exists($object->lines[$i], 'get_prev_progress')) |
|
1955 | - { |
|
1956 | - $prev_progress = $object->lines[$i]->get_prev_progress($object->id); |
|
1957 | - $progress = ($object->lines[$i]->situation_percent - $prev_progress) / 100; |
|
1958 | - } |
|
1959 | - $result.=price($sign * ($total_ht/($object->lines[$i]->situation_percent/100)) * $progress, 0, $outputlangs); |
|
1960 | - } |
|
1961 | - else |
|
1962 | - $result.=price($sign * $total_ht, 0, $outputlangs); |
|
1963 | - } |
|
1964 | - } |
|
1965 | - return $result; |
|
1949 | + $total_ht = ($conf->multicurrency->enabled && $object->multicurrency_tx != 1 ? $object->lines[$i]->multicurrency_total_ht : $object->lines[$i]->total_ht); |
|
1950 | + if ($object->lines[$i]->situation_percent > 0) |
|
1951 | + { |
|
1952 | + $prev_progress = 0; |
|
1953 | + $progress = 1; |
|
1954 | + if (method_exists($object->lines[$i], 'get_prev_progress')) |
|
1955 | + { |
|
1956 | + $prev_progress = $object->lines[$i]->get_prev_progress($object->id); |
|
1957 | + $progress = ($object->lines[$i]->situation_percent - $prev_progress) / 100; |
|
1958 | + } |
|
1959 | + $result.=price($sign * ($total_ht/($object->lines[$i]->situation_percent/100)) * $progress, 0, $outputlangs); |
|
1960 | + } |
|
1961 | + else |
|
1962 | + $result.=price($sign * $total_ht, 0, $outputlangs); |
|
1963 | + } |
|
1964 | + } |
|
1965 | + return $result; |
|
1966 | 1966 | } |
1967 | 1967 | |
1968 | 1968 | /** |
@@ -1976,33 +1976,33 @@ discard block |
||
1976 | 1976 | */ |
1977 | 1977 | function pdf_getlinetotalwithtax($object,$i,$outputlangs,$hidedetails=0) |
1978 | 1978 | { |
1979 | - global $hookmanager,$conf; |
|
1980 | - |
|
1981 | - $sign=1; |
|
1982 | - if (isset($object->type) && $object->type == 2 && ! empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign=-1; |
|
1983 | - |
|
1984 | - $reshook=0; |
|
1985 | - $result=''; |
|
1986 | - //if (is_object($hookmanager) && ( (isset($object->lines[$i]->product_type) && $object->lines[$i]->product_type == 9 && ! empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line) ) ) |
|
1987 | - if (is_object($hookmanager)) // Old code is commented on preceding line. Reproduct this test in the pdf_xxx function if you don't want your hook to run |
|
1988 | - { |
|
1989 | - $special_code = $object->lines[$i]->special_code; |
|
1990 | - if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); |
|
1991 | - $parameters = array('i'=>$i,'outputlangs'=>$outputlangs,'hidedetails'=>$hidedetails,'special_code'=>$special_code); |
|
1992 | - $action=''; |
|
1993 | - $reshook = $hookmanager->executeHooks('pdf_getlinetotalwithtax',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks |
|
1994 | - |
|
1995 | - if(!empty($hookmanager->resPrint)) $result.=$hookmanager->resPrint; |
|
1996 | - } |
|
1997 | - if (empty($reshook)) |
|
1998 | - { |
|
1999 | - if ($object->lines[$i]->special_code == 3) |
|
2000 | - { |
|
2001 | - $result.=$outputlangs->transnoentities("Option"); |
|
2002 | - } |
|
2003 | - elseif (empty($hidedetails) || $hidedetails > 1) $result.=price($sign * ($object->lines[$i]->total_ht) + ($object->lines[$i]->total_ht)*($object->lines[$i]->tva_tx)/100, 0, $outputlangs); |
|
2004 | - } |
|
2005 | - return $result; |
|
1979 | + global $hookmanager,$conf; |
|
1980 | + |
|
1981 | + $sign=1; |
|
1982 | + if (isset($object->type) && $object->type == 2 && ! empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign=-1; |
|
1983 | + |
|
1984 | + $reshook=0; |
|
1985 | + $result=''; |
|
1986 | + //if (is_object($hookmanager) && ( (isset($object->lines[$i]->product_type) && $object->lines[$i]->product_type == 9 && ! empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line) ) ) |
|
1987 | + if (is_object($hookmanager)) // Old code is commented on preceding line. Reproduct this test in the pdf_xxx function if you don't want your hook to run |
|
1988 | + { |
|
1989 | + $special_code = $object->lines[$i]->special_code; |
|
1990 | + if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); |
|
1991 | + $parameters = array('i'=>$i,'outputlangs'=>$outputlangs,'hidedetails'=>$hidedetails,'special_code'=>$special_code); |
|
1992 | + $action=''; |
|
1993 | + $reshook = $hookmanager->executeHooks('pdf_getlinetotalwithtax',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks |
|
1994 | + |
|
1995 | + if(!empty($hookmanager->resPrint)) $result.=$hookmanager->resPrint; |
|
1996 | + } |
|
1997 | + if (empty($reshook)) |
|
1998 | + { |
|
1999 | + if ($object->lines[$i]->special_code == 3) |
|
2000 | + { |
|
2001 | + $result.=$outputlangs->transnoentities("Option"); |
|
2002 | + } |
|
2003 | + elseif (empty($hidedetails) || $hidedetails > 1) $result.=price($sign * ($object->lines[$i]->total_ht) + ($object->lines[$i]->total_ht)*($object->lines[$i]->tva_tx)/100, 0, $outputlangs); |
|
2004 | + } |
|
2005 | + return $result; |
|
2006 | 2006 | } |
2007 | 2007 | |
2008 | 2008 | /** |
@@ -2016,41 +2016,41 @@ discard block |
||
2016 | 2016 | */ |
2017 | 2017 | function pdf_getTotalQty($object,$type,$outputlangs) |
2018 | 2018 | { |
2019 | - global $hookmanager; |
|
2020 | - |
|
2021 | - $total=0; |
|
2022 | - $nblignes=count($object->lines); |
|
2023 | - |
|
2024 | - // Loop on each lines |
|
2025 | - for ($i = 0 ; $i < $nblignes ; $i++) |
|
2026 | - { |
|
2027 | - if ($object->lines[$i]->special_code != 3) |
|
2028 | - { |
|
2029 | - if ($type=='all') |
|
2030 | - { |
|
2031 | - $total += $object->lines[$i]->qty; |
|
2032 | - } |
|
2033 | - else if ($type==9 && is_object($hookmanager) && (($object->lines[$i]->product_type == 9 && ! empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line))) |
|
2034 | - { |
|
2035 | - $special_code = $object->lines[$i]->special_code; |
|
2036 | - if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); |
|
2037 | - $parameters = array('i'=>$i,'outputlangs'=>$outputlangs,'hidedetails'=>$hidedetails,'special_code'=>$special_code); |
|
2038 | - $action=''; |
|
2039 | - $reshook = $hookmanager->executeHooks('pdf_getTotalQty',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks |
|
2040 | - return $hookmanager->resPrint; |
|
2041 | - } |
|
2042 | - else if ($type==0 && $object->lines[$i]->product_type == 0) |
|
2043 | - { |
|
2044 | - $total += $object->lines[$i]->qty; |
|
2045 | - } |
|
2046 | - else if ($type==1 && $object->lines[$i]->product_type == 1) |
|
2047 | - { |
|
2048 | - $total += $object->lines[$i]->qty; |
|
2049 | - } |
|
2050 | - } |
|
2051 | - } |
|
2052 | - |
|
2053 | - return $total; |
|
2019 | + global $hookmanager; |
|
2020 | + |
|
2021 | + $total=0; |
|
2022 | + $nblignes=count($object->lines); |
|
2023 | + |
|
2024 | + // Loop on each lines |
|
2025 | + for ($i = 0 ; $i < $nblignes ; $i++) |
|
2026 | + { |
|
2027 | + if ($object->lines[$i]->special_code != 3) |
|
2028 | + { |
|
2029 | + if ($type=='all') |
|
2030 | + { |
|
2031 | + $total += $object->lines[$i]->qty; |
|
2032 | + } |
|
2033 | + else if ($type==9 && is_object($hookmanager) && (($object->lines[$i]->product_type == 9 && ! empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line))) |
|
2034 | + { |
|
2035 | + $special_code = $object->lines[$i]->special_code; |
|
2036 | + if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); |
|
2037 | + $parameters = array('i'=>$i,'outputlangs'=>$outputlangs,'hidedetails'=>$hidedetails,'special_code'=>$special_code); |
|
2038 | + $action=''; |
|
2039 | + $reshook = $hookmanager->executeHooks('pdf_getTotalQty',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks |
|
2040 | + return $hookmanager->resPrint; |
|
2041 | + } |
|
2042 | + else if ($type==0 && $object->lines[$i]->product_type == 0) |
|
2043 | + { |
|
2044 | + $total += $object->lines[$i]->qty; |
|
2045 | + } |
|
2046 | + else if ($type==1 && $object->lines[$i]->product_type == 1) |
|
2047 | + { |
|
2048 | + $total += $object->lines[$i]->qty; |
|
2049 | + } |
|
2050 | + } |
|
2051 | + } |
|
2052 | + |
|
2053 | + return $total; |
|
2054 | 2054 | } |
2055 | 2055 | |
2056 | 2056 | /** |
@@ -2063,97 +2063,97 @@ discard block |
||
2063 | 2063 | */ |
2064 | 2064 | function pdf_getLinkedObjects($object,$outputlangs) |
2065 | 2065 | { |
2066 | - global $hookmanager; |
|
2067 | - |
|
2068 | - $linkedobjects=array(); |
|
2069 | - |
|
2070 | - $object->fetchObjectLinked(); |
|
2071 | - |
|
2072 | - foreach($object->linkedObjects as $objecttype => $objects) |
|
2073 | - { |
|
2074 | - if ($objecttype == 'facture') |
|
2075 | - { |
|
2076 | - // For invoice, we don't want to have a reference line on document. Image we are using recuring invoice, we will have a line longer than document width. |
|
2077 | - } |
|
2078 | - elseif ($objecttype == 'propal' || $objecttype == 'supplier_proposal') |
|
2079 | - { |
|
2080 | - $outputlangs->load('propal'); |
|
2081 | - |
|
2082 | - foreach($objects as $elementobject) |
|
2083 | - { |
|
2084 | - $linkedobjects[$objecttype]['ref_title'] = $outputlangs->transnoentities("RefProposal"); |
|
2085 | - $linkedobjects[$objecttype]['ref_value'] = $outputlangs->transnoentities($elementobject->ref); |
|
2086 | - $linkedobjects[$objecttype]['date_title'] = $outputlangs->transnoentities("DatePropal"); |
|
2087 | - $linkedobjects[$objecttype]['date_value'] = dol_print_date($elementobject->date,'day','',$outputlangs); |
|
2088 | - } |
|
2089 | - } |
|
2090 | - else if ($objecttype == 'commande' || $objecttype == 'supplier_order') |
|
2091 | - { |
|
2092 | - $outputlangs->load('orders'); |
|
2093 | - foreach($objects as $elementobject) |
|
2094 | - { |
|
2095 | - $linkedobjects[$objecttype]['ref_title'] = $outputlangs->transnoentities("RefOrder"); |
|
2096 | - $linkedobjects[$objecttype]['ref_value'] = $outputlangs->transnoentities($elementobject->ref) . ($elementobject->ref_client ? ' ('.$elementobject->ref_client.')' : '') . ($elementobject->ref_supplier ? ' ('.$elementobject->ref_supplier.')' : ''); |
|
2097 | - $linkedobjects[$objecttype]['date_title'] = $outputlangs->transnoentities("OrderDate"); |
|
2098 | - $linkedobjects[$objecttype]['date_value'] = dol_print_date($elementobject->date,'day','',$outputlangs); |
|
2099 | - } |
|
2100 | - } |
|
2101 | - else if ($objecttype == 'contrat') |
|
2102 | - { |
|
2103 | - $outputlangs->load('contracts'); |
|
2104 | - foreach($objects as $elementobject) |
|
2105 | - { |
|
2106 | - $linkedobjects[$objecttype]['ref_title'] = $outputlangs->transnoentities("RefContract"); |
|
2107 | - $linkedobjects[$objecttype]['ref_value'] = $outputlangs->transnoentities($elementobject->ref); |
|
2108 | - $linkedobjects[$objecttype]['date_title'] = $outputlangs->transnoentities("DateContract"); |
|
2109 | - $linkedobjects[$objecttype]['date_value'] = dol_print_date($elementobject->date_contrat,'day','',$outputlangs); |
|
2110 | - } |
|
2111 | - } |
|
2112 | - else if ($objecttype == 'shipping') |
|
2113 | - { |
|
2114 | - $outputlangs->loadLangs(array("orders", "sendings")); |
|
2115 | - |
|
2116 | - foreach($objects as $x => $elementobject) |
|
2117 | - { |
|
2118 | - $order=null; |
|
2119 | - // We concat this record info into fields xxx_value. title is overwrote. |
|
2120 | - if (empty($object->linkedObjects['commande']) && $object->element != 'commande') // There is not already a link to order and object is not the order, so we show also info with order |
|
2121 | - { |
|
2122 | - $elementobject->fetchObjectLinked(); |
|
2123 | - if (! empty($elementobject->linkedObjects['commande'])) $order = reset($elementobject->linkedObjects['commande']); |
|
2124 | - } |
|
2125 | - if (! is_object($order)) |
|
2126 | - { |
|
2127 | - $linkedobjects[$objecttype]['ref_title'] = $outputlangs->transnoentities("RefSending"); |
|
2128 | - if (! empty($linkedobjects[$objecttype]['ref_value'])) $linkedobjects[$objecttype]['ref_value'].=' / '; |
|
2129 | - $linkedobjects[$objecttype]['ref_value'].= $outputlangs->transnoentities($elementobject->ref); |
|
2130 | - //$linkedobjects[$objecttype]['date_title'] = $outputlangs->transnoentities("DateShipment"); |
|
2131 | - //if (! empty($linkedobjects[$objecttype]['date_value'])) $linkedobjects[$objecttype]['date_value'].=' / '; |
|
2132 | - //$linkedobjects[$objecttype]['date_value'].= dol_print_date($elementobject->date_delivery,'day','',$outputlangs); |
|
2133 | - } |
|
2134 | - else |
|
2135 | - { |
|
2136 | - $linkedobjects[$objecttype]['ref_title'] = $outputlangs->transnoentities("RefOrder") . ' / ' . $outputlangs->transnoentities("RefSending"); |
|
2137 | - if (empty($linkedobjects[$objecttype]['ref_value'])) $linkedobjects[$objecttype]['ref_value'] = $outputlangs->convToOutputCharset($order->ref) . ($order->ref_client ? ' ('.$order->ref_client.')' : ''); |
|
2138 | - $linkedobjects[$objecttype]['ref_value'].= ' / ' . $outputlangs->transnoentities($elementobject->ref); |
|
2139 | - //$linkedobjects[$objecttype]['date_title'] = $outputlangs->transnoentities("OrderDate") . ($elementobject->date_delivery ? ' / ' . $outputlangs->transnoentities("DateShipment") : ''); |
|
2140 | - //if (empty($linkedobjects[$objecttype]['date_value'])) $linkedobjects[$objecttype]['date_value'] = dol_print_date($order->date,'day','',$outputlangs); |
|
2141 | - //$linkedobjects[$objecttype]['date_value'].= ($elementobject->date_delivery ? ' / ' . dol_print_date($elementobject->date_delivery,'day','',$outputlangs) : ''); |
|
2142 | - } |
|
2143 | - } |
|
2144 | - } |
|
2145 | - } |
|
2146 | - |
|
2147 | - // For add external linked objects |
|
2148 | - if (is_object($hookmanager)) |
|
2149 | - { |
|
2150 | - $parameters = array('linkedobjects' => $linkedobjects, 'outputlangs'=>$outputlangs); |
|
2151 | - $action=''; |
|
2152 | - $hookmanager->executeHooks('pdf_getLinkedObjects',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks |
|
2153 | - if (! empty($hookmanager->resArray)) $linkedobjects = $hookmanager->resArray; |
|
2154 | - } |
|
2155 | - |
|
2156 | - return $linkedobjects; |
|
2066 | + global $hookmanager; |
|
2067 | + |
|
2068 | + $linkedobjects=array(); |
|
2069 | + |
|
2070 | + $object->fetchObjectLinked(); |
|
2071 | + |
|
2072 | + foreach($object->linkedObjects as $objecttype => $objects) |
|
2073 | + { |
|
2074 | + if ($objecttype == 'facture') |
|
2075 | + { |
|
2076 | + // For invoice, we don't want to have a reference line on document. Image we are using recuring invoice, we will have a line longer than document width. |
|
2077 | + } |
|
2078 | + elseif ($objecttype == 'propal' || $objecttype == 'supplier_proposal') |
|
2079 | + { |
|
2080 | + $outputlangs->load('propal'); |
|
2081 | + |
|
2082 | + foreach($objects as $elementobject) |
|
2083 | + { |
|
2084 | + $linkedobjects[$objecttype]['ref_title'] = $outputlangs->transnoentities("RefProposal"); |
|
2085 | + $linkedobjects[$objecttype]['ref_value'] = $outputlangs->transnoentities($elementobject->ref); |
|
2086 | + $linkedobjects[$objecttype]['date_title'] = $outputlangs->transnoentities("DatePropal"); |
|
2087 | + $linkedobjects[$objecttype]['date_value'] = dol_print_date($elementobject->date,'day','',$outputlangs); |
|
2088 | + } |
|
2089 | + } |
|
2090 | + else if ($objecttype == 'commande' || $objecttype == 'supplier_order') |
|
2091 | + { |
|
2092 | + $outputlangs->load('orders'); |
|
2093 | + foreach($objects as $elementobject) |
|
2094 | + { |
|
2095 | + $linkedobjects[$objecttype]['ref_title'] = $outputlangs->transnoentities("RefOrder"); |
|
2096 | + $linkedobjects[$objecttype]['ref_value'] = $outputlangs->transnoentities($elementobject->ref) . ($elementobject->ref_client ? ' ('.$elementobject->ref_client.')' : '') . ($elementobject->ref_supplier ? ' ('.$elementobject->ref_supplier.')' : ''); |
|
2097 | + $linkedobjects[$objecttype]['date_title'] = $outputlangs->transnoentities("OrderDate"); |
|
2098 | + $linkedobjects[$objecttype]['date_value'] = dol_print_date($elementobject->date,'day','',$outputlangs); |
|
2099 | + } |
|
2100 | + } |
|
2101 | + else if ($objecttype == 'contrat') |
|
2102 | + { |
|
2103 | + $outputlangs->load('contracts'); |
|
2104 | + foreach($objects as $elementobject) |
|
2105 | + { |
|
2106 | + $linkedobjects[$objecttype]['ref_title'] = $outputlangs->transnoentities("RefContract"); |
|
2107 | + $linkedobjects[$objecttype]['ref_value'] = $outputlangs->transnoentities($elementobject->ref); |
|
2108 | + $linkedobjects[$objecttype]['date_title'] = $outputlangs->transnoentities("DateContract"); |
|
2109 | + $linkedobjects[$objecttype]['date_value'] = dol_print_date($elementobject->date_contrat,'day','',$outputlangs); |
|
2110 | + } |
|
2111 | + } |
|
2112 | + else if ($objecttype == 'shipping') |
|
2113 | + { |
|
2114 | + $outputlangs->loadLangs(array("orders", "sendings")); |
|
2115 | + |
|
2116 | + foreach($objects as $x => $elementobject) |
|
2117 | + { |
|
2118 | + $order=null; |
|
2119 | + // We concat this record info into fields xxx_value. title is overwrote. |
|
2120 | + if (empty($object->linkedObjects['commande']) && $object->element != 'commande') // There is not already a link to order and object is not the order, so we show also info with order |
|
2121 | + { |
|
2122 | + $elementobject->fetchObjectLinked(); |
|
2123 | + if (! empty($elementobject->linkedObjects['commande'])) $order = reset($elementobject->linkedObjects['commande']); |
|
2124 | + } |
|
2125 | + if (! is_object($order)) |
|
2126 | + { |
|
2127 | + $linkedobjects[$objecttype]['ref_title'] = $outputlangs->transnoentities("RefSending"); |
|
2128 | + if (! empty($linkedobjects[$objecttype]['ref_value'])) $linkedobjects[$objecttype]['ref_value'].=' / '; |
|
2129 | + $linkedobjects[$objecttype]['ref_value'].= $outputlangs->transnoentities($elementobject->ref); |
|
2130 | + //$linkedobjects[$objecttype]['date_title'] = $outputlangs->transnoentities("DateShipment"); |
|
2131 | + //if (! empty($linkedobjects[$objecttype]['date_value'])) $linkedobjects[$objecttype]['date_value'].=' / '; |
|
2132 | + //$linkedobjects[$objecttype]['date_value'].= dol_print_date($elementobject->date_delivery,'day','',$outputlangs); |
|
2133 | + } |
|
2134 | + else |
|
2135 | + { |
|
2136 | + $linkedobjects[$objecttype]['ref_title'] = $outputlangs->transnoentities("RefOrder") . ' / ' . $outputlangs->transnoentities("RefSending"); |
|
2137 | + if (empty($linkedobjects[$objecttype]['ref_value'])) $linkedobjects[$objecttype]['ref_value'] = $outputlangs->convToOutputCharset($order->ref) . ($order->ref_client ? ' ('.$order->ref_client.')' : ''); |
|
2138 | + $linkedobjects[$objecttype]['ref_value'].= ' / ' . $outputlangs->transnoentities($elementobject->ref); |
|
2139 | + //$linkedobjects[$objecttype]['date_title'] = $outputlangs->transnoentities("OrderDate") . ($elementobject->date_delivery ? ' / ' . $outputlangs->transnoentities("DateShipment") : ''); |
|
2140 | + //if (empty($linkedobjects[$objecttype]['date_value'])) $linkedobjects[$objecttype]['date_value'] = dol_print_date($order->date,'day','',$outputlangs); |
|
2141 | + //$linkedobjects[$objecttype]['date_value'].= ($elementobject->date_delivery ? ' / ' . dol_print_date($elementobject->date_delivery,'day','',$outputlangs) : ''); |
|
2142 | + } |
|
2143 | + } |
|
2144 | + } |
|
2145 | + } |
|
2146 | + |
|
2147 | + // For add external linked objects |
|
2148 | + if (is_object($hookmanager)) |
|
2149 | + { |
|
2150 | + $parameters = array('linkedobjects' => $linkedobjects, 'outputlangs'=>$outputlangs); |
|
2151 | + $action=''; |
|
2152 | + $hookmanager->executeHooks('pdf_getLinkedObjects',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks |
|
2153 | + if (! empty($hookmanager->resArray)) $linkedobjects = $hookmanager->resArray; |
|
2154 | + } |
|
2155 | + |
|
2156 | + return $linkedobjects; |
|
2157 | 2157 | } |
2158 | 2158 | |
2159 | 2159 | /** |
@@ -2165,24 +2165,24 @@ discard block |
||
2165 | 2165 | */ |
2166 | 2166 | function pdf_getSizeForImage($realpath) |
2167 | 2167 | { |
2168 | - global $conf; |
|
2169 | - |
|
2170 | - $maxwidth=(empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH)?20:$conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH); |
|
2171 | - $maxheight=(empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_HEIGHT)?32:$conf->global->MAIN_DOCUMENTS_WITH_PICTURE_HEIGHT); |
|
2172 | - include_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php'; |
|
2173 | - $tmp=dol_getImageSize($realpath); |
|
2174 | - if ($tmp['height']) |
|
2175 | - { |
|
2176 | - $width=(int) round($maxheight*$tmp['width']/$tmp['height']); // I try to use maxheight |
|
2177 | - if ($width > $maxwidth) // Pb with maxheight, so i use maxwidth |
|
2178 | - { |
|
2179 | - $width=$maxwidth; |
|
2180 | - $height=(int) round($maxwidth*$tmp['height']/$tmp['width']); |
|
2181 | - } |
|
2182 | - else // No pb with maxheight |
|
2183 | - { |
|
2184 | - $height=$maxheight; |
|
2185 | - } |
|
2186 | - } |
|
2187 | - return array('width'=>$width,'height'=>$height); |
|
2168 | + global $conf; |
|
2169 | + |
|
2170 | + $maxwidth=(empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH)?20:$conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH); |
|
2171 | + $maxheight=(empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_HEIGHT)?32:$conf->global->MAIN_DOCUMENTS_WITH_PICTURE_HEIGHT); |
|
2172 | + include_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php'; |
|
2173 | + $tmp=dol_getImageSize($realpath); |
|
2174 | + if ($tmp['height']) |
|
2175 | + { |
|
2176 | + $width=(int) round($maxheight*$tmp['width']/$tmp['height']); // I try to use maxheight |
|
2177 | + if ($width > $maxwidth) // Pb with maxheight, so i use maxwidth |
|
2178 | + { |
|
2179 | + $width=$maxwidth; |
|
2180 | + $height=(int) round($maxwidth*$tmp['height']/$tmp['width']); |
|
2181 | + } |
|
2182 | + else // No pb with maxheight |
|
2183 | + { |
|
2184 | + $height=$maxheight; |
|
2185 | + } |
|
2186 | + } |
|
2187 | + return array('width'=>$width,'height'=>$height); |
|
2188 | 2188 | } |
@@ -84,330 +84,330 @@ |
||
84 | 84 | */ |
85 | 85 | function calcul_price_total($qty, $pu, $remise_percent_ligne, $txtva, $uselocaltax1_rate, $uselocaltax2_rate, $remise_percent_global, $price_base_type, $info_bits, $type, $seller = '', $localtaxes_array='', $progress=100, $multicurrency_tx=1, $pu_devise=0) |
86 | 86 | { |
87 | - global $conf,$mysoc,$db; |
|
88 | - |
|
89 | - $result=array(); |
|
90 | - |
|
91 | - // Clean parameters |
|
92 | - if (empty($info_bits)) $info_bits=0; |
|
93 | - if (empty($txtva)) $txtva=0; |
|
94 | - if (empty($seller) || ! is_object($seller)) |
|
95 | - { |
|
96 | - dol_syslog("Price.lib::calcul_price_total Warning: function is called with parameter seller that is missing", LOG_WARNING); |
|
97 | - if (! is_object($mysoc)) // mysoc may be not defined (during migration process) |
|
98 | - { |
|
99 | - $mysoc=new Societe($db); |
|
100 | - $mysoc->setMysoc($conf); |
|
101 | - } |
|
102 | - $seller=$mysoc; // If sell is done to a customer, $seller is not provided, we use $mysoc |
|
103 | - //var_dump($seller->country_id);exit; |
|
104 | - } |
|
105 | - if (empty($localtaxes_array) || ! is_array($localtaxes_array)) |
|
106 | - { |
|
107 | - dol_syslog("Price.lib::calcul_price_total Warning: function is called with parameter localtaxes_array that is missing", LOG_WARNING); |
|
108 | - } |
|
109 | - // Too verbose. Enable for debug only |
|
110 | - //dol_syslog("Price.lib::calcul_price_total qty=".$qty." pu=".$pu." remiserpercent_ligne=".$remise_percent_ligne." txtva=".$txtva." uselocaltax1_rate=".$uselocaltax1_rate." uselocaltax2_rate=".$uselocaltax2_rate.' remise_percent_global='.$remise_percent_global.' price_base_type='.$ice_base_type.' type='.$type.' progress='.$progress); |
|
111 | - |
|
112 | - $countryid=$seller->country_id; |
|
113 | - |
|
114 | - if (is_numeric($uselocaltax1_rate)) $uselocaltax1_rate=(float) $uselocaltax1_rate; |
|
115 | - if (is_numeric($uselocaltax2_rate)) $uselocaltax2_rate=(float) $uselocaltax2_rate; |
|
116 | - |
|
117 | - if ($uselocaltax1_rate < 0) $uselocaltax1_rate=$seller->localtax1_assuj; |
|
118 | - if ($uselocaltax2_rate < 0) $uselocaltax2_rate=$seller->localtax2_assuj; |
|
119 | - |
|
120 | - //var_dump($uselocaltax1_rate.' - '.$uselocaltax2_rate); |
|
121 | - dol_syslog('Price.lib::calcul_price_total qty='.$qty.' pu='.$pu.' remise_percent_ligne='.$remise_percent_ligne.' txtva='.$txtva.' uselocaltax1_rate='.$uselocaltax1_rate.' uselocaltax2_rate='.$uselocaltax2_rate.' remise_percent_global='.$remise_percent_global.' price_base_type='.$price_base_type.' type='.$type.' progress='.$progress); |
|
87 | + global $conf,$mysoc,$db; |
|
88 | + |
|
89 | + $result=array(); |
|
90 | + |
|
91 | + // Clean parameters |
|
92 | + if (empty($info_bits)) $info_bits=0; |
|
93 | + if (empty($txtva)) $txtva=0; |
|
94 | + if (empty($seller) || ! is_object($seller)) |
|
95 | + { |
|
96 | + dol_syslog("Price.lib::calcul_price_total Warning: function is called with parameter seller that is missing", LOG_WARNING); |
|
97 | + if (! is_object($mysoc)) // mysoc may be not defined (during migration process) |
|
98 | + { |
|
99 | + $mysoc=new Societe($db); |
|
100 | + $mysoc->setMysoc($conf); |
|
101 | + } |
|
102 | + $seller=$mysoc; // If sell is done to a customer, $seller is not provided, we use $mysoc |
|
103 | + //var_dump($seller->country_id);exit; |
|
104 | + } |
|
105 | + if (empty($localtaxes_array) || ! is_array($localtaxes_array)) |
|
106 | + { |
|
107 | + dol_syslog("Price.lib::calcul_price_total Warning: function is called with parameter localtaxes_array that is missing", LOG_WARNING); |
|
108 | + } |
|
109 | + // Too verbose. Enable for debug only |
|
110 | + //dol_syslog("Price.lib::calcul_price_total qty=".$qty." pu=".$pu." remiserpercent_ligne=".$remise_percent_ligne." txtva=".$txtva." uselocaltax1_rate=".$uselocaltax1_rate." uselocaltax2_rate=".$uselocaltax2_rate.' remise_percent_global='.$remise_percent_global.' price_base_type='.$ice_base_type.' type='.$type.' progress='.$progress); |
|
111 | + |
|
112 | + $countryid=$seller->country_id; |
|
113 | + |
|
114 | + if (is_numeric($uselocaltax1_rate)) $uselocaltax1_rate=(float) $uselocaltax1_rate; |
|
115 | + if (is_numeric($uselocaltax2_rate)) $uselocaltax2_rate=(float) $uselocaltax2_rate; |
|
116 | + |
|
117 | + if ($uselocaltax1_rate < 0) $uselocaltax1_rate=$seller->localtax1_assuj; |
|
118 | + if ($uselocaltax2_rate < 0) $uselocaltax2_rate=$seller->localtax2_assuj; |
|
119 | + |
|
120 | + //var_dump($uselocaltax1_rate.' - '.$uselocaltax2_rate); |
|
121 | + dol_syslog('Price.lib::calcul_price_total qty='.$qty.' pu='.$pu.' remise_percent_ligne='.$remise_percent_ligne.' txtva='.$txtva.' uselocaltax1_rate='.$uselocaltax1_rate.' uselocaltax2_rate='.$uselocaltax2_rate.' remise_percent_global='.$remise_percent_global.' price_base_type='.$price_base_type.' type='.$type.' progress='.$progress); |
|
122 | 122 | |
123 | 123 | // Now we search localtaxes information ourself (rates and types). |
124 | - $localtax1_type=0; |
|
125 | - $localtax2_type=0; |
|
126 | - |
|
127 | - if (is_array($localtaxes_array)) |
|
128 | - { |
|
129 | - $localtax1_type = $localtaxes_array[0]; |
|
130 | - $localtax1_rate = $localtaxes_array[1]; |
|
131 | - $localtax2_type = $localtaxes_array[2]; |
|
132 | - $localtax2_rate = $localtaxes_array[3]; |
|
133 | - } |
|
134 | - else // deprecated method. values and type for localtaxes must be provided by caller and loaded with getLocalTaxesFromRate |
|
135 | - { |
|
136 | - $sql = "SELECT taux, localtax1, localtax2, localtax1_type, localtax2_type"; |
|
137 | - $sql.= " FROM ".MAIN_DB_PREFIX."c_tva as cv"; |
|
138 | - $sql.= " WHERE cv.taux = ".$txtva; |
|
139 | - $sql.= " AND cv.fk_pays = ".$countryid; |
|
140 | - dol_syslog("Price.lib::calcul_price_total search vat information using old deprecated method", LOG_WARNING); |
|
141 | - $resql = $db->query($sql); |
|
142 | - if ($resql) |
|
143 | - { |
|
144 | - $obj = $db->fetch_object($resql); |
|
145 | - if ($obj) |
|
146 | - { |
|
147 | - $localtax1_rate=$obj->localtax1; |
|
148 | - $localtax2_rate=$obj->localtax2; |
|
149 | - $localtax1_type=$obj->localtax1_type; |
|
150 | - $localtax2_type=$obj->localtax2_type; |
|
151 | - //var_dump($localtax1_rate.' '.$localtax2_rate.' '.$localtax1_type.' '.$localtax2_type);exit; |
|
152 | - } |
|
153 | - } |
|
154 | - else dol_print_error($db); |
|
155 | - } |
|
156 | - |
|
157 | - // pu calculation from pu_devise if pu empty |
|
158 | - if (empty($pu) && !empty($pu_devise)) { |
|
159 | - if (! empty($multicurrency_tx)) $pu = $pu_devise / $multicurrency_tx; |
|
160 | - else |
|
161 | - { |
|
162 | - dol_syslog('Price.lib::calcul_price_total function called with bad parameters combination (multicurrency_tx empty when pu_devise not) ', LOG_ERR); |
|
163 | - return array(); |
|
164 | - } |
|
165 | - } |
|
166 | - if ($pu === '') $pu=0; |
|
167 | - // pu_devise calculation from pu |
|
168 | - if (empty($pu_devise) && !empty($multicurrency_tx)) { |
|
169 | - if (is_numeric($pu) && is_numeric($multicurrency_tx)) $pu_devise = $pu * $multicurrency_tx; |
|
170 | - else |
|
171 | - { |
|
172 | - dol_syslog('Price.lib::calcul_price_total function called with bad parameters combination (pu or multicurrency_tx are not numeric)', LOG_ERR); |
|
173 | - return array(); |
|
174 | - } |
|
175 | - } |
|
176 | - |
|
177 | - // initialize total (may be HT or TTC depending on price_base_type) |
|
178 | - $tot_sans_remise = $pu * $qty * $progress / 100; |
|
179 | - $tot_avec_remise_ligne = $tot_sans_remise * (1 - ($remise_percent_ligne / 100)); |
|
180 | - $tot_avec_remise = $tot_avec_remise_ligne * (1 - ($remise_percent_global / 100)); |
|
181 | - |
|
182 | - // initialize result array |
|
183 | - for ($i=0; $i <= 15; $i++) $result[$i] = 0; |
|
184 | - |
|
185 | - // if there's some localtax including vat, we calculate localtaxes (we will add later) |
|
124 | + $localtax1_type=0; |
|
125 | + $localtax2_type=0; |
|
126 | + |
|
127 | + if (is_array($localtaxes_array)) |
|
128 | + { |
|
129 | + $localtax1_type = $localtaxes_array[0]; |
|
130 | + $localtax1_rate = $localtaxes_array[1]; |
|
131 | + $localtax2_type = $localtaxes_array[2]; |
|
132 | + $localtax2_rate = $localtaxes_array[3]; |
|
133 | + } |
|
134 | + else // deprecated method. values and type for localtaxes must be provided by caller and loaded with getLocalTaxesFromRate |
|
135 | + { |
|
136 | + $sql = "SELECT taux, localtax1, localtax2, localtax1_type, localtax2_type"; |
|
137 | + $sql.= " FROM ".MAIN_DB_PREFIX."c_tva as cv"; |
|
138 | + $sql.= " WHERE cv.taux = ".$txtva; |
|
139 | + $sql.= " AND cv.fk_pays = ".$countryid; |
|
140 | + dol_syslog("Price.lib::calcul_price_total search vat information using old deprecated method", LOG_WARNING); |
|
141 | + $resql = $db->query($sql); |
|
142 | + if ($resql) |
|
143 | + { |
|
144 | + $obj = $db->fetch_object($resql); |
|
145 | + if ($obj) |
|
146 | + { |
|
147 | + $localtax1_rate=$obj->localtax1; |
|
148 | + $localtax2_rate=$obj->localtax2; |
|
149 | + $localtax1_type=$obj->localtax1_type; |
|
150 | + $localtax2_type=$obj->localtax2_type; |
|
151 | + //var_dump($localtax1_rate.' '.$localtax2_rate.' '.$localtax1_type.' '.$localtax2_type);exit; |
|
152 | + } |
|
153 | + } |
|
154 | + else dol_print_error($db); |
|
155 | + } |
|
156 | + |
|
157 | + // pu calculation from pu_devise if pu empty |
|
158 | + if (empty($pu) && !empty($pu_devise)) { |
|
159 | + if (! empty($multicurrency_tx)) $pu = $pu_devise / $multicurrency_tx; |
|
160 | + else |
|
161 | + { |
|
162 | + dol_syslog('Price.lib::calcul_price_total function called with bad parameters combination (multicurrency_tx empty when pu_devise not) ', LOG_ERR); |
|
163 | + return array(); |
|
164 | + } |
|
165 | + } |
|
166 | + if ($pu === '') $pu=0; |
|
167 | + // pu_devise calculation from pu |
|
168 | + if (empty($pu_devise) && !empty($multicurrency_tx)) { |
|
169 | + if (is_numeric($pu) && is_numeric($multicurrency_tx)) $pu_devise = $pu * $multicurrency_tx; |
|
170 | + else |
|
171 | + { |
|
172 | + dol_syslog('Price.lib::calcul_price_total function called with bad parameters combination (pu or multicurrency_tx are not numeric)', LOG_ERR); |
|
173 | + return array(); |
|
174 | + } |
|
175 | + } |
|
176 | + |
|
177 | + // initialize total (may be HT or TTC depending on price_base_type) |
|
178 | + $tot_sans_remise = $pu * $qty * $progress / 100; |
|
179 | + $tot_avec_remise_ligne = $tot_sans_remise * (1 - ($remise_percent_ligne / 100)); |
|
180 | + $tot_avec_remise = $tot_avec_remise_ligne * (1 - ($remise_percent_global / 100)); |
|
181 | + |
|
182 | + // initialize result array |
|
183 | + for ($i=0; $i <= 15; $i++) $result[$i] = 0; |
|
184 | + |
|
185 | + // if there's some localtax including vat, we calculate localtaxes (we will add later) |
|
186 | 186 | |
187 | 187 | //If input unit price is 'HT', we need to have the totals with main VAT for a correct calculation |
188 | 188 | if ($price_base_type != 'TTC') |
189 | 189 | { |
190 | - $tot_sans_remise_wt = price2num($tot_sans_remise * (1 + ($txtva / 100)),'MU'); |
|
191 | - $tot_avec_remise_wt = price2num($tot_avec_remise * (1 + ($txtva / 100)),'MU'); |
|
192 | - $pu_wt = price2num($pu * (1 + ($txtva / 100)),'MU'); |
|
190 | + $tot_sans_remise_wt = price2num($tot_sans_remise * (1 + ($txtva / 100)),'MU'); |
|
191 | + $tot_avec_remise_wt = price2num($tot_avec_remise * (1 + ($txtva / 100)),'MU'); |
|
192 | + $pu_wt = price2num($pu * (1 + ($txtva / 100)),'MU'); |
|
193 | 193 | } |
194 | 194 | else |
195 | 195 | { |
196 | - $tot_sans_remise_wt = $tot_sans_remise; |
|
197 | - $tot_avec_remise_wt = $tot_avec_remise; |
|
198 | - $pu_wt = $pu; |
|
196 | + $tot_sans_remise_wt = $tot_sans_remise; |
|
197 | + $tot_avec_remise_wt = $tot_avec_remise; |
|
198 | + $pu_wt = $pu; |
|
199 | 199 | } |
200 | 200 | |
201 | - //print 'rr'.$price_base_type.'-'.$txtva.'-'.$tot_sans_remise_wt."-".$pu_wt."-".$uselocaltax1_rate."-".$localtax1_rate."-".$localtax1_type."\n"; |
|
201 | + //print 'rr'.$price_base_type.'-'.$txtva.'-'.$tot_sans_remise_wt."-".$pu_wt."-".$uselocaltax1_rate."-".$localtax1_rate."-".$localtax1_type."\n"; |
|
202 | 202 | |
203 | 203 | $localtaxes = array(0,0,0); |
204 | 204 | $apply_tax = false; |
205 | - switch($localtax1_type) { |
|
206 | - case '2': // localtax on product or service |
|
205 | + switch($localtax1_type) { |
|
206 | + case '2': // localtax on product or service |
|
207 | 207 | $apply_tax = true; |
208 | 208 | break; |
209 | - case '4': // localtax on product |
|
209 | + case '4': // localtax on product |
|
210 | 210 | if ($type == 0) $apply_tax = true; |
211 | 211 | break; |
212 | - case '6': // localtax on service |
|
212 | + case '6': // localtax on service |
|
213 | 213 | if ($type == 1) $apply_tax = true; |
214 | 214 | break; |
215 | 215 | } |
216 | 216 | |
217 | 217 | if ($uselocaltax1_rate && $apply_tax) { |
218 | - $result[14] = price2num(($tot_sans_remise_wt * (1 + ( $localtax1_rate / 100))) - $tot_sans_remise_wt, 'MT'); |
|
219 | - $localtaxes[0] += $result[14]; |
|
218 | + $result[14] = price2num(($tot_sans_remise_wt * (1 + ( $localtax1_rate / 100))) - $tot_sans_remise_wt, 'MT'); |
|
219 | + $localtaxes[0] += $result[14]; |
|
220 | 220 | |
221 | - $result[9] = price2num(($tot_avec_remise_wt * (1 + ( $localtax1_rate / 100))) - $tot_avec_remise_wt, 'MT'); |
|
222 | - $localtaxes[1] += $result[9]; |
|
221 | + $result[9] = price2num(($tot_avec_remise_wt * (1 + ( $localtax1_rate / 100))) - $tot_avec_remise_wt, 'MT'); |
|
222 | + $localtaxes[1] += $result[9]; |
|
223 | 223 | |
224 | - $result[11] = price2num(($pu_wt * (1 + ( $localtax1_rate / 100))) - $pu_wt, 'MU'); |
|
225 | - $localtaxes[2] += $result[11]; |
|
224 | + $result[11] = price2num(($pu_wt * (1 + ( $localtax1_rate / 100))) - $pu_wt, 'MU'); |
|
225 | + $localtaxes[2] += $result[11]; |
|
226 | 226 | } |
227 | 227 | |
228 | 228 | $apply_tax = false; |
229 | - switch($localtax2_type) { |
|
230 | - case '2': // localtax on product or service |
|
229 | + switch($localtax2_type) { |
|
230 | + case '2': // localtax on product or service |
|
231 | 231 | $apply_tax = true; |
232 | 232 | break; |
233 | - case '4': // localtax on product |
|
233 | + case '4': // localtax on product |
|
234 | 234 | if ($type == 0) $apply_tax = true; |
235 | 235 | break; |
236 | - case '6': // localtax on service |
|
236 | + case '6': // localtax on service |
|
237 | 237 | if ($type == 1) $apply_tax = true; |
238 | 238 | break; |
239 | 239 | } |
240 | 240 | if ($uselocaltax2_rate && $apply_tax) { |
241 | - $result[15] = price2num(($tot_sans_remise_wt * (1 + ( $localtax2_rate / 100))) - $tot_sans_remise_wt, 'MT'); |
|
242 | - $localtaxes[0] += $result[15]; |
|
241 | + $result[15] = price2num(($tot_sans_remise_wt * (1 + ( $localtax2_rate / 100))) - $tot_sans_remise_wt, 'MT'); |
|
242 | + $localtaxes[0] += $result[15]; |
|
243 | + |
|
244 | + $result[10] = price2num(($tot_avec_remise_wt * (1 + ( $localtax2_rate / 100))) - $tot_avec_remise_wt, 'MT'); |
|
245 | + $localtaxes[1] += $result[10]; |
|
243 | 246 | |
244 | - $result[10] = price2num(($tot_avec_remise_wt * (1 + ( $localtax2_rate / 100))) - $tot_avec_remise_wt, 'MT'); |
|
245 | - $localtaxes[1] += $result[10]; |
|
247 | + $result[12] = price2num(($pu_wt * (1 + ( $localtax2_rate / 100))) - $pu_wt, 'MU'); |
|
248 | + $localtaxes[2] += $result[12]; |
|
249 | + } |
|
246 | 250 | |
247 | - $result[12] = price2num(($pu_wt * (1 + ( $localtax2_rate / 100))) - $pu_wt, 'MU'); |
|
248 | - $localtaxes[2] += $result[12]; |
|
251 | + //dol_syslog("price.lib::calcul_price_total $qty, $pu, $remise_percent_ligne, $txtva, $price_base_type $info_bits"); |
|
252 | + if ($price_base_type == 'HT') |
|
253 | + { |
|
254 | + // We work to define prices using the price without tax |
|
255 | + $result[6] = price2num($tot_sans_remise, 'MT'); |
|
256 | + $result[8] = price2num($tot_sans_remise * (1 + ( (($info_bits & 1)?0:$txtva) / 100)) + $localtaxes[0], 'MT'); // Selon TVA NPR ou non |
|
257 | + $result8bis= price2num($tot_sans_remise * (1 + ( $txtva / 100)) + $localtaxes[0], 'MT'); // Si TVA consideree normale (non NPR) |
|
258 | + $result[7] = price2num($result8bis - ($result[6] + $localtaxes[0]), 'MT'); |
|
259 | + |
|
260 | + $result[0] = price2num($tot_avec_remise, 'MT'); |
|
261 | + $result[2] = price2num($tot_avec_remise * (1 + ( (($info_bits & 1)?0:$txtva) / 100)) + $localtaxes[1], 'MT'); // Selon TVA NPR ou non |
|
262 | + $result2bis= price2num($tot_avec_remise * (1 + ( $txtva / 100)) + $localtaxes[1], 'MT'); // Si TVA consideree normale (non NPR) |
|
263 | + $result[1] = price2num($result2bis - ($result[0] + $localtaxes[1]), 'MT'); // Total VAT = TTC - (HT + localtax) |
|
264 | + |
|
265 | + $result[3] = price2num($pu, 'MU'); |
|
266 | + $result[5] = price2num($pu * (1 + ( (($info_bits & 1)?0:$txtva) / 100)) + $localtaxes[2], 'MU'); // Selon TVA NPR ou non |
|
267 | + $result5bis= price2num($pu * (1 + ($txtva / 100)) + $localtaxes[2], 'MU'); // Si TVA consideree normale (non NPR) |
|
268 | + $result[4] = price2num($result5bis - ($result[3] + $localtaxes[2]), 'MU'); |
|
269 | + } |
|
270 | + else |
|
271 | + { |
|
272 | + // We work to define prices using the price with tax |
|
273 | + $result[8] = price2num($tot_sans_remise + $localtaxes[0], 'MT'); |
|
274 | + $result[6] = price2num($tot_sans_remise / (1 + ((($info_bits & 1)?0:$txtva) / 100)), 'MT'); // Selon TVA NPR ou non |
|
275 | + $result6bis= price2num($tot_sans_remise / (1 + ($txtva / 100)), 'MT'); // Si TVA consideree normale (non NPR) |
|
276 | + $result[7] = price2num($result[8] - ($result6bis + $localtaxes[0]), 'MT'); |
|
277 | + |
|
278 | + $result[2] = price2num($tot_avec_remise + $localtaxes[1], 'MT'); |
|
279 | + $result[0] = price2num($tot_avec_remise / (1 + ((($info_bits & 1)?0:$txtva) / 100)), 'MT'); // Selon TVA NPR ou non |
|
280 | + $result0bis= price2num($tot_avec_remise / (1 + ($txtva / 100)), 'MT'); // Si TVA consideree normale (non NPR) |
|
281 | + $result[1] = price2num($result[2] - ($result0bis + $localtaxes[1]), 'MT'); // Total VAT = TTC - (HT + localtax) |
|
282 | + |
|
283 | + $result[5] = price2num($pu + $localtaxes[2], 'MU'); |
|
284 | + $result[3] = price2num($pu / (1 + ((($info_bits & 1)?0:$txtva) / 100)), 'MU'); // Selon TVA NPR ou non |
|
285 | + $result3bis= price2num($pu / (1 + ($txtva / 100)), 'MU'); // Si TVA consideree normale (non NPR) |
|
286 | + $result[4] = price2num($result[5] - ($result3bis + $localtaxes[2]), 'MU'); |
|
249 | 287 | } |
250 | 288 | |
251 | - //dol_syslog("price.lib::calcul_price_total $qty, $pu, $remise_percent_ligne, $txtva, $price_base_type $info_bits"); |
|
252 | - if ($price_base_type == 'HT') |
|
253 | - { |
|
254 | - // We work to define prices using the price without tax |
|
255 | - $result[6] = price2num($tot_sans_remise, 'MT'); |
|
256 | - $result[8] = price2num($tot_sans_remise * (1 + ( (($info_bits & 1)?0:$txtva) / 100)) + $localtaxes[0], 'MT'); // Selon TVA NPR ou non |
|
257 | - $result8bis= price2num($tot_sans_remise * (1 + ( $txtva / 100)) + $localtaxes[0], 'MT'); // Si TVA consideree normale (non NPR) |
|
258 | - $result[7] = price2num($result8bis - ($result[6] + $localtaxes[0]), 'MT'); |
|
259 | - |
|
260 | - $result[0] = price2num($tot_avec_remise, 'MT'); |
|
261 | - $result[2] = price2num($tot_avec_remise * (1 + ( (($info_bits & 1)?0:$txtva) / 100)) + $localtaxes[1], 'MT'); // Selon TVA NPR ou non |
|
262 | - $result2bis= price2num($tot_avec_remise * (1 + ( $txtva / 100)) + $localtaxes[1], 'MT'); // Si TVA consideree normale (non NPR) |
|
263 | - $result[1] = price2num($result2bis - ($result[0] + $localtaxes[1]), 'MT'); // Total VAT = TTC - (HT + localtax) |
|
264 | - |
|
265 | - $result[3] = price2num($pu, 'MU'); |
|
266 | - $result[5] = price2num($pu * (1 + ( (($info_bits & 1)?0:$txtva) / 100)) + $localtaxes[2], 'MU'); // Selon TVA NPR ou non |
|
267 | - $result5bis= price2num($pu * (1 + ($txtva / 100)) + $localtaxes[2], 'MU'); // Si TVA consideree normale (non NPR) |
|
268 | - $result[4] = price2num($result5bis - ($result[3] + $localtaxes[2]), 'MU'); |
|
269 | - } |
|
270 | - else |
|
271 | - { |
|
272 | - // We work to define prices using the price with tax |
|
273 | - $result[8] = price2num($tot_sans_remise + $localtaxes[0], 'MT'); |
|
274 | - $result[6] = price2num($tot_sans_remise / (1 + ((($info_bits & 1)?0:$txtva) / 100)), 'MT'); // Selon TVA NPR ou non |
|
275 | - $result6bis= price2num($tot_sans_remise / (1 + ($txtva / 100)), 'MT'); // Si TVA consideree normale (non NPR) |
|
276 | - $result[7] = price2num($result[8] - ($result6bis + $localtaxes[0]), 'MT'); |
|
277 | - |
|
278 | - $result[2] = price2num($tot_avec_remise + $localtaxes[1], 'MT'); |
|
279 | - $result[0] = price2num($tot_avec_remise / (1 + ((($info_bits & 1)?0:$txtva) / 100)), 'MT'); // Selon TVA NPR ou non |
|
280 | - $result0bis= price2num($tot_avec_remise / (1 + ($txtva / 100)), 'MT'); // Si TVA consideree normale (non NPR) |
|
281 | - $result[1] = price2num($result[2] - ($result0bis + $localtaxes[1]), 'MT'); // Total VAT = TTC - (HT + localtax) |
|
282 | - |
|
283 | - $result[5] = price2num($pu + $localtaxes[2], 'MU'); |
|
284 | - $result[3] = price2num($pu / (1 + ((($info_bits & 1)?0:$txtva) / 100)), 'MU'); // Selon TVA NPR ou non |
|
285 | - $result3bis= price2num($pu / (1 + ($txtva / 100)), 'MU'); // Si TVA consideree normale (non NPR) |
|
286 | - $result[4] = price2num($result[5] - ($result3bis + $localtaxes[2]), 'MU'); |
|
287 | - } |
|
288 | - |
|
289 | - // if there's some localtax without vat, we calculate localtaxes (we will add them at end) |
|
289 | + // if there's some localtax without vat, we calculate localtaxes (we will add them at end) |
|
290 | 290 | |
291 | 291 | //If input unit price is 'TTC', we need to have the totals without main VAT for a correct calculation |
292 | 292 | if ($price_base_type == 'TTC') |
293 | 293 | { |
294 | - $tot_sans_remise= price2num($tot_sans_remise / (1 + ($txtva / 100)),'MU'); |
|
295 | - $tot_avec_remise= price2num($tot_avec_remise / (1 + ($txtva / 100)),'MU'); |
|
296 | - $pu = price2num($pu / (1 + ($txtva / 100)),'MU'); |
|
294 | + $tot_sans_remise= price2num($tot_sans_remise / (1 + ($txtva / 100)),'MU'); |
|
295 | + $tot_avec_remise= price2num($tot_avec_remise / (1 + ($txtva / 100)),'MU'); |
|
296 | + $pu = price2num($pu / (1 + ($txtva / 100)),'MU'); |
|
297 | 297 | } |
298 | 298 | |
299 | - $apply_tax = false; |
|
299 | + $apply_tax = false; |
|
300 | 300 | switch($localtax1_type) { |
301 | - case '1': // localtax on product or service |
|
301 | + case '1': // localtax on product or service |
|
302 | 302 | $apply_tax = true; |
303 | 303 | break; |
304 | - case '3': // localtax on product |
|
304 | + case '3': // localtax on product |
|
305 | 305 | if ($type == 0) $apply_tax = true; |
306 | 306 | break; |
307 | - case '5': // localtax on service |
|
307 | + case '5': // localtax on service |
|
308 | 308 | if ($type == 1) $apply_tax = true; |
309 | 309 | break; |
310 | 310 | } |
311 | 311 | if ($uselocaltax1_rate && $apply_tax) { |
312 | - $result[14] = price2num(($tot_sans_remise * (1 + ( $localtax1_rate / 100))) - $tot_sans_remise, 'MT'); // amount tax1 for total_ht_without_discount |
|
313 | - $result[8] += $result[14]; // total_ttc_without_discount + tax1 |
|
312 | + $result[14] = price2num(($tot_sans_remise * (1 + ( $localtax1_rate / 100))) - $tot_sans_remise, 'MT'); // amount tax1 for total_ht_without_discount |
|
313 | + $result[8] += $result[14]; // total_ttc_without_discount + tax1 |
|
314 | 314 | |
315 | - $result[9] = price2num(($tot_avec_remise * (1 + ( $localtax1_rate / 100))) - $tot_avec_remise, 'MT'); // amount tax1 for total_ht |
|
316 | - $result[2] += $result[9]; // total_ttc + tax1 |
|
315 | + $result[9] = price2num(($tot_avec_remise * (1 + ( $localtax1_rate / 100))) - $tot_avec_remise, 'MT'); // amount tax1 for total_ht |
|
316 | + $result[2] += $result[9]; // total_ttc + tax1 |
|
317 | 317 | |
318 | - $result[11] = price2num(($pu * (1 + ( $localtax1_rate / 100))) - $pu, 'MU'); // amount tax1 for pu_ht |
|
319 | - $result[5] += $result[11]; // pu_ht + tax1 |
|
318 | + $result[11] = price2num(($pu * (1 + ( $localtax1_rate / 100))) - $pu, 'MU'); // amount tax1 for pu_ht |
|
319 | + $result[5] += $result[11]; // pu_ht + tax1 |
|
320 | 320 | } |
321 | 321 | |
322 | 322 | $apply_tax = false; |
323 | - switch($localtax2_type) { |
|
324 | - case '1': // localtax on product or service |
|
323 | + switch($localtax2_type) { |
|
324 | + case '1': // localtax on product or service |
|
325 | 325 | $apply_tax = true; |
326 | 326 | break; |
327 | - case '3': // localtax on product |
|
327 | + case '3': // localtax on product |
|
328 | 328 | if ($type == 0) $apply_tax = true; |
329 | 329 | break; |
330 | - case '5': // localtax on service |
|
330 | + case '5': // localtax on service |
|
331 | 331 | if ($type == 1) $apply_tax = true; |
332 | 332 | break; |
333 | 333 | } |
334 | 334 | if ($uselocaltax2_rate && $apply_tax) { |
335 | - $result[15] = price2num(($tot_sans_remise * (1 + ( $localtax2_rate / 100))) - $tot_sans_remise, 'MT'); // amount tax2 for total_ht_without_discount |
|
336 | - $result[8] += $result[15]; // total_ttc_without_discount + tax2 |
|
335 | + $result[15] = price2num(($tot_sans_remise * (1 + ( $localtax2_rate / 100))) - $tot_sans_remise, 'MT'); // amount tax2 for total_ht_without_discount |
|
336 | + $result[8] += $result[15]; // total_ttc_without_discount + tax2 |
|
337 | 337 | |
338 | - $result[10] = price2num(($tot_avec_remise * (1 + ( $localtax2_rate / 100))) - $tot_avec_remise, 'MT'); // amount tax2 for total_ht |
|
339 | - $result[2] += $result[10]; // total_ttc + tax2 |
|
338 | + $result[10] = price2num(($tot_avec_remise * (1 + ( $localtax2_rate / 100))) - $tot_avec_remise, 'MT'); // amount tax2 for total_ht |
|
339 | + $result[2] += $result[10]; // total_ttc + tax2 |
|
340 | 340 | |
341 | - $result[12] = price2num(($pu * (1 + ( $localtax2_rate / 100))) - $pu, 'MU'); // amount tax2 for pu_ht |
|
342 | - $result[5] += $result[12]; // pu_ht + tax2 |
|
341 | + $result[12] = price2num(($pu * (1 + ( $localtax2_rate / 100))) - $pu, 'MU'); // amount tax2 for pu_ht |
|
342 | + $result[5] += $result[12]; // pu_ht + tax2 |
|
343 | 343 | } |
344 | 344 | |
345 | - // If rounding is not using base 10 (rare) |
|
346 | - if (! empty($conf->global->MAIN_ROUNDING_RULE_TOT)) |
|
347 | - { |
|
348 | - if ($price_base_type == 'HT') |
|
349 | - { |
|
350 | - $result[0]=round($result[0]/$conf->global->MAIN_ROUNDING_RULE_TOT, 0)*$conf->global->MAIN_ROUNDING_RULE_TOT; |
|
351 | - $result[1]=round($result[1]/$conf->global->MAIN_ROUNDING_RULE_TOT, 0)*$conf->global->MAIN_ROUNDING_RULE_TOT; |
|
352 | - $result[2]=price2num($result[0]+$result[1], 'MT'); |
|
353 | - $result[9]=round($result[9]/$conf->global->MAIN_ROUNDING_RULE_TOT, 0)*$conf->global->MAIN_ROUNDING_RULE_TOT; |
|
354 | - $result[10]=round($result[10]/$conf->global->MAIN_ROUNDING_RULE_TOT, 0)*$conf->global->MAIN_ROUNDING_RULE_TOT; |
|
355 | - } |
|
356 | - else |
|
357 | - { |
|
358 | - $result[1]=round($result[1]/$conf->global->MAIN_ROUNDING_RULE_TOT, 0)*$conf->global->MAIN_ROUNDING_RULE_TOT; |
|
359 | - $result[2]=round($result[2]/$conf->global->MAIN_ROUNDING_RULE_TOT, 0)*$conf->global->MAIN_ROUNDING_RULE_TOT; |
|
360 | - $result[0]=price2num($result[2]-$result[1], 'MT'); |
|
361 | - $result[9]=round($result[9]/$conf->global->MAIN_ROUNDING_RULE_TOT, 0)*$conf->global->MAIN_ROUNDING_RULE_TOT; |
|
362 | - $result[10]=round($result[10]/$conf->global->MAIN_ROUNDING_RULE_TOT, 0)*$conf->global->MAIN_ROUNDING_RULE_TOT; |
|
363 | - } |
|
364 | - } |
|
365 | - |
|
366 | - // Multicurrency |
|
367 | - if ($multicurrency_tx != 1) |
|
368 | - { |
|
369 | - // Recal function using the multicurrency price as reference price. We must set param $multicurrency_tx to 1 to avoid infinite loop. |
|
370 | - $newresult = calcul_price_total($qty, $pu_devise, $remise_percent_ligne, $txtva, $uselocaltax1_rate, $uselocaltax2_rate, $remise_percent_global, $price_base_type, $info_bits, $type, $seller, $localtaxes_array, $progress, 1, 0); |
|
371 | - |
|
372 | - $result[16] = $newresult[0]; |
|
373 | - $result[17] = $newresult[1]; |
|
374 | - $result[18] = $newresult[2]; |
|
375 | - $result[19] = $newresult[3]; |
|
376 | - $result[20] = $newresult[4]; |
|
377 | - $result[21] = $newresult[5]; |
|
378 | - $result[22] = $newresult[6]; |
|
379 | - $result[23] = $newresult[7]; |
|
380 | - $result[24] = $newresult[8]; |
|
381 | - $result[25] = $newresult[9]; |
|
382 | - $result[26] = $newresult[10]; |
|
383 | - /* |
|
345 | + // If rounding is not using base 10 (rare) |
|
346 | + if (! empty($conf->global->MAIN_ROUNDING_RULE_TOT)) |
|
347 | + { |
|
348 | + if ($price_base_type == 'HT') |
|
349 | + { |
|
350 | + $result[0]=round($result[0]/$conf->global->MAIN_ROUNDING_RULE_TOT, 0)*$conf->global->MAIN_ROUNDING_RULE_TOT; |
|
351 | + $result[1]=round($result[1]/$conf->global->MAIN_ROUNDING_RULE_TOT, 0)*$conf->global->MAIN_ROUNDING_RULE_TOT; |
|
352 | + $result[2]=price2num($result[0]+$result[1], 'MT'); |
|
353 | + $result[9]=round($result[9]/$conf->global->MAIN_ROUNDING_RULE_TOT, 0)*$conf->global->MAIN_ROUNDING_RULE_TOT; |
|
354 | + $result[10]=round($result[10]/$conf->global->MAIN_ROUNDING_RULE_TOT, 0)*$conf->global->MAIN_ROUNDING_RULE_TOT; |
|
355 | + } |
|
356 | + else |
|
357 | + { |
|
358 | + $result[1]=round($result[1]/$conf->global->MAIN_ROUNDING_RULE_TOT, 0)*$conf->global->MAIN_ROUNDING_RULE_TOT; |
|
359 | + $result[2]=round($result[2]/$conf->global->MAIN_ROUNDING_RULE_TOT, 0)*$conf->global->MAIN_ROUNDING_RULE_TOT; |
|
360 | + $result[0]=price2num($result[2]-$result[1], 'MT'); |
|
361 | + $result[9]=round($result[9]/$conf->global->MAIN_ROUNDING_RULE_TOT, 0)*$conf->global->MAIN_ROUNDING_RULE_TOT; |
|
362 | + $result[10]=round($result[10]/$conf->global->MAIN_ROUNDING_RULE_TOT, 0)*$conf->global->MAIN_ROUNDING_RULE_TOT; |
|
363 | + } |
|
364 | + } |
|
365 | + |
|
366 | + // Multicurrency |
|
367 | + if ($multicurrency_tx != 1) |
|
368 | + { |
|
369 | + // Recal function using the multicurrency price as reference price. We must set param $multicurrency_tx to 1 to avoid infinite loop. |
|
370 | + $newresult = calcul_price_total($qty, $pu_devise, $remise_percent_ligne, $txtva, $uselocaltax1_rate, $uselocaltax2_rate, $remise_percent_global, $price_base_type, $info_bits, $type, $seller, $localtaxes_array, $progress, 1, 0); |
|
371 | + |
|
372 | + $result[16] = $newresult[0]; |
|
373 | + $result[17] = $newresult[1]; |
|
374 | + $result[18] = $newresult[2]; |
|
375 | + $result[19] = $newresult[3]; |
|
376 | + $result[20] = $newresult[4]; |
|
377 | + $result[21] = $newresult[5]; |
|
378 | + $result[22] = $newresult[6]; |
|
379 | + $result[23] = $newresult[7]; |
|
380 | + $result[24] = $newresult[8]; |
|
381 | + $result[25] = $newresult[9]; |
|
382 | + $result[26] = $newresult[10]; |
|
383 | + /* |
|
384 | 384 | $result[16] = price2num($result[0] * $multicurrency_tx, 'MT'); |
385 | 385 | $result[17] = price2num($result[1] * $multicurrency_tx, 'MT'); |
386 | 386 | $result[18] = price2num($result[2] * $multicurrency_tx, 'MT'); |
387 | 387 | $result[19] = price2num($pu_devise, 'MU'); |
388 | 388 | */ |
389 | - } |
|
390 | - else |
|
391 | - { |
|
392 | - $result[16] = $result[0]; |
|
393 | - $result[17] = $result[1]; |
|
394 | - $result[18] = $result[2]; |
|
395 | - $result[19] = $result[3]; |
|
396 | - $result[20] = $result[4]; |
|
397 | - $result[21] = $result[5]; |
|
398 | - $result[22] = $result[6]; |
|
399 | - $result[23] = $result[7]; |
|
400 | - $result[24] = $result[8]; |
|
401 | - $result[25] = $result[9]; |
|
402 | - $result[26] = $result[10]; |
|
403 | - } |
|
404 | - |
|
405 | - //var_dump($result); |
|
406 | - // initialize result array |
|
407 | - //for ($i=0; $i <= 18; $i++) $result[$i] = (float) $result[$i]; |
|
408 | - |
|
409 | - dol_syslog('Price.lib::calcul_price_total MAIN_ROUNDING_RULE_TOT='.$conf->global->MAIN_ROUNDING_RULE_TOT.' pu='.$pu.' qty='.$qty.' price_base_type='.$price_base_type.' total_ht='.$result[0].'-total_vat='.$result[1].'-total_ttc='.$result[2]); |
|
410 | - |
|
411 | - return $result; |
|
389 | + } |
|
390 | + else |
|
391 | + { |
|
392 | + $result[16] = $result[0]; |
|
393 | + $result[17] = $result[1]; |
|
394 | + $result[18] = $result[2]; |
|
395 | + $result[19] = $result[3]; |
|
396 | + $result[20] = $result[4]; |
|
397 | + $result[21] = $result[5]; |
|
398 | + $result[22] = $result[6]; |
|
399 | + $result[23] = $result[7]; |
|
400 | + $result[24] = $result[8]; |
|
401 | + $result[25] = $result[9]; |
|
402 | + $result[26] = $result[10]; |
|
403 | + } |
|
404 | + |
|
405 | + //var_dump($result); |
|
406 | + // initialize result array |
|
407 | + //for ($i=0; $i <= 18; $i++) $result[$i] = (float) $result[$i]; |
|
408 | + |
|
409 | + dol_syslog('Price.lib::calcul_price_total MAIN_ROUNDING_RULE_TOT='.$conf->global->MAIN_ROUNDING_RULE_TOT.' pu='.$pu.' qty='.$qty.' price_base_type='.$price_base_type.' total_ht='.$result[0].'-total_vat='.$result[1].'-total_ttc='.$result[2]); |
|
410 | + |
|
411 | + return $result; |
|
412 | 412 | } |
413 | 413 |
@@ -30,66 +30,66 @@ discard block |
||
30 | 30 | */ |
31 | 31 | function ldap_prepare_head() |
32 | 32 | { |
33 | - global $langs, $conf, $user; |
|
34 | - |
|
35 | - $langs->load("ldap"); |
|
36 | - |
|
37 | - // Onglets |
|
38 | - $head=array(); |
|
39 | - $h = 0; |
|
40 | - |
|
41 | - $head[$h][0] = DOL_URL_ROOT."/admin/ldap.php"; |
|
42 | - $head[$h][1] = $langs->trans("LDAPGlobalParameters"); |
|
43 | - $head[$h][2] = 'ldap'; |
|
44 | - $h++; |
|
45 | - |
|
46 | - if (! empty($conf->global->LDAP_SYNCHRO_ACTIVE)) |
|
47 | - { |
|
48 | - $head[$h][0] = DOL_URL_ROOT."/admin/ldap_users.php"; |
|
49 | - $head[$h][1] = $langs->trans("LDAPUsersSynchro"); |
|
50 | - $head[$h][2] = 'users'; |
|
51 | - $h++; |
|
52 | - } |
|
53 | - |
|
54 | - if (! empty($conf->global->LDAP_SYNCHRO_ACTIVE)) |
|
55 | - { |
|
56 | - $head[$h][0] = DOL_URL_ROOT."/admin/ldap_groups.php"; |
|
57 | - $head[$h][1] = $langs->trans("LDAPGroupsSynchro"); |
|
58 | - $head[$h][2] = 'groups'; |
|
59 | - $h++; |
|
60 | - } |
|
61 | - |
|
62 | - if (! empty($conf->societe->enabled) && ! empty($conf->global->LDAP_CONTACT_ACTIVE)) |
|
63 | - { |
|
64 | - $head[$h][0] = DOL_URL_ROOT."/admin/ldap_contacts.php"; |
|
65 | - $head[$h][1] = $langs->trans("LDAPContactsSynchro"); |
|
66 | - $head[$h][2] = 'contacts'; |
|
67 | - $h++; |
|
68 | - } |
|
69 | - |
|
70 | - if (! empty($conf->adherent->enabled) && ! empty($conf->global->LDAP_MEMBER_ACTIVE)) |
|
71 | - { |
|
72 | - $head[$h][0] = DOL_URL_ROOT."/admin/ldap_members.php"; |
|
73 | - $head[$h][1] = $langs->trans("LDAPMembersSynchro"); |
|
74 | - $head[$h][2] = 'members'; |
|
75 | - $h++; |
|
76 | - } |
|
77 | - |
|
78 | - if (! empty($conf->adherent->enabled) && ! empty($conf->global->LDAP_MEMBER_TYPE_ACTIVE)) |
|
79 | - { |
|
80 | - $head[$h][0] = DOL_URL_ROOT."/admin/ldap_members_types.php"; |
|
81 | - $head[$h][1] = $langs->trans("LDAPMembersTypesSynchro"); |
|
82 | - $head[$h][2] = 'memberstypes'; |
|
83 | - $h++; |
|
84 | - } |
|
85 | - |
|
86 | - // Show more tabs from modules |
|
87 | - // Entries must be declared in modules descriptor with line |
|
88 | - // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab |
|
89 | - // $this->tabs = array('entity:-tabname); to remove a tab |
|
90 | - complete_head_from_modules($conf,$langs,'',$head,$h,'ldap'); |
|
91 | - |
|
92 | - return $head; |
|
33 | + global $langs, $conf, $user; |
|
34 | + |
|
35 | + $langs->load("ldap"); |
|
36 | + |
|
37 | + // Onglets |
|
38 | + $head=array(); |
|
39 | + $h = 0; |
|
40 | + |
|
41 | + $head[$h][0] = DOL_URL_ROOT."/admin/ldap.php"; |
|
42 | + $head[$h][1] = $langs->trans("LDAPGlobalParameters"); |
|
43 | + $head[$h][2] = 'ldap'; |
|
44 | + $h++; |
|
45 | + |
|
46 | + if (! empty($conf->global->LDAP_SYNCHRO_ACTIVE)) |
|
47 | + { |
|
48 | + $head[$h][0] = DOL_URL_ROOT."/admin/ldap_users.php"; |
|
49 | + $head[$h][1] = $langs->trans("LDAPUsersSynchro"); |
|
50 | + $head[$h][2] = 'users'; |
|
51 | + $h++; |
|
52 | + } |
|
53 | + |
|
54 | + if (! empty($conf->global->LDAP_SYNCHRO_ACTIVE)) |
|
55 | + { |
|
56 | + $head[$h][0] = DOL_URL_ROOT."/admin/ldap_groups.php"; |
|
57 | + $head[$h][1] = $langs->trans("LDAPGroupsSynchro"); |
|
58 | + $head[$h][2] = 'groups'; |
|
59 | + $h++; |
|
60 | + } |
|
61 | + |
|
62 | + if (! empty($conf->societe->enabled) && ! empty($conf->global->LDAP_CONTACT_ACTIVE)) |
|
63 | + { |
|
64 | + $head[$h][0] = DOL_URL_ROOT."/admin/ldap_contacts.php"; |
|
65 | + $head[$h][1] = $langs->trans("LDAPContactsSynchro"); |
|
66 | + $head[$h][2] = 'contacts'; |
|
67 | + $h++; |
|
68 | + } |
|
69 | + |
|
70 | + if (! empty($conf->adherent->enabled) && ! empty($conf->global->LDAP_MEMBER_ACTIVE)) |
|
71 | + { |
|
72 | + $head[$h][0] = DOL_URL_ROOT."/admin/ldap_members.php"; |
|
73 | + $head[$h][1] = $langs->trans("LDAPMembersSynchro"); |
|
74 | + $head[$h][2] = 'members'; |
|
75 | + $h++; |
|
76 | + } |
|
77 | + |
|
78 | + if (! empty($conf->adherent->enabled) && ! empty($conf->global->LDAP_MEMBER_TYPE_ACTIVE)) |
|
79 | + { |
|
80 | + $head[$h][0] = DOL_URL_ROOT."/admin/ldap_members_types.php"; |
|
81 | + $head[$h][1] = $langs->trans("LDAPMembersTypesSynchro"); |
|
82 | + $head[$h][2] = 'memberstypes'; |
|
83 | + $h++; |
|
84 | + } |
|
85 | + |
|
86 | + // Show more tabs from modules |
|
87 | + // Entries must be declared in modules descriptor with line |
|
88 | + // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab |
|
89 | + // $this->tabs = array('entity:-tabname); to remove a tab |
|
90 | + complete_head_from_modules($conf,$langs,'',$head,$h,'ldap'); |
|
91 | + |
|
92 | + return $head; |
|
93 | 93 | } |
94 | 94 | |
95 | 95 | |
@@ -105,28 +105,28 @@ discard block |
||
105 | 105 | */ |
106 | 106 | function show_ldap_test_button($butlabel,$testlabel,$key,$dn,$objectclass) |
107 | 107 | { |
108 | - global $langs, $conf, $user; |
|
109 | - //print 'key='.$key.' dn='.$dn.' objectclass='.$objectclass; |
|
110 | - |
|
111 | - print '<br>'; |
|
112 | - if (! function_exists("ldap_connect")) |
|
113 | - { |
|
114 | - print '<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans('LDAPFunctionsNotAvailableOnPHP').'">'.$butlabel.'</a>'; |
|
115 | - } |
|
116 | - else if (empty($conf->global->LDAP_SERVER_HOST)) |
|
117 | - { |
|
118 | - print '<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans('LDAPSetupNotComplete').'">'.$butlabel.'</a>'; |
|
119 | - } |
|
120 | - else if (empty($key) || empty($dn) || empty($objectclass)) |
|
121 | - { |
|
122 | - $langs->load("errors"); |
|
123 | - print '<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans('ErrorLDAPSetupNotComplete').'">'.$butlabel.'</a>'; |
|
124 | - } |
|
125 | - else |
|
126 | - { |
|
127 | - print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action='.$testlabel.'">'.$butlabel.'</a>'; |
|
128 | - } |
|
129 | - print '<br><br>'; |
|
108 | + global $langs, $conf, $user; |
|
109 | + //print 'key='.$key.' dn='.$dn.' objectclass='.$objectclass; |
|
110 | + |
|
111 | + print '<br>'; |
|
112 | + if (! function_exists("ldap_connect")) |
|
113 | + { |
|
114 | + print '<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans('LDAPFunctionsNotAvailableOnPHP').'">'.$butlabel.'</a>'; |
|
115 | + } |
|
116 | + else if (empty($conf->global->LDAP_SERVER_HOST)) |
|
117 | + { |
|
118 | + print '<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans('LDAPSetupNotComplete').'">'.$butlabel.'</a>'; |
|
119 | + } |
|
120 | + else if (empty($key) || empty($dn) || empty($objectclass)) |
|
121 | + { |
|
122 | + $langs->load("errors"); |
|
123 | + print '<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans('ErrorLDAPSetupNotComplete').'">'.$butlabel.'</a>'; |
|
124 | + } |
|
125 | + else |
|
126 | + { |
|
127 | + print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action='.$testlabel.'">'.$butlabel.'</a>'; |
|
128 | + } |
|
129 | + print '<br><br>'; |
|
130 | 130 | } |
131 | 131 | |
132 | 132 | |
@@ -143,45 +143,45 @@ discard block |
||
143 | 143 | */ |
144 | 144 | function show_ldap_content($result,$level,$count,$var,$hide=0,$subcount=0) |
145 | 145 | { |
146 | - global $bc, $conf; |
|
147 | - |
|
148 | - $count--; |
|
149 | - if ($count == 0) return -1; // To stop loop |
|
150 | - if (! is_array($result)) return -1; |
|
151 | - |
|
152 | - foreach($result as $key => $val) |
|
153 | - { |
|
154 | - if ("$key" == "objectclass") continue; |
|
155 | - if ("$key" == "count") continue; |
|
156 | - if ("$key" == "dn") continue; |
|
157 | - if ("$val" == "objectclass") continue; |
|
158 | - |
|
159 | - $lastkey[$level]=$key; |
|
160 | - |
|
161 | - if (is_array($val)) |
|
162 | - { |
|
163 | - $hide=0; |
|
164 | - if (! is_numeric($key)) |
|
165 | - { |
|
166 | - |
|
167 | - print '<tr '.$bc[$var].' valign="top">'; |
|
168 | - print '<td>'; |
|
169 | - print $key; |
|
170 | - print '</td><td>'; |
|
171 | - if (strtolower($key) == 'userpassword') $hide=1; |
|
172 | - } |
|
173 | - show_ldap_content($val,$level+1,$count,$var,$hide,$val["count"]); |
|
174 | - } |
|
175 | - else if ($subcount) |
|
176 | - { |
|
177 | - $subcount--; |
|
178 | - $newstring=dol_htmlentitiesbr($val); |
|
179 | - if ($hide) print preg_replace('/./i','*',$newstring); |
|
180 | - else print $newstring; |
|
181 | - print '<br>'; |
|
182 | - } |
|
183 | - if ("$val" != $lastkey[$level] && !$subcount) print '</td></tr>'; |
|
184 | - } |
|
185 | - return 1; |
|
146 | + global $bc, $conf; |
|
147 | + |
|
148 | + $count--; |
|
149 | + if ($count == 0) return -1; // To stop loop |
|
150 | + if (! is_array($result)) return -1; |
|
151 | + |
|
152 | + foreach($result as $key => $val) |
|
153 | + { |
|
154 | + if ("$key" == "objectclass") continue; |
|
155 | + if ("$key" == "count") continue; |
|
156 | + if ("$key" == "dn") continue; |
|
157 | + if ("$val" == "objectclass") continue; |
|
158 | + |
|
159 | + $lastkey[$level]=$key; |
|
160 | + |
|
161 | + if (is_array($val)) |
|
162 | + { |
|
163 | + $hide=0; |
|
164 | + if (! is_numeric($key)) |
|
165 | + { |
|
166 | + |
|
167 | + print '<tr '.$bc[$var].' valign="top">'; |
|
168 | + print '<td>'; |
|
169 | + print $key; |
|
170 | + print '</td><td>'; |
|
171 | + if (strtolower($key) == 'userpassword') $hide=1; |
|
172 | + } |
|
173 | + show_ldap_content($val,$level+1,$count,$var,$hide,$val["count"]); |
|
174 | + } |
|
175 | + else if ($subcount) |
|
176 | + { |
|
177 | + $subcount--; |
|
178 | + $newstring=dol_htmlentitiesbr($val); |
|
179 | + if ($hide) print preg_replace('/./i','*',$newstring); |
|
180 | + else print $newstring; |
|
181 | + print '<br>'; |
|
182 | + } |
|
183 | + if ("$val" != $lastkey[$level] && !$subcount) print '</td></tr>'; |
|
184 | + } |
|
185 | + return 1; |
|
186 | 186 | } |
187 | 187 |
@@ -36,29 +36,29 @@ discard block |
||
36 | 36 | */ |
37 | 37 | function dol_encode($chain, $key='1') |
38 | 38 | { |
39 | - if (is_numeric($key) && $key == '1') // rule 1 is offset of 17 for char |
|
40 | - { |
|
41 | - $output_tab=array(); |
|
42 | - $strlength=dol_strlen($chain); |
|
43 | - for ($i=0; $i < $strlength; $i++) |
|
44 | - { |
|
45 | - $output_tab[$i] = chr(ord(substr($chain,$i,1))+17); |
|
46 | - } |
|
47 | - $chain = implode("",$output_tab); |
|
48 | - } |
|
49 | - elseif ($key) |
|
50 | - { |
|
51 | - $result=''; |
|
52 | - $strlength=dol_strlen($chain); |
|
53 | - for ($i=0; $i < $strlength; $i++) |
|
54 | - { |
|
55 | - $keychar = substr($key, ($i % strlen($key))-1, 1); |
|
56 | - $result.= chr(ord(substr($chain,$i,1))+(ord($keychar)-65)); |
|
57 | - } |
|
58 | - $chain=$result; |
|
59 | - } |
|
60 | - |
|
61 | - return base64_encode($chain); |
|
39 | + if (is_numeric($key) && $key == '1') // rule 1 is offset of 17 for char |
|
40 | + { |
|
41 | + $output_tab=array(); |
|
42 | + $strlength=dol_strlen($chain); |
|
43 | + for ($i=0; $i < $strlength; $i++) |
|
44 | + { |
|
45 | + $output_tab[$i] = chr(ord(substr($chain,$i,1))+17); |
|
46 | + } |
|
47 | + $chain = implode("",$output_tab); |
|
48 | + } |
|
49 | + elseif ($key) |
|
50 | + { |
|
51 | + $result=''; |
|
52 | + $strlength=dol_strlen($chain); |
|
53 | + for ($i=0; $i < $strlength; $i++) |
|
54 | + { |
|
55 | + $keychar = substr($key, ($i % strlen($key))-1, 1); |
|
56 | + $result.= chr(ord(substr($chain,$i,1))+(ord($keychar)-65)); |
|
57 | + } |
|
58 | + $chain=$result; |
|
59 | + } |
|
60 | + |
|
61 | + return base64_encode($chain); |
|
62 | 62 | } |
63 | 63 | |
64 | 64 | /** |
@@ -72,32 +72,32 @@ discard block |
||
72 | 72 | */ |
73 | 73 | function dol_decode($chain, $key='1') |
74 | 74 | { |
75 | - $chain = base64_decode($chain); |
|
76 | - |
|
77 | - if (is_numeric($key) && $key == '1') // rule 1 is offset of 17 for char |
|
78 | - { |
|
79 | - $output_tab=array(); |
|
80 | - $strlength=dol_strlen($chain); |
|
81 | - for ($i=0; $i < $strlength;$i++) |
|
82 | - { |
|
83 | - $output_tab[$i] = chr(ord(substr($chain,$i,1))-17); |
|
84 | - } |
|
85 | - |
|
86 | - $chain = implode("",$output_tab); |
|
87 | - } |
|
88 | - elseif ($key) |
|
89 | - { |
|
90 | - $result=''; |
|
91 | - $strlength=dol_strlen($chain); |
|
92 | - for ($i=0; $i < $strlength; $i++) |
|
93 | - { |
|
94 | - $keychar = substr($key, ($i % strlen($key))-1, 1); |
|
95 | - $result.= chr(ord(substr($chain, $i, 1))-(ord($keychar)-65)); |
|
96 | - } |
|
97 | - $chain=$result; |
|
98 | - } |
|
99 | - |
|
100 | - return $chain; |
|
75 | + $chain = base64_decode($chain); |
|
76 | + |
|
77 | + if (is_numeric($key) && $key == '1') // rule 1 is offset of 17 for char |
|
78 | + { |
|
79 | + $output_tab=array(); |
|
80 | + $strlength=dol_strlen($chain); |
|
81 | + for ($i=0; $i < $strlength;$i++) |
|
82 | + { |
|
83 | + $output_tab[$i] = chr(ord(substr($chain,$i,1))-17); |
|
84 | + } |
|
85 | + |
|
86 | + $chain = implode("",$output_tab); |
|
87 | + } |
|
88 | + elseif ($key) |
|
89 | + { |
|
90 | + $result=''; |
|
91 | + $strlength=dol_strlen($chain); |
|
92 | + for ($i=0; $i < $strlength; $i++) |
|
93 | + { |
|
94 | + $keychar = substr($key, ($i % strlen($key))-1, 1); |
|
95 | + $result.= chr(ord(substr($chain, $i, 1))-(ord($keychar)-65)); |
|
96 | + } |
|
97 | + $chain=$result; |
|
98 | + } |
|
99 | + |
|
100 | + return $chain; |
|
101 | 101 | } |
102 | 102 | |
103 | 103 | |
@@ -113,27 +113,27 @@ discard block |
||
113 | 113 | */ |
114 | 114 | function dol_hash($chain, $type='0') |
115 | 115 | { |
116 | - global $conf; |
|
117 | - |
|
118 | - // No need to add salt for password_hash |
|
119 | - if (($type == '0' || $type == 'auto') && ! empty($conf->global->MAIN_SECURITY_HASH_ALGO) && $conf->global->MAIN_SECURITY_HASH_ALGO == 'password_hash' && function_exists('password_hash')) |
|
120 | - { |
|
121 | - return password_hash($chain, PASSWORD_DEFAULT); |
|
122 | - } |
|
123 | - |
|
124 | - // Salt value |
|
125 | - if (! empty($conf->global->MAIN_SECURITY_SALT)) $chain=$conf->global->MAIN_SECURITY_SALT.$chain; |
|
126 | - |
|
127 | - if ($type == '1' || $type == 'sha1') return sha1($chain); |
|
128 | - else if ($type == '2' || $type == 'sha1md5') return sha1(md5($chain)); |
|
129 | - else if ($type == '3' || $type == 'md5') return md5($chain); |
|
130 | - else if ($type == '4' || $type == 'md5openldap') return '{md5}'.base64_encode(mhash(MHASH_MD5,$chain)); // For OpenLdap with md5 (based on an unencrypted password in base) |
|
131 | - else if ($type == '5') return hash('sha256',$chain); |
|
132 | - else if (! empty($conf->global->MAIN_SECURITY_HASH_ALGO) && $conf->global->MAIN_SECURITY_HASH_ALGO == 'sha1') return sha1($chain); |
|
133 | - else if (! empty($conf->global->MAIN_SECURITY_HASH_ALGO) && $conf->global->MAIN_SECURITY_HASH_ALGO == 'sha1md5') return sha1(md5($chain)); |
|
134 | - |
|
135 | - // No particular encoding defined, use default |
|
136 | - return md5($chain); |
|
116 | + global $conf; |
|
117 | + |
|
118 | + // No need to add salt for password_hash |
|
119 | + if (($type == '0' || $type == 'auto') && ! empty($conf->global->MAIN_SECURITY_HASH_ALGO) && $conf->global->MAIN_SECURITY_HASH_ALGO == 'password_hash' && function_exists('password_hash')) |
|
120 | + { |
|
121 | + return password_hash($chain, PASSWORD_DEFAULT); |
|
122 | + } |
|
123 | + |
|
124 | + // Salt value |
|
125 | + if (! empty($conf->global->MAIN_SECURITY_SALT)) $chain=$conf->global->MAIN_SECURITY_SALT.$chain; |
|
126 | + |
|
127 | + if ($type == '1' || $type == 'sha1') return sha1($chain); |
|
128 | + else if ($type == '2' || $type == 'sha1md5') return sha1(md5($chain)); |
|
129 | + else if ($type == '3' || $type == 'md5') return md5($chain); |
|
130 | + else if ($type == '4' || $type == 'md5openldap') return '{md5}'.base64_encode(mhash(MHASH_MD5,$chain)); // For OpenLdap with md5 (based on an unencrypted password in base) |
|
131 | + else if ($type == '5') return hash('sha256',$chain); |
|
132 | + else if (! empty($conf->global->MAIN_SECURITY_HASH_ALGO) && $conf->global->MAIN_SECURITY_HASH_ALGO == 'sha1') return sha1($chain); |
|
133 | + else if (! empty($conf->global->MAIN_SECURITY_HASH_ALGO) && $conf->global->MAIN_SECURITY_HASH_ALGO == 'sha1md5') return sha1(md5($chain)); |
|
134 | + |
|
135 | + // No particular encoding defined, use default |
|
136 | + return md5($chain); |
|
137 | 137 | } |
138 | 138 | |
139 | 139 | /** |
@@ -149,17 +149,17 @@ discard block |
||
149 | 149 | */ |
150 | 150 | function dol_verifyHash($chain, $hash, $type='0') |
151 | 151 | { |
152 | - global $conf; |
|
152 | + global $conf; |
|
153 | 153 | |
154 | - if ($type == '0' && ! empty($conf->global->MAIN_SECURITY_HASH_ALGO) && $conf->global->MAIN_SECURITY_HASH_ALGO == 'password_hash' && function_exists('password_verify')) { |
|
155 | - if ($hash[0] == '$') return password_verify($chain, $hash); |
|
156 | - else if(strlen($hash) == 32) return dol_verifyHash($chain, $hash, '3'); // md5 |
|
157 | - else if(strlen($hash) == 40) return dol_verifyHash($chain, $hash, '2'); // sha1md5 |
|
154 | + if ($type == '0' && ! empty($conf->global->MAIN_SECURITY_HASH_ALGO) && $conf->global->MAIN_SECURITY_HASH_ALGO == 'password_hash' && function_exists('password_verify')) { |
|
155 | + if ($hash[0] == '$') return password_verify($chain, $hash); |
|
156 | + else if(strlen($hash) == 32) return dol_verifyHash($chain, $hash, '3'); // md5 |
|
157 | + else if(strlen($hash) == 40) return dol_verifyHash($chain, $hash, '2'); // sha1md5 |
|
158 | 158 | |
159 | - return false; |
|
160 | - } |
|
159 | + return false; |
|
160 | + } |
|
161 | 161 | |
162 | - return dol_hash($chain, $type) == $hash; |
|
162 | + return dol_hash($chain, $type) == $hash; |
|
163 | 163 | } |
164 | 164 | |
165 | 165 | |
@@ -180,242 +180,242 @@ discard block |
||
180 | 180 | */ |
181 | 181 | function restrictedArea($user, $features, $objectid=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0) |
182 | 182 | { |
183 | - global $db, $conf; |
|
184 | - global $hookmanager; |
|
185 | - |
|
186 | - //dol_syslog("functions.lib:restrictedArea $feature, $objectid, $dbtablename,$feature2,$dbt_socfield,$dbt_select"); |
|
187 | - //print "user_id=".$user->id.", features=".$features.", feature2=".$feature2.", objectid=".$objectid; |
|
188 | - //print ", dbtablename=".$dbtablename.", dbt_socfield=".$dbt_keyfield.", dbt_select=".$dbt_select; |
|
189 | - //print ", perm: ".$features."->".$feature2."=".($user->rights->$features->$feature2->lire)."<br>"; |
|
190 | - |
|
191 | - // Get more permissions checks from hooks |
|
192 | - $parameters=array('features'=>$features, 'objectid'=>$objectid, 'idtype'=>$dbt_select); |
|
193 | - $reshook=$hookmanager->executeHooks('restrictedArea',$parameters); |
|
194 | - if (! empty($hookmanager->resArray['result'])) return true; |
|
195 | - if ($reshook > 0) return false; |
|
196 | - |
|
197 | - if ($dbt_select != 'rowid' && $dbt_select != 'id') $objectid = "'".$objectid."'"; |
|
198 | - |
|
199 | - // Features/modules to check |
|
200 | - $featuresarray = array($features); |
|
201 | - if (preg_match('/&/', $features)) $featuresarray = explode("&", $features); |
|
202 | - else if (preg_match('/\|/', $features)) $featuresarray = explode("|", $features); |
|
203 | - |
|
204 | - // More subfeatures to check |
|
205 | - if (! empty($feature2)) $feature2 = explode("|", $feature2); |
|
206 | - |
|
207 | - // More parameters |
|
208 | - $params = explode('&', $tableandshare); |
|
209 | - $dbtablename=(! empty($params[0]) ? $params[0] : ''); |
|
210 | - $sharedelement=(! empty($params[1]) ? $params[1] : $dbtablename); |
|
211 | - |
|
212 | - $listofmodules=explode(',',$conf->global->MAIN_MODULES_FOR_EXTERNAL); |
|
213 | - |
|
214 | - // Check read permission from module |
|
215 | - $readok=1; $nbko=0; |
|
216 | - foreach ($featuresarray as $feature) // first we check nb of test ko |
|
217 | - { |
|
218 | - $featureforlistofmodule=$feature; |
|
219 | - if ($featureforlistofmodule == 'produit') $featureforlistofmodule='product'; |
|
220 | - if (! empty($user->societe_id) && ! empty($conf->global->MAIN_MODULES_FOR_EXTERNAL) && ! in_array($featureforlistofmodule,$listofmodules)) // If limits on modules for external users, module must be into list of modules for external users |
|
221 | - { |
|
222 | - $readok=0; $nbko++; |
|
223 | - continue; |
|
224 | - } |
|
225 | - |
|
226 | - if ($feature == 'societe') |
|
227 | - { |
|
228 | - if (! $user->rights->societe->lire && ! $user->rights->fournisseur->lire) { $readok=0; $nbko++; } |
|
229 | - } |
|
230 | - else if ($feature == 'contact') |
|
231 | - { |
|
232 | - if (! $user->rights->societe->contact->lire) { $readok=0; $nbko++; } |
|
233 | - } |
|
234 | - else if ($feature == 'produit|service') |
|
235 | - { |
|
236 | - if (! $user->rights->produit->lire && ! $user->rights->service->lire) { $readok=0; $nbko++; } |
|
237 | - } |
|
238 | - else if ($feature == 'prelevement') |
|
239 | - { |
|
240 | - if (! $user->rights->prelevement->bons->lire) { $readok=0; $nbko++; } |
|
241 | - } |
|
242 | - else if ($feature == 'cheque') |
|
243 | - { |
|
244 | - if (! $user->rights->banque->cheque) { $readok=0; $nbko++; } |
|
245 | - } |
|
246 | - else if ($feature == 'projet') |
|
247 | - { |
|
248 | - if (! $user->rights->projet->lire && ! $user->rights->projet->all->lire) { $readok=0; $nbko++; } |
|
249 | - } |
|
250 | - else if (! empty($feature2)) // This should be used for future changes |
|
251 | - { |
|
252 | - $tmpreadok=1; |
|
253 | - foreach($feature2 as $subfeature) |
|
254 | - { |
|
255 | - if (! empty($subfeature) && empty($user->rights->$feature->$subfeature->lire) && empty($user->rights->$feature->$subfeature->read)) { $tmpreadok=0; } |
|
256 | - else if (empty($subfeature) && empty($user->rights->$feature->lire) && empty($user->rights->$feature->read)) { $tmpreadok=0; } |
|
257 | - else { $tmpreadok=1; break; } // Break is to bypass second test if the first is ok |
|
258 | - } |
|
259 | - if (! $tmpreadok) // We found a test on feature that is ko |
|
260 | - { |
|
261 | - $readok=0; // All tests are ko (we manage here the and, the or will be managed later using $nbko). |
|
262 | - $nbko++; |
|
263 | - } |
|
264 | - } |
|
265 | - else if (! empty($feature) && ($feature!='user' && $feature!='usergroup')) // This is for old permissions |
|
266 | - { |
|
267 | - if (empty($user->rights->$feature->lire) |
|
268 | - && empty($user->rights->$feature->read) |
|
269 | - && empty($user->rights->$feature->run)) { $readok=0; $nbko++; } |
|
270 | - } |
|
271 | - } |
|
272 | - |
|
273 | - // If a or and at least one ok |
|
274 | - if (preg_match('/\|/', $features) && $nbko < count($featuresarray)) $readok=1; |
|
275 | - |
|
276 | - if (! $readok) accessforbidden(); |
|
277 | - //print "Read access is ok"; |
|
278 | - |
|
279 | - // Check write permission from module (we need to know write permission to create but also to delete drafts record) |
|
280 | - $createok=1; $nbko=0; |
|
281 | - if (GETPOST('action','aZ09') == 'create' || ((GETPOST("action","aZ09") == 'confirm_delete' && GETPOST("confirm","aZ09") == 'yes') || GETPOST("action","aZ09") == 'delete')) |
|
282 | - { |
|
283 | - foreach ($featuresarray as $feature) |
|
284 | - { |
|
285 | - if ($feature == 'contact') |
|
286 | - { |
|
287 | - if (! $user->rights->societe->contact->creer) { $createok=0; $nbko++; } |
|
288 | - } |
|
289 | - else if ($feature == 'produit|service') |
|
290 | - { |
|
291 | - if (! $user->rights->produit->creer && ! $user->rights->service->creer) { $createok=0; $nbko++; } |
|
292 | - } |
|
293 | - else if ($feature == 'prelevement') |
|
294 | - { |
|
295 | - if (! $user->rights->prelevement->bons->creer) { $createok=0; $nbko++; } |
|
296 | - } |
|
297 | - else if ($feature == 'commande_fournisseur') |
|
298 | - { |
|
299 | - if (! $user->rights->fournisseur->commande->creer) { $createok=0; $nbko++; } |
|
300 | - } |
|
301 | - else if ($feature == 'banque') |
|
302 | - { |
|
303 | - if (! $user->rights->banque->modifier) { $createok=0; $nbko++; } |
|
304 | - } |
|
305 | - else if ($feature == 'cheque') |
|
306 | - { |
|
307 | - if (! $user->rights->banque->cheque) { $createok=0; $nbko++; } |
|
308 | - } |
|
309 | - else if (! empty($feature2)) // This should be used |
|
310 | - { |
|
311 | - foreach($feature2 as $subfeature) |
|
312 | - { |
|
313 | - if (empty($user->rights->$feature->$subfeature->creer) |
|
314 | - && empty($user->rights->$feature->$subfeature->write) |
|
315 | - && empty($user->rights->$feature->$subfeature->create)) { $createok=0; $nbko++; } |
|
316 | - else { $createok=1; break; } // Break to bypass second test if the first is ok |
|
317 | - } |
|
318 | - } |
|
319 | - else if (! empty($feature)) // This is for old permissions ('creer' or 'write') |
|
320 | - { |
|
321 | - //print '<br>feature='.$feature.' creer='.$user->rights->$feature->creer.' write='.$user->rights->$feature->write; |
|
322 | - if (empty($user->rights->$feature->creer) |
|
323 | - && empty($user->rights->$feature->write) |
|
324 | - && empty($user->rights->$feature->create)) { $createok=0; $nbko++; } |
|
325 | - } |
|
326 | - } |
|
327 | - |
|
328 | - // If a or and at least one ok |
|
329 | - if (preg_match('/\|/', $features) && $nbko < count($featuresarray)) $createok=1; |
|
330 | - |
|
331 | - if (GETPOST('action','aZ09') == 'create' && ! $createok) accessforbidden(); |
|
332 | - //print "Write access is ok"; |
|
333 | - } |
|
334 | - |
|
335 | - // Check create user permission |
|
336 | - $createuserok=1; |
|
337 | - if (GETPOST('action','aZ09') == 'confirm_create_user' && GETPOST("confirm",'aZ09') == 'yes') |
|
338 | - { |
|
339 | - if (! $user->rights->user->user->creer) $createuserok=0; |
|
340 | - |
|
341 | - if (! $createuserok) accessforbidden(); |
|
342 | - //print "Create user access is ok"; |
|
343 | - } |
|
344 | - |
|
345 | - // Check delete permission from module |
|
346 | - $deleteok=1; $nbko=0; |
|
347 | - if ((GETPOST("action","aZ09") == 'confirm_delete' && GETPOST("confirm","aZ09") == 'yes') || GETPOST("action","aZ09") == 'delete') |
|
348 | - { |
|
349 | - foreach ($featuresarray as $feature) |
|
350 | - { |
|
351 | - if ($feature == 'contact') |
|
352 | - { |
|
353 | - if (! $user->rights->societe->contact->supprimer) $deleteok=0; |
|
354 | - } |
|
355 | - else if ($feature == 'produit|service') |
|
356 | - { |
|
357 | - if (! $user->rights->produit->supprimer && ! $user->rights->service->supprimer) $deleteok=0; |
|
358 | - } |
|
359 | - else if ($feature == 'commande_fournisseur') |
|
360 | - { |
|
361 | - if (! $user->rights->fournisseur->commande->supprimer) $deleteok=0; |
|
362 | - } |
|
363 | - else if ($feature == 'banque') |
|
364 | - { |
|
365 | - if (! $user->rights->banque->modifier) $deleteok=0; |
|
366 | - } |
|
367 | - else if ($feature == 'cheque') |
|
368 | - { |
|
369 | - if (! $user->rights->banque->cheque) $deleteok=0; |
|
370 | - } |
|
371 | - else if ($feature == 'ecm') |
|
372 | - { |
|
373 | - if (! $user->rights->ecm->upload) $deleteok=0; |
|
374 | - } |
|
375 | - else if ($feature == 'ftp') |
|
376 | - { |
|
377 | - if (! $user->rights->ftp->write) $deleteok=0; |
|
378 | - }else if ($feature == 'salaries') |
|
379 | - { |
|
380 | - if (! $user->rights->salaries->delete) $deleteok=0; |
|
381 | - } |
|
382 | - else if ($feature == 'salaries') |
|
383 | - { |
|
384 | - if (! $user->rights->salaries->delete) $deleteok=0; |
|
385 | - } |
|
386 | - else if (! empty($feature2)) // This should be used for permissions on 2 levels |
|
387 | - { |
|
388 | - foreach($feature2 as $subfeature) |
|
389 | - { |
|
390 | - if (empty($user->rights->$feature->$subfeature->supprimer) && empty($user->rights->$feature->$subfeature->delete)) $deleteok=0; |
|
391 | - else { $deleteok=1; break; } // For bypass the second test if the first is ok |
|
392 | - } |
|
393 | - } |
|
394 | - else if (! empty($feature)) // This is used for permissions on 1 level |
|
395 | - { |
|
396 | - //print '<br>feature='.$feature.' creer='.$user->rights->$feature->supprimer.' write='.$user->rights->$feature->delete; |
|
397 | - if (empty($user->rights->$feature->supprimer) |
|
398 | - && empty($user->rights->$feature->delete) |
|
399 | - && empty($user->rights->$feature->run)) $deleteok=0; |
|
400 | - } |
|
401 | - } |
|
402 | - |
|
403 | - // If a or and at least one ok |
|
404 | - if (preg_match('/\|/', $features) && $nbko < count($featuresarray)) $deleteok=1; |
|
405 | - |
|
406 | - if (! $deleteok && ! ($isdraft && $createok)) accessforbidden(); |
|
407 | - //print "Delete access is ok"; |
|
408 | - } |
|
409 | - |
|
410 | - // If we have a particular object to check permissions on, we check this object |
|
411 | - // is linked to a company allowed to $user. |
|
412 | - if (! empty($objectid) && $objectid > 0) |
|
413 | - { |
|
414 | - $ok = checkUserAccessToObject($user, $featuresarray, $objectid, $tableandshare, $feature2, $dbt_keyfield, $dbt_select); |
|
415 | - return $ok ? 1 : accessforbidden(); |
|
416 | - } |
|
417 | - |
|
418 | - return 1; |
|
183 | + global $db, $conf; |
|
184 | + global $hookmanager; |
|
185 | + |
|
186 | + //dol_syslog("functions.lib:restrictedArea $feature, $objectid, $dbtablename,$feature2,$dbt_socfield,$dbt_select"); |
|
187 | + //print "user_id=".$user->id.", features=".$features.", feature2=".$feature2.", objectid=".$objectid; |
|
188 | + //print ", dbtablename=".$dbtablename.", dbt_socfield=".$dbt_keyfield.", dbt_select=".$dbt_select; |
|
189 | + //print ", perm: ".$features."->".$feature2."=".($user->rights->$features->$feature2->lire)."<br>"; |
|
190 | + |
|
191 | + // Get more permissions checks from hooks |
|
192 | + $parameters=array('features'=>$features, 'objectid'=>$objectid, 'idtype'=>$dbt_select); |
|
193 | + $reshook=$hookmanager->executeHooks('restrictedArea',$parameters); |
|
194 | + if (! empty($hookmanager->resArray['result'])) return true; |
|
195 | + if ($reshook > 0) return false; |
|
196 | + |
|
197 | + if ($dbt_select != 'rowid' && $dbt_select != 'id') $objectid = "'".$objectid."'"; |
|
198 | + |
|
199 | + // Features/modules to check |
|
200 | + $featuresarray = array($features); |
|
201 | + if (preg_match('/&/', $features)) $featuresarray = explode("&", $features); |
|
202 | + else if (preg_match('/\|/', $features)) $featuresarray = explode("|", $features); |
|
203 | + |
|
204 | + // More subfeatures to check |
|
205 | + if (! empty($feature2)) $feature2 = explode("|", $feature2); |
|
206 | + |
|
207 | + // More parameters |
|
208 | + $params = explode('&', $tableandshare); |
|
209 | + $dbtablename=(! empty($params[0]) ? $params[0] : ''); |
|
210 | + $sharedelement=(! empty($params[1]) ? $params[1] : $dbtablename); |
|
211 | + |
|
212 | + $listofmodules=explode(',',$conf->global->MAIN_MODULES_FOR_EXTERNAL); |
|
213 | + |
|
214 | + // Check read permission from module |
|
215 | + $readok=1; $nbko=0; |
|
216 | + foreach ($featuresarray as $feature) // first we check nb of test ko |
|
217 | + { |
|
218 | + $featureforlistofmodule=$feature; |
|
219 | + if ($featureforlistofmodule == 'produit') $featureforlistofmodule='product'; |
|
220 | + if (! empty($user->societe_id) && ! empty($conf->global->MAIN_MODULES_FOR_EXTERNAL) && ! in_array($featureforlistofmodule,$listofmodules)) // If limits on modules for external users, module must be into list of modules for external users |
|
221 | + { |
|
222 | + $readok=0; $nbko++; |
|
223 | + continue; |
|
224 | + } |
|
225 | + |
|
226 | + if ($feature == 'societe') |
|
227 | + { |
|
228 | + if (! $user->rights->societe->lire && ! $user->rights->fournisseur->lire) { $readok=0; $nbko++; } |
|
229 | + } |
|
230 | + else if ($feature == 'contact') |
|
231 | + { |
|
232 | + if (! $user->rights->societe->contact->lire) { $readok=0; $nbko++; } |
|
233 | + } |
|
234 | + else if ($feature == 'produit|service') |
|
235 | + { |
|
236 | + if (! $user->rights->produit->lire && ! $user->rights->service->lire) { $readok=0; $nbko++; } |
|
237 | + } |
|
238 | + else if ($feature == 'prelevement') |
|
239 | + { |
|
240 | + if (! $user->rights->prelevement->bons->lire) { $readok=0; $nbko++; } |
|
241 | + } |
|
242 | + else if ($feature == 'cheque') |
|
243 | + { |
|
244 | + if (! $user->rights->banque->cheque) { $readok=0; $nbko++; } |
|
245 | + } |
|
246 | + else if ($feature == 'projet') |
|
247 | + { |
|
248 | + if (! $user->rights->projet->lire && ! $user->rights->projet->all->lire) { $readok=0; $nbko++; } |
|
249 | + } |
|
250 | + else if (! empty($feature2)) // This should be used for future changes |
|
251 | + { |
|
252 | + $tmpreadok=1; |
|
253 | + foreach($feature2 as $subfeature) |
|
254 | + { |
|
255 | + if (! empty($subfeature) && empty($user->rights->$feature->$subfeature->lire) && empty($user->rights->$feature->$subfeature->read)) { $tmpreadok=0; } |
|
256 | + else if (empty($subfeature) && empty($user->rights->$feature->lire) && empty($user->rights->$feature->read)) { $tmpreadok=0; } |
|
257 | + else { $tmpreadok=1; break; } // Break is to bypass second test if the first is ok |
|
258 | + } |
|
259 | + if (! $tmpreadok) // We found a test on feature that is ko |
|
260 | + { |
|
261 | + $readok=0; // All tests are ko (we manage here the and, the or will be managed later using $nbko). |
|
262 | + $nbko++; |
|
263 | + } |
|
264 | + } |
|
265 | + else if (! empty($feature) && ($feature!='user' && $feature!='usergroup')) // This is for old permissions |
|
266 | + { |
|
267 | + if (empty($user->rights->$feature->lire) |
|
268 | + && empty($user->rights->$feature->read) |
|
269 | + && empty($user->rights->$feature->run)) { $readok=0; $nbko++; } |
|
270 | + } |
|
271 | + } |
|
272 | + |
|
273 | + // If a or and at least one ok |
|
274 | + if (preg_match('/\|/', $features) && $nbko < count($featuresarray)) $readok=1; |
|
275 | + |
|
276 | + if (! $readok) accessforbidden(); |
|
277 | + //print "Read access is ok"; |
|
278 | + |
|
279 | + // Check write permission from module (we need to know write permission to create but also to delete drafts record) |
|
280 | + $createok=1; $nbko=0; |
|
281 | + if (GETPOST('action','aZ09') == 'create' || ((GETPOST("action","aZ09") == 'confirm_delete' && GETPOST("confirm","aZ09") == 'yes') || GETPOST("action","aZ09") == 'delete')) |
|
282 | + { |
|
283 | + foreach ($featuresarray as $feature) |
|
284 | + { |
|
285 | + if ($feature == 'contact') |
|
286 | + { |
|
287 | + if (! $user->rights->societe->contact->creer) { $createok=0; $nbko++; } |
|
288 | + } |
|
289 | + else if ($feature == 'produit|service') |
|
290 | + { |
|
291 | + if (! $user->rights->produit->creer && ! $user->rights->service->creer) { $createok=0; $nbko++; } |
|
292 | + } |
|
293 | + else if ($feature == 'prelevement') |
|
294 | + { |
|
295 | + if (! $user->rights->prelevement->bons->creer) { $createok=0; $nbko++; } |
|
296 | + } |
|
297 | + else if ($feature == 'commande_fournisseur') |
|
298 | + { |
|
299 | + if (! $user->rights->fournisseur->commande->creer) { $createok=0; $nbko++; } |
|
300 | + } |
|
301 | + else if ($feature == 'banque') |
|
302 | + { |
|
303 | + if (! $user->rights->banque->modifier) { $createok=0; $nbko++; } |
|
304 | + } |
|
305 | + else if ($feature == 'cheque') |
|
306 | + { |
|
307 | + if (! $user->rights->banque->cheque) { $createok=0; $nbko++; } |
|
308 | + } |
|
309 | + else if (! empty($feature2)) // This should be used |
|
310 | + { |
|
311 | + foreach($feature2 as $subfeature) |
|
312 | + { |
|
313 | + if (empty($user->rights->$feature->$subfeature->creer) |
|
314 | + && empty($user->rights->$feature->$subfeature->write) |
|
315 | + && empty($user->rights->$feature->$subfeature->create)) { $createok=0; $nbko++; } |
|
316 | + else { $createok=1; break; } // Break to bypass second test if the first is ok |
|
317 | + } |
|
318 | + } |
|
319 | + else if (! empty($feature)) // This is for old permissions ('creer' or 'write') |
|
320 | + { |
|
321 | + //print '<br>feature='.$feature.' creer='.$user->rights->$feature->creer.' write='.$user->rights->$feature->write; |
|
322 | + if (empty($user->rights->$feature->creer) |
|
323 | + && empty($user->rights->$feature->write) |
|
324 | + && empty($user->rights->$feature->create)) { $createok=0; $nbko++; } |
|
325 | + } |
|
326 | + } |
|
327 | + |
|
328 | + // If a or and at least one ok |
|
329 | + if (preg_match('/\|/', $features) && $nbko < count($featuresarray)) $createok=1; |
|
330 | + |
|
331 | + if (GETPOST('action','aZ09') == 'create' && ! $createok) accessforbidden(); |
|
332 | + //print "Write access is ok"; |
|
333 | + } |
|
334 | + |
|
335 | + // Check create user permission |
|
336 | + $createuserok=1; |
|
337 | + if (GETPOST('action','aZ09') == 'confirm_create_user' && GETPOST("confirm",'aZ09') == 'yes') |
|
338 | + { |
|
339 | + if (! $user->rights->user->user->creer) $createuserok=0; |
|
340 | + |
|
341 | + if (! $createuserok) accessforbidden(); |
|
342 | + //print "Create user access is ok"; |
|
343 | + } |
|
344 | + |
|
345 | + // Check delete permission from module |
|
346 | + $deleteok=1; $nbko=0; |
|
347 | + if ((GETPOST("action","aZ09") == 'confirm_delete' && GETPOST("confirm","aZ09") == 'yes') || GETPOST("action","aZ09") == 'delete') |
|
348 | + { |
|
349 | + foreach ($featuresarray as $feature) |
|
350 | + { |
|
351 | + if ($feature == 'contact') |
|
352 | + { |
|
353 | + if (! $user->rights->societe->contact->supprimer) $deleteok=0; |
|
354 | + } |
|
355 | + else if ($feature == 'produit|service') |
|
356 | + { |
|
357 | + if (! $user->rights->produit->supprimer && ! $user->rights->service->supprimer) $deleteok=0; |
|
358 | + } |
|
359 | + else if ($feature == 'commande_fournisseur') |
|
360 | + { |
|
361 | + if (! $user->rights->fournisseur->commande->supprimer) $deleteok=0; |
|
362 | + } |
|
363 | + else if ($feature == 'banque') |
|
364 | + { |
|
365 | + if (! $user->rights->banque->modifier) $deleteok=0; |
|
366 | + } |
|
367 | + else if ($feature == 'cheque') |
|
368 | + { |
|
369 | + if (! $user->rights->banque->cheque) $deleteok=0; |
|
370 | + } |
|
371 | + else if ($feature == 'ecm') |
|
372 | + { |
|
373 | + if (! $user->rights->ecm->upload) $deleteok=0; |
|
374 | + } |
|
375 | + else if ($feature == 'ftp') |
|
376 | + { |
|
377 | + if (! $user->rights->ftp->write) $deleteok=0; |
|
378 | + }else if ($feature == 'salaries') |
|
379 | + { |
|
380 | + if (! $user->rights->salaries->delete) $deleteok=0; |
|
381 | + } |
|
382 | + else if ($feature == 'salaries') |
|
383 | + { |
|
384 | + if (! $user->rights->salaries->delete) $deleteok=0; |
|
385 | + } |
|
386 | + else if (! empty($feature2)) // This should be used for permissions on 2 levels |
|
387 | + { |
|
388 | + foreach($feature2 as $subfeature) |
|
389 | + { |
|
390 | + if (empty($user->rights->$feature->$subfeature->supprimer) && empty($user->rights->$feature->$subfeature->delete)) $deleteok=0; |
|
391 | + else { $deleteok=1; break; } // For bypass the second test if the first is ok |
|
392 | + } |
|
393 | + } |
|
394 | + else if (! empty($feature)) // This is used for permissions on 1 level |
|
395 | + { |
|
396 | + //print '<br>feature='.$feature.' creer='.$user->rights->$feature->supprimer.' write='.$user->rights->$feature->delete; |
|
397 | + if (empty($user->rights->$feature->supprimer) |
|
398 | + && empty($user->rights->$feature->delete) |
|
399 | + && empty($user->rights->$feature->run)) $deleteok=0; |
|
400 | + } |
|
401 | + } |
|
402 | + |
|
403 | + // If a or and at least one ok |
|
404 | + if (preg_match('/\|/', $features) && $nbko < count($featuresarray)) $deleteok=1; |
|
405 | + |
|
406 | + if (! $deleteok && ! ($isdraft && $createok)) accessforbidden(); |
|
407 | + //print "Delete access is ok"; |
|
408 | + } |
|
409 | + |
|
410 | + // If we have a particular object to check permissions on, we check this object |
|
411 | + // is linked to a company allowed to $user. |
|
412 | + if (! empty($objectid) && $objectid > 0) |
|
413 | + { |
|
414 | + $ok = checkUserAccessToObject($user, $featuresarray, $objectid, $tableandshare, $feature2, $dbt_keyfield, $dbt_select); |
|
415 | + return $ok ? 1 : accessforbidden(); |
|
416 | + } |
|
417 | + |
|
418 | + return 1; |
|
419 | 419 | } |
420 | 420 | |
421 | 421 | /** |
@@ -434,216 +434,216 @@ discard block |
||
434 | 434 | */ |
435 | 435 | function checkUserAccessToObject($user, $featuresarray, $objectid=0, $tableandshare='', $feature2='', $dbt_keyfield='', $dbt_select='rowid') |
436 | 436 | { |
437 | - global $db, $conf; |
|
438 | - |
|
439 | - // More parameters |
|
440 | - $params = explode('&', $tableandshare); |
|
441 | - $dbtablename=(! empty($params[0]) ? $params[0] : ''); |
|
442 | - $sharedelement=(! empty($params[1]) ? $params[1] : $dbtablename); |
|
443 | - |
|
444 | - foreach ($featuresarray as $feature) |
|
445 | - { |
|
446 | - $sql=''; |
|
447 | - |
|
448 | - // For backward compatibility |
|
449 | - if ($feature == 'member') $feature='adherent'; |
|
450 | - if ($feature == 'project') $feature='projet'; |
|
451 | - if ($feature == 'task') $feature='projet_task'; |
|
452 | - |
|
453 | - $check = array('adherent','banque','don','user','usergroup','product','produit','service','produit|service','categorie','resource'); // Test on entity only (Objects with no link to company) |
|
454 | - $checksoc = array('societe'); // Test for societe object |
|
455 | - $checkother = array('contact','agenda'); // Test on entity and link to third party. Allowed if link is empty (Ex: contacts...). |
|
456 | - $checkproject = array('projet','project'); // Test for project object |
|
457 | - $checktask = array('projet_task'); |
|
458 | - $nocheck = array('barcode','stock'); // No test |
|
459 | - $checkdefault = 'all other not already defined'; // Test on entity and link to third party. Not allowed if link is empty (Ex: invoice, orders...). |
|
460 | - |
|
461 | - // If dbtablename not defined, we use same name for table than module name |
|
462 | - if (empty($dbtablename)) |
|
463 | - { |
|
464 | - $dbtablename = $feature; |
|
465 | - $sharedelement = (! empty($params[1]) ? $params[1] : $dbtablename); // We change dbtablename, so we set sharedelement too. |
|
466 | - } |
|
467 | - |
|
468 | - // Check permission for object with entity |
|
469 | - if (in_array($feature,$check)) |
|
470 | - { |
|
471 | - $sql = "SELECT COUNT(dbt.".$dbt_select.") as nb"; |
|
472 | - $sql.= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt"; |
|
473 | - if (($feature == 'user' || $feature == 'usergroup') && ! empty($conf->multicompany->enabled)) |
|
474 | - { |
|
475 | - if (! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) |
|
476 | - { |
|
477 | - if ($conf->entity == 1 && $user->admin && ! $user->entity) |
|
478 | - { |
|
479 | - $sql.= " WHERE dbt.".$dbt_select." IN (".$objectid.")"; |
|
480 | - $sql.= " AND dbt.entity IS NOT NULL"; |
|
481 | - } |
|
482 | - else |
|
483 | - { |
|
484 | - $sql.= ",".MAIN_DB_PREFIX."usergroup_user as ug"; |
|
485 | - $sql.= " WHERE dbt.".$dbt_select." IN (".$objectid.")"; |
|
486 | - $sql.= " AND (ug.fk_user = dbt.rowid"; |
|
487 | - $sql.= " AND ug.entity IN (".getEntity('user')."))"; |
|
488 | - $sql.= " OR dbt.entity = 0"; // Show always superadmin |
|
489 | - } |
|
490 | - } |
|
491 | - else { |
|
492 | - $sql.= " WHERE dbt.".$dbt_select." IN (".$objectid.")"; |
|
493 | - $sql.= " AND dbt.entity IN (".getEntity($sharedelement, 1).")"; |
|
494 | - } |
|
495 | - } |
|
496 | - else |
|
497 | - { |
|
498 | - $sql.= " WHERE dbt.".$dbt_select." IN (".$objectid.")"; |
|
499 | - $sql.= " AND dbt.entity IN (".getEntity($sharedelement, 1).")"; |
|
500 | - } |
|
501 | - } |
|
502 | - else if (in_array($feature,$checksoc)) // We check feature = checksoc |
|
503 | - { |
|
504 | - // If external user: Check permission for external users |
|
505 | - if ($user->socid > 0) |
|
506 | - { |
|
507 | - if ($user->socid <> $objectid) return false; |
|
508 | - } |
|
509 | - // If internal user: Check permission for internal users that are restricted on their objects |
|
510 | - else if (! empty($conf->societe->enabled) && ($user->rights->societe->lire && ! $user->rights->societe->client->voir)) |
|
511 | - { |
|
512 | - $sql = "SELECT COUNT(sc.fk_soc) as nb"; |
|
513 | - $sql.= " FROM (".MAIN_DB_PREFIX."societe_commerciaux as sc"; |
|
514 | - $sql.= ", ".MAIN_DB_PREFIX."societe as s)"; |
|
515 | - $sql.= " WHERE sc.fk_soc IN (".$objectid.")"; |
|
516 | - $sql.= " AND sc.fk_user = ".$user->id; |
|
517 | - $sql.= " AND sc.fk_soc = s.rowid"; |
|
518 | - $sql.= " AND s.entity IN (".getEntity($sharedelement, 1).")"; |
|
519 | - } |
|
520 | - // If multicompany and internal users with all permissions, check user is in correct entity |
|
521 | - else if (! empty($conf->multicompany->enabled)) |
|
522 | - { |
|
523 | - $sql = "SELECT COUNT(s.rowid) as nb"; |
|
524 | - $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; |
|
525 | - $sql.= " WHERE s.rowid IN (".$objectid.")"; |
|
526 | - $sql.= " AND s.entity IN (".getEntity($sharedelement, 1).")"; |
|
527 | - } |
|
528 | - } |
|
529 | - else if (in_array($feature,$checkother)) // Test on entity and link to societe. Allowed if link is empty (Ex: contacts...). |
|
530 | - { |
|
531 | - // If external user: Check permission for external users |
|
532 | - if ($user->socid > 0) |
|
533 | - { |
|
534 | - $sql = "SELECT COUNT(dbt.".$dbt_select.") as nb"; |
|
535 | - $sql.= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt"; |
|
536 | - $sql.= " WHERE dbt.".$dbt_select." IN (".$objectid.")"; |
|
537 | - $sql.= " AND dbt.fk_soc = ".$user->socid; |
|
538 | - } |
|
539 | - // If internal user: Check permission for internal users that are restricted on their objects |
|
540 | - else if (! empty($conf->societe->enabled) && ($user->rights->societe->lire && ! $user->rights->societe->client->voir)) |
|
541 | - { |
|
542 | - $sql = "SELECT COUNT(dbt.".$dbt_select.") as nb"; |
|
543 | - $sql.= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt"; |
|
544 | - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON dbt.fk_soc = sc.fk_soc AND sc.fk_user = '".$user->id."'"; |
|
545 | - $sql.= " WHERE dbt.".$dbt_select." IN (".$objectid.")"; |
|
546 | - $sql.= " AND (dbt.fk_soc IS NULL OR sc.fk_soc IS NOT NULL)"; // Contact not linked to a company or to a company of user |
|
547 | - $sql.= " AND dbt.entity IN (".getEntity($sharedelement, 1).")"; |
|
548 | - } |
|
549 | - // If multicompany and internal users with all permissions, check user is in correct entity |
|
550 | - else if (! empty($conf->multicompany->enabled)) |
|
551 | - { |
|
552 | - $sql = "SELECT COUNT(dbt.".$dbt_select.") as nb"; |
|
553 | - $sql.= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt"; |
|
554 | - $sql.= " WHERE dbt.".$dbt_select." IN (".$objectid.")"; |
|
555 | - $sql.= " AND dbt.entity IN (".getEntity($sharedelement, 1).")"; |
|
556 | - } |
|
557 | - } |
|
558 | - else if (in_array($feature,$checkproject)) |
|
559 | - { |
|
560 | - if (! empty($conf->projet->enabled) && empty($user->rights->projet->all->lire)) |
|
561 | - { |
|
562 | - include_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; |
|
563 | - $projectstatic=new Project($db); |
|
564 | - $tmps=$projectstatic->getProjectsAuthorizedForUser($user,0,1,0); |
|
565 | - $tmparray=explode(',',$tmps); |
|
566 | - if (! in_array($objectid,$tmparray)) return false; |
|
567 | - } |
|
568 | - else |
|
569 | - { |
|
570 | - $sql = "SELECT COUNT(dbt.".$dbt_select.") as nb"; |
|
571 | - $sql.= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt"; |
|
572 | - $sql.= " WHERE dbt.".$dbt_select." IN (".$objectid.")"; |
|
573 | - $sql.= " AND dbt.entity IN (".getEntity($sharedelement, 1).")"; |
|
574 | - } |
|
575 | - } |
|
576 | - else if (in_array($feature,$checktask)) |
|
577 | - { |
|
578 | - if (! empty($conf->projet->enabled) && empty($user->rights->projet->all->lire)) |
|
579 | - { |
|
580 | - $task = new Task($db); |
|
581 | - $task->fetch($objectid); |
|
582 | - |
|
583 | - include_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; |
|
584 | - $projectstatic=new Project($db); |
|
585 | - $tmps=$projectstatic->getProjectsAuthorizedForUser($user,0,1,0); |
|
586 | - $tmparray=explode(',',$tmps); |
|
587 | - if (! in_array($task->fk_project,$tmparray)) return false; |
|
588 | - } |
|
589 | - else |
|
590 | - { |
|
591 | - $sql = "SELECT COUNT(dbt.".$dbt_select.") as nb"; |
|
592 | - $sql.= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt"; |
|
593 | - $sql.= " WHERE dbt.".$dbt_select." IN (".$objectid.")"; |
|
594 | - $sql.= " AND dbt.entity IN (".getEntity($sharedelement, 1).")"; |
|
595 | - } |
|
596 | - } |
|
597 | - else if (! in_array($feature,$nocheck)) // By default (case of $checkdefault), we check on object entity + link to third party on field $dbt_keyfield |
|
598 | - { |
|
599 | - // If external user: Check permission for external users |
|
600 | - if ($user->socid > 0) |
|
601 | - { |
|
602 | - if (empty($dbt_keyfield)) dol_print_error('','Param dbt_keyfield is required but not defined'); |
|
603 | - $sql = "SELECT COUNT(dbt.".$dbt_keyfield.") as nb"; |
|
604 | - $sql.= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt"; |
|
605 | - $sql.= " WHERE dbt.rowid IN (".$objectid.")"; |
|
606 | - $sql.= " AND dbt.".$dbt_keyfield." = ".$user->socid; |
|
607 | - } |
|
608 | - // If internal user: Check permission for internal users that are restricted on their objects |
|
609 | - else if (! empty($conf->societe->enabled) && ($user->rights->societe->lire && ! $user->rights->societe->client->voir)) |
|
610 | - { |
|
611 | - if (empty($dbt_keyfield)) dol_print_error('','Param dbt_keyfield is required but not defined'); |
|
612 | - $sql = "SELECT COUNT(sc.fk_soc) as nb"; |
|
613 | - $sql.= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt"; |
|
614 | - $sql.= ", ".MAIN_DB_PREFIX."societe as s"; |
|
615 | - $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; |
|
616 | - $sql.= " WHERE dbt.".$dbt_select." IN (".$objectid.")"; |
|
617 | - $sql.= " AND sc.fk_soc = dbt.".$dbt_keyfield; |
|
618 | - $sql.= " AND dbt.".$dbt_keyfield." = s.rowid"; |
|
619 | - $sql.= " AND dbt.entity IN (".getEntity($sharedelement, 1).")"; |
|
620 | - $sql.= " AND sc.fk_user = ".$user->id; |
|
621 | - } |
|
622 | - // If multicompany and internal users with all permissions, check user is in correct entity |
|
623 | - else if (! empty($conf->multicompany->enabled)) |
|
624 | - { |
|
625 | - $sql = "SELECT COUNT(dbt.".$dbt_select.") as nb"; |
|
626 | - $sql.= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt"; |
|
627 | - $sql.= " WHERE dbt.".$dbt_select." IN (".$objectid.")"; |
|
628 | - $sql.= " AND dbt.entity IN (".getEntity($sharedelement, 1).")"; |
|
629 | - } |
|
630 | - } |
|
631 | - |
|
632 | - if ($sql) |
|
633 | - { |
|
634 | - $resql=$db->query($sql); |
|
635 | - if ($resql) |
|
636 | - { |
|
637 | - $obj = $db->fetch_object($resql); |
|
638 | - if (! $obj || $obj->nb < count(explode(',', $objectid))) return false; |
|
639 | - } |
|
640 | - else |
|
641 | - { |
|
642 | - return false; |
|
643 | - } |
|
644 | - } |
|
645 | - } |
|
646 | - return true; |
|
437 | + global $db, $conf; |
|
438 | + |
|
439 | + // More parameters |
|
440 | + $params = explode('&', $tableandshare); |
|
441 | + $dbtablename=(! empty($params[0]) ? $params[0] : ''); |
|
442 | + $sharedelement=(! empty($params[1]) ? $params[1] : $dbtablename); |
|
443 | + |
|
444 | + foreach ($featuresarray as $feature) |
|
445 | + { |
|
446 | + $sql=''; |
|
447 | + |
|
448 | + // For backward compatibility |
|
449 | + if ($feature == 'member') $feature='adherent'; |
|
450 | + if ($feature == 'project') $feature='projet'; |
|
451 | + if ($feature == 'task') $feature='projet_task'; |
|
452 | + |
|
453 | + $check = array('adherent','banque','don','user','usergroup','product','produit','service','produit|service','categorie','resource'); // Test on entity only (Objects with no link to company) |
|
454 | + $checksoc = array('societe'); // Test for societe object |
|
455 | + $checkother = array('contact','agenda'); // Test on entity and link to third party. Allowed if link is empty (Ex: contacts...). |
|
456 | + $checkproject = array('projet','project'); // Test for project object |
|
457 | + $checktask = array('projet_task'); |
|
458 | + $nocheck = array('barcode','stock'); // No test |
|
459 | + $checkdefault = 'all other not already defined'; // Test on entity and link to third party. Not allowed if link is empty (Ex: invoice, orders...). |
|
460 | + |
|
461 | + // If dbtablename not defined, we use same name for table than module name |
|
462 | + if (empty($dbtablename)) |
|
463 | + { |
|
464 | + $dbtablename = $feature; |
|
465 | + $sharedelement = (! empty($params[1]) ? $params[1] : $dbtablename); // We change dbtablename, so we set sharedelement too. |
|
466 | + } |
|
467 | + |
|
468 | + // Check permission for object with entity |
|
469 | + if (in_array($feature,$check)) |
|
470 | + { |
|
471 | + $sql = "SELECT COUNT(dbt.".$dbt_select.") as nb"; |
|
472 | + $sql.= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt"; |
|
473 | + if (($feature == 'user' || $feature == 'usergroup') && ! empty($conf->multicompany->enabled)) |
|
474 | + { |
|
475 | + if (! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) |
|
476 | + { |
|
477 | + if ($conf->entity == 1 && $user->admin && ! $user->entity) |
|
478 | + { |
|
479 | + $sql.= " WHERE dbt.".$dbt_select." IN (".$objectid.")"; |
|
480 | + $sql.= " AND dbt.entity IS NOT NULL"; |
|
481 | + } |
|
482 | + else |
|
483 | + { |
|
484 | + $sql.= ",".MAIN_DB_PREFIX."usergroup_user as ug"; |
|
485 | + $sql.= " WHERE dbt.".$dbt_select." IN (".$objectid.")"; |
|
486 | + $sql.= " AND (ug.fk_user = dbt.rowid"; |
|
487 | + $sql.= " AND ug.entity IN (".getEntity('user')."))"; |
|
488 | + $sql.= " OR dbt.entity = 0"; // Show always superadmin |
|
489 | + } |
|
490 | + } |
|
491 | + else { |
|
492 | + $sql.= " WHERE dbt.".$dbt_select." IN (".$objectid.")"; |
|
493 | + $sql.= " AND dbt.entity IN (".getEntity($sharedelement, 1).")"; |
|
494 | + } |
|
495 | + } |
|
496 | + else |
|
497 | + { |
|
498 | + $sql.= " WHERE dbt.".$dbt_select." IN (".$objectid.")"; |
|
499 | + $sql.= " AND dbt.entity IN (".getEntity($sharedelement, 1).")"; |
|
500 | + } |
|
501 | + } |
|
502 | + else if (in_array($feature,$checksoc)) // We check feature = checksoc |
|
503 | + { |
|
504 | + // If external user: Check permission for external users |
|
505 | + if ($user->socid > 0) |
|
506 | + { |
|
507 | + if ($user->socid <> $objectid) return false; |
|
508 | + } |
|
509 | + // If internal user: Check permission for internal users that are restricted on their objects |
|
510 | + else if (! empty($conf->societe->enabled) && ($user->rights->societe->lire && ! $user->rights->societe->client->voir)) |
|
511 | + { |
|
512 | + $sql = "SELECT COUNT(sc.fk_soc) as nb"; |
|
513 | + $sql.= " FROM (".MAIN_DB_PREFIX."societe_commerciaux as sc"; |
|
514 | + $sql.= ", ".MAIN_DB_PREFIX."societe as s)"; |
|
515 | + $sql.= " WHERE sc.fk_soc IN (".$objectid.")"; |
|
516 | + $sql.= " AND sc.fk_user = ".$user->id; |
|
517 | + $sql.= " AND sc.fk_soc = s.rowid"; |
|
518 | + $sql.= " AND s.entity IN (".getEntity($sharedelement, 1).")"; |
|
519 | + } |
|
520 | + // If multicompany and internal users with all permissions, check user is in correct entity |
|
521 | + else if (! empty($conf->multicompany->enabled)) |
|
522 | + { |
|
523 | + $sql = "SELECT COUNT(s.rowid) as nb"; |
|
524 | + $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; |
|
525 | + $sql.= " WHERE s.rowid IN (".$objectid.")"; |
|
526 | + $sql.= " AND s.entity IN (".getEntity($sharedelement, 1).")"; |
|
527 | + } |
|
528 | + } |
|
529 | + else if (in_array($feature,$checkother)) // Test on entity and link to societe. Allowed if link is empty (Ex: contacts...). |
|
530 | + { |
|
531 | + // If external user: Check permission for external users |
|
532 | + if ($user->socid > 0) |
|
533 | + { |
|
534 | + $sql = "SELECT COUNT(dbt.".$dbt_select.") as nb"; |
|
535 | + $sql.= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt"; |
|
536 | + $sql.= " WHERE dbt.".$dbt_select." IN (".$objectid.")"; |
|
537 | + $sql.= " AND dbt.fk_soc = ".$user->socid; |
|
538 | + } |
|
539 | + // If internal user: Check permission for internal users that are restricted on their objects |
|
540 | + else if (! empty($conf->societe->enabled) && ($user->rights->societe->lire && ! $user->rights->societe->client->voir)) |
|
541 | + { |
|
542 | + $sql = "SELECT COUNT(dbt.".$dbt_select.") as nb"; |
|
543 | + $sql.= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt"; |
|
544 | + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON dbt.fk_soc = sc.fk_soc AND sc.fk_user = '".$user->id."'"; |
|
545 | + $sql.= " WHERE dbt.".$dbt_select." IN (".$objectid.")"; |
|
546 | + $sql.= " AND (dbt.fk_soc IS NULL OR sc.fk_soc IS NOT NULL)"; // Contact not linked to a company or to a company of user |
|
547 | + $sql.= " AND dbt.entity IN (".getEntity($sharedelement, 1).")"; |
|
548 | + } |
|
549 | + // If multicompany and internal users with all permissions, check user is in correct entity |
|
550 | + else if (! empty($conf->multicompany->enabled)) |
|
551 | + { |
|
552 | + $sql = "SELECT COUNT(dbt.".$dbt_select.") as nb"; |
|
553 | + $sql.= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt"; |
|
554 | + $sql.= " WHERE dbt.".$dbt_select." IN (".$objectid.")"; |
|
555 | + $sql.= " AND dbt.entity IN (".getEntity($sharedelement, 1).")"; |
|
556 | + } |
|
557 | + } |
|
558 | + else if (in_array($feature,$checkproject)) |
|
559 | + { |
|
560 | + if (! empty($conf->projet->enabled) && empty($user->rights->projet->all->lire)) |
|
561 | + { |
|
562 | + include_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; |
|
563 | + $projectstatic=new Project($db); |
|
564 | + $tmps=$projectstatic->getProjectsAuthorizedForUser($user,0,1,0); |
|
565 | + $tmparray=explode(',',$tmps); |
|
566 | + if (! in_array($objectid,$tmparray)) return false; |
|
567 | + } |
|
568 | + else |
|
569 | + { |
|
570 | + $sql = "SELECT COUNT(dbt.".$dbt_select.") as nb"; |
|
571 | + $sql.= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt"; |
|
572 | + $sql.= " WHERE dbt.".$dbt_select." IN (".$objectid.")"; |
|
573 | + $sql.= " AND dbt.entity IN (".getEntity($sharedelement, 1).")"; |
|
574 | + } |
|
575 | + } |
|
576 | + else if (in_array($feature,$checktask)) |
|
577 | + { |
|
578 | + if (! empty($conf->projet->enabled) && empty($user->rights->projet->all->lire)) |
|
579 | + { |
|
580 | + $task = new Task($db); |
|
581 | + $task->fetch($objectid); |
|
582 | + |
|
583 | + include_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; |
|
584 | + $projectstatic=new Project($db); |
|
585 | + $tmps=$projectstatic->getProjectsAuthorizedForUser($user,0,1,0); |
|
586 | + $tmparray=explode(',',$tmps); |
|
587 | + if (! in_array($task->fk_project,$tmparray)) return false; |
|
588 | + } |
|
589 | + else |
|
590 | + { |
|
591 | + $sql = "SELECT COUNT(dbt.".$dbt_select.") as nb"; |
|
592 | + $sql.= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt"; |
|
593 | + $sql.= " WHERE dbt.".$dbt_select." IN (".$objectid.")"; |
|
594 | + $sql.= " AND dbt.entity IN (".getEntity($sharedelement, 1).")"; |
|
595 | + } |
|
596 | + } |
|
597 | + else if (! in_array($feature,$nocheck)) // By default (case of $checkdefault), we check on object entity + link to third party on field $dbt_keyfield |
|
598 | + { |
|
599 | + // If external user: Check permission for external users |
|
600 | + if ($user->socid > 0) |
|
601 | + { |
|
602 | + if (empty($dbt_keyfield)) dol_print_error('','Param dbt_keyfield is required but not defined'); |
|
603 | + $sql = "SELECT COUNT(dbt.".$dbt_keyfield.") as nb"; |
|
604 | + $sql.= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt"; |
|
605 | + $sql.= " WHERE dbt.rowid IN (".$objectid.")"; |
|
606 | + $sql.= " AND dbt.".$dbt_keyfield." = ".$user->socid; |
|
607 | + } |
|
608 | + // If internal user: Check permission for internal users that are restricted on their objects |
|
609 | + else if (! empty($conf->societe->enabled) && ($user->rights->societe->lire && ! $user->rights->societe->client->voir)) |
|
610 | + { |
|
611 | + if (empty($dbt_keyfield)) dol_print_error('','Param dbt_keyfield is required but not defined'); |
|
612 | + $sql = "SELECT COUNT(sc.fk_soc) as nb"; |
|
613 | + $sql.= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt"; |
|
614 | + $sql.= ", ".MAIN_DB_PREFIX."societe as s"; |
|
615 | + $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; |
|
616 | + $sql.= " WHERE dbt.".$dbt_select." IN (".$objectid.")"; |
|
617 | + $sql.= " AND sc.fk_soc = dbt.".$dbt_keyfield; |
|
618 | + $sql.= " AND dbt.".$dbt_keyfield." = s.rowid"; |
|
619 | + $sql.= " AND dbt.entity IN (".getEntity($sharedelement, 1).")"; |
|
620 | + $sql.= " AND sc.fk_user = ".$user->id; |
|
621 | + } |
|
622 | + // If multicompany and internal users with all permissions, check user is in correct entity |
|
623 | + else if (! empty($conf->multicompany->enabled)) |
|
624 | + { |
|
625 | + $sql = "SELECT COUNT(dbt.".$dbt_select.") as nb"; |
|
626 | + $sql.= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt"; |
|
627 | + $sql.= " WHERE dbt.".$dbt_select." IN (".$objectid.")"; |
|
628 | + $sql.= " AND dbt.entity IN (".getEntity($sharedelement, 1).")"; |
|
629 | + } |
|
630 | + } |
|
631 | + |
|
632 | + if ($sql) |
|
633 | + { |
|
634 | + $resql=$db->query($sql); |
|
635 | + if ($resql) |
|
636 | + { |
|
637 | + $obj = $db->fetch_object($resql); |
|
638 | + if (! $obj || $obj->nb < count(explode(',', $objectid))) return false; |
|
639 | + } |
|
640 | + else |
|
641 | + { |
|
642 | + return false; |
|
643 | + } |
|
644 | + } |
|
645 | + } |
|
646 | + return true; |
|
647 | 647 | } |
648 | 648 | |
649 | 649 | /** |
@@ -666,30 +666,30 @@ discard block |
||
666 | 666 | $langs->setDefaultLang(); |
667 | 667 | } |
668 | 668 | |
669 | - $langs->load("errors"); |
|
670 | - |
|
671 | - if ($printheader) |
|
672 | - { |
|
673 | - if (function_exists("llxHeader")) llxHeader(''); |
|
674 | - else if (function_exists("llxHeaderVierge")) llxHeaderVierge(''); |
|
675 | - } |
|
676 | - print '<div class="error">'; |
|
677 | - if (! $message) print $langs->trans("ErrorForbidden"); |
|
678 | - else print $message; |
|
679 | - print '</div>'; |
|
680 | - print '<br>'; |
|
681 | - if (empty($showonlymessage)) |
|
682 | - { |
|
683 | - if ($user->login) |
|
684 | - { |
|
685 | - print $langs->trans("CurrentLogin").': <font class="error">'.$user->login.'</font><br>'; |
|
686 | - print $langs->trans("ErrorForbidden2",$langs->trans("Home"),$langs->trans("Users")); |
|
687 | - } |
|
688 | - else |
|
689 | - { |
|
690 | - print $langs->trans("ErrorForbidden3"); |
|
691 | - } |
|
692 | - } |
|
693 | - if ($printfooter && function_exists("llxFooter")) llxFooter(); |
|
694 | - exit(0); |
|
669 | + $langs->load("errors"); |
|
670 | + |
|
671 | + if ($printheader) |
|
672 | + { |
|
673 | + if (function_exists("llxHeader")) llxHeader(''); |
|
674 | + else if (function_exists("llxHeaderVierge")) llxHeaderVierge(''); |
|
675 | + } |
|
676 | + print '<div class="error">'; |
|
677 | + if (! $message) print $langs->trans("ErrorForbidden"); |
|
678 | + else print $message; |
|
679 | + print '</div>'; |
|
680 | + print '<br>'; |
|
681 | + if (empty($showonlymessage)) |
|
682 | + { |
|
683 | + if ($user->login) |
|
684 | + { |
|
685 | + print $langs->trans("CurrentLogin").': <font class="error">'.$user->login.'</font><br>'; |
|
686 | + print $langs->trans("ErrorForbidden2",$langs->trans("Home"),$langs->trans("Users")); |
|
687 | + } |
|
688 | + else |
|
689 | + { |
|
690 | + print $langs->trans("ErrorForbidden3"); |
|
691 | + } |
|
692 | + } |
|
693 | + if ($printfooter && function_exists("llxFooter")) llxFooter(); |
|
694 | + exit(0); |
|
695 | 695 | } |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | |
127 | 127 | $selected='EUA4'; |
128 | 128 | if (!$outputlangs) { |
129 | - $outputlangs=$langs; |
|
129 | + $outputlangs=$langs; |
|
130 | 130 | } |
131 | 131 | |
132 | 132 | if ($outputlangs->defaultlang == 'ca_CA') $selected='CAP4'; // Canada |
@@ -230,15 +230,15 @@ discard block |
||
230 | 230 | else print ': '; |
231 | 231 | if (is_object($object->user_creation)) |
232 | 232 | { |
233 | - if ($object->user_creation->id) print $object->user_creation->getNomUrl(1, '', 0, 0, 0); |
|
234 | - else print $langs->trans("Unknown"); |
|
233 | + if ($object->user_creation->id) print $object->user_creation->getNomUrl(1, '', 0, 0, 0); |
|
234 | + else print $langs->trans("Unknown"); |
|
235 | 235 | } |
236 | 236 | else |
237 | 237 | { |
238 | 238 | $userstatic=new User($db); |
239 | 239 | $userstatic->fetch($object->user_creation_id ? $object->user_creation_id : $object->user_creation); |
240 | 240 | if ($userstatic->id) print $userstatic->getNomUrl(1, '', 0, 0, 0); |
241 | - else print $langs->trans("Unknown"); |
|
241 | + else print $langs->trans("Unknown"); |
|
242 | 242 | } |
243 | 243 | if ($usetable) print '</td></tr>'; |
244 | 244 | else print '<br>'; |
@@ -266,15 +266,15 @@ discard block |
||
266 | 266 | else print ': '; |
267 | 267 | if (is_object($object->user_modification)) |
268 | 268 | { |
269 | - if ($object->user_modification->id) print $object->user_modification->getNomUrl(1, '', 0, 0, 0); |
|
270 | - else print $langs->trans("Unknown"); |
|
269 | + if ($object->user_modification->id) print $object->user_modification->getNomUrl(1, '', 0, 0, 0); |
|
270 | + else print $langs->trans("Unknown"); |
|
271 | 271 | } |
272 | 272 | else |
273 | 273 | { |
274 | 274 | $userstatic=new User($db); |
275 | 275 | $userstatic->fetch($object->user_modification_id ? $object->user_modification_id : $object->user_modification); |
276 | 276 | if ($userstatic->id) print $userstatic->getNomUrl(1, '', 0, 0, 0); |
277 | - else print $langs->trans("Unknown"); |
|
277 | + else print $langs->trans("Unknown"); |
|
278 | 278 | } |
279 | 279 | if ($usetable) print '</td></tr>'; |
280 | 280 | else print '<br>'; |
@@ -303,14 +303,14 @@ discard block |
||
303 | 303 | if (is_object($object->user_validation)) |
304 | 304 | { |
305 | 305 | if ($object->user_validation->id) print $object->user_validation->getNomUrl(1, '', 0, 0, 0); |
306 | - else print $langs->trans("Unknown"); |
|
306 | + else print $langs->trans("Unknown"); |
|
307 | 307 | } |
308 | 308 | else |
309 | 309 | { |
310 | 310 | $userstatic=new User($db); |
311 | 311 | $userstatic->fetch($object->user_validation_id ? $object->user_validation_id : $object->user_validation); |
312 | - if ($userstatic->id) print $userstatic->getNomUrl(1, '', 0, 0, 0); |
|
313 | - else print $langs->trans("Unknown"); |
|
312 | + if ($userstatic->id) print $userstatic->getNomUrl(1, '', 0, 0, 0); |
|
313 | + else print $langs->trans("Unknown"); |
|
314 | 314 | } |
315 | 315 | if ($usetable) print '</td></tr>'; |
316 | 316 | else print '<br>'; |
@@ -339,14 +339,14 @@ discard block |
||
339 | 339 | if (is_object($object->user_approve)) |
340 | 340 | { |
341 | 341 | if ($object->user_approve->id) print $object->user_approve->getNomUrl(1, '', 0, 0, 0); |
342 | - else print $langs->trans("Unknown"); |
|
342 | + else print $langs->trans("Unknown"); |
|
343 | 343 | } |
344 | 344 | else |
345 | 345 | { |
346 | 346 | $userstatic=new User($db); |
347 | 347 | $userstatic->fetch($object->user_approve_id ? $object->user_approve_id : $object->user_approve); |
348 | - if ($userstatic->id) print $userstatic->getNomUrl(1, '', 0, 0, 0); |
|
349 | - else print $langs->trans("Unknown"); |
|
348 | + if ($userstatic->id) print $userstatic->getNomUrl(1, '', 0, 0, 0); |
|
349 | + else print $langs->trans("Unknown"); |
|
350 | 350 | } |
351 | 351 | if ($usetable) print '</td></tr>'; |
352 | 352 | else print '<br>'; |
@@ -402,15 +402,15 @@ discard block |
||
402 | 402 | else print ': '; |
403 | 403 | if (is_object($object->user_cloture)) |
404 | 404 | { |
405 | - if ($object->user_cloture->id) print $object->user_cloture->getNomUrl(1, '', 0, 0, 0); |
|
406 | - else print $langs->trans("Unknown"); |
|
405 | + if ($object->user_cloture->id) print $object->user_cloture->getNomUrl(1, '', 0, 0, 0); |
|
406 | + else print $langs->trans("Unknown"); |
|
407 | 407 | } |
408 | 408 | else |
409 | 409 | { |
410 | 410 | $userstatic=new User($db); |
411 | 411 | $userstatic->fetch($object->user_cloture); |
412 | - if ($userstatic->id) print $userstatic->getNomUrl(1, '', 0, 0, 0); |
|
413 | - else print $langs->trans("Unknown"); |
|
412 | + if ($userstatic->id) print $userstatic->getNomUrl(1, '', 0, 0, 0); |
|
413 | + else print $langs->trans("Unknown"); |
|
414 | 414 | } |
415 | 415 | if ($usetable) print '</td></tr>'; |
416 | 416 | else print '<br>'; |
@@ -438,15 +438,15 @@ discard block |
||
438 | 438 | else print ': '; |
439 | 439 | if (is_object($object->user_rappro)) |
440 | 440 | { |
441 | - if ($object->user_rappro->id) print $object->user_rappro->getNomUrl(1, '', 0, 0, 0); |
|
442 | - else print $langs->trans("Unknown"); |
|
441 | + if ($object->user_rappro->id) print $object->user_rappro->getNomUrl(1, '', 0, 0, 0); |
|
442 | + else print $langs->trans("Unknown"); |
|
443 | 443 | } |
444 | 444 | else |
445 | 445 | { |
446 | 446 | $userstatic=new User($db); |
447 | 447 | $userstatic->fetch($object->user_rappro); |
448 | - if ($userstatic->id) print $userstatic->getNomUrl(1, '', 0, 0, 0); |
|
449 | - else print $langs->trans("Unknown"); |
|
448 | + if ($userstatic->id) print $userstatic->getNomUrl(1, '', 0, 0, 0); |
|
449 | + else print $langs->trans("Unknown"); |
|
450 | 450 | } |
451 | 451 | if ($usetable) print '</td></tr>'; |
452 | 452 | else print '<br>'; |
@@ -492,8 +492,8 @@ discard block |
||
492 | 492 | */ |
493 | 493 | function dolAddEmailTrackId($email, $trackingid) |
494 | 494 | { |
495 | - $tmp=explode('@',$email); |
|
496 | - return $tmp[0].'+'.$trackingid.'@'.(isset($tmp[1])?$tmp[1]:''); |
|
495 | + $tmp=explode('@',$email); |
|
496 | + return $tmp[0].'+'.$trackingid.'@'.(isset($tmp[1])?$tmp[1]:''); |
|
497 | 497 | } |
498 | 498 | |
499 | 499 | /** |
@@ -619,33 +619,33 @@ discard block |
||
619 | 619 | */ |
620 | 620 | function dolObfuscateEmail($mail, $replace="*", $nbreplace=8, $nbdisplaymail=4, $nbdisplaydomain=3, $displaytld=true) |
621 | 621 | { |
622 | - if(!isValidEmail($mail))return ''; |
|
623 | - $tab = explode('@', $mail); |
|
624 | - $tab2 = explode('.',$tab[1]); |
|
625 | - $string_replace = ''; |
|
626 | - $mail_name = $tab[0]; |
|
627 | - $mail_domaine = $tab2[0]; |
|
628 | - $mail_tld = ''; |
|
629 | - |
|
630 | - $nbofelem = count($tab2); |
|
631 | - for($i=1; $i < $nbofelem && $displaytld; $i++) |
|
632 | - { |
|
633 | - $mail_tld .= '.'.$tab2[$i]; |
|
634 | - } |
|
635 | - |
|
636 | - for($i=0; $i < $nbreplace; $i++){ |
|
637 | - $string_replace .= $replace; |
|
638 | - } |
|
639 | - |
|
640 | - if(strlen($mail_name) > $nbdisplaymail){ |
|
641 | - $mail_name = substr($mail_name, 0, $nbdisplaymail); |
|
642 | - } |
|
643 | - |
|
644 | - if(strlen($mail_domaine) > $nbdisplaydomain){ |
|
645 | - $mail_domaine = substr($mail_domaine, strlen($mail_domaine)-$nbdisplaydomain); |
|
646 | - } |
|
647 | - |
|
648 | - return $mail_name . $string_replace . $mail_domaine . $mail_tld; |
|
622 | + if(!isValidEmail($mail))return ''; |
|
623 | + $tab = explode('@', $mail); |
|
624 | + $tab2 = explode('.',$tab[1]); |
|
625 | + $string_replace = ''; |
|
626 | + $mail_name = $tab[0]; |
|
627 | + $mail_domaine = $tab2[0]; |
|
628 | + $mail_tld = ''; |
|
629 | + |
|
630 | + $nbofelem = count($tab2); |
|
631 | + for($i=1; $i < $nbofelem && $displaytld; $i++) |
|
632 | + { |
|
633 | + $mail_tld .= '.'.$tab2[$i]; |
|
634 | + } |
|
635 | + |
|
636 | + for($i=0; $i < $nbreplace; $i++){ |
|
637 | + $string_replace .= $replace; |
|
638 | + } |
|
639 | + |
|
640 | + if(strlen($mail_name) > $nbdisplaymail){ |
|
641 | + $mail_name = substr($mail_name, 0, $nbdisplaymail); |
|
642 | + } |
|
643 | + |
|
644 | + if(strlen($mail_domaine) > $nbdisplaydomain){ |
|
645 | + $mail_domaine = substr($mail_domaine, strlen($mail_domaine)-$nbdisplaydomain); |
|
646 | + } |
|
647 | + |
|
648 | + return $mail_name . $string_replace . $mail_domaine . $mail_tld; |
|
649 | 649 | } |
650 | 650 | |
651 | 651 | |
@@ -783,24 +783,24 @@ discard block |
||
783 | 783 | } |
784 | 784 | else |
785 | 785 | { |
786 | - $masktype=''; |
|
787 | - $masktype_value=''; |
|
786 | + $masktype=''; |
|
787 | + $masktype_value=''; |
|
788 | 788 | } |
789 | 789 | |
790 | 790 | // Extract value for user |
791 | 791 | if (preg_match('/\{(u+)\}/i',$mask,$regType)) |
792 | 792 | { |
793 | - $lastname = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'; |
|
794 | - if (is_object($objuser)) $lastname = $objuser->lastname; |
|
793 | + $lastname = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'; |
|
794 | + if (is_object($objuser)) $lastname = $objuser->lastname; |
|
795 | 795 | |
796 | - $maskuser=$regType[1]; |
|
797 | - $maskuser_value=substr($lastname,0,dol_strlen($regType[1]));// get n first characters of user firstname (where n is length in mask) |
|
798 | - $maskuser_value=str_pad($maskuser_value,dol_strlen($regType[1]),"#",STR_PAD_RIGHT); // we fill on right with # to have same number of char than into mask |
|
796 | + $maskuser=$regType[1]; |
|
797 | + $maskuser_value=substr($lastname,0,dol_strlen($regType[1]));// get n first characters of user firstname (where n is length in mask) |
|
798 | + $maskuser_value=str_pad($maskuser_value,dol_strlen($regType[1]),"#",STR_PAD_RIGHT); // we fill on right with # to have same number of char than into mask |
|
799 | 799 | } |
800 | 800 | else |
801 | 801 | { |
802 | - $maskuser=''; |
|
803 | - $maskuser_value=''; |
|
802 | + $maskuser=''; |
|
803 | + $maskuser_value=''; |
|
804 | 804 | } |
805 | 805 | |
806 | 806 | // Personalized field {XXX-1} à {XXX-9} |
@@ -816,12 +816,12 @@ discard block |
||
816 | 816 | |
817 | 817 | if (strstr($mask,'user_extra_')) |
818 | 818 | { |
819 | - $start = "{user_extra_"; |
|
820 | - $end = "\}"; |
|
821 | - $extra= get_string_between($mask, "user_extra_", "}"); |
|
822 | - if(!empty($user->array_options['options_'.$extra])){ |
|
823 | - $mask = preg_replace('#('.$start.')(.*?)('.$end.')#si', $user->array_options['options_'.$extra], $mask); |
|
824 | - } |
|
819 | + $start = "{user_extra_"; |
|
820 | + $end = "\}"; |
|
821 | + $extra= get_string_between($mask, "user_extra_", "}"); |
|
822 | + if(!empty($user->array_options['options_'.$extra])){ |
|
823 | + $mask = preg_replace('#('.$start.')(.*?)('.$end.')#si', $user->array_options['options_'.$extra], $mask); |
|
824 | + } |
|
825 | 825 | } |
826 | 826 | $maskwithonlyymcode=$mask; |
827 | 827 | $maskwithonlyymcode=preg_replace('/\{(0+)([@\+][0-9\-\+\=]+)?([@\+][0-9\-\+\=]+)?\}/i',$maskcounter,$maskwithonlyymcode); |
@@ -882,7 +882,7 @@ discard block |
||
882 | 882 | else // if reset is for a specific month in year, we need year |
883 | 883 | { |
884 | 884 | if (preg_match('/^(.*)\{(m+)\}\{(y+)\}/i',$maskwithonlyymcode,$reg)) { $posy=3; $posm=2; } |
885 | - else if (preg_match('/^(.*)\{(y+)\}\{(m+)\}/i',$maskwithonlyymcode,$reg)) { $posy=2; $posm=3; } |
|
885 | + else if (preg_match('/^(.*)\{(y+)\}\{(m+)\}/i',$maskwithonlyymcode,$reg)) { $posy=2; $posm=3; } |
|
886 | 886 | else if (preg_match('/^(.*)\{(y+)\}/i',$maskwithonlyymcode,$reg)) { $posy=2; $posm=0; } |
887 | 887 | else return 'ErrorCantUseRazIfNoYearInMask'; |
888 | 888 | } |
@@ -890,11 +890,11 @@ discard block |
||
890 | 890 | $yearlen = $posy?dol_strlen($reg[$posy]):0; |
891 | 891 | $monthlen = $posm?dol_strlen($reg[$posm]):0; |
892 | 892 | // Define pos |
893 | - $yearpos = (dol_strlen($reg[1])+1); |
|
893 | + $yearpos = (dol_strlen($reg[1])+1); |
|
894 | 894 | $monthpos = ($yearpos+$yearlen); |
895 | 895 | if ($posy == 3 && $posm == 2) { // if month is before year |
896 | - $monthpos = (dol_strlen($reg[1])+1); |
|
897 | - $yearpos = ($monthpos+$monthlen); |
|
896 | + $monthpos = (dol_strlen($reg[1])+1); |
|
897 | + $yearpos = ($monthpos+$monthlen); |
|
898 | 898 | } |
899 | 899 | //print "xxx ".$maskwithonlyymcode." maskraz=".$maskraz." posy=".$posy." yearlen=".$yearlen." yearpos=".$yearpos." posm=".$posm." monthlen=".$monthlen." monthpos=".$monthpos." yearoffsettype=".$yearoffsettype." resetEveryMonth=".$resetEveryMonth."\n"; |
900 | 900 | |
@@ -904,20 +904,20 @@ discard block |
||
904 | 904 | |
905 | 905 | if (! empty($yearoffsettype) && ! is_numeric($yearoffsettype) && $yearoffsettype != '=') // $yearoffsettype is - or + |
906 | 906 | { |
907 | - $currentyear=date("Y", $date); |
|
908 | - $fiscaldate=dol_mktime('0','0','0',$maskraz,'1',$currentyear); |
|
909 | - $newyeardate=dol_mktime('0','0','0','1','1',$currentyear); |
|
910 | - $nextnewyeardate=dol_mktime('0','0','0','1','1',$currentyear+1); |
|
911 | - //echo 'currentyear='.$currentyear.' date='.dol_print_date($date, 'day').' fiscaldate='.dol_print_date($fiscaldate, 'day').'<br>'; |
|
912 | - |
|
913 | - // If after or equal of current fiscal date |
|
914 | - if ($date >= $fiscaldate) |
|
915 | - { |
|
916 | - // If before of next new year date |
|
917 | - if ($date < $nextnewyeardate && $yearoffsettype == '+') $yearoffset=1; |
|
918 | - } |
|
919 | - // If after or equal of current new year date |
|
920 | - else if ($date >= $newyeardate && $yearoffsettype == '-') $yearoffset=-1; |
|
907 | + $currentyear=date("Y", $date); |
|
908 | + $fiscaldate=dol_mktime('0','0','0',$maskraz,'1',$currentyear); |
|
909 | + $newyeardate=dol_mktime('0','0','0','1','1',$currentyear); |
|
910 | + $nextnewyeardate=dol_mktime('0','0','0','1','1',$currentyear+1); |
|
911 | + //echo 'currentyear='.$currentyear.' date='.dol_print_date($date, 'day').' fiscaldate='.dol_print_date($fiscaldate, 'day').'<br>'; |
|
912 | + |
|
913 | + // If after or equal of current fiscal date |
|
914 | + if ($date >= $fiscaldate) |
|
915 | + { |
|
916 | + // If before of next new year date |
|
917 | + if ($date < $nextnewyeardate && $yearoffsettype == '+') $yearoffset=1; |
|
918 | + } |
|
919 | + // If after or equal of current new year date |
|
920 | + else if ($date >= $newyeardate && $yearoffsettype == '-') $yearoffset=-1; |
|
921 | 921 | } |
922 | 922 | // For backward compatibility |
923 | 923 | else if (date("m",$date) < $maskraz && empty($resetEveryMonth)) { $yearoffset=-1; } // If current month lower that month of return to zero, year is previous year |
@@ -938,11 +938,11 @@ discard block |
||
938 | 938 | $sqlwhere.=" AND SUBSTRING(".$field.", ".$monthpos.", ".$monthlen.") < '".str_pad($monthcomp, $monthlen, '0', STR_PAD_LEFT)."') "; |
939 | 939 | $sqlwhere.=')'; |
940 | 940 | } |
941 | - else if ($resetEveryMonth) |
|
942 | - { |
|
943 | - $sqlwhere.="(SUBSTRING(".$field.", ".$yearpos.", ".$yearlen.") = '".$yearcomp."'"; |
|
941 | + else if ($resetEveryMonth) |
|
942 | + { |
|
943 | + $sqlwhere.="(SUBSTRING(".$field.", ".$yearpos.", ".$yearlen.") = '".$yearcomp."'"; |
|
944 | 944 | $sqlwhere.=" AND SUBSTRING(".$field.", ".$monthpos.", ".$monthlen.") = '".str_pad($monthcomp, $monthlen, '0', STR_PAD_LEFT)."')"; |
945 | - } |
|
945 | + } |
|
946 | 946 | else // reset is done on january |
947 | 947 | { |
948 | 948 | $sqlwhere.='(SUBSTRING('.$field.', '.$yearpos.', '.$yearlen.") = '".$yearcomp."')"; |
@@ -953,13 +953,13 @@ discard block |
||
953 | 953 | |
954 | 954 | // Define $sqlstring |
955 | 955 | if (function_exists('mb_strrpos')) |
956 | - { |
|
957 | - $posnumstart=mb_strrpos($maskwithnocode,$maskcounter, 'UTF-8'); |
|
958 | - } |
|
959 | - else |
|
960 | - { |
|
961 | - $posnumstart=strrpos($maskwithnocode,$maskcounter); |
|
962 | - } // Pos of counter in final string (from 0 to ...) |
|
956 | + { |
|
957 | + $posnumstart=mb_strrpos($maskwithnocode,$maskcounter, 'UTF-8'); |
|
958 | + } |
|
959 | + else |
|
960 | + { |
|
961 | + $posnumstart=strrpos($maskwithnocode,$maskcounter); |
|
962 | + } // Pos of counter in final string (from 0 to ...) |
|
963 | 963 | if ($posnumstart < 0) return 'ErrorBadMaskFailedToLocatePosOfSequence'; |
964 | 964 | $sqlstring='SUBSTRING('.$field.', '.($posnumstart+1).', '.dol_strlen($maskcounter).')'; |
965 | 965 | |
@@ -978,7 +978,7 @@ discard block |
||
978 | 978 | if ($maskuser) $maskLike = str_replace(dol_string_nospecial('{'.$maskuser.'}'),$maskuser_value,$maskLike); |
979 | 979 | foreach($maskperso as $key => $val) |
980 | 980 | { |
981 | - $maskLike = str_replace(dol_string_nospecial($maskperso[$key]),$maskpersonew[$key],$maskLike); |
|
981 | + $maskLike = str_replace(dol_string_nospecial($maskperso[$key]),$maskpersonew[$key],$maskLike); |
|
982 | 982 | } |
983 | 983 | |
984 | 984 | // Get counter in database |
@@ -986,11 +986,11 @@ discard block |
||
986 | 986 | $sql = "SELECT MAX(".$sqlstring.") as val"; |
987 | 987 | $sql.= " FROM ".MAIN_DB_PREFIX.$table; |
988 | 988 | $sql.= " WHERE ".$field." LIKE '".$maskLike."'"; |
989 | - $sql.= " AND ".$field." NOT LIKE '(PROV%)'"; |
|
989 | + $sql.= " AND ".$field." NOT LIKE '(PROV%)'"; |
|
990 | 990 | if ($bentityon) // only if entity enable |
991 | - $sql.= " AND entity IN (".getEntity($sharetable).")"; |
|
991 | + $sql.= " AND entity IN (".getEntity($sharetable).")"; |
|
992 | 992 | else if (! empty($forceentity)) |
993 | - $sql.= " AND entity IN (".$forceentity.")"; |
|
993 | + $sql.= " AND entity IN (".$forceentity.")"; |
|
994 | 994 | if ($where) $sql.=$where; |
995 | 995 | if ($sqlwhere) $sql.=' AND '.$sqlwhere; |
996 | 996 | |
@@ -1008,8 +1008,8 @@ discard block |
||
1008 | 1008 | if (empty($counter)) $counter=$maskoffset; |
1009 | 1009 | else if (preg_match('/[^0-9]/i',$counter)) |
1010 | 1010 | { |
1011 | - $counter=0; |
|
1012 | - dol_syslog("Error, the last counter found is '".$counter."' so is not a numeric value. We will restart to 1.", LOG_ERR); |
|
1011 | + $counter=0; |
|
1012 | + dol_syslog("Error, the last counter found is '".$counter."' so is not a numeric value. We will restart to 1.", LOG_ERR); |
|
1013 | 1013 | } |
1014 | 1014 | else if ($counter < $maskoffset && empty($conf->global->MAIN_NUMBERING_OFFSET_ONLY_FOR_FIRST)) $counter=$maskoffset; |
1015 | 1015 | |
@@ -1035,11 +1035,11 @@ discard block |
||
1035 | 1035 | $sql = "SELECT ".$field." as ref"; |
1036 | 1036 | $sql.= " FROM ".MAIN_DB_PREFIX.$table; |
1037 | 1037 | $sql.= " WHERE ".$field." LIKE '".$maskLike."'"; |
1038 | - $sql.= " AND ".$field." NOT LIKE '%PROV%'"; |
|
1039 | - if ($bentityon) // only if entity enable |
|
1040 | - $sql.= " AND entity IN (".getEntity($sharetable).")"; |
|
1038 | + $sql.= " AND ".$field." NOT LIKE '%PROV%'"; |
|
1039 | + if ($bentityon) // only if entity enable |
|
1040 | + $sql.= " AND entity IN (".getEntity($sharetable).")"; |
|
1041 | 1041 | else if (! empty($forceentity)) |
1042 | - $sql.= " AND entity IN (".$forceentity.")"; |
|
1042 | + $sql.= " AND entity IN (".$forceentity.")"; |
|
1043 | 1043 | if ($where) $sql.=$where; |
1044 | 1044 | if ($sqlwhere) $sql.=' AND '.$sqlwhere; |
1045 | 1045 | |
@@ -1061,7 +1061,7 @@ discard block |
||
1061 | 1061 | // If value for $counter has a length higher than $maskcounter chars |
1062 | 1062 | if ($counter >= pow(10, dol_strlen($maskcounter))) |
1063 | 1063 | { |
1064 | - $counter='ErrorMaxNumberReachForThisMask'; |
|
1064 | + $counter='ErrorMaxNumberReachForThisMask'; |
|
1065 | 1065 | } |
1066 | 1066 | |
1067 | 1067 | if (! empty($maskrefclient_maskcounter)) |
@@ -1093,9 +1093,9 @@ discard block |
||
1093 | 1093 | //$sql.= " WHERE ".$field." not like '(%'"; |
1094 | 1094 | $maskrefclient_sql.= " WHERE ".$field." LIKE '".$maskrefclient_maskLike."'"; |
1095 | 1095 | if ($bentityon) // only if entity enable |
1096 | - $maskrefclient_sql.= " AND entity IN (".getEntity($sharetable).")"; |
|
1096 | + $maskrefclient_sql.= " AND entity IN (".getEntity($sharetable).")"; |
|
1097 | 1097 | else if (! empty($forceentity)) |
1098 | - $sql.= " AND entity IN (".$forceentity.")"; |
|
1098 | + $sql.= " AND entity IN (".$forceentity.")"; |
|
1099 | 1099 | if ($where) $maskrefclient_sql.=$where; //use the same optional where as general mask |
1100 | 1100 | if ($sqlwhere) $maskrefclient_sql.=' AND '.$sqlwhere; //use the same sqlwhere as general mask |
1101 | 1101 | $maskrefclient_sql.=' AND (SUBSTRING('.$field.', '.(strpos($maskwithnocode,$maskrefclient)+1).', '.dol_strlen($maskrefclient_maskclientcode).")='".$maskrefclient_clientcode."')"; |
@@ -1110,25 +1110,25 @@ discard block |
||
1110 | 1110 | else dol_print_error($db); |
1111 | 1111 | |
1112 | 1112 | if (empty($maskrefclient_counter) || preg_match('/[^0-9]/i',$maskrefclient_counter)) $maskrefclient_counter=$maskrefclient_maskoffset; |
1113 | - $maskrefclient_counter++; |
|
1113 | + $maskrefclient_counter++; |
|
1114 | 1114 | } |
1115 | 1115 | |
1116 | 1116 | // Build numFinal |
1117 | 1117 | $numFinal = $mask; |
1118 | 1118 | |
1119 | 1119 | // We replace special codes except refclient |
1120 | - if (! empty($yearoffsettype) && ! is_numeric($yearoffsettype) && $yearoffsettype != '=') // yearoffsettype is - or +, so we don't want current year |
|
1121 | - { |
|
1122 | - $numFinal = preg_replace('/\{yyyy\}/i',date("Y",$date)+$yearoffset, $numFinal); |
|
1123 | - $numFinal = preg_replace('/\{yy\}/i', date("y",$date)+$yearoffset, $numFinal); |
|
1124 | - $numFinal = preg_replace('/\{y\}/i', substr(date("y",$date),1,1)+$yearoffset, $numFinal); |
|
1125 | - } |
|
1126 | - else // we want yyyy to be current year |
|
1127 | - { |
|
1128 | - $numFinal = preg_replace('/\{yyyy\}/i',date("Y",$date), $numFinal); |
|
1129 | - $numFinal = preg_replace('/\{yy\}/i', date("y",$date), $numFinal); |
|
1130 | - $numFinal = preg_replace('/\{y\}/i', substr(date("y",$date),1,1), $numFinal); |
|
1131 | - } |
|
1120 | + if (! empty($yearoffsettype) && ! is_numeric($yearoffsettype) && $yearoffsettype != '=') // yearoffsettype is - or +, so we don't want current year |
|
1121 | + { |
|
1122 | + $numFinal = preg_replace('/\{yyyy\}/i',date("Y",$date)+$yearoffset, $numFinal); |
|
1123 | + $numFinal = preg_replace('/\{yy\}/i', date("y",$date)+$yearoffset, $numFinal); |
|
1124 | + $numFinal = preg_replace('/\{y\}/i', substr(date("y",$date),1,1)+$yearoffset, $numFinal); |
|
1125 | + } |
|
1126 | + else // we want yyyy to be current year |
|
1127 | + { |
|
1128 | + $numFinal = preg_replace('/\{yyyy\}/i',date("Y",$date), $numFinal); |
|
1129 | + $numFinal = preg_replace('/\{yy\}/i', date("y",$date), $numFinal); |
|
1130 | + $numFinal = preg_replace('/\{y\}/i', substr(date("y",$date),1,1), $numFinal); |
|
1131 | + } |
|
1132 | 1132 | $numFinal = preg_replace('/\{mm\}/i', date("m",$date), $numFinal); |
1133 | 1133 | $numFinal = preg_replace('/\{dd\}/i', date("d",$date), $numFinal); |
1134 | 1134 | |
@@ -1158,9 +1158,9 @@ discard block |
||
1158 | 1158 | // Now we replace the user |
1159 | 1159 | if ($maskuser) |
1160 | 1160 | { |
1161 | - $maskuser_maskbefore='{'.$maskuser.'}'; |
|
1162 | - $maskuser_maskafter=$maskuser_value; |
|
1163 | - $numFinal = str_replace($maskuser_maskbefore,$maskuser_maskafter,$numFinal); |
|
1161 | + $maskuser_maskbefore='{'.$maskuser.'}'; |
|
1162 | + $maskuser_maskafter=$maskuser_value; |
|
1163 | + $numFinal = str_replace($maskuser_maskbefore,$maskuser_maskafter,$numFinal); |
|
1164 | 1164 | } |
1165 | 1165 | } |
1166 | 1166 | |
@@ -1179,11 +1179,11 @@ discard block |
||
1179 | 1179 | function get_string_between($string, $start, $end) |
1180 | 1180 | { |
1181 | 1181 | $string = " ".$string; |
1182 | - $ini = strpos($string,$start); |
|
1183 | - if ($ini == 0) return ""; |
|
1184 | - $ini += strlen($start); |
|
1185 | - $len = strpos($string,$end,$ini) - $ini; |
|
1186 | - return substr($string,$ini,$len); |
|
1182 | + $ini = strpos($string,$start); |
|
1183 | + if ($ini == 0) return ""; |
|
1184 | + $ini += strlen($start); |
|
1185 | + $len = strpos($string,$end,$ini) - $ini; |
|
1186 | + return substr($string,$ini,$len); |
|
1187 | 1187 | } |
1188 | 1188 | |
1189 | 1189 | /** |
@@ -1531,7 +1531,7 @@ discard block |
||
1531 | 1531 | } |
1532 | 1532 | else |
1533 | 1533 | { |
1534 | - $string = vatrate($reduction,true); |
|
1534 | + $string = vatrate($reduction,true); |
|
1535 | 1535 | } |
1536 | 1536 | |
1537 | 1537 | return $string; |
@@ -1624,7 +1624,7 @@ discard block |
||
1624 | 1624 | //irtoscan.=($dirtoscan?',':'').preg_replace('/[\r\n]+/',',',trim($conf->global->$const)); |
1625 | 1625 | $dirtoscan= preg_replace('/[\r\n]+/',',',trim($conf->global->$const)); |
1626 | 1626 | |
1627 | - $listoffiles=array(); |
|
1627 | + $listoffiles=array(); |
|
1628 | 1628 | |
1629 | 1629 | // Now we add models found in directories scanned |
1630 | 1630 | $listofdir=explode(',',$dirtoscan); |
@@ -1635,8 +1635,8 @@ discard block |
||
1635 | 1635 | if (! $tmpdir) { unset($listofdir[$key]); continue; } |
1636 | 1636 | if (is_dir($tmpdir)) |
1637 | 1637 | { |
1638 | - // all type of template is allowed |
|
1639 | - $tmpfiles=dol_dir_list($tmpdir, 'files', 0, '', '', 'name', SORT_ASC, 0); |
|
1638 | + // all type of template is allowed |
|
1639 | + $tmpfiles=dol_dir_list($tmpdir, 'files', 0, '', '', 'name', SORT_ASC, 0); |
|
1640 | 1640 | if (count($tmpfiles)) $listoffiles=array_merge($listoffiles,$tmpfiles); |
1641 | 1641 | } |
1642 | 1642 | } |
@@ -1692,19 +1692,19 @@ discard block |
||
1692 | 1692 | */ |
1693 | 1693 | function is_ip($ip) |
1694 | 1694 | { |
1695 | - // First we test if it is a valid IPv4 |
|
1696 | - if (filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) { |
|
1695 | + // First we test if it is a valid IPv4 |
|
1696 | + if (filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) { |
|
1697 | 1697 | |
1698 | - // Then we test if it is a private range |
|
1699 | - if (! filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE)) return 2; |
|
1698 | + // Then we test if it is a private range |
|
1699 | + if (! filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE)) return 2; |
|
1700 | 1700 | |
1701 | - // Then we test if it is a reserved range |
|
1702 | - if (! filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_RES_RANGE)) return 0; |
|
1701 | + // Then we test if it is a reserved range |
|
1702 | + if (! filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_RES_RANGE)) return 0; |
|
1703 | 1703 | |
1704 | - return 1; |
|
1705 | - } |
|
1704 | + return 1; |
|
1705 | + } |
|
1706 | 1706 | |
1707 | - return 0; |
|
1707 | + return 0; |
|
1708 | 1708 | } |
1709 | 1709 | |
1710 | 1710 | /** |
@@ -1744,25 +1744,25 @@ discard block |
||
1744 | 1744 | if ($proxyuse) |
1745 | 1745 | { |
1746 | 1746 | $params=array('connection_timeout'=>$timeout, |
1747 | - 'response_timeout'=>$response_timeout, |
|
1748 | - 'proxy_use' => 1, |
|
1749 | - 'proxy_host' => $proxyhost, |
|
1750 | - 'proxy_port' => $proxyport, |
|
1751 | - 'proxy_login' => $proxyuser, |
|
1752 | - 'proxy_password' => $proxypass, |
|
1753 | - 'trace' => 1 |
|
1747 | + 'response_timeout'=>$response_timeout, |
|
1748 | + 'proxy_use' => 1, |
|
1749 | + 'proxy_host' => $proxyhost, |
|
1750 | + 'proxy_port' => $proxyport, |
|
1751 | + 'proxy_login' => $proxyuser, |
|
1752 | + 'proxy_password' => $proxypass, |
|
1753 | + 'trace' => 1 |
|
1754 | 1754 | ); |
1755 | 1755 | } |
1756 | 1756 | else |
1757 | 1757 | { |
1758 | 1758 | $params=array('connection_timeout'=>$timeout, |
1759 | - 'response_timeout'=>$response_timeout, |
|
1760 | - 'proxy_use' => 0, |
|
1761 | - 'proxy_host' => false, |
|
1762 | - 'proxy_port' => false, |
|
1763 | - 'proxy_login' => false, |
|
1764 | - 'proxy_password' => false, |
|
1765 | - 'trace' => 1 |
|
1759 | + 'response_timeout'=>$response_timeout, |
|
1760 | + 'proxy_use' => 0, |
|
1761 | + 'proxy_host' => false, |
|
1762 | + 'proxy_port' => false, |
|
1763 | + 'proxy_login' => false, |
|
1764 | + 'proxy_password' => false, |
|
1765 | + 'trace' => 1 |
|
1766 | 1766 | ); |
1767 | 1767 | } |
1768 | 1768 | return $params; |
@@ -1780,118 +1780,118 @@ discard block |
||
1780 | 1780 | */ |
1781 | 1781 | function dolGetElementUrl($objectid,$objecttype,$withpicto=0,$option='') |
1782 | 1782 | { |
1783 | - global $db, $conf, $langs; |
|
1784 | - |
|
1785 | - $ret=''; |
|
1786 | - |
|
1787 | - // Parse element/subelement (ex: project_task) |
|
1788 | - $module = $element = $subelement = $objecttype; |
|
1789 | - if (preg_match('/^([^_]+)_([^_]+)/i',$objecttype,$regs)) |
|
1790 | - { |
|
1791 | - $module = $element = $regs[1]; |
|
1792 | - $subelement = $regs[2]; |
|
1793 | - } |
|
1794 | - |
|
1795 | - $classpath = $element.'/class'; |
|
1796 | - |
|
1797 | - // To work with non standard path |
|
1798 | - if ($objecttype == 'facture' || $objecttype == 'invoice') { |
|
1799 | - $classpath = 'compta/facture/class'; |
|
1800 | - $module='facture'; |
|
1801 | - $subelement='facture'; |
|
1802 | - } |
|
1803 | - if ($objecttype == 'commande' || $objecttype == 'order') { |
|
1804 | - $classpath = 'commande/class'; |
|
1805 | - $module='commande'; |
|
1806 | - $subelement='commande'; |
|
1807 | - } |
|
1808 | - if ($objecttype == 'propal') { |
|
1809 | - $classpath = 'comm/propal/class'; |
|
1810 | - } |
|
1811 | - if ($objecttype == 'supplier_proposal') { |
|
1812 | - $classpath = 'supplier_proposal/class'; |
|
1813 | - } |
|
1814 | - if ($objecttype == 'shipping') { |
|
1815 | - $classpath = 'expedition/class'; |
|
1816 | - $subelement = 'expedition'; |
|
1817 | - $module = 'expedition_bon'; |
|
1818 | - } |
|
1819 | - if ($objecttype == 'delivery') { |
|
1820 | - $classpath = 'livraison/class'; |
|
1821 | - $subelement = 'livraison'; |
|
1822 | - $module = 'livraison_bon'; |
|
1823 | - } |
|
1824 | - if ($objecttype == 'contract') { |
|
1825 | - $classpath = 'contrat/class'; |
|
1826 | - $module='contrat'; |
|
1827 | - $subelement='contrat'; |
|
1828 | - } |
|
1829 | - if ($objecttype == 'member') { |
|
1830 | - $classpath = 'adherents/class'; |
|
1831 | - $module='adherent'; |
|
1832 | - $subelement='adherent'; |
|
1833 | - } |
|
1834 | - if ($objecttype == 'cabinetmed_cons') { |
|
1835 | - $classpath = 'cabinetmed/class'; |
|
1836 | - $module='cabinetmed'; |
|
1837 | - $subelement='cabinetmedcons'; |
|
1838 | - } |
|
1839 | - if ($objecttype == 'fichinter') { |
|
1840 | - $classpath = 'fichinter/class'; |
|
1841 | - $module='ficheinter'; |
|
1842 | - $subelement='fichinter'; |
|
1843 | - } |
|
1844 | - if ($objecttype == 'task') { |
|
1845 | - $classpath = 'projet/class'; |
|
1846 | - $module='projet'; |
|
1847 | - $subelement='task'; |
|
1848 | - } |
|
1849 | - if ($objecttype == 'stock') { |
|
1850 | - $classpath = 'product/stock/class'; |
|
1851 | - $module='stock'; |
|
1852 | - $subelement='stock'; |
|
1853 | - } |
|
1854 | - |
|
1855 | - //print "objecttype=".$objecttype." module=".$module." subelement=".$subelement; |
|
1856 | - |
|
1857 | - $classfile = strtolower($subelement); $classname = ucfirst($subelement); |
|
1858 | - if ($objecttype == 'invoice_supplier') { |
|
1859 | - $classfile = 'fournisseur.facture'; |
|
1860 | - $classname='FactureFournisseur'; |
|
1861 | - $classpath = 'fourn/class'; |
|
1862 | - $module='fournisseur'; |
|
1863 | - } |
|
1864 | - elseif ($objecttype == 'order_supplier') { |
|
1865 | - $classfile = 'fournisseur.commande'; |
|
1866 | - $classname='CommandeFournisseur'; |
|
1867 | - $classpath = 'fourn/class'; |
|
1868 | - $module='fournisseur'; |
|
1869 | - } |
|
1870 | - elseif ($objecttype == 'stock') { |
|
1871 | - $classpath = 'product/stock/class'; |
|
1872 | - $classfile='entrepot'; |
|
1873 | - $classname='Entrepot'; |
|
1874 | - } |
|
1875 | - if (! empty($conf->$module->enabled)) |
|
1876 | - { |
|
1877 | - $res=dol_include_once('/'.$classpath.'/'.$classfile.'.class.php'); |
|
1878 | - if ($res) |
|
1879 | - { |
|
1880 | - if (class_exists($classname)) |
|
1881 | - { |
|
1882 | - $object = new $classname($db); |
|
1883 | - $res=$object->fetch($objectid); |
|
1884 | - if ($res > 0) { |
|
1885 | - $ret=$object->getNomUrl($withpicto,$option); |
|
1886 | - } elseif($res==0) { |
|
1887 | - $ret=$langs->trans('Deleted'); |
|
1888 | - } |
|
1889 | - unset($object); |
|
1890 | - } |
|
1891 | - else dol_syslog("Class with classname ".$classname." is unknown even after the include", LOG_ERR); |
|
1892 | - } |
|
1893 | - } |
|
1894 | - return $ret; |
|
1783 | + global $db, $conf, $langs; |
|
1784 | + |
|
1785 | + $ret=''; |
|
1786 | + |
|
1787 | + // Parse element/subelement (ex: project_task) |
|
1788 | + $module = $element = $subelement = $objecttype; |
|
1789 | + if (preg_match('/^([^_]+)_([^_]+)/i',$objecttype,$regs)) |
|
1790 | + { |
|
1791 | + $module = $element = $regs[1]; |
|
1792 | + $subelement = $regs[2]; |
|
1793 | + } |
|
1794 | + |
|
1795 | + $classpath = $element.'/class'; |
|
1796 | + |
|
1797 | + // To work with non standard path |
|
1798 | + if ($objecttype == 'facture' || $objecttype == 'invoice') { |
|
1799 | + $classpath = 'compta/facture/class'; |
|
1800 | + $module='facture'; |
|
1801 | + $subelement='facture'; |
|
1802 | + } |
|
1803 | + if ($objecttype == 'commande' || $objecttype == 'order') { |
|
1804 | + $classpath = 'commande/class'; |
|
1805 | + $module='commande'; |
|
1806 | + $subelement='commande'; |
|
1807 | + } |
|
1808 | + if ($objecttype == 'propal') { |
|
1809 | + $classpath = 'comm/propal/class'; |
|
1810 | + } |
|
1811 | + if ($objecttype == 'supplier_proposal') { |
|
1812 | + $classpath = 'supplier_proposal/class'; |
|
1813 | + } |
|
1814 | + if ($objecttype == 'shipping') { |
|
1815 | + $classpath = 'expedition/class'; |
|
1816 | + $subelement = 'expedition'; |
|
1817 | + $module = 'expedition_bon'; |
|
1818 | + } |
|
1819 | + if ($objecttype == 'delivery') { |
|
1820 | + $classpath = 'livraison/class'; |
|
1821 | + $subelement = 'livraison'; |
|
1822 | + $module = 'livraison_bon'; |
|
1823 | + } |
|
1824 | + if ($objecttype == 'contract') { |
|
1825 | + $classpath = 'contrat/class'; |
|
1826 | + $module='contrat'; |
|
1827 | + $subelement='contrat'; |
|
1828 | + } |
|
1829 | + if ($objecttype == 'member') { |
|
1830 | + $classpath = 'adherents/class'; |
|
1831 | + $module='adherent'; |
|
1832 | + $subelement='adherent'; |
|
1833 | + } |
|
1834 | + if ($objecttype == 'cabinetmed_cons') { |
|
1835 | + $classpath = 'cabinetmed/class'; |
|
1836 | + $module='cabinetmed'; |
|
1837 | + $subelement='cabinetmedcons'; |
|
1838 | + } |
|
1839 | + if ($objecttype == 'fichinter') { |
|
1840 | + $classpath = 'fichinter/class'; |
|
1841 | + $module='ficheinter'; |
|
1842 | + $subelement='fichinter'; |
|
1843 | + } |
|
1844 | + if ($objecttype == 'task') { |
|
1845 | + $classpath = 'projet/class'; |
|
1846 | + $module='projet'; |
|
1847 | + $subelement='task'; |
|
1848 | + } |
|
1849 | + if ($objecttype == 'stock') { |
|
1850 | + $classpath = 'product/stock/class'; |
|
1851 | + $module='stock'; |
|
1852 | + $subelement='stock'; |
|
1853 | + } |
|
1854 | + |
|
1855 | + //print "objecttype=".$objecttype." module=".$module." subelement=".$subelement; |
|
1856 | + |
|
1857 | + $classfile = strtolower($subelement); $classname = ucfirst($subelement); |
|
1858 | + if ($objecttype == 'invoice_supplier') { |
|
1859 | + $classfile = 'fournisseur.facture'; |
|
1860 | + $classname='FactureFournisseur'; |
|
1861 | + $classpath = 'fourn/class'; |
|
1862 | + $module='fournisseur'; |
|
1863 | + } |
|
1864 | + elseif ($objecttype == 'order_supplier') { |
|
1865 | + $classfile = 'fournisseur.commande'; |
|
1866 | + $classname='CommandeFournisseur'; |
|
1867 | + $classpath = 'fourn/class'; |
|
1868 | + $module='fournisseur'; |
|
1869 | + } |
|
1870 | + elseif ($objecttype == 'stock') { |
|
1871 | + $classpath = 'product/stock/class'; |
|
1872 | + $classfile='entrepot'; |
|
1873 | + $classname='Entrepot'; |
|
1874 | + } |
|
1875 | + if (! empty($conf->$module->enabled)) |
|
1876 | + { |
|
1877 | + $res=dol_include_once('/'.$classpath.'/'.$classfile.'.class.php'); |
|
1878 | + if ($res) |
|
1879 | + { |
|
1880 | + if (class_exists($classname)) |
|
1881 | + { |
|
1882 | + $object = new $classname($db); |
|
1883 | + $res=$object->fetch($objectid); |
|
1884 | + if ($res > 0) { |
|
1885 | + $ret=$object->getNomUrl($withpicto,$option); |
|
1886 | + } elseif($res==0) { |
|
1887 | + $ret=$langs->trans('Deleted'); |
|
1888 | + } |
|
1889 | + unset($object); |
|
1890 | + } |
|
1891 | + else dol_syslog("Class with classname ".$classname." is unknown even after the include", LOG_ERR); |
|
1892 | + } |
|
1893 | + } |
|
1894 | + return $ret; |
|
1895 | 1895 | } |
1896 | 1896 | |
1897 | 1897 | |
@@ -1905,113 +1905,113 @@ discard block |
||
1905 | 1905 | */ |
1906 | 1906 | function cleanCorruptedTree($db, $tabletocleantree, $fieldfkparent) |
1907 | 1907 | { |
1908 | - $totalnb=0; |
|
1909 | - $listofid=array(); |
|
1910 | - $listofparentid=array(); |
|
1911 | - |
|
1912 | - // Get list of all id in array listofid and all parents in array listofparentid |
|
1913 | - $sql='SELECT rowid, '.$fieldfkparent.' as parent_id FROM '.MAIN_DB_PREFIX.$tabletocleantree; |
|
1914 | - $resql = $db->query($sql); |
|
1915 | - if ($resql) |
|
1916 | - { |
|
1917 | - $num = $db->num_rows($resql); |
|
1918 | - $i = 0; |
|
1919 | - while ($i < $num) |
|
1920 | - { |
|
1921 | - $obj = $db->fetch_object($resql); |
|
1922 | - $listofid[]=$obj->rowid; |
|
1923 | - if ($obj->parent_id > 0) $listofparentid[$obj->rowid]=$obj->parent_id; |
|
1924 | - $i++; |
|
1925 | - } |
|
1926 | - } |
|
1927 | - else |
|
1928 | - { |
|
1929 | - dol_print_error($db); |
|
1930 | - } |
|
1931 | - |
|
1932 | - if (count($listofid)) |
|
1933 | - { |
|
1934 | - print 'Code requested to clean tree (may be to solve data corruption), so we check/clean orphelins and loops.'."<br>\n"; |
|
1935 | - |
|
1936 | - // Check loops on each other |
|
1937 | - $sql = "UPDATE ".MAIN_DB_PREFIX.$tabletocleantree." SET ".$fieldfkparent." = 0 WHERE ".$fieldfkparent." = rowid"; // So we update only records linked to themself |
|
1938 | - $resql = $db->query($sql); |
|
1939 | - if ($resql) |
|
1940 | - { |
|
1941 | - $nb=$db->affected_rows($sql); |
|
1942 | - if ($nb > 0) |
|
1943 | - { |
|
1944 | - print '<br>Some record that were parent of themself were cleaned.'; |
|
1945 | - } |
|
1946 | - |
|
1947 | - $totalnb+=$nb; |
|
1948 | - } |
|
1949 | - //else dol_print_error($db); |
|
1950 | - |
|
1951 | - // Check other loops |
|
1952 | - $listofidtoclean=array(); |
|
1953 | - foreach($listofparentid as $id => $pid) |
|
1954 | - { |
|
1955 | - // Check depth |
|
1956 | - //print 'Analyse record id='.$id.' with parent '.$pid.'<br>'; |
|
1957 | - |
|
1958 | - $cursor=$id; $arrayidparsed=array(); // We start from child $id |
|
1959 | - while ($cursor > 0) |
|
1960 | - { |
|
1961 | - $arrayidparsed[$cursor]=1; |
|
1962 | - if ($arrayidparsed[$listofparentid[$cursor]]) // We detect a loop. A record with a parent that was already into child |
|
1963 | - { |
|
1964 | - print 'Found a loop between id '.$id.' - '.$cursor.'<br>'; |
|
1965 | - unset($arrayidparsed); |
|
1966 | - $listofidtoclean[$cursor]=$id; |
|
1967 | - break; |
|
1968 | - } |
|
1969 | - $cursor=$listofparentid[$cursor]; |
|
1970 | - } |
|
1971 | - |
|
1972 | - if (count($listofidtoclean)) break; |
|
1973 | - } |
|
1974 | - |
|
1975 | - $sql = "UPDATE ".MAIN_DB_PREFIX.$tabletocleantree; |
|
1976 | - $sql.= " SET ".$fieldfkparent." = 0"; |
|
1977 | - $sql.= " WHERE rowid IN (".join(',',$listofidtoclean).")"; // So we update only records detected wrong |
|
1978 | - $resql = $db->query($sql); |
|
1979 | - if ($resql) |
|
1980 | - { |
|
1981 | - $nb=$db->affected_rows($sql); |
|
1982 | - if ($nb > 0) |
|
1983 | - { |
|
1984 | - // Removed orphelins records |
|
1985 | - print '<br>Some records were detected to have parent that is a child, we set them as root record for id: '; |
|
1986 | - print join(',',$listofidtoclean); |
|
1987 | - } |
|
1988 | - |
|
1989 | - $totalnb+=$nb; |
|
1990 | - } |
|
1991 | - //else dol_print_error($db); |
|
1992 | - |
|
1993 | - // Check and clean orphelins |
|
1994 | - $sql = "UPDATE ".MAIN_DB_PREFIX.$tabletocleantree; |
|
1995 | - $sql.= " SET ".$fieldfkparent." = 0"; |
|
1996 | - $sql.= " WHERE ".$fieldfkparent." NOT IN (".join(',',$listofid).")"; // So we update only records linked to a non existing parent |
|
1997 | - $resql = $db->query($sql); |
|
1998 | - if ($resql) |
|
1999 | - { |
|
2000 | - $nb=$db->affected_rows($sql); |
|
2001 | - if ($nb > 0) |
|
2002 | - { |
|
2003 | - // Removed orphelins records |
|
2004 | - print '<br>Some orphelins were found and modified to be parent so records are visible again for id: '; |
|
2005 | - print join(',',$listofid); |
|
2006 | - } |
|
2007 | - |
|
2008 | - $totalnb+=$nb; |
|
2009 | - } |
|
2010 | - //else dol_print_error($db); |
|
2011 | - |
|
2012 | - print '<br>We fixed '.$totalnb.' record(s). Some records may still be corrupted. New check may be required.'; |
|
2013 | - return $totalnb; |
|
2014 | - } |
|
1908 | + $totalnb=0; |
|
1909 | + $listofid=array(); |
|
1910 | + $listofparentid=array(); |
|
1911 | + |
|
1912 | + // Get list of all id in array listofid and all parents in array listofparentid |
|
1913 | + $sql='SELECT rowid, '.$fieldfkparent.' as parent_id FROM '.MAIN_DB_PREFIX.$tabletocleantree; |
|
1914 | + $resql = $db->query($sql); |
|
1915 | + if ($resql) |
|
1916 | + { |
|
1917 | + $num = $db->num_rows($resql); |
|
1918 | + $i = 0; |
|
1919 | + while ($i < $num) |
|
1920 | + { |
|
1921 | + $obj = $db->fetch_object($resql); |
|
1922 | + $listofid[]=$obj->rowid; |
|
1923 | + if ($obj->parent_id > 0) $listofparentid[$obj->rowid]=$obj->parent_id; |
|
1924 | + $i++; |
|
1925 | + } |
|
1926 | + } |
|
1927 | + else |
|
1928 | + { |
|
1929 | + dol_print_error($db); |
|
1930 | + } |
|
1931 | + |
|
1932 | + if (count($listofid)) |
|
1933 | + { |
|
1934 | + print 'Code requested to clean tree (may be to solve data corruption), so we check/clean orphelins and loops.'."<br>\n"; |
|
1935 | + |
|
1936 | + // Check loops on each other |
|
1937 | + $sql = "UPDATE ".MAIN_DB_PREFIX.$tabletocleantree." SET ".$fieldfkparent." = 0 WHERE ".$fieldfkparent." = rowid"; // So we update only records linked to themself |
|
1938 | + $resql = $db->query($sql); |
|
1939 | + if ($resql) |
|
1940 | + { |
|
1941 | + $nb=$db->affected_rows($sql); |
|
1942 | + if ($nb > 0) |
|
1943 | + { |
|
1944 | + print '<br>Some record that were parent of themself were cleaned.'; |
|
1945 | + } |
|
1946 | + |
|
1947 | + $totalnb+=$nb; |
|
1948 | + } |
|
1949 | + //else dol_print_error($db); |
|
1950 | + |
|
1951 | + // Check other loops |
|
1952 | + $listofidtoclean=array(); |
|
1953 | + foreach($listofparentid as $id => $pid) |
|
1954 | + { |
|
1955 | + // Check depth |
|
1956 | + //print 'Analyse record id='.$id.' with parent '.$pid.'<br>'; |
|
1957 | + |
|
1958 | + $cursor=$id; $arrayidparsed=array(); // We start from child $id |
|
1959 | + while ($cursor > 0) |
|
1960 | + { |
|
1961 | + $arrayidparsed[$cursor]=1; |
|
1962 | + if ($arrayidparsed[$listofparentid[$cursor]]) // We detect a loop. A record with a parent that was already into child |
|
1963 | + { |
|
1964 | + print 'Found a loop between id '.$id.' - '.$cursor.'<br>'; |
|
1965 | + unset($arrayidparsed); |
|
1966 | + $listofidtoclean[$cursor]=$id; |
|
1967 | + break; |
|
1968 | + } |
|
1969 | + $cursor=$listofparentid[$cursor]; |
|
1970 | + } |
|
1971 | + |
|
1972 | + if (count($listofidtoclean)) break; |
|
1973 | + } |
|
1974 | + |
|
1975 | + $sql = "UPDATE ".MAIN_DB_PREFIX.$tabletocleantree; |
|
1976 | + $sql.= " SET ".$fieldfkparent." = 0"; |
|
1977 | + $sql.= " WHERE rowid IN (".join(',',$listofidtoclean).")"; // So we update only records detected wrong |
|
1978 | + $resql = $db->query($sql); |
|
1979 | + if ($resql) |
|
1980 | + { |
|
1981 | + $nb=$db->affected_rows($sql); |
|
1982 | + if ($nb > 0) |
|
1983 | + { |
|
1984 | + // Removed orphelins records |
|
1985 | + print '<br>Some records were detected to have parent that is a child, we set them as root record for id: '; |
|
1986 | + print join(',',$listofidtoclean); |
|
1987 | + } |
|
1988 | + |
|
1989 | + $totalnb+=$nb; |
|
1990 | + } |
|
1991 | + //else dol_print_error($db); |
|
1992 | + |
|
1993 | + // Check and clean orphelins |
|
1994 | + $sql = "UPDATE ".MAIN_DB_PREFIX.$tabletocleantree; |
|
1995 | + $sql.= " SET ".$fieldfkparent." = 0"; |
|
1996 | + $sql.= " WHERE ".$fieldfkparent." NOT IN (".join(',',$listofid).")"; // So we update only records linked to a non existing parent |
|
1997 | + $resql = $db->query($sql); |
|
1998 | + if ($resql) |
|
1999 | + { |
|
2000 | + $nb=$db->affected_rows($sql); |
|
2001 | + if ($nb > 0) |
|
2002 | + { |
|
2003 | + // Removed orphelins records |
|
2004 | + print '<br>Some orphelins were found and modified to be parent so records are visible again for id: '; |
|
2005 | + print join(',',$listofid); |
|
2006 | + } |
|
2007 | + |
|
2008 | + $totalnb+=$nb; |
|
2009 | + } |
|
2010 | + //else dol_print_error($db); |
|
2011 | + |
|
2012 | + print '<br>We fixed '.$totalnb.' record(s). Some records may still be corrupted. New check may be required.'; |
|
2013 | + return $totalnb; |
|
2014 | + } |
|
2015 | 2015 | } |
2016 | 2016 | |
2017 | 2017 | /** |
@@ -2143,21 +2143,21 @@ discard block |
||
2143 | 2143 | function fetchObjectByElement($element_id, $element_type, $element_ref='') |
2144 | 2144 | { |
2145 | 2145 | global $conf; |
2146 | - global $db,$conf; |
|
2146 | + global $db,$conf; |
|
2147 | 2147 | |
2148 | 2148 | $element_prop = getElementProperties($element_type); |
2149 | 2149 | if (is_array($element_prop) && $conf->{$element_prop['module']}->enabled) |
2150 | 2150 | { |
2151 | 2151 | dol_include_once('/'.$element_prop['classpath'].'/'.$element_prop['classfile'].'.class.php'); |
2152 | 2152 | |
2153 | - $objecttmp = new $element_prop['classname']($db); |
|
2154 | - $ret = $objecttmp->fetch($element_id, $element_ref); |
|
2155 | - if ($ret >= 0) |
|
2156 | - { |
|
2157 | - return $objecttmp; |
|
2158 | - } |
|
2159 | - } |
|
2160 | - return 0; |
|
2153 | + $objecttmp = new $element_prop['classname']($db); |
|
2154 | + $ret = $objecttmp->fetch($element_id, $element_ref); |
|
2155 | + if ($ret >= 0) |
|
2156 | + { |
|
2157 | + return $objecttmp; |
|
2158 | + } |
|
2159 | + } |
|
2160 | + return 0; |
|
2161 | 2161 | } |
2162 | 2162 | |
2163 | 2163 | |
@@ -2172,9 +2172,9 @@ discard block |
||
2172 | 2172 | */ |
2173 | 2173 | function colorArrayToHex($arraycolor,$colorifnotfound='888888') |
2174 | 2174 | { |
2175 | - if (! is_array($arraycolor)) return $colorifnotfound; |
|
2176 | - if (empty($arraycolor)) return $colorifnotfound; |
|
2177 | - return sprintf("%02s",dechex($arraycolor[0])).sprintf("%02s",dechex($arraycolor[1])).sprintf("%02s",dechex($arraycolor[2])); |
|
2175 | + if (! is_array($arraycolor)) return $colorifnotfound; |
|
2176 | + if (empty($arraycolor)) return $colorifnotfound; |
|
2177 | + return sprintf("%02s",dechex($arraycolor[0])).sprintf("%02s",dechex($arraycolor[1])).sprintf("%02s",dechex($arraycolor[2])); |
|
2178 | 2178 | } |
2179 | 2179 | |
2180 | 2180 | /** |
@@ -2189,15 +2189,15 @@ discard block |
||
2189 | 2189 | */ |
2190 | 2190 | function colorStringToArray($stringcolor,$colorifnotfound=array(88,88,88)) |
2191 | 2191 | { |
2192 | - if (is_array($stringcolor)) return $stringcolor; // If already into correct output format, we return as is |
|
2193 | - $tmp=preg_match('/^#?([0-9a-fA-F][0-9a-fA-F])([0-9a-fA-F][0-9a-fA-F])([0-9a-fA-F][0-9a-fA-F])$/',$stringcolor,$reg); |
|
2194 | - if (! $tmp) |
|
2195 | - { |
|
2196 | - $tmp=explode(',',$stringcolor); |
|
2197 | - if (count($tmp) < 3) return $colorifnotfound; |
|
2198 | - return $tmp; |
|
2199 | - } |
|
2200 | - return array(hexdec($reg[1]),hexdec($reg[2]),hexdec($reg[3])); |
|
2192 | + if (is_array($stringcolor)) return $stringcolor; // If already into correct output format, we return as is |
|
2193 | + $tmp=preg_match('/^#?([0-9a-fA-F][0-9a-fA-F])([0-9a-fA-F][0-9a-fA-F])([0-9a-fA-F][0-9a-fA-F])$/',$stringcolor,$reg); |
|
2194 | + if (! $tmp) |
|
2195 | + { |
|
2196 | + $tmp=explode(',',$stringcolor); |
|
2197 | + if (count($tmp) < 3) return $colorifnotfound; |
|
2198 | + return $tmp; |
|
2199 | + } |
|
2200 | + return array(hexdec($reg[1]),hexdec($reg[2]),hexdec($reg[3])); |
|
2201 | 2201 | } |
2202 | 2202 | |
2203 | 2203 | /** |
@@ -2243,7 +2243,7 @@ discard block |
||
2243 | 2243 | if ($moduledirforclass != 'api') $moduledirforclass = preg_replace('/api$/i','',$moduledirforclass); |
2244 | 2244 | |
2245 | 2245 | if ($module == 'contracts') { |
2246 | - $moduledirforclass = 'contrat'; |
|
2246 | + $moduledirforclass = 'contrat'; |
|
2247 | 2247 | } |
2248 | 2248 | elseif (in_array($module, array('admin', 'login', 'setup', 'access', 'status', 'tools', 'documents'))) { |
2249 | 2249 | $moduledirforclass = 'api'; |
@@ -2270,7 +2270,7 @@ discard block |
||
2270 | 2270 | $moduledirforclass = 'commande'; |
2271 | 2271 | } |
2272 | 2272 | elseif ($module == 'shipments') { |
2273 | - $moduledirforclass = 'expedition'; |
|
2273 | + $moduledirforclass = 'expedition'; |
|
2274 | 2274 | } |
2275 | 2275 | elseif ($module == 'facture' || $module == 'invoice' || $module == 'invoices') { |
2276 | 2276 | $moduledirforclass = 'compta/facture'; |
@@ -2288,7 +2288,7 @@ discard block |
||
2288 | 2288 | $moduledirforclass = 'product/stock'; |
2289 | 2289 | } |
2290 | 2290 | elseif ($module == 'supplierproposals' || $module == 'supplierproposal' || $module == 'supplier_proposal') { |
2291 | - $moduledirforclass = 'supplier_proposal'; |
|
2291 | + $moduledirforclass = 'supplier_proposal'; |
|
2292 | 2292 | } |
2293 | 2293 | elseif ($module == 'fournisseur' || $module == 'supplierinvoices' || $module == 'supplierorders') { |
2294 | 2294 | $moduledirforclass = 'fourn'; |
@@ -2300,10 +2300,10 @@ discard block |
||
2300 | 2300 | $moduledirforclass = 'user'; |
2301 | 2301 | } |
2302 | 2302 | elseif ($module == 'ficheinter' || $module == 'interventions') { |
2303 | - $moduledirforclass = 'fichinter'; |
|
2303 | + $moduledirforclass = 'fichinter'; |
|
2304 | 2304 | } |
2305 | 2305 | elseif ($module == 'tickets') { |
2306 | - $moduledirforclass = 'ticket'; |
|
2306 | + $moduledirforclass = 'ticket'; |
|
2307 | 2307 | } |
2308 | 2308 | |
2309 | 2309 | return $moduledirforclass; |
@@ -29,29 +29,29 @@ discard block |
||
29 | 29 | */ |
30 | 30 | function stock_prepare_head($object) |
31 | 31 | { |
32 | - global $langs, $conf; |
|
32 | + global $langs, $conf; |
|
33 | 33 | |
34 | - $h = 0; |
|
35 | - $head = array(); |
|
34 | + $h = 0; |
|
35 | + $head = array(); |
|
36 | 36 | |
37 | - $head[$h][0] = DOL_URL_ROOT.'/product/stock/card.php?id='.$object->id; |
|
38 | - $head[$h][1] = $langs->trans("Card"); |
|
39 | - $head[$h][2] = 'card'; |
|
40 | - $h++; |
|
37 | + $head[$h][0] = DOL_URL_ROOT.'/product/stock/card.php?id='.$object->id; |
|
38 | + $head[$h][1] = $langs->trans("Card"); |
|
39 | + $head[$h][2] = 'card'; |
|
40 | + $h++; |
|
41 | 41 | |
42 | - $head[$h][0] = DOL_URL_ROOT.'/product/stock/movement_list.php?id='.$object->id; |
|
43 | - $head[$h][1] = $langs->trans("StockMovements"); |
|
44 | - $head[$h][2] = 'movements'; |
|
45 | - $h++; |
|
42 | + $head[$h][0] = DOL_URL_ROOT.'/product/stock/movement_list.php?id='.$object->id; |
|
43 | + $head[$h][1] = $langs->trans("StockMovements"); |
|
44 | + $head[$h][2] = 'movements'; |
|
45 | + $h++; |
|
46 | 46 | |
47 | - /* |
|
47 | + /* |
|
48 | 48 | $head[$h][0] = DOL_URL_ROOT.'/product/stock/fiche-valo.php?id='.$object->id; |
49 | 49 | $head[$h][1] = $langs->trans("EnhancedValue"); |
50 | 50 | $head[$h][2] = 'value'; |
51 | 51 | $h++; |
52 | 52 | */ |
53 | 53 | |
54 | - /* Disabled because will never be implemented. Table always empty. |
|
54 | + /* Disabled because will never be implemented. Table always empty. |
|
55 | 55 | if (! empty($conf->global->STOCK_USE_WAREHOUSE_BY_USER)) |
56 | 56 | { |
57 | 57 | // Should not be enabled by defaut because does not work yet correctly because |
@@ -70,9 +70,9 @@ discard block |
||
70 | 70 | complete_head_from_modules($conf,$langs,$object,$head,$h,'stock'); |
71 | 71 | |
72 | 72 | $head[$h][0] = DOL_URL_ROOT.'/product/stock/info.php?id='.$object->id; |
73 | - $head[$h][1] = $langs->trans("Info"); |
|
74 | - $head[$h][2] = 'info'; |
|
75 | - $h++; |
|
73 | + $head[$h][1] = $langs->trans("Info"); |
|
74 | + $head[$h][2] = 'info'; |
|
75 | + $h++; |
|
76 | 76 | |
77 | 77 | complete_head_from_modules($conf,$langs,$object,$head,$h,'stock','remove'); |
78 | 78 |
@@ -27,15 +27,15 @@ discard block |
||
27 | 27 | function salaries_prepare_head($object) |
28 | 28 | { |
29 | 29 | |
30 | - global $db, $langs, $conf; |
|
30 | + global $db, $langs, $conf; |
|
31 | 31 | |
32 | - $h = 0; |
|
33 | - $head = array(); |
|
32 | + $h = 0; |
|
33 | + $head = array(); |
|
34 | 34 | |
35 | - $head[$h][0] = DOL_URL_ROOT.'/compta/salaries/card.php?id='.$object->id; |
|
36 | - $head[$h][1] = $langs->trans("Card"); |
|
37 | - $head[$h][2] = 'card'; |
|
38 | - $h++; |
|
35 | + $head[$h][0] = DOL_URL_ROOT.'/compta/salaries/card.php?id='.$object->id; |
|
36 | + $head[$h][1] = $langs->trans("Card"); |
|
37 | + $head[$h][2] = 'card'; |
|
38 | + $h++; |
|
39 | 39 | |
40 | 40 | // Show more tabs from modules |
41 | 41 | // Entries must be declared in modules descriptor with line |
@@ -43,23 +43,23 @@ discard block |
||
43 | 43 | // $this->tabs = array('entity:-tabname); to remove a tab |
44 | 44 | complete_head_from_modules($conf,$langs,$object,$head,$h,'salaries'); |
45 | 45 | |
46 | - require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; |
|
46 | + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; |
|
47 | 47 | require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php'; |
48 | - $upload_dir = $conf->salaries->dir_output . "/" . dol_sanitizeFileName($object->ref); |
|
49 | - $nbFiles = count(dol_dir_list($upload_dir,'files',0,'','(\.meta|_preview.*\.png)$')); |
|
48 | + $upload_dir = $conf->salaries->dir_output . "/" . dol_sanitizeFileName($object->ref); |
|
49 | + $nbFiles = count(dol_dir_list($upload_dir,'files',0,'','(\.meta|_preview.*\.png)$')); |
|
50 | 50 | $nbLinks=Link::count($db, $object->element, $object->id); |
51 | - $head[$h][0] = DOL_URL_ROOT.'/compta/salaries/document.php?id='.$object->id; |
|
52 | - $head[$h][1] = $langs->trans('Documents'); |
|
53 | - if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>'; |
|
54 | - $head[$h][2] = 'documents'; |
|
55 | - $h++; |
|
51 | + $head[$h][0] = DOL_URL_ROOT.'/compta/salaries/document.php?id='.$object->id; |
|
52 | + $head[$h][1] = $langs->trans('Documents'); |
|
53 | + if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>'; |
|
54 | + $head[$h][2] = 'documents'; |
|
55 | + $h++; |
|
56 | 56 | |
57 | - $head[$h][0] = DOL_URL_ROOT.'/compta/salaries/info.php?id='.$object->id; |
|
58 | - $head[$h][1] = $langs->trans("Info"); |
|
59 | - $head[$h][2] = 'info'; |
|
60 | - $h++; |
|
57 | + $head[$h][0] = DOL_URL_ROOT.'/compta/salaries/info.php?id='.$object->id; |
|
58 | + $head[$h][1] = $langs->trans("Info"); |
|
59 | + $head[$h][2] = 'info'; |
|
60 | + $h++; |
|
61 | 61 | |
62 | - complete_head_from_modules($conf,$langs,$object,$head,$h,'salaries', 'remove'); |
|
62 | + complete_head_from_modules($conf,$langs,$object,$head,$h,'salaries', 'remove'); |
|
63 | 63 | |
64 | - return $head; |
|
64 | + return $head; |
|
65 | 65 | } |