@@ -35,26 +35,26 @@ discard block |
||
35 | 35 | */ |
36 | 36 | function fichinter_prepare_head($object) |
37 | 37 | { |
38 | - global $db, $langs, $conf, $user; |
|
39 | - $langs->load("fichinter"); |
|
40 | - |
|
41 | - $h = 0; |
|
42 | - $head = array(); |
|
43 | - |
|
44 | - $head[$h][0] = DOL_URL_ROOT.'/fichinter/card.php?id='.$object->id; |
|
45 | - $head[$h][1] = $langs->trans("Card"); |
|
46 | - $head[$h][2] = 'card'; |
|
47 | - $h++; |
|
48 | - |
|
49 | - if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) |
|
50 | - { |
|
51 | - $nbContact = count($object->liste_contact(-1,'internal')) + count($object->liste_contact(-1,'external')); |
|
52 | - $head[$h][0] = DOL_URL_ROOT.'/fichinter/contact.php?id='.$object->id; |
|
53 | - $head[$h][1] = $langs->trans('InterventionContact'); |
|
54 | - if ($nbContact > 0) $head[$h][1].= ' <span class="badge">'.$nbContact.'</span>'; |
|
55 | - $head[$h][2] = 'contact'; |
|
56 | - $h++; |
|
57 | - } |
|
38 | + global $db, $langs, $conf, $user; |
|
39 | + $langs->load("fichinter"); |
|
40 | + |
|
41 | + $h = 0; |
|
42 | + $head = array(); |
|
43 | + |
|
44 | + $head[$h][0] = DOL_URL_ROOT.'/fichinter/card.php?id='.$object->id; |
|
45 | + $head[$h][1] = $langs->trans("Card"); |
|
46 | + $head[$h][2] = 'card'; |
|
47 | + $h++; |
|
48 | + |
|
49 | + if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) |
|
50 | + { |
|
51 | + $nbContact = count($object->liste_contact(-1,'internal')) + count($object->liste_contact(-1,'external')); |
|
52 | + $head[$h][0] = DOL_URL_ROOT.'/fichinter/contact.php?id='.$object->id; |
|
53 | + $head[$h][1] = $langs->trans('InterventionContact'); |
|
54 | + if ($nbContact > 0) $head[$h][1].= ' <span class="badge">'.$nbContact.'</span>'; |
|
55 | + $head[$h][2] = 'contact'; |
|
56 | + $h++; |
|
57 | + } |
|
58 | 58 | |
59 | 59 | // Show more tabs from modules |
60 | 60 | // Entries must be declared in modules descriptor with line |
@@ -62,58 +62,58 @@ discard block |
||
62 | 62 | // $this->tabs = array('entity:-tabname); to remove a tab |
63 | 63 | complete_head_from_modules($conf,$langs,$object,$head,$h,'intervention'); |
64 | 64 | |
65 | - // Tab to link resources |
|
66 | - if ($conf->resource->enabled) |
|
67 | - { |
|
68 | - require_once DOL_DOCUMENT_ROOT.'/resource/class/dolresource.class.php'; |
|
69 | - $nbResource = 0; |
|
70 | - $objectres=new Dolresource($db); |
|
71 | - if (is_array($objectres->available_resources)) |
|
72 | - { |
|
73 | - foreach ($objectres->available_resources as $modresources => $resources) |
|
74 | - { |
|
75 | - $resources=(array) $resources; // To be sure $resources is an array |
|
76 | - foreach($resources as $resource_obj) |
|
77 | - { |
|
78 | - $linked_resources = $object->getElementResources('fichinter',$object->id,$resource_obj); |
|
79 | - } |
|
80 | - } |
|
81 | - } |
|
82 | - |
|
83 | - $head[$h][0] = DOL_URL_ROOT.'/resource/element_resource.php?element=fichinter&element_id='.$object->id; |
|
84 | - $head[$h][1] = $langs->trans("Resources"); |
|
85 | - if ($nbResource > 0) $head[$h][1].= ' <span class="badge">'.$nbResource.'</span>'; |
|
86 | - $head[$h][2] = 'resource'; |
|
87 | - $h++; |
|
88 | - } |
|
65 | + // Tab to link resources |
|
66 | + if ($conf->resource->enabled) |
|
67 | + { |
|
68 | + require_once DOL_DOCUMENT_ROOT.'/resource/class/dolresource.class.php'; |
|
69 | + $nbResource = 0; |
|
70 | + $objectres=new Dolresource($db); |
|
71 | + if (is_array($objectres->available_resources)) |
|
72 | + { |
|
73 | + foreach ($objectres->available_resources as $modresources => $resources) |
|
74 | + { |
|
75 | + $resources=(array) $resources; // To be sure $resources is an array |
|
76 | + foreach($resources as $resource_obj) |
|
77 | + { |
|
78 | + $linked_resources = $object->getElementResources('fichinter',$object->id,$resource_obj); |
|
79 | + } |
|
80 | + } |
|
81 | + } |
|
82 | + |
|
83 | + $head[$h][0] = DOL_URL_ROOT.'/resource/element_resource.php?element=fichinter&element_id='.$object->id; |
|
84 | + $head[$h][1] = $langs->trans("Resources"); |
|
85 | + if ($nbResource > 0) $head[$h][1].= ' <span class="badge">'.$nbResource.'</span>'; |
|
86 | + $head[$h][2] = 'resource'; |
|
87 | + $h++; |
|
88 | + } |
|
89 | 89 | |
90 | 90 | if (empty($conf->global->MAIN_DISABLE_NOTES_TAB)) |
91 | 91 | { |
92 | - $nbNote = 0; |
|
92 | + $nbNote = 0; |
|
93 | 93 | if(!empty($object->note_private)) $nbNote++; |
94 | - if(!empty($object->note_public)) $nbNote++; |
|
95 | - $head[$h][0] = DOL_URL_ROOT.'/fichinter/note.php?id='.$object->id; |
|
96 | - $head[$h][1] = $langs->trans('Notes'); |
|
97 | - if ($nbNote > 0) $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>'; |
|
98 | - $head[$h][2] = 'note'; |
|
99 | - $h++; |
|
94 | + if(!empty($object->note_public)) $nbNote++; |
|
95 | + $head[$h][0] = DOL_URL_ROOT.'/fichinter/note.php?id='.$object->id; |
|
96 | + $head[$h][1] = $langs->trans('Notes'); |
|
97 | + if ($nbNote > 0) $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>'; |
|
98 | + $head[$h][2] = 'note'; |
|
99 | + $h++; |
|
100 | 100 | } |
101 | 101 | |
102 | - require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; |
|
102 | + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; |
|
103 | 103 | require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php'; |
104 | - $upload_dir = $conf->ficheinter->dir_output . "/" . dol_sanitizeFileName($object->ref); |
|
105 | - $nbFiles = count(dol_dir_list($upload_dir,'files',0,'','(\.meta|_preview.*\.png)$')); |
|
104 | + $upload_dir = $conf->ficheinter->dir_output . "/" . dol_sanitizeFileName($object->ref); |
|
105 | + $nbFiles = count(dol_dir_list($upload_dir,'files',0,'','(\.meta|_preview.*\.png)$')); |
|
106 | 106 | $nbLinks=Link::count($db, $object->element, $object->id); |
107 | - $head[$h][0] = DOL_URL_ROOT.'/fichinter/document.php?id='.$object->id; |
|
108 | - $head[$h][1] = $langs->trans("Documents"); |
|
109 | - if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>'; |
|
110 | - $head[$h][2] = 'documents'; |
|
111 | - $h++; |
|
107 | + $head[$h][0] = DOL_URL_ROOT.'/fichinter/document.php?id='.$object->id; |
|
108 | + $head[$h][1] = $langs->trans("Documents"); |
|
109 | + if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>'; |
|
110 | + $head[$h][2] = 'documents'; |
|
111 | + $h++; |
|
112 | 112 | |
113 | 113 | $head[$h][0] = DOL_URL_ROOT.'/fichinter/info.php?id='.$object->id; |
114 | - $head[$h][1] = $langs->trans('Info'); |
|
115 | - $head[$h][2] = 'info'; |
|
116 | - $h++; |
|
114 | + $head[$h][1] = $langs->trans('Info'); |
|
115 | + $head[$h][2] = 'info'; |
|
116 | + $h++; |
|
117 | 117 | |
118 | 118 | complete_head_from_modules($conf,$langs,$object,$head,$h,'intervention','remove'); |
119 | 119 | |
@@ -127,39 +127,39 @@ discard block |
||
127 | 127 | */ |
128 | 128 | function fichinter_admin_prepare_head() |
129 | 129 | { |
130 | - global $langs, $conf, $user; |
|
130 | + global $langs, $conf, $user; |
|
131 | 131 | |
132 | - $h = 0; |
|
133 | - $head = array(); |
|
132 | + $h = 0; |
|
133 | + $head = array(); |
|
134 | 134 | |
135 | - $h = 0; |
|
135 | + $h = 0; |
|
136 | 136 | |
137 | - $head[$h][0] = DOL_URL_ROOT."/admin/fichinter.php"; |
|
138 | - $head[$h][1] = $langs->trans("Interventions"); |
|
139 | - $head[$h][2] = 'ficheinter'; |
|
140 | - $h++; |
|
137 | + $head[$h][0] = DOL_URL_ROOT."/admin/fichinter.php"; |
|
138 | + $head[$h][1] = $langs->trans("Interventions"); |
|
139 | + $head[$h][2] = 'ficheinter'; |
|
140 | + $h++; |
|
141 | 141 | |
142 | - // Show more tabs from modules |
|
143 | - // Entries must be declared in modules descriptor with line |
|
144 | - // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab |
|
145 | - // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab |
|
146 | - complete_head_from_modules($conf,$langs,null,$head,$h,'fichinter_admin'); |
|
142 | + // Show more tabs from modules |
|
143 | + // Entries must be declared in modules descriptor with line |
|
144 | + // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab |
|
145 | + // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab |
|
146 | + complete_head_from_modules($conf,$langs,null,$head,$h,'fichinter_admin'); |
|
147 | 147 | |
148 | - $head[$h][0] = DOL_URL_ROOT.'/fichinter/admin/fichinter_extrafields.php'; |
|
149 | - $head[$h][1] = $langs->trans("ExtraFields"); |
|
148 | + $head[$h][0] = DOL_URL_ROOT.'/fichinter/admin/fichinter_extrafields.php'; |
|
149 | + $head[$h][1] = $langs->trans("ExtraFields"); |
|
150 | 150 | $head[$h][2] = 'attributes'; |
151 | 151 | $h++; |
152 | 152 | |
153 | - $head[$h][0] = DOL_URL_ROOT.'/fichinter/admin/fichinterdet_extrafields.php'; |
|
154 | - $head[$h][1] = $langs->trans("ExtraFieldsLines"); |
|
153 | + $head[$h][0] = DOL_URL_ROOT.'/fichinter/admin/fichinterdet_extrafields.php'; |
|
154 | + $head[$h][1] = $langs->trans("ExtraFieldsLines"); |
|
155 | 155 | $head[$h][2] = 'attributesdet'; |
156 | 156 | $h++; |
157 | 157 | |
158 | 158 | |
159 | 159 | |
160 | - complete_head_from_modules($conf,$langs,null,$head,$h,'fichinter_admin','remove'); |
|
160 | + complete_head_from_modules($conf,$langs,null,$head,$h,'fichinter_admin','remove'); |
|
161 | 161 | |
162 | - return $head; |
|
162 | + return $head; |
|
163 | 163 | } |
164 | 164 | |
165 | 165 | /** |
@@ -170,20 +170,20 @@ discard block |
||
170 | 170 | */ |
171 | 171 | function fichinter_rec_prepare_head($object) |
172 | 172 | { |
173 | - global $langs, $conf; //, $user; |
|
173 | + global $langs, $conf; //, $user; |
|
174 | 174 | |
175 | - $h = 0; |
|
176 | - $head = array(); |
|
175 | + $h = 0; |
|
176 | + $head = array(); |
|
177 | 177 | |
178 | - $head[$h][0] = DOL_URL_ROOT.'/fichinter/card-rec.php?id='.$object->id; |
|
179 | - $head[$h][1] = $langs->trans("CardFichinter"); |
|
180 | - $head[$h][2] = 'card'; |
|
181 | - $h++; |
|
178 | + $head[$h][0] = DOL_URL_ROOT.'/fichinter/card-rec.php?id='.$object->id; |
|
179 | + $head[$h][1] = $langs->trans("CardFichinter"); |
|
180 | + $head[$h][2] = 'card'; |
|
181 | + $h++; |
|
182 | 182 | |
183 | - complete_head_from_modules($conf, $langs, $object, $head, $h, 'intervention-rec'); |
|
183 | + complete_head_from_modules($conf, $langs, $object, $head, $h, 'intervention-rec'); |
|
184 | 184 | |
185 | - complete_head_from_modules($conf, $langs, $object, $head, $h,'intervention-rec','remove'); |
|
185 | + complete_head_from_modules($conf, $langs, $object, $head, $h,'intervention-rec','remove'); |
|
186 | 186 | |
187 | 187 | |
188 | - return $head; |
|
188 | + return $head; |
|
189 | 189 | } |
@@ -29,42 +29,42 @@ |
||
29 | 29 | */ |
30 | 30 | function emailing_prepare_head(Mailing $object) |
31 | 31 | { |
32 | - global $user, $langs, $conf; |
|
32 | + global $user, $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."/comm/mailing/card.php?id=".$object->id; |
|
38 | - $head[$h][1] = $langs->trans("MailCard"); |
|
39 | - $head[$h][2] = 'card'; |
|
40 | - $h++; |
|
37 | + $head[$h][0] = DOL_URL_ROOT."/comm/mailing/card.php?id=".$object->id; |
|
38 | + $head[$h][1] = $langs->trans("MailCard"); |
|
39 | + $head[$h][2] = 'card'; |
|
40 | + $h++; |
|
41 | 41 | |
42 | - if (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->mailing->mailing_advance->recipient)) |
|
43 | - { |
|
44 | - $head[$h][0] = DOL_URL_ROOT."/comm/mailing/cibles.php?id=".$object->id; |
|
45 | - $head[$h][1] = $langs->trans("MailRecipients"); |
|
46 | - if ($object->nbemail > 0) $head[$h][1].= ' <span class="badge">'.$object->nbemail.'</span>'; |
|
47 | - $head[$h][2] = 'targets'; |
|
48 | - $h++; |
|
49 | - } |
|
42 | + if (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->mailing->mailing_advance->recipient)) |
|
43 | + { |
|
44 | + $head[$h][0] = DOL_URL_ROOT."/comm/mailing/cibles.php?id=".$object->id; |
|
45 | + $head[$h][1] = $langs->trans("MailRecipients"); |
|
46 | + if ($object->nbemail > 0) $head[$h][1].= ' <span class="badge">'.$object->nbemail.'</span>'; |
|
47 | + $head[$h][2] = 'targets'; |
|
48 | + $h++; |
|
49 | + } |
|
50 | 50 | |
51 | - if (! empty($conf->global->EMAILING_USE_ADVANCED_SELECTOR)) |
|
52 | - { |
|
53 | - $head[$h][0] = DOL_URL_ROOT."/comm/mailing/advtargetemailing.php?id=".$object->id; |
|
54 | - $head[$h][1] = $langs->trans("MailAdvTargetRecipients"); |
|
55 | - $head[$h][2] = 'advtargets'; |
|
56 | - $h++; |
|
57 | - } |
|
51 | + if (! empty($conf->global->EMAILING_USE_ADVANCED_SELECTOR)) |
|
52 | + { |
|
53 | + $head[$h][0] = DOL_URL_ROOT."/comm/mailing/advtargetemailing.php?id=".$object->id; |
|
54 | + $head[$h][1] = $langs->trans("MailAdvTargetRecipients"); |
|
55 | + $head[$h][2] = 'advtargets'; |
|
56 | + $h++; |
|
57 | + } |
|
58 | 58 | |
59 | - $head[$h][0] = DOL_URL_ROOT."/comm/mailing/info.php?id=".$object->id; |
|
60 | - $head[$h][1] = $langs->trans("Info"); |
|
61 | - $head[$h][2] = 'info'; |
|
62 | - $h++; |
|
59 | + $head[$h][0] = DOL_URL_ROOT."/comm/mailing/info.php?id=".$object->id; |
|
60 | + $head[$h][1] = $langs->trans("Info"); |
|
61 | + $head[$h][2] = 'info'; |
|
62 | + $h++; |
|
63 | 63 | |
64 | - complete_head_from_modules($conf,$langs,$object,$head,$h,'emailing'); |
|
64 | + complete_head_from_modules($conf,$langs,$object,$head,$h,'emailing'); |
|
65 | 65 | |
66 | - complete_head_from_modules($conf,$langs,$object,$head,$h,'emailing','remove'); |
|
66 | + complete_head_from_modules($conf,$langs,$object,$head,$h,'emailing','remove'); |
|
67 | 67 | |
68 | - return $head; |
|
68 | + return $head; |
|
69 | 69 | } |
70 | 70 |
@@ -33,48 +33,48 @@ discard block |
||
33 | 33 | */ |
34 | 34 | function commande_prepare_head(Commande $object) |
35 | 35 | { |
36 | - global $db, $langs, $conf, $user; |
|
37 | - if (! empty($conf->expedition->enabled)) $langs->load("sendings"); |
|
38 | - $langs->load("orders"); |
|
39 | - |
|
40 | - $h = 0; |
|
41 | - $head = array(); |
|
42 | - |
|
43 | - if (! empty($conf->commande->enabled) && $user->rights->commande->lire) |
|
44 | - { |
|
45 | - $head[$h][0] = DOL_URL_ROOT.'/commande/card.php?id='.$object->id; |
|
46 | - $head[$h][1] = $langs->trans("OrderCard"); |
|
47 | - $head[$h][2] = 'order'; |
|
48 | - $h++; |
|
49 | - } |
|
50 | - |
|
51 | - if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) |
|
52 | - { |
|
53 | - $nbContact = count($object->liste_contact(-1,'internal')) + count($object->liste_contact(-1,'external')); |
|
54 | - $head[$h][0] = DOL_URL_ROOT.'/commande/contact.php?id='.$object->id; |
|
55 | - $head[$h][1] = $langs->trans('ContactsAddresses'); |
|
56 | - if ($nbContact > 0) $head[$h][1].= ' <span class="badge">'.$nbContact.'</span>'; |
|
57 | - $head[$h][2] = 'contact'; |
|
58 | - $h++; |
|
59 | - } |
|
60 | - |
|
61 | - if (($conf->expedition_bon->enabled && $user->rights->expedition->lire) |
|
62 | - || ($conf->livraison_bon->enabled && $user->rights->expedition->livraison->lire)) |
|
63 | - { |
|
64 | - $nbShipments=$object->getNbOfShipments(); $nbReceiption=0; |
|
65 | - $head[$h][0] = DOL_URL_ROOT.'/expedition/shipment.php?id='.$object->id; |
|
66 | - $text=''; |
|
67 | - if ($conf->expedition_bon->enabled) $text.=$langs->trans("Shipments"); |
|
68 | - if ($conf->expedition_bon->enabled && $conf->livraison_bon->enabled) $text.='/'; |
|
69 | - if ($conf->livraison_bon->enabled) $text.=$langs->trans("Receivings"); |
|
70 | - if ($nbShipments > 0 || $nbReceiption > 0) $text.= ' <span class="badge">'.($nbShipments?$nbShipments:0); |
|
71 | - if ($conf->expedition_bon->enabled && $conf->livraison_bon->enabled) $text.='/'; |
|
72 | - if ($conf->expedition_bon->enabled && $conf->livraison_bon->enabled && ($nbShipments > 0 || $nbReceiption > 0)) $text.= ($nbReceiption?$nbReceiption:0); |
|
73 | - if ($nbShipments > 0 || $nbReceiption > 0) $text.= '</span>'; |
|
74 | - $head[$h][1] = $text; |
|
75 | - $head[$h][2] = 'shipping'; |
|
76 | - $h++; |
|
77 | - } |
|
36 | + global $db, $langs, $conf, $user; |
|
37 | + if (! empty($conf->expedition->enabled)) $langs->load("sendings"); |
|
38 | + $langs->load("orders"); |
|
39 | + |
|
40 | + $h = 0; |
|
41 | + $head = array(); |
|
42 | + |
|
43 | + if (! empty($conf->commande->enabled) && $user->rights->commande->lire) |
|
44 | + { |
|
45 | + $head[$h][0] = DOL_URL_ROOT.'/commande/card.php?id='.$object->id; |
|
46 | + $head[$h][1] = $langs->trans("OrderCard"); |
|
47 | + $head[$h][2] = 'order'; |
|
48 | + $h++; |
|
49 | + } |
|
50 | + |
|
51 | + if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) |
|
52 | + { |
|
53 | + $nbContact = count($object->liste_contact(-1,'internal')) + count($object->liste_contact(-1,'external')); |
|
54 | + $head[$h][0] = DOL_URL_ROOT.'/commande/contact.php?id='.$object->id; |
|
55 | + $head[$h][1] = $langs->trans('ContactsAddresses'); |
|
56 | + if ($nbContact > 0) $head[$h][1].= ' <span class="badge">'.$nbContact.'</span>'; |
|
57 | + $head[$h][2] = 'contact'; |
|
58 | + $h++; |
|
59 | + } |
|
60 | + |
|
61 | + if (($conf->expedition_bon->enabled && $user->rights->expedition->lire) |
|
62 | + || ($conf->livraison_bon->enabled && $user->rights->expedition->livraison->lire)) |
|
63 | + { |
|
64 | + $nbShipments=$object->getNbOfShipments(); $nbReceiption=0; |
|
65 | + $head[$h][0] = DOL_URL_ROOT.'/expedition/shipment.php?id='.$object->id; |
|
66 | + $text=''; |
|
67 | + if ($conf->expedition_bon->enabled) $text.=$langs->trans("Shipments"); |
|
68 | + if ($conf->expedition_bon->enabled && $conf->livraison_bon->enabled) $text.='/'; |
|
69 | + if ($conf->livraison_bon->enabled) $text.=$langs->trans("Receivings"); |
|
70 | + if ($nbShipments > 0 || $nbReceiption > 0) $text.= ' <span class="badge">'.($nbShipments?$nbShipments:0); |
|
71 | + if ($conf->expedition_bon->enabled && $conf->livraison_bon->enabled) $text.='/'; |
|
72 | + if ($conf->expedition_bon->enabled && $conf->livraison_bon->enabled && ($nbShipments > 0 || $nbReceiption > 0)) $text.= ($nbReceiption?$nbReceiption:0); |
|
73 | + if ($nbShipments > 0 || $nbReceiption > 0) $text.= '</span>'; |
|
74 | + $head[$h][1] = $text; |
|
75 | + $head[$h][2] = 'shipping'; |
|
76 | + $h++; |
|
77 | + } |
|
78 | 78 | |
79 | 79 | // Show more tabs from modules |
80 | 80 | // Entries must be declared in modules descriptor with line |
@@ -82,33 +82,33 @@ discard block |
||
82 | 82 | // $this->tabs = array('entity:-tabname); to remove a tab |
83 | 83 | complete_head_from_modules($conf,$langs,$object,$head,$h,'order'); |
84 | 84 | |
85 | - if (empty($conf->global->MAIN_DISABLE_NOTES_TAB)) |
|
86 | - { |
|
87 | - $nbNote = 0; |
|
85 | + if (empty($conf->global->MAIN_DISABLE_NOTES_TAB)) |
|
86 | + { |
|
87 | + $nbNote = 0; |
|
88 | 88 | if(!empty($object->note_private)) $nbNote++; |
89 | - if(!empty($object->note_public)) $nbNote++; |
|
90 | - $head[$h][0] = DOL_URL_ROOT.'/commande/note.php?id='.$object->id; |
|
91 | - $head[$h][1] = $langs->trans('Notes'); |
|
92 | - if ($nbNote > 0) $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>'; |
|
93 | - $head[$h][2] = 'note'; |
|
94 | - $h++; |
|
95 | - } |
|
96 | - |
|
97 | - require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; |
|
89 | + if(!empty($object->note_public)) $nbNote++; |
|
90 | + $head[$h][0] = DOL_URL_ROOT.'/commande/note.php?id='.$object->id; |
|
91 | + $head[$h][1] = $langs->trans('Notes'); |
|
92 | + if ($nbNote > 0) $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>'; |
|
93 | + $head[$h][2] = 'note'; |
|
94 | + $h++; |
|
95 | + } |
|
96 | + |
|
97 | + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; |
|
98 | 98 | require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php'; |
99 | - $upload_dir = $conf->commande->dir_output . "/" . dol_sanitizeFileName($object->ref); |
|
100 | - $nbFiles = count(dol_dir_list($upload_dir,'files',0,'','(\.meta|_preview.*\.png)$')); |
|
99 | + $upload_dir = $conf->commande->dir_output . "/" . dol_sanitizeFileName($object->ref); |
|
100 | + $nbFiles = count(dol_dir_list($upload_dir,'files',0,'','(\.meta|_preview.*\.png)$')); |
|
101 | 101 | $nbLinks=Link::count($db, $object->element, $object->id); |
102 | - $head[$h][0] = DOL_URL_ROOT.'/commande/document.php?id='.$object->id; |
|
103 | - $head[$h][1] = $langs->trans('Documents'); |
|
104 | - if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>'; |
|
105 | - $head[$h][2] = 'documents'; |
|
106 | - $h++; |
|
102 | + $head[$h][0] = DOL_URL_ROOT.'/commande/document.php?id='.$object->id; |
|
103 | + $head[$h][1] = $langs->trans('Documents'); |
|
104 | + if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>'; |
|
105 | + $head[$h][2] = 'documents'; |
|
106 | + $h++; |
|
107 | 107 | |
108 | - $head[$h][0] = DOL_URL_ROOT.'/commande/info.php?id='.$object->id; |
|
109 | - $head[$h][1] = $langs->trans("Info"); |
|
110 | - $head[$h][2] = 'info'; |
|
111 | - $h++; |
|
108 | + $head[$h][0] = DOL_URL_ROOT.'/commande/info.php?id='.$object->id; |
|
109 | + $head[$h][1] = $langs->trans("Info"); |
|
110 | + $head[$h][2] = 'info'; |
|
111 | + $h++; |
|
112 | 112 | |
113 | 113 | complete_head_from_modules($conf,$langs,$object,$head,$h,'order','remove'); |
114 | 114 | |
@@ -122,31 +122,31 @@ discard block |
||
122 | 122 | */ |
123 | 123 | function order_admin_prepare_head() |
124 | 124 | { |
125 | - global $langs, $conf, $user; |
|
125 | + global $langs, $conf, $user; |
|
126 | 126 | |
127 | - $h = 0; |
|
128 | - $head = array(); |
|
127 | + $h = 0; |
|
128 | + $head = array(); |
|
129 | 129 | |
130 | - $head[$h][0] = DOL_URL_ROOT.'/admin/commande.php'; |
|
131 | - $head[$h][1] = $langs->trans("Miscellaneous"); |
|
132 | - $head[$h][2] = 'general'; |
|
133 | - $h++; |
|
130 | + $head[$h][0] = DOL_URL_ROOT.'/admin/commande.php'; |
|
131 | + $head[$h][1] = $langs->trans("Miscellaneous"); |
|
132 | + $head[$h][2] = 'general'; |
|
133 | + $h++; |
|
134 | 134 | |
135 | - complete_head_from_modules($conf,$langs,null,$head,$h,'order_admin'); |
|
135 | + complete_head_from_modules($conf,$langs,null,$head,$h,'order_admin'); |
|
136 | 136 | |
137 | - $head[$h][0] = DOL_URL_ROOT.'/admin/order_extrafields.php'; |
|
138 | - $head[$h][1] = $langs->trans("ExtraFields"); |
|
139 | - $head[$h][2] = 'attributes'; |
|
140 | - $h++; |
|
137 | + $head[$h][0] = DOL_URL_ROOT.'/admin/order_extrafields.php'; |
|
138 | + $head[$h][1] = $langs->trans("ExtraFields"); |
|
139 | + $head[$h][2] = 'attributes'; |
|
140 | + $h++; |
|
141 | 141 | |
142 | - $head[$h][0] = DOL_URL_ROOT.'/admin/orderdet_extrafields.php'; |
|
143 | - $head[$h][1] = $langs->trans("ExtraFieldsLines"); |
|
144 | - $head[$h][2] = 'attributeslines'; |
|
145 | - $h++; |
|
142 | + $head[$h][0] = DOL_URL_ROOT.'/admin/orderdet_extrafields.php'; |
|
143 | + $head[$h][1] = $langs->trans("ExtraFieldsLines"); |
|
144 | + $head[$h][2] = 'attributeslines'; |
|
145 | + $h++; |
|
146 | 146 | |
147 | - complete_head_from_modules($conf,$langs,null,$head,$h,'order_admin','remove'); |
|
147 | + complete_head_from_modules($conf,$langs,null,$head,$h,'order_admin','remove'); |
|
148 | 148 | |
149 | - return $head; |
|
149 | + return $head; |
|
150 | 150 | } |
151 | 151 | |
152 | 152 |
@@ -35,63 +35,63 @@ discard block |
||
35 | 35 | */ |
36 | 36 | function dolWebsiteReplacementOfLinks($website, $content, $removephppart=0) |
37 | 37 | { |
38 | - $nbrep = 0; |
|
39 | - |
|
40 | - // Replace php code. Note $content may come from database and does not contains body tags. |
|
41 | - $replacewith='...php...'; |
|
42 | - if ($removephppart) $replacewith=''; |
|
43 | - $content = preg_replace('/value="<\?php((?!\?>).)*\?>\n*/ims', 'value="'.$replacewith.'"', $content); |
|
44 | - |
|
45 | - $replacewith='"callto=#'; |
|
46 | - if ($removephppart) $replacewith=''; |
|
47 | - $content = preg_replace('/"callto:<\?php((?!\?>).)*\?>\n*/ims', $replacewith, $content); |
|
48 | - |
|
49 | - $replacewith='"mailto=#'; |
|
50 | - if ($removephppart) $replacewith=''; |
|
51 | - $content = preg_replace('/"mailto:<\?php((?!\?>).)*\?>\n*/ims', $replacewith, $content); |
|
52 | - |
|
53 | - $replacewith='src="php'; |
|
54 | - if ($removephppart) $replacewith=''; |
|
55 | - $content = preg_replace('/src="<\?php((?!\?>).)*\?>\n*/ims', $replacewith, $content); |
|
56 | - |
|
57 | - $replacewith='href="php'; |
|
58 | - if ($removephppart) $replacewith=''; |
|
59 | - $content = preg_replace('/href="<\?php((?!\?>).)*\?>\n*/ims', $replacewith, $content); |
|
60 | - |
|
61 | - //$replacewith='<span class="phptag">...php...</span>'; |
|
62 | - $replacewith='<span class="phptag">...php...</span>'; |
|
63 | - if ($removephppart) $replacewith=''; |
|
64 | - //$content = preg_replace('/<\?php((?!\?toremove>).)*\?toremove>\n*/ims', $replacewith, $content); |
|
65 | - /*if ($content === null) { |
|
38 | + $nbrep = 0; |
|
39 | + |
|
40 | + // Replace php code. Note $content may come from database and does not contains body tags. |
|
41 | + $replacewith='...php...'; |
|
42 | + if ($removephppart) $replacewith=''; |
|
43 | + $content = preg_replace('/value="<\?php((?!\?>).)*\?>\n*/ims', 'value="'.$replacewith.'"', $content); |
|
44 | + |
|
45 | + $replacewith='"callto=#'; |
|
46 | + if ($removephppart) $replacewith=''; |
|
47 | + $content = preg_replace('/"callto:<\?php((?!\?>).)*\?>\n*/ims', $replacewith, $content); |
|
48 | + |
|
49 | + $replacewith='"mailto=#'; |
|
50 | + if ($removephppart) $replacewith=''; |
|
51 | + $content = preg_replace('/"mailto:<\?php((?!\?>).)*\?>\n*/ims', $replacewith, $content); |
|
52 | + |
|
53 | + $replacewith='src="php'; |
|
54 | + if ($removephppart) $replacewith=''; |
|
55 | + $content = preg_replace('/src="<\?php((?!\?>).)*\?>\n*/ims', $replacewith, $content); |
|
56 | + |
|
57 | + $replacewith='href="php'; |
|
58 | + if ($removephppart) $replacewith=''; |
|
59 | + $content = preg_replace('/href="<\?php((?!\?>).)*\?>\n*/ims', $replacewith, $content); |
|
60 | + |
|
61 | + //$replacewith='<span class="phptag">...php...</span>'; |
|
62 | + $replacewith='<span class="phptag">...php...</span>'; |
|
63 | + if ($removephppart) $replacewith=''; |
|
64 | + //$content = preg_replace('/<\?php((?!\?toremove>).)*\?toremove>\n*/ims', $replacewith, $content); |
|
65 | + /*if ($content === null) { |
|
66 | 66 | if (preg_last_error() == PREG_JIT_STACKLIMIT_ERROR) $content = 'preg_replace error (when removing php tags) PREG_JIT_STACKLIMIT_ERROR'; |
67 | 67 | }*/ |
68 | - $content = dolStripPhpCode($content, $replacewith); |
|
69 | - //var_dump($content); |
|
68 | + $content = dolStripPhpCode($content, $replacewith); |
|
69 | + //var_dump($content); |
|
70 | 70 | |
71 | - // Replace relative link / with dolibarr URL |
|
72 | - $content = preg_replace('/(href=")\/\"/', '\1'.DOL_URL_ROOT.'/website/index.php?website='.$website->ref.'&pageid='.$website->fk_default_home.'"', $content, -1, $nbrep); |
|
73 | - // Replace relative link /xxx.php with dolibarr URL |
|
74 | - $content = preg_replace('/(href=")\/?([^:\"]*)(\.php\")/', '\1'.DOL_URL_ROOT.'/website/index.php?website='.$website->ref.'&pageref=\2"', $content, -1, $nbrep); |
|
71 | + // Replace relative link / with dolibarr URL |
|
72 | + $content = preg_replace('/(href=")\/\"/', '\1'.DOL_URL_ROOT.'/website/index.php?website='.$website->ref.'&pageid='.$website->fk_default_home.'"', $content, -1, $nbrep); |
|
73 | + // Replace relative link /xxx.php with dolibarr URL |
|
74 | + $content = preg_replace('/(href=")\/?([^:\"]*)(\.php\")/', '\1'.DOL_URL_ROOT.'/website/index.php?website='.$website->ref.'&pageref=\2"', $content, -1, $nbrep); |
|
75 | 75 | |
76 | - // Fix relative link into medias with correct URL after the DOL_URL_ROOT: ../url("medias/ |
|
77 | - $content = preg_replace('/url\((["\']?)medias\//', 'url(\1'.DOL_URL_ROOT.'/viewimage.php?modulepart=medias&file=', $content, -1, $nbrep); |
|
78 | - $content = preg_replace('/data-slide-bg=(["\']?)medias\//', 'data-slide-bg=\1'.DOL_URL_ROOT.'/viewimage.php?modulepart=medias&file=', $content, -1, $nbrep); |
|
76 | + // Fix relative link into medias with correct URL after the DOL_URL_ROOT: ../url("medias/ |
|
77 | + $content = preg_replace('/url\((["\']?)medias\//', 'url(\1'.DOL_URL_ROOT.'/viewimage.php?modulepart=medias&file=', $content, -1, $nbrep); |
|
78 | + $content = preg_replace('/data-slide-bg=(["\']?)medias\//', 'data-slide-bg=\1'.DOL_URL_ROOT.'/viewimage.php?modulepart=medias&file=', $content, -1, $nbrep); |
|
79 | 79 | |
80 | - // <img src="medias/image.png... => <img src="dolibarr/viewimage.php/modulepart=medias&file=image.png... |
|
81 | - $content = preg_replace('/(<img[^>]*src=")(medias\/)/', '\1'.DOL_URL_ROOT.'/viewimage.php?modulepart=medias&file=', $content, -1, $nbrep); |
|
82 | - // <img src="image.png... => <img src="dolibarr/viewimage.php/modulepart=medias&file=image.png... |
|
83 | - $content = preg_replace('/(<img[^>]*src=")(?!(http|\/?viewimage|'.preg_quote(DOL_URL_ROOT,'/').'\/viewimage))/', '\1'.DOL_URL_ROOT.'/viewimage.php?modulepart=medias&file=', $content, -1, $nbrep); |
|
84 | - // <img src="viewimage.php/modulepart=medias&file=image.png" => <img src="dolibarr/viewimage.php/modulepart=medias&file=image.png" |
|
85 | - $content = preg_replace('/(<img[^>]*src=")(\/?viewimage\.php)/', '\1'.DOL_URL_ROOT.'/viewimage.php', $content, -1, $nbrep); |
|
80 | + // <img src="medias/image.png... => <img src="dolibarr/viewimage.php/modulepart=medias&file=image.png... |
|
81 | + $content = preg_replace('/(<img[^>]*src=")(medias\/)/', '\1'.DOL_URL_ROOT.'/viewimage.php?modulepart=medias&file=', $content, -1, $nbrep); |
|
82 | + // <img src="image.png... => <img src="dolibarr/viewimage.php/modulepart=medias&file=image.png... |
|
83 | + $content = preg_replace('/(<img[^>]*src=")(?!(http|\/?viewimage|'.preg_quote(DOL_URL_ROOT,'/').'\/viewimage))/', '\1'.DOL_URL_ROOT.'/viewimage.php?modulepart=medias&file=', $content, -1, $nbrep); |
|
84 | + // <img src="viewimage.php/modulepart=medias&file=image.png" => <img src="dolibarr/viewimage.php/modulepart=medias&file=image.png" |
|
85 | + $content = preg_replace('/(<img[^>]*src=")(\/?viewimage\.php)/', '\1'.DOL_URL_ROOT.'/viewimage.php', $content, -1, $nbrep); |
|
86 | 86 | |
87 | - // action="newpage.php" => action="dolibarr/website/index.php?website=...&pageref=newpage |
|
88 | - $content = preg_replace('/(action=")\/?([^:\"]*)(\.php\")/', '\1'.DOL_URL_ROOT.'/website/index.php?website='.$website->ref.'&pageref=\2"', $content, -1, $nbrep); |
|
87 | + // action="newpage.php" => action="dolibarr/website/index.php?website=...&pageref=newpage |
|
88 | + $content = preg_replace('/(action=")\/?([^:\"]*)(\.php\")/', '\1'.DOL_URL_ROOT.'/website/index.php?website='.$website->ref.'&pageref=\2"', $content, -1, $nbrep); |
|
89 | 89 | |
90 | - // Fix relative link /document.php with correct URL after the DOL_URL_ROOT: ...href="/document.php?modulepart=" |
|
91 | - $content=preg_replace('/(href=")(\/?document\.php\?[^\"]*modulepart=[^\"]*)(\")/', '\1'.DOL_URL_ROOT.'\2\3', $content, -1, $nbrep); |
|
92 | - $content=preg_replace('/(src=")(\/?document\.php\?[^\"]*modulepart=[^\"]*)(\")/', '\1'.DOL_URL_ROOT.'\2\3', $content, -1, $nbrep); |
|
90 | + // Fix relative link /document.php with correct URL after the DOL_URL_ROOT: ...href="/document.php?modulepart=" |
|
91 | + $content=preg_replace('/(href=")(\/?document\.php\?[^\"]*modulepart=[^\"]*)(\")/', '\1'.DOL_URL_ROOT.'\2\3', $content, -1, $nbrep); |
|
92 | + $content=preg_replace('/(src=")(\/?document\.php\?[^\"]*modulepart=[^\"]*)(\")/', '\1'.DOL_URL_ROOT.'\2\3', $content, -1, $nbrep); |
|
93 | 93 | |
94 | - return $content; |
|
94 | + return $content; |
|
95 | 95 | } |
96 | 96 | |
97 | 97 | |
@@ -104,33 +104,33 @@ discard block |
||
104 | 104 | */ |
105 | 105 | function dolStripPhpCode($str, $replacewith='') |
106 | 106 | { |
107 | - $newstr = ''; |
|
108 | - |
|
109 | - //split on each opening tag |
|
110 | - $parts = explode('<?php',$str); |
|
111 | - if (!empty($parts)) |
|
112 | - { |
|
113 | - $i=0; |
|
114 | - foreach($parts as $part) |
|
115 | - { |
|
116 | - if ($i == 0) // The first part is never php code |
|
117 | - { |
|
118 | - $i++; |
|
119 | - $newstr .= $part; |
|
120 | - continue; |
|
121 | - } |
|
122 | - //split on closing tag |
|
123 | - $partlings = explode('?>', $part); |
|
124 | - if (!empty($partlings)) |
|
125 | - { |
|
126 | - //remove content before closing tag |
|
127 | - if (count($partlings) > 1) $partlings[0] = ''; |
|
128 | - //append to out string |
|
129 | - $newstr .= $replacewith.implode('',$partlings); |
|
130 | - } |
|
131 | - } |
|
132 | - } |
|
133 | - return $newstr; |
|
107 | + $newstr = ''; |
|
108 | + |
|
109 | + //split on each opening tag |
|
110 | + $parts = explode('<?php',$str); |
|
111 | + if (!empty($parts)) |
|
112 | + { |
|
113 | + $i=0; |
|
114 | + foreach($parts as $part) |
|
115 | + { |
|
116 | + if ($i == 0) // The first part is never php code |
|
117 | + { |
|
118 | + $i++; |
|
119 | + $newstr .= $part; |
|
120 | + continue; |
|
121 | + } |
|
122 | + //split on closing tag |
|
123 | + $partlings = explode('?>', $part); |
|
124 | + if (!empty($partlings)) |
|
125 | + { |
|
126 | + //remove content before closing tag |
|
127 | + if (count($partlings) > 1) $partlings[0] = ''; |
|
128 | + //append to out string |
|
129 | + $newstr .= $replacewith.implode('',$partlings); |
|
130 | + } |
|
131 | + } |
|
132 | + } |
|
133 | + return $newstr; |
|
134 | 134 | } |
135 | 135 | |
136 | 136 | |
@@ -144,101 +144,101 @@ discard block |
||
144 | 144 | */ |
145 | 145 | function dolWebsiteOutput($content) |
146 | 146 | { |
147 | - global $db, $langs, $conf, $user; |
|
148 | - global $dolibarr_main_url_root, $dolibarr_main_data_root; |
|
147 | + global $db, $langs, $conf, $user; |
|
148 | + global $dolibarr_main_url_root, $dolibarr_main_data_root; |
|
149 | + |
|
150 | + dol_syslog("dolWebsiteOutput start (USEDOLIBARRSERVER=".(defined('USEDOLIBARRSERVER')?'1':'')." (USEDOLIBARREDITOR=".(defined('USEDOLIBARREDITOR')?'1':'').')'); |
|
151 | + |
|
152 | + // Define $urlwithroot |
|
153 | + $urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root)); |
|
154 | + $urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file |
|
155 | + //$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current |
|
156 | + |
|
157 | + if (defined('USEDOLIBARREDITOR')) // REPLACEMENT OF LINKS When page called from Dolibarr editor |
|
158 | + { |
|
159 | + // We remove the <head> part of content |
|
160 | + $content = preg_replace('/<head>.*<\/head>/ims', '', $content); |
|
161 | + $content = preg_replace('/^.*<body(\s[^>]*)*>/ims', '', $content); |
|
162 | + $content = preg_replace('/<\/body(\s[^>]*)*>.*$/ims', '', $content); |
|
163 | + } |
|
164 | + elseif (defined('USEDOLIBARRSERVER')) // REPLACEMENT OF LINKS When page called from Dolibarr server |
|
165 | + { |
|
166 | + global $website; |
|
167 | + |
|
168 | + // Replace relative link / with dolibarr URL: ...href="/"... |
|
169 | + $content=preg_replace('/(href=")\/\"/', '\1'.DOL_URL_ROOT.'/public/website/index.php?website='.$website->ref.'"', $content, -1, $nbrep); |
|
170 | + // Replace relative link /xxx.php with dolibarr URL: ...href="....php" |
|
171 | + $content=preg_replace('/(href=")\/?([^:\"]*)(\.php\")/', '\1'.DOL_URL_ROOT.'/public/website/index.php?website='.$website->ref.'&pageref=\2"', $content, -1, $nbrep); |
|
172 | + // Replace relative link /xxx with dolibarr URL: ...href="....php" |
|
173 | + $content=preg_replace('/(href=")\/?([a-zA-Z0-9\-]+)(\")/', '\1'.DOL_URL_ROOT.'/public/website/index.php?website='.$website->ref.'&pageref=\2\3', $content, -1, $nbrep); |
|
174 | + $content=preg_replace('/(href=")\/?([a-zA-Z0-9\-]+)(\?)/', '\1'.DOL_URL_ROOT.'/public/website/index.php?website='.$website->ref.'&pageref=\2\3', $content, -1, $nbrep); |
|
175 | + |
|
176 | + // Fix relative link /document.php with correct URL after the DOL_URL_ROOT: href="/document.php?modulepart=" => href="/dolibarr/document.php?modulepart=" |
|
177 | + $content=preg_replace('/(href=")(\/?document\.php\?[^\"]*modulepart=[^\"]*)(\")/', '\1'.DOL_URL_ROOT.'\2\3', $content, -1, $nbrep); |
|
178 | + $content=preg_replace('/(src=")(\/?document\.php\?[^\"]*modulepart=[^\"]*)(\")/', '\1'.DOL_URL_ROOT.'\2\3', $content, -1, $nbrep); |
|
179 | + |
|
180 | + // Fix relative link /viewimage.php with correct URL after the DOL_URL_ROOT: href="/viewimage.php?modulepart=" => href="/dolibarr/viewimage.php?modulepart=" |
|
181 | + $content=preg_replace('/(href=")(\/?viewimage\.php\?[^\"]*modulepart=[^\"]*)(\")/', '\1'.DOL_URL_ROOT.'\2\3', $content, -1, $nbrep); |
|
182 | + $content=preg_replace('/(src=")(\/?viewimage\.php\?[^\"]*modulepart=[^\"]*)(\")/', '\1'.DOL_URL_ROOT.'\2\3', $content, -1, $nbrep); |
|
183 | + |
|
184 | + // Fix relative link into medias with correct URL after the DOL_URL_ROOT: ../url("medias/ |
|
185 | + $content=preg_replace('/url\((["\']?)medias\//', 'url(\1'.DOL_URL_ROOT.'/viewimage.php?modulepart=medias&file=', $content, -1, $nbrep); |
|
186 | + $content=preg_replace('/data-slide-bg=(["\']?)medias\//', 'data-slide-bg=\1'.DOL_URL_ROOT.'/viewimage.php?modulepart=medias&file=', $content, -1, $nbrep); |
|
187 | + |
|
188 | + // <img src="medias/image.png... => <img src="dolibarr/viewimage.php/modulepart=medias&file=image.png... |
|
189 | + $content = preg_replace('/(<img[^>]*src=")(medias\/)/', '\1'.DOL_URL_ROOT.'/viewimage.php?modulepart=medias&file=', $content, -1, $nbrep); |
|
190 | + // <img src="image.png... => <img src="dolibarr/viewimage.php/modulepart=medias&file=image.png... |
|
191 | + $content = preg_replace('/(<img[^>]*src=")(?!(http|\/?viewimage|'.preg_quote(DOL_URL_ROOT,'/').'\/viewimage))/', '\1'.DOL_URL_ROOT.'/viewimage.php?modulepart=medias&file=', $content, -1, $nbrep); |
|
192 | + // <img src="viewimage.php/modulepart=medias&file=image.png" => <img src="dolibarr/viewimage.php/modulepart=medias&file=image.png" |
|
193 | + $content = preg_replace('/(<img[^>]*src=")(\/?viewimage\.php)/', '\1'.DOL_URL_ROOT.'/viewimage.php', $content, -1, $nbrep); |
|
194 | + |
|
195 | + // action="newpage.php" => action="dolibarr/website/index.php?website=...&pageref=newpage |
|
196 | + $content = preg_replace('/(action=")\/?([^:\"]*)(\.php\")/', '\1'.DOL_URL_ROOT.'/public/website/index.php?website='.$website->ref.'&pageref=\2"', $content, -1, $nbrep); |
|
197 | + } |
|
198 | + else // REPLACEMENT OF LINKS When page called from virtual host |
|
199 | + { |
|
200 | + $symlinktomediaexists=1; |
|
201 | + |
|
202 | + // Make a change into HTML code to allow to include images from medias directory correct with direct link for virtual server |
|
203 | + // <img alt="" src="/dolibarr_dev/htdocs/viewimage.php?modulepart=medias&entity=1&file=image/ldestailleur_166x166.jpg" style="height:166px; width:166px" /> |
|
204 | + // become |
|
205 | + // <img alt="" src="'.$urlwithroot.'/medias/image/ldestailleur_166x166.jpg" style="height:166px; width:166px" /> |
|
206 | + $nbrep=0; |
|
207 | + if (! $symlinktomediaexists) |
|
208 | + { |
|
209 | + $content=preg_replace('/(<script[^>]*src=")[^\"]*document\.php([^\"]*)modulepart=medias([^\"]*)file=([^\"]*)("[^>]*>)/', '\wrapper.php\2modulepart=medias\3file=\4\5', $content, -1, $nbrep); |
|
210 | + |
|
211 | + $content=preg_replace('/(<a[^>]*href=")[^\"]*viewimage\.php([^\"]*)modulepart=medias([^\"]*)file=([^\"]*)("[^>]*>)/', '\1/wrapper.php\2modulepart=medias\3file=\4\5', $content, -1, $nbrep); |
|
212 | + $content=preg_replace('/(<img[^>]*src=")[^\"]*viewimage\.php([^\"]*)modulepart=medias([^\"]*)file=([^\"]*)("[^>]*>)/', '\1/wrapper.php\2modulepart=medias\3file=\4\5', $content, -1, $nbrep); |
|
213 | + $content=preg_replace('/(url\(["\']?)[^\)]*viewimage\.php([^\)]*)modulepart=medias([^\)]*)file=([^\)]*)(["\']?\))/', '\1/wrapper.php\2modulepart=medias\3file=\4\5', $content, -1, $nbrep); |
|
214 | + |
|
215 | + $content=preg_replace('/(<a[^>]*href=")[^\"]*viewimage\.php([^\"]*)hashp=([^\"]*)("[^>]*>)/', '\1/wrapper.php\2hashp=\3\4', $content, -1, $nbrep); |
|
216 | + $content=preg_replace('/(<img[^>]*src=")[^\"]*viewimage\.php([^\"]*)hashp=([^\"]*)("[^>]*>)/', '\1/wrapper.php\2hashp=\3\4', $content, -1, $nbrep); |
|
217 | + $content=preg_replace('/(url\(["\']?)[^\)]*viewimage\.php([^\)]*)hashp=([^\)]*)(["\']?\))/', '\1/wrapper.php\2hashp\3\4', $content, -1, $nbrep); |
|
218 | + |
|
219 | + $content=preg_replace('/(<img[^>]*src=")[^\"]*viewimage\.php([^\"]*)modulepart=mycompany([^\"]*)file=([^\"]*)("[^>]*>)/', '\1/wrapper.php\2modulepart=mycompany\3file=\4\5', $content, -1, $nbrep); |
|
220 | + } |
|
221 | + else |
|
222 | + { |
|
223 | + $content=preg_replace('/(<script[^>]*src=")[^\"]*document\.php([^\"]*)modulepart=medias([^\"]*)file=([^\"]*)("[^>]*>)/', '\1medias/\4\5', $content, -1, $nbrep); |
|
224 | + |
|
225 | + $content=preg_replace('/(<a[^>]*href=")[^\"]*viewimage\.php([^\"]*)modulepart=medias([^\"]*)file=([^\"]*)("[^>]*>)/', '\1medias/\4\5', $content, -1, $nbrep); |
|
226 | + $content=preg_replace('/(<img[^>]*src=")[^\"]*viewimage\.php([^\"]*)modulepart=medias([^\"]*)file=([^\"]*)("[^>]*>)/', '\1medias/\4\5', $content, -1, $nbrep); |
|
227 | + $content=preg_replace('/(url\(["\']?)[^\)]*viewimage\.php([^\)]*)modulepart=medias([^\)]*)file=([^\)]*)(["\']?\))/', '\1medias/\4\5', $content, -1, $nbrep); |
|
228 | + |
|
229 | + $content=preg_replace('/(<a[^>]*href=")[^\"]*viewimage\.php([^\"]*)hashp=([^\"]*)("[^>]*>)/', '\1/wrapper.php\2hashp=\3\4', $content, -1, $nbrep); |
|
230 | + $content=preg_replace('/(<img[^>]*src=")[^\"]*viewimage\.php([^\"]*)hashp=([^\"]*)("[^>]*>)/', '\1/wrapper.php\2hashp=\3\4', $content, -1, $nbrep); |
|
231 | + $content=preg_replace('/(url\(["\']?)[^\)]*viewimage\.php([^\)]*)hashp=([^\)]*)(["\']?\))/', '\1/wrapper.php\2hashp=\3\4', $content, -1, $nbrep); |
|
232 | + |
|
233 | + $content=preg_replace('/(<img[^>]*src=")[^\"]*viewimage\.php([^\"]*)modulepart=mycompany([^\"]*)file=([^\"]*)("[^>]*>)/', '\1/wrapper.php\2modulepart=mycompany\3file=\4\5', $content, -1, $nbrep); |
|
234 | + } |
|
235 | + } |
|
149 | 236 | |
150 | - dol_syslog("dolWebsiteOutput start (USEDOLIBARRSERVER=".(defined('USEDOLIBARRSERVER')?'1':'')." (USEDOLIBARREDITOR=".(defined('USEDOLIBARREDITOR')?'1':'').')'); |
|
237 | + $content=preg_replace('/ contenteditable="true"/', ' contenteditable="false"', $content, -1, $nbrep); |
|
151 | 238 | |
152 | - // Define $urlwithroot |
|
153 | - $urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root)); |
|
154 | - $urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file |
|
155 | - //$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current |
|
239 | + dol_syslog("dolWebsiteOutput end"); |
|
156 | 240 | |
157 | - if (defined('USEDOLIBARREDITOR')) // REPLACEMENT OF LINKS When page called from Dolibarr editor |
|
158 | - { |
|
159 | - // We remove the <head> part of content |
|
160 | - $content = preg_replace('/<head>.*<\/head>/ims', '', $content); |
|
161 | - $content = preg_replace('/^.*<body(\s[^>]*)*>/ims', '', $content); |
|
162 | - $content = preg_replace('/<\/body(\s[^>]*)*>.*$/ims', '', $content); |
|
163 | - } |
|
164 | - elseif (defined('USEDOLIBARRSERVER')) // REPLACEMENT OF LINKS When page called from Dolibarr server |
|
165 | - { |
|
166 | - global $website; |
|
167 | - |
|
168 | - // Replace relative link / with dolibarr URL: ...href="/"... |
|
169 | - $content=preg_replace('/(href=")\/\"/', '\1'.DOL_URL_ROOT.'/public/website/index.php?website='.$website->ref.'"', $content, -1, $nbrep); |
|
170 | - // Replace relative link /xxx.php with dolibarr URL: ...href="....php" |
|
171 | - $content=preg_replace('/(href=")\/?([^:\"]*)(\.php\")/', '\1'.DOL_URL_ROOT.'/public/website/index.php?website='.$website->ref.'&pageref=\2"', $content, -1, $nbrep); |
|
172 | - // Replace relative link /xxx with dolibarr URL: ...href="....php" |
|
173 | - $content=preg_replace('/(href=")\/?([a-zA-Z0-9\-]+)(\")/', '\1'.DOL_URL_ROOT.'/public/website/index.php?website='.$website->ref.'&pageref=\2\3', $content, -1, $nbrep); |
|
174 | - $content=preg_replace('/(href=")\/?([a-zA-Z0-9\-]+)(\?)/', '\1'.DOL_URL_ROOT.'/public/website/index.php?website='.$website->ref.'&pageref=\2\3', $content, -1, $nbrep); |
|
175 | - |
|
176 | - // Fix relative link /document.php with correct URL after the DOL_URL_ROOT: href="/document.php?modulepart=" => href="/dolibarr/document.php?modulepart=" |
|
177 | - $content=preg_replace('/(href=")(\/?document\.php\?[^\"]*modulepart=[^\"]*)(\")/', '\1'.DOL_URL_ROOT.'\2\3', $content, -1, $nbrep); |
|
178 | - $content=preg_replace('/(src=")(\/?document\.php\?[^\"]*modulepart=[^\"]*)(\")/', '\1'.DOL_URL_ROOT.'\2\3', $content, -1, $nbrep); |
|
179 | - |
|
180 | - // Fix relative link /viewimage.php with correct URL after the DOL_URL_ROOT: href="/viewimage.php?modulepart=" => href="/dolibarr/viewimage.php?modulepart=" |
|
181 | - $content=preg_replace('/(href=")(\/?viewimage\.php\?[^\"]*modulepart=[^\"]*)(\")/', '\1'.DOL_URL_ROOT.'\2\3', $content, -1, $nbrep); |
|
182 | - $content=preg_replace('/(src=")(\/?viewimage\.php\?[^\"]*modulepart=[^\"]*)(\")/', '\1'.DOL_URL_ROOT.'\2\3', $content, -1, $nbrep); |
|
183 | - |
|
184 | - // Fix relative link into medias with correct URL after the DOL_URL_ROOT: ../url("medias/ |
|
185 | - $content=preg_replace('/url\((["\']?)medias\//', 'url(\1'.DOL_URL_ROOT.'/viewimage.php?modulepart=medias&file=', $content, -1, $nbrep); |
|
186 | - $content=preg_replace('/data-slide-bg=(["\']?)medias\//', 'data-slide-bg=\1'.DOL_URL_ROOT.'/viewimage.php?modulepart=medias&file=', $content, -1, $nbrep); |
|
187 | - |
|
188 | - // <img src="medias/image.png... => <img src="dolibarr/viewimage.php/modulepart=medias&file=image.png... |
|
189 | - $content = preg_replace('/(<img[^>]*src=")(medias\/)/', '\1'.DOL_URL_ROOT.'/viewimage.php?modulepart=medias&file=', $content, -1, $nbrep); |
|
190 | - // <img src="image.png... => <img src="dolibarr/viewimage.php/modulepart=medias&file=image.png... |
|
191 | - $content = preg_replace('/(<img[^>]*src=")(?!(http|\/?viewimage|'.preg_quote(DOL_URL_ROOT,'/').'\/viewimage))/', '\1'.DOL_URL_ROOT.'/viewimage.php?modulepart=medias&file=', $content, -1, $nbrep); |
|
192 | - // <img src="viewimage.php/modulepart=medias&file=image.png" => <img src="dolibarr/viewimage.php/modulepart=medias&file=image.png" |
|
193 | - $content = preg_replace('/(<img[^>]*src=")(\/?viewimage\.php)/', '\1'.DOL_URL_ROOT.'/viewimage.php', $content, -1, $nbrep); |
|
194 | - |
|
195 | - // action="newpage.php" => action="dolibarr/website/index.php?website=...&pageref=newpage |
|
196 | - $content = preg_replace('/(action=")\/?([^:\"]*)(\.php\")/', '\1'.DOL_URL_ROOT.'/public/website/index.php?website='.$website->ref.'&pageref=\2"', $content, -1, $nbrep); |
|
197 | - } |
|
198 | - else // REPLACEMENT OF LINKS When page called from virtual host |
|
199 | - { |
|
200 | - $symlinktomediaexists=1; |
|
201 | - |
|
202 | - // Make a change into HTML code to allow to include images from medias directory correct with direct link for virtual server |
|
203 | - // <img alt="" src="/dolibarr_dev/htdocs/viewimage.php?modulepart=medias&entity=1&file=image/ldestailleur_166x166.jpg" style="height:166px; width:166px" /> |
|
204 | - // become |
|
205 | - // <img alt="" src="'.$urlwithroot.'/medias/image/ldestailleur_166x166.jpg" style="height:166px; width:166px" /> |
|
206 | - $nbrep=0; |
|
207 | - if (! $symlinktomediaexists) |
|
208 | - { |
|
209 | - $content=preg_replace('/(<script[^>]*src=")[^\"]*document\.php([^\"]*)modulepart=medias([^\"]*)file=([^\"]*)("[^>]*>)/', '\wrapper.php\2modulepart=medias\3file=\4\5', $content, -1, $nbrep); |
|
210 | - |
|
211 | - $content=preg_replace('/(<a[^>]*href=")[^\"]*viewimage\.php([^\"]*)modulepart=medias([^\"]*)file=([^\"]*)("[^>]*>)/', '\1/wrapper.php\2modulepart=medias\3file=\4\5', $content, -1, $nbrep); |
|
212 | - $content=preg_replace('/(<img[^>]*src=")[^\"]*viewimage\.php([^\"]*)modulepart=medias([^\"]*)file=([^\"]*)("[^>]*>)/', '\1/wrapper.php\2modulepart=medias\3file=\4\5', $content, -1, $nbrep); |
|
213 | - $content=preg_replace('/(url\(["\']?)[^\)]*viewimage\.php([^\)]*)modulepart=medias([^\)]*)file=([^\)]*)(["\']?\))/', '\1/wrapper.php\2modulepart=medias\3file=\4\5', $content, -1, $nbrep); |
|
214 | - |
|
215 | - $content=preg_replace('/(<a[^>]*href=")[^\"]*viewimage\.php([^\"]*)hashp=([^\"]*)("[^>]*>)/', '\1/wrapper.php\2hashp=\3\4', $content, -1, $nbrep); |
|
216 | - $content=preg_replace('/(<img[^>]*src=")[^\"]*viewimage\.php([^\"]*)hashp=([^\"]*)("[^>]*>)/', '\1/wrapper.php\2hashp=\3\4', $content, -1, $nbrep); |
|
217 | - $content=preg_replace('/(url\(["\']?)[^\)]*viewimage\.php([^\)]*)hashp=([^\)]*)(["\']?\))/', '\1/wrapper.php\2hashp\3\4', $content, -1, $nbrep); |
|
218 | - |
|
219 | - $content=preg_replace('/(<img[^>]*src=")[^\"]*viewimage\.php([^\"]*)modulepart=mycompany([^\"]*)file=([^\"]*)("[^>]*>)/', '\1/wrapper.php\2modulepart=mycompany\3file=\4\5', $content, -1, $nbrep); |
|
220 | - } |
|
221 | - else |
|
222 | - { |
|
223 | - $content=preg_replace('/(<script[^>]*src=")[^\"]*document\.php([^\"]*)modulepart=medias([^\"]*)file=([^\"]*)("[^>]*>)/', '\1medias/\4\5', $content, -1, $nbrep); |
|
224 | - |
|
225 | - $content=preg_replace('/(<a[^>]*href=")[^\"]*viewimage\.php([^\"]*)modulepart=medias([^\"]*)file=([^\"]*)("[^>]*>)/', '\1medias/\4\5', $content, -1, $nbrep); |
|
226 | - $content=preg_replace('/(<img[^>]*src=")[^\"]*viewimage\.php([^\"]*)modulepart=medias([^\"]*)file=([^\"]*)("[^>]*>)/', '\1medias/\4\5', $content, -1, $nbrep); |
|
227 | - $content=preg_replace('/(url\(["\']?)[^\)]*viewimage\.php([^\)]*)modulepart=medias([^\)]*)file=([^\)]*)(["\']?\))/', '\1medias/\4\5', $content, -1, $nbrep); |
|
228 | - |
|
229 | - $content=preg_replace('/(<a[^>]*href=")[^\"]*viewimage\.php([^\"]*)hashp=([^\"]*)("[^>]*>)/', '\1/wrapper.php\2hashp=\3\4', $content, -1, $nbrep); |
|
230 | - $content=preg_replace('/(<img[^>]*src=")[^\"]*viewimage\.php([^\"]*)hashp=([^\"]*)("[^>]*>)/', '\1/wrapper.php\2hashp=\3\4', $content, -1, $nbrep); |
|
231 | - $content=preg_replace('/(url\(["\']?)[^\)]*viewimage\.php([^\)]*)hashp=([^\)]*)(["\']?\))/', '\1/wrapper.php\2hashp=\3\4', $content, -1, $nbrep); |
|
232 | - |
|
233 | - $content=preg_replace('/(<img[^>]*src=")[^\"]*viewimage\.php([^\"]*)modulepart=mycompany([^\"]*)file=([^\"]*)("[^>]*>)/', '\1/wrapper.php\2modulepart=mycompany\3file=\4\5', $content, -1, $nbrep); |
|
234 | - } |
|
235 | - } |
|
236 | - |
|
237 | - $content=preg_replace('/ contenteditable="true"/', ' contenteditable="false"', $content, -1, $nbrep); |
|
238 | - |
|
239 | - dol_syslog("dolWebsiteOutput end"); |
|
240 | - |
|
241 | - print $content; |
|
241 | + print $content; |
|
242 | 242 | } |
243 | 243 | |
244 | 244 | |
@@ -279,74 +279,74 @@ discard block |
||
279 | 279 | */ |
280 | 280 | function redirectToContainer($containerref, $containeraliasalt='',$containerid=0) |
281 | 281 | { |
282 | - global $db, $website; |
|
283 | - |
|
284 | - $newurl = ''; |
|
285 | - $result=0; |
|
286 | - |
|
287 | - // We make redirect using the alternative alias, we must find the real $containerref |
|
288 | - if ($containeraliasalt) |
|
289 | - { |
|
290 | - include_once DOL_DOCUMENT_ROOT.'/website/class/websitepage.class.php'; |
|
291 | - $tmpwebsitepage=new WebsitePage($db); |
|
292 | - $result = $tmpwebsitepage->fetch(0, $website->id, '', $containeraliasalt); |
|
293 | - if ($result > 0) |
|
294 | - { |
|
295 | - $containerref = $tmpwebsitepage->pageurl; |
|
296 | - } |
|
297 | - else |
|
298 | - { |
|
299 | - print "Error, page contains a redirect to the alternative alias '".$containeraliasalt."' that does not exists in web site (".$website->id." / ".$website->ref.")"; |
|
300 | - exit; |
|
301 | - } |
|
302 | - } |
|
303 | - |
|
304 | - if (defined('USEDOLIBARRSERVER')) // When page called from Dolibarr server |
|
305 | - { |
|
306 | - // Check new container exists |
|
307 | - if (! $containeraliasalt) // If containeraliasalt set, we already did the test |
|
308 | - { |
|
309 | - include_once DOL_DOCUMENT_ROOT.'/website/class/websitepage.class.php'; |
|
310 | - $tmpwebsitepage=new WebsitePage($db); |
|
311 | - $result = $tmpwebsitepage->fetch(0, $website->id, $containerref); |
|
312 | - unset($tmpwebsitepage); |
|
313 | - } |
|
314 | - if ($result > 0) |
|
315 | - { |
|
316 | - $currenturi = $_SERVER["REQUEST_URI"]; |
|
317 | - if (preg_match('/&pageref=([^&]+)/', $currenturi, $regtmp)) |
|
318 | - { |
|
319 | - if ($regtmp[0] == $containerref) |
|
320 | - { |
|
321 | - print "Error, page with uri '.$currenturi.' try a redirect to the same alias page '".$containerref."' in web site '".$website->ref."'"; |
|
322 | - exit; |
|
323 | - } |
|
324 | - else |
|
325 | - { |
|
326 | - $newurl = preg_replace('/&pageref=([^&]+)/', '&pageref='.$containerref, $currenturi); |
|
327 | - } |
|
328 | - } |
|
329 | - else |
|
330 | - { |
|
331 | - $newurl = $currenturi.'&pageref='.urlencode($containerref); |
|
332 | - } |
|
333 | - } |
|
334 | - } |
|
335 | - else // When page called from virtual host server |
|
336 | - { |
|
337 | - $newurl = '/'.$containerref.'.php'; |
|
338 | - } |
|
339 | - |
|
340 | - if ($newurl) |
|
341 | - { |
|
342 | - header("Location: ".$newurl); |
|
343 | - exit; |
|
344 | - } |
|
345 | - else |
|
346 | - { |
|
347 | - print "Error, page contains a redirect to the alias page '".$containerref."' that does not exists in web site (".$website->id." / ".$website->ref.")"; |
|
348 | - exit; |
|
349 | - } |
|
282 | + global $db, $website; |
|
283 | + |
|
284 | + $newurl = ''; |
|
285 | + $result=0; |
|
286 | + |
|
287 | + // We make redirect using the alternative alias, we must find the real $containerref |
|
288 | + if ($containeraliasalt) |
|
289 | + { |
|
290 | + include_once DOL_DOCUMENT_ROOT.'/website/class/websitepage.class.php'; |
|
291 | + $tmpwebsitepage=new WebsitePage($db); |
|
292 | + $result = $tmpwebsitepage->fetch(0, $website->id, '', $containeraliasalt); |
|
293 | + if ($result > 0) |
|
294 | + { |
|
295 | + $containerref = $tmpwebsitepage->pageurl; |
|
296 | + } |
|
297 | + else |
|
298 | + { |
|
299 | + print "Error, page contains a redirect to the alternative alias '".$containeraliasalt."' that does not exists in web site (".$website->id." / ".$website->ref.")"; |
|
300 | + exit; |
|
301 | + } |
|
302 | + } |
|
303 | + |
|
304 | + if (defined('USEDOLIBARRSERVER')) // When page called from Dolibarr server |
|
305 | + { |
|
306 | + // Check new container exists |
|
307 | + if (! $containeraliasalt) // If containeraliasalt set, we already did the test |
|
308 | + { |
|
309 | + include_once DOL_DOCUMENT_ROOT.'/website/class/websitepage.class.php'; |
|
310 | + $tmpwebsitepage=new WebsitePage($db); |
|
311 | + $result = $tmpwebsitepage->fetch(0, $website->id, $containerref); |
|
312 | + unset($tmpwebsitepage); |
|
313 | + } |
|
314 | + if ($result > 0) |
|
315 | + { |
|
316 | + $currenturi = $_SERVER["REQUEST_URI"]; |
|
317 | + if (preg_match('/&pageref=([^&]+)/', $currenturi, $regtmp)) |
|
318 | + { |
|
319 | + if ($regtmp[0] == $containerref) |
|
320 | + { |
|
321 | + print "Error, page with uri '.$currenturi.' try a redirect to the same alias page '".$containerref."' in web site '".$website->ref."'"; |
|
322 | + exit; |
|
323 | + } |
|
324 | + else |
|
325 | + { |
|
326 | + $newurl = preg_replace('/&pageref=([^&]+)/', '&pageref='.$containerref, $currenturi); |
|
327 | + } |
|
328 | + } |
|
329 | + else |
|
330 | + { |
|
331 | + $newurl = $currenturi.'&pageref='.urlencode($containerref); |
|
332 | + } |
|
333 | + } |
|
334 | + } |
|
335 | + else // When page called from virtual host server |
|
336 | + { |
|
337 | + $newurl = '/'.$containerref.'.php'; |
|
338 | + } |
|
339 | + |
|
340 | + if ($newurl) |
|
341 | + { |
|
342 | + header("Location: ".$newurl); |
|
343 | + exit; |
|
344 | + } |
|
345 | + else |
|
346 | + { |
|
347 | + print "Error, page contains a redirect to the alias page '".$containerref."' that does not exists in web site (".$website->id." / ".$website->ref.")"; |
|
348 | + exit; |
|
349 | + } |
|
350 | 350 | } |
351 | 351 | |
352 | 352 | |
@@ -359,41 +359,41 @@ discard block |
||
359 | 359 | */ |
360 | 360 | function includeContainer($containerref) |
361 | 361 | { |
362 | - global $conf, $db, $hookmanager, $langs, $mysoc, $user, $website, $websitepage, $weblangs; // Very important. Required to have var available when running inluded containers. |
|
363 | - global $includehtmlcontentopened; |
|
364 | - global $websitekey, $websitepagefile; |
|
362 | + global $conf, $db, $hookmanager, $langs, $mysoc, $user, $website, $websitepage, $weblangs; // Very important. Required to have var available when running inluded containers. |
|
363 | + global $includehtmlcontentopened; |
|
364 | + global $websitekey, $websitepagefile; |
|
365 | 365 | |
366 | - $MAXLEVEL=20; |
|
366 | + $MAXLEVEL=20; |
|
367 | 367 | |
368 | - if (! preg_match('/\.php$/i', $containerref)) $containerref.='.php'; |
|
368 | + if (! preg_match('/\.php$/i', $containerref)) $containerref.='.php'; |
|
369 | 369 | |
370 | - $fullpathfile=DOL_DATA_ROOT.'/website/'.$websitekey.'/'.$containerref; |
|
370 | + $fullpathfile=DOL_DATA_ROOT.'/website/'.$websitekey.'/'.$containerref; |
|
371 | 371 | |
372 | - if (empty($includehtmlcontentopened)) $includehtmlcontentopened=0; |
|
373 | - $includehtmlcontentopened++; |
|
374 | - if ($includehtmlcontentopened > $MAXLEVEL) |
|
375 | - { |
|
376 | - print 'ERROR: RECURSIVE CONTENT LEVEL. Depth of recursive call is more than the limit of '.$MAXLEVEL.".\n"; |
|
377 | - return; |
|
378 | - } |
|
379 | - // file_get_contents is not possible. We must execute code with include |
|
380 | - //$content = file_get_contents($fullpathfile); |
|
381 | - //print preg_replace(array('/^.*<body[^>]*>/ims','/<\/body>.*$/ims'), array('', ''), $content);*/ |
|
372 | + if (empty($includehtmlcontentopened)) $includehtmlcontentopened=0; |
|
373 | + $includehtmlcontentopened++; |
|
374 | + if ($includehtmlcontentopened > $MAXLEVEL) |
|
375 | + { |
|
376 | + print 'ERROR: RECURSIVE CONTENT LEVEL. Depth of recursive call is more than the limit of '.$MAXLEVEL.".\n"; |
|
377 | + return; |
|
378 | + } |
|
379 | + // file_get_contents is not possible. We must execute code with include |
|
380 | + //$content = file_get_contents($fullpathfile); |
|
381 | + //print preg_replace(array('/^.*<body[^>]*>/ims','/<\/body>.*$/ims'), array('', ''), $content);*/ |
|
382 | 382 | |
383 | - ob_start(); |
|
384 | - $res = include $fullpathfile; // Include because we want to execute code content |
|
385 | - $tmpoutput = ob_get_contents(); |
|
386 | - ob_end_clean(); |
|
383 | + ob_start(); |
|
384 | + $res = include $fullpathfile; // Include because we want to execute code content |
|
385 | + $tmpoutput = ob_get_contents(); |
|
386 | + ob_end_clean(); |
|
387 | 387 | |
388 | - print "\n".'<!-- include '.$fullpathfile.' level = '.$includehtmlcontentopened.' -->'."\n"; |
|
389 | - print preg_replace(array('/^.*<body[^>]*>/ims','/<\/body>.*$/ims'), array('', ''), $tmpoutput); |
|
388 | + print "\n".'<!-- include '.$fullpathfile.' level = '.$includehtmlcontentopened.' -->'."\n"; |
|
389 | + print preg_replace(array('/^.*<body[^>]*>/ims','/<\/body>.*$/ims'), array('', ''), $tmpoutput); |
|
390 | 390 | |
391 | - if (! $res) |
|
392 | - { |
|
393 | - print 'ERROR: FAILED TO INCLUDE PAGE '.$containerref.".\n"; |
|
394 | - } |
|
391 | + if (! $res) |
|
392 | + { |
|
393 | + print 'ERROR: FAILED TO INCLUDE PAGE '.$containerref.".\n"; |
|
394 | + } |
|
395 | 395 | |
396 | - $includehtmlcontentopened--; |
|
396 | + $includehtmlcontentopened--; |
|
397 | 397 | } |
398 | 398 | |
399 | 399 | |
@@ -414,172 +414,172 @@ discard block |
||
414 | 414 | */ |
415 | 415 | function getAllImages($object, $objectpage, $urltograb, &$tmp, &$action, $modifylinks=0, $grabimages=1, $grabimagesinto='subpage') |
416 | 416 | { |
417 | - global $conf; |
|
418 | - |
|
419 | - $error=0; |
|
420 | - |
|
421 | - dol_syslog("Call getAllImages with grabimagesinto=".$grabimagesinto); |
|
422 | - |
|
423 | - $alreadygrabbed=array(); |
|
424 | - |
|
425 | - if (preg_match('/\/$/', $urltograb)) $urltograb.='.'; |
|
426 | - $urltograb = dirname($urltograb); // So urltograb is now http://www.nltechno.com or http://www.nltechno.com/dir1 |
|
427 | - |
|
428 | - // Search X in "img...src=X" |
|
429 | - preg_match_all('/<img([^\.\/]+)src="([^>"]+)"([^>]*)>/i', $tmp, $regs); |
|
430 | - |
|
431 | - foreach ($regs[0] as $key => $val) |
|
432 | - { |
|
433 | - if (preg_match('/^data:image/i', $regs[2][$key])) continue; // We do nothing for such images |
|
434 | - |
|
435 | - if (preg_match('/^\//', $regs[2][$key])) |
|
436 | - { |
|
437 | - $urltograbdirrootwithoutslash = getRootURLFromURL($urltograb); |
|
438 | - $urltograbbis = $urltograbdirrootwithoutslash.$regs[2][$key]; // We use dirroot |
|
439 | - } |
|
440 | - else |
|
441 | - { |
|
442 | - $urltograbbis = $urltograb.'/'.$regs[2][$key]; // We use dir of grabbed file |
|
443 | - } |
|
444 | - |
|
445 | - $linkwithoutdomain = $regs[2][$key]; |
|
446 | - $dirforimages = '/'.$objectpage->pageurl; |
|
447 | - if ($grabimagesinto == 'root') $dirforimages=''; |
|
448 | - |
|
449 | - // Define $filetosave and $filename |
|
450 | - $filetosave = $conf->medias->multidir_output[$conf->entity].'/image/'.$object->ref.$dirforimages.(preg_match('/^\//', $regs[2][$key])?'':'/').$regs[2][$key]; |
|
451 | - if (preg_match('/^http/', $regs[2][$key])) |
|
452 | - { |
|
453 | - $urltograbbis = $regs[2][$key]; |
|
454 | - $linkwithoutdomain = preg_replace('/^https?:\/\/[^\/]+\//i', '', $regs[2][$key]); |
|
455 | - $filetosave = $conf->medias->multidir_output[$conf->entity].'/image/'.$object->ref.$dirforimages.(preg_match('/^\//', $linkwithoutdomain)?'':'/').$linkwithoutdomain; |
|
456 | - } |
|
457 | - $filename = 'image/'.$object->ref.$dirforimages.(preg_match('/^\//', $linkwithoutdomain)?'':'/').$linkwithoutdomain; |
|
458 | - |
|
459 | - // Clean the aa/bb/../cc into aa/cc |
|
460 | - $filetosave = preg_replace('/\/[^\/]+\/\.\./', '', $filetosave); |
|
461 | - $filename = preg_replace('/\/[^\/]+\/\.\./', '', $filename); |
|
462 | - |
|
463 | - //var_dump($filetosave); |
|
464 | - //var_dump($filename); |
|
465 | - //exit; |
|
466 | - |
|
467 | - if (empty($alreadygrabbed[$urltograbbis])) |
|
468 | - { |
|
469 | - if ($grabimages) |
|
470 | - { |
|
471 | - $tmpgeturl = getURLContent($urltograbbis); |
|
472 | - if ($tmpgeturl['curl_error_no']) |
|
473 | - { |
|
474 | - $error++; |
|
475 | - setEventMessages('Error getting '.$urltograbbis.': '.$tmpgeturl['curl_error_msg'], null, 'errors'); |
|
476 | - $action='create'; |
|
477 | - } |
|
478 | - elseif ($tmpgeturl['http_code'] != '200') |
|
479 | - { |
|
480 | - $error++; |
|
481 | - setEventMessages('Error getting '.$urltograbbis.': '.$tmpgeturl['http_code'], null, 'errors'); |
|
482 | - $action='create'; |
|
483 | - } |
|
484 | - else |
|
485 | - { |
|
486 | - $alreadygrabbed[$urltograbbis]=1; // Track that file was alreay grabbed. |
|
487 | - |
|
488 | - dol_mkdir(dirname($filetosave)); |
|
489 | - |
|
490 | - $fp = fopen($filetosave, "w"); |
|
491 | - fputs($fp, $tmpgeturl['content']); |
|
492 | - fclose($fp); |
|
493 | - if (! empty($conf->global->MAIN_UMASK)) |
|
494 | - @chmod($filetosave, octdec($conf->global->MAIN_UMASK)); |
|
495 | - } |
|
496 | - } |
|
497 | - } |
|
498 | - |
|
499 | - if ($modifylinks) |
|
500 | - { |
|
501 | - $tmp = preg_replace('/'.preg_quote($regs[0][$key],'/').'/i', '<img'.$regs[1][$key].'src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=medias&file='.$filename.'"'.$regs[3][$key].'>', $tmp); |
|
502 | - } |
|
503 | - } |
|
504 | - |
|
505 | - // Search X in "background...url(X)" |
|
506 | - preg_match_all('/background([^\.\/\(;]+)url\([\"\']?([^\)\"\']*)[\"\']?\)/i', $tmp, $regs); |
|
507 | - |
|
508 | - foreach ($regs[0] as $key => $val) |
|
509 | - { |
|
510 | - if (preg_match('/^data:image/i', $regs[2][$key])) continue; // We do nothing for such images |
|
511 | - |
|
512 | - if (preg_match('/^\//', $regs[2][$key])) |
|
513 | - { |
|
514 | - $urltograbdirrootwithoutslash = getRootURLFromURL($urltograb); |
|
515 | - $urltograbbis = $urltograbdirrootwithoutslash.$regs[2][$key]; // We use dirroot |
|
516 | - } |
|
517 | - else |
|
518 | - { |
|
519 | - $urltograbbis = $urltograb.'/'.$regs[2][$key]; // We use dir of grabbed file |
|
520 | - } |
|
521 | - |
|
522 | - $linkwithoutdomain = $regs[2][$key]; |
|
523 | - |
|
524 | - $dirforimages = '/'.$objectpage->pageurl; |
|
525 | - if ($grabimagesinto == 'root') $dirforimages=''; |
|
526 | - |
|
527 | - $filetosave = $conf->medias->multidir_output[$conf->entity].'/image/'.$object->ref.$dirforimages.(preg_match('/^\//', $regs[2][$key])?'':'/').$regs[2][$key]; |
|
528 | - |
|
529 | - if (preg_match('/^http/', $regs[2][$key])) |
|
530 | - { |
|
531 | - $urltograbbis = $regs[2][$key]; |
|
532 | - $linkwithoutdomain = preg_replace('/^https?:\/\/[^\/]+\//i', '', $regs[2][$key]); |
|
533 | - $filetosave = $conf->medias->multidir_output[$conf->entity].'/image/'.$object->ref.$dirforimages.(preg_match('/^\//', $linkwithoutdomain)?'':'/').$linkwithoutdomain; |
|
534 | - } |
|
535 | - |
|
536 | - $filename = 'image/'.$object->ref.$dirforimages.(preg_match('/^\//', $linkwithoutdomain)?'':'/').$linkwithoutdomain; |
|
537 | - |
|
538 | - // Clean the aa/bb/../cc into aa/cc |
|
539 | - $filetosave = preg_replace('/\/[^\/]+\/\.\./', '', $filetosave); |
|
540 | - $filename = preg_replace('/\/[^\/]+\/\.\./', '', $filename); |
|
541 | - |
|
542 | - //var_dump($filetosave); |
|
543 | - //var_dump($filename); |
|
544 | - //exit; |
|
545 | - |
|
546 | - if (empty($alreadygrabbed[$urltograbbis])) |
|
547 | - { |
|
548 | - if ($grabimages) |
|
549 | - { |
|
550 | - $tmpgeturl = getURLContent($urltograbbis); |
|
551 | - if ($tmpgeturl['curl_error_no']) |
|
552 | - { |
|
553 | - $error++; |
|
554 | - setEventMessages('Error getting '.$urltograbbis.': '.$tmpgeturl['curl_error_msg'], null, 'errors'); |
|
555 | - $action='create'; |
|
556 | - } |
|
557 | - elseif ($tmpgeturl['http_code'] != '200') |
|
558 | - { |
|
559 | - $error++; |
|
560 | - setEventMessages('Error getting '.$urltograbbis.': '.$tmpgeturl['http_code'], null, 'errors'); |
|
561 | - $action='create'; |
|
562 | - } |
|
563 | - else |
|
564 | - { |
|
565 | - $alreadygrabbed[$urltograbbis]=1; // Track that file was alreay grabbed. |
|
566 | - |
|
567 | - dol_mkdir(dirname($filetosave)); |
|
568 | - |
|
569 | - $fp = fopen($filetosave, "w"); |
|
570 | - fputs($fp, $tmpgeturl['content']); |
|
571 | - fclose($fp); |
|
572 | - if (! empty($conf->global->MAIN_UMASK)) |
|
573 | - @chmod($filetosave, octdec($conf->global->MAIN_UMASK)); |
|
574 | - } |
|
575 | - } |
|
576 | - } |
|
577 | - |
|
578 | - if ($modifylinks) |
|
579 | - { |
|
580 | - $tmp = preg_replace('/'.preg_quote($regs[0][$key],'/').'/i', 'background'.$regs[1][$key].'url("'.DOL_URL_ROOT.'/viewimage.php?modulepart=medias&file='.$filename.'")', $tmp); |
|
581 | - } |
|
582 | - } |
|
417 | + global $conf; |
|
418 | + |
|
419 | + $error=0; |
|
420 | + |
|
421 | + dol_syslog("Call getAllImages with grabimagesinto=".$grabimagesinto); |
|
422 | + |
|
423 | + $alreadygrabbed=array(); |
|
424 | + |
|
425 | + if (preg_match('/\/$/', $urltograb)) $urltograb.='.'; |
|
426 | + $urltograb = dirname($urltograb); // So urltograb is now http://www.nltechno.com or http://www.nltechno.com/dir1 |
|
427 | + |
|
428 | + // Search X in "img...src=X" |
|
429 | + preg_match_all('/<img([^\.\/]+)src="([^>"]+)"([^>]*)>/i', $tmp, $regs); |
|
430 | + |
|
431 | + foreach ($regs[0] as $key => $val) |
|
432 | + { |
|
433 | + if (preg_match('/^data:image/i', $regs[2][$key])) continue; // We do nothing for such images |
|
434 | + |
|
435 | + if (preg_match('/^\//', $regs[2][$key])) |
|
436 | + { |
|
437 | + $urltograbdirrootwithoutslash = getRootURLFromURL($urltograb); |
|
438 | + $urltograbbis = $urltograbdirrootwithoutslash.$regs[2][$key]; // We use dirroot |
|
439 | + } |
|
440 | + else |
|
441 | + { |
|
442 | + $urltograbbis = $urltograb.'/'.$regs[2][$key]; // We use dir of grabbed file |
|
443 | + } |
|
444 | + |
|
445 | + $linkwithoutdomain = $regs[2][$key]; |
|
446 | + $dirforimages = '/'.$objectpage->pageurl; |
|
447 | + if ($grabimagesinto == 'root') $dirforimages=''; |
|
448 | + |
|
449 | + // Define $filetosave and $filename |
|
450 | + $filetosave = $conf->medias->multidir_output[$conf->entity].'/image/'.$object->ref.$dirforimages.(preg_match('/^\//', $regs[2][$key])?'':'/').$regs[2][$key]; |
|
451 | + if (preg_match('/^http/', $regs[2][$key])) |
|
452 | + { |
|
453 | + $urltograbbis = $regs[2][$key]; |
|
454 | + $linkwithoutdomain = preg_replace('/^https?:\/\/[^\/]+\//i', '', $regs[2][$key]); |
|
455 | + $filetosave = $conf->medias->multidir_output[$conf->entity].'/image/'.$object->ref.$dirforimages.(preg_match('/^\//', $linkwithoutdomain)?'':'/').$linkwithoutdomain; |
|
456 | + } |
|
457 | + $filename = 'image/'.$object->ref.$dirforimages.(preg_match('/^\//', $linkwithoutdomain)?'':'/').$linkwithoutdomain; |
|
458 | + |
|
459 | + // Clean the aa/bb/../cc into aa/cc |
|
460 | + $filetosave = preg_replace('/\/[^\/]+\/\.\./', '', $filetosave); |
|
461 | + $filename = preg_replace('/\/[^\/]+\/\.\./', '', $filename); |
|
462 | + |
|
463 | + //var_dump($filetosave); |
|
464 | + //var_dump($filename); |
|
465 | + //exit; |
|
466 | + |
|
467 | + if (empty($alreadygrabbed[$urltograbbis])) |
|
468 | + { |
|
469 | + if ($grabimages) |
|
470 | + { |
|
471 | + $tmpgeturl = getURLContent($urltograbbis); |
|
472 | + if ($tmpgeturl['curl_error_no']) |
|
473 | + { |
|
474 | + $error++; |
|
475 | + setEventMessages('Error getting '.$urltograbbis.': '.$tmpgeturl['curl_error_msg'], null, 'errors'); |
|
476 | + $action='create'; |
|
477 | + } |
|
478 | + elseif ($tmpgeturl['http_code'] != '200') |
|
479 | + { |
|
480 | + $error++; |
|
481 | + setEventMessages('Error getting '.$urltograbbis.': '.$tmpgeturl['http_code'], null, 'errors'); |
|
482 | + $action='create'; |
|
483 | + } |
|
484 | + else |
|
485 | + { |
|
486 | + $alreadygrabbed[$urltograbbis]=1; // Track that file was alreay grabbed. |
|
487 | + |
|
488 | + dol_mkdir(dirname($filetosave)); |
|
489 | + |
|
490 | + $fp = fopen($filetosave, "w"); |
|
491 | + fputs($fp, $tmpgeturl['content']); |
|
492 | + fclose($fp); |
|
493 | + if (! empty($conf->global->MAIN_UMASK)) |
|
494 | + @chmod($filetosave, octdec($conf->global->MAIN_UMASK)); |
|
495 | + } |
|
496 | + } |
|
497 | + } |
|
498 | + |
|
499 | + if ($modifylinks) |
|
500 | + { |
|
501 | + $tmp = preg_replace('/'.preg_quote($regs[0][$key],'/').'/i', '<img'.$regs[1][$key].'src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=medias&file='.$filename.'"'.$regs[3][$key].'>', $tmp); |
|
502 | + } |
|
503 | + } |
|
504 | + |
|
505 | + // Search X in "background...url(X)" |
|
506 | + preg_match_all('/background([^\.\/\(;]+)url\([\"\']?([^\)\"\']*)[\"\']?\)/i', $tmp, $regs); |
|
507 | + |
|
508 | + foreach ($regs[0] as $key => $val) |
|
509 | + { |
|
510 | + if (preg_match('/^data:image/i', $regs[2][$key])) continue; // We do nothing for such images |
|
511 | + |
|
512 | + if (preg_match('/^\//', $regs[2][$key])) |
|
513 | + { |
|
514 | + $urltograbdirrootwithoutslash = getRootURLFromURL($urltograb); |
|
515 | + $urltograbbis = $urltograbdirrootwithoutslash.$regs[2][$key]; // We use dirroot |
|
516 | + } |
|
517 | + else |
|
518 | + { |
|
519 | + $urltograbbis = $urltograb.'/'.$regs[2][$key]; // We use dir of grabbed file |
|
520 | + } |
|
521 | + |
|
522 | + $linkwithoutdomain = $regs[2][$key]; |
|
523 | + |
|
524 | + $dirforimages = '/'.$objectpage->pageurl; |
|
525 | + if ($grabimagesinto == 'root') $dirforimages=''; |
|
526 | + |
|
527 | + $filetosave = $conf->medias->multidir_output[$conf->entity].'/image/'.$object->ref.$dirforimages.(preg_match('/^\//', $regs[2][$key])?'':'/').$regs[2][$key]; |
|
528 | + |
|
529 | + if (preg_match('/^http/', $regs[2][$key])) |
|
530 | + { |
|
531 | + $urltograbbis = $regs[2][$key]; |
|
532 | + $linkwithoutdomain = preg_replace('/^https?:\/\/[^\/]+\//i', '', $regs[2][$key]); |
|
533 | + $filetosave = $conf->medias->multidir_output[$conf->entity].'/image/'.$object->ref.$dirforimages.(preg_match('/^\//', $linkwithoutdomain)?'':'/').$linkwithoutdomain; |
|
534 | + } |
|
535 | + |
|
536 | + $filename = 'image/'.$object->ref.$dirforimages.(preg_match('/^\//', $linkwithoutdomain)?'':'/').$linkwithoutdomain; |
|
537 | + |
|
538 | + // Clean the aa/bb/../cc into aa/cc |
|
539 | + $filetosave = preg_replace('/\/[^\/]+\/\.\./', '', $filetosave); |
|
540 | + $filename = preg_replace('/\/[^\/]+\/\.\./', '', $filename); |
|
541 | + |
|
542 | + //var_dump($filetosave); |
|
543 | + //var_dump($filename); |
|
544 | + //exit; |
|
545 | + |
|
546 | + if (empty($alreadygrabbed[$urltograbbis])) |
|
547 | + { |
|
548 | + if ($grabimages) |
|
549 | + { |
|
550 | + $tmpgeturl = getURLContent($urltograbbis); |
|
551 | + if ($tmpgeturl['curl_error_no']) |
|
552 | + { |
|
553 | + $error++; |
|
554 | + setEventMessages('Error getting '.$urltograbbis.': '.$tmpgeturl['curl_error_msg'], null, 'errors'); |
|
555 | + $action='create'; |
|
556 | + } |
|
557 | + elseif ($tmpgeturl['http_code'] != '200') |
|
558 | + { |
|
559 | + $error++; |
|
560 | + setEventMessages('Error getting '.$urltograbbis.': '.$tmpgeturl['http_code'], null, 'errors'); |
|
561 | + $action='create'; |
|
562 | + } |
|
563 | + else |
|
564 | + { |
|
565 | + $alreadygrabbed[$urltograbbis]=1; // Track that file was alreay grabbed. |
|
566 | + |
|
567 | + dol_mkdir(dirname($filetosave)); |
|
568 | + |
|
569 | + $fp = fopen($filetosave, "w"); |
|
570 | + fputs($fp, $tmpgeturl['content']); |
|
571 | + fclose($fp); |
|
572 | + if (! empty($conf->global->MAIN_UMASK)) |
|
573 | + @chmod($filetosave, octdec($conf->global->MAIN_UMASK)); |
|
574 | + } |
|
575 | + } |
|
576 | + } |
|
577 | + |
|
578 | + if ($modifylinks) |
|
579 | + { |
|
580 | + $tmp = preg_replace('/'.preg_quote($regs[0][$key],'/').'/i', 'background'.$regs[1][$key].'url("'.DOL_URL_ROOT.'/viewimage.php?modulepart=medias&file='.$filename.'")', $tmp); |
|
581 | + } |
|
582 | + } |
|
583 | 583 | } |
584 | 584 | |
585 | 585 | |
@@ -592,21 +592,21 @@ discard block |
||
592 | 592 | */ |
593 | 593 | function dolSaveMasterFile($filemaster) |
594 | 594 | { |
595 | - global $conf; |
|
595 | + global $conf; |
|
596 | 596 | |
597 | - // Now generate the master.inc.php page |
|
598 | - dol_syslog("We regenerate the master file"); |
|
599 | - dol_delete_file($filemaster); |
|
597 | + // Now generate the master.inc.php page |
|
598 | + dol_syslog("We regenerate the master file"); |
|
599 | + dol_delete_file($filemaster); |
|
600 | 600 | |
601 | - $mastercontent = '<?php'."\n"; |
|
602 | - $mastercontent.= '// File generated to link to the master file - DO NOT MODIFY - It is just an include'."\n"; |
|
603 | - $mastercontent.= "if (! defined('USEDOLIBARRSERVER') && ! defined('USEDOLIBARREDITOR')) require_once '".DOL_DOCUMENT_ROOT."/master.inc.php';\n"; |
|
604 | - $mastercontent.= '?>'."\n"; |
|
605 | - $result = file_put_contents($filemaster, $mastercontent); |
|
606 | - if (! empty($conf->global->MAIN_UMASK)) |
|
607 | - @chmod($filemaster, octdec($conf->global->MAIN_UMASK)); |
|
601 | + $mastercontent = '<?php'."\n"; |
|
602 | + $mastercontent.= '// File generated to link to the master file - DO NOT MODIFY - It is just an include'."\n"; |
|
603 | + $mastercontent.= "if (! defined('USEDOLIBARRSERVER') && ! defined('USEDOLIBARREDITOR')) require_once '".DOL_DOCUMENT_ROOT."/master.inc.php';\n"; |
|
604 | + $mastercontent.= '?>'."\n"; |
|
605 | + $result = file_put_contents($filemaster, $mastercontent); |
|
606 | + if (! empty($conf->global->MAIN_UMASK)) |
|
607 | + @chmod($filemaster, octdec($conf->global->MAIN_UMASK)); |
|
608 | 608 | |
609 | - return $result; |
|
609 | + return $result; |
|
610 | 610 | } |
611 | 611 | |
612 | 612 | /** |
@@ -619,23 +619,23 @@ discard block |
||
619 | 619 | */ |
620 | 620 | function dolSavePageAlias($filealias, $object, $objectpage) |
621 | 621 | { |
622 | - global $conf; |
|
623 | - |
|
624 | - // Now create the .tpl file (duplicate code with actions updatesource or updatecontent but we need this to save new header) |
|
625 | - dol_syslog("We regenerate the alias page filealias=".$filealias); |
|
626 | - |
|
627 | - $aliascontent = '<?php'."\n"; |
|
628 | - $aliascontent.= "// File generated to wrap the alias page - DO NOT MODIFY - It is just a wrapper to real page\n"; |
|
629 | - $aliascontent.= 'global $dolibarr_main_data_root;'."\n"; |
|
630 | - $aliascontent.= 'if (empty($dolibarr_main_data_root)) require \'./page'.$objectpage->id.'.tpl.php\'; '; |
|
631 | - $aliascontent.= 'else require $dolibarr_main_data_root.\'/website/\'.$website->ref.\'/page'.$objectpage->id.'.tpl.php\';'."\n"; |
|
632 | - $aliascontent.= '?>'."\n"; |
|
633 | - $result = file_put_contents($filealias, $aliascontent); |
|
634 | - if (! empty($conf->global->MAIN_UMASK)) { |
|
622 | + global $conf; |
|
623 | + |
|
624 | + // Now create the .tpl file (duplicate code with actions updatesource or updatecontent but we need this to save new header) |
|
625 | + dol_syslog("We regenerate the alias page filealias=".$filealias); |
|
626 | + |
|
627 | + $aliascontent = '<?php'."\n"; |
|
628 | + $aliascontent.= "// File generated to wrap the alias page - DO NOT MODIFY - It is just a wrapper to real page\n"; |
|
629 | + $aliascontent.= 'global $dolibarr_main_data_root;'."\n"; |
|
630 | + $aliascontent.= 'if (empty($dolibarr_main_data_root)) require \'./page'.$objectpage->id.'.tpl.php\'; '; |
|
631 | + $aliascontent.= 'else require $dolibarr_main_data_root.\'/website/\'.$website->ref.\'/page'.$objectpage->id.'.tpl.php\';'."\n"; |
|
632 | + $aliascontent.= '?>'."\n"; |
|
633 | + $result = file_put_contents($filealias, $aliascontent); |
|
634 | + if (! empty($conf->global->MAIN_UMASK)) { |
|
635 | 635 | @chmod($filealias, octdec($conf->global->MAIN_UMASK)); |
636 | 636 | } |
637 | 637 | |
638 | - return ($result?true:false); |
|
638 | + return ($result?true:false); |
|
639 | 639 | } |
640 | 640 | |
641 | 641 | |
@@ -649,60 +649,60 @@ discard block |
||
649 | 649 | */ |
650 | 650 | function dolSavePageContent($filetpl, $object, $objectpage) |
651 | 651 | { |
652 | - global $conf; |
|
653 | - |
|
654 | - // Now create the .tpl file (duplicate code with actions updatesource or updatecontent but we need this to save new header) |
|
655 | - dol_syslog("We regenerate the tpl page filetpl=".$filetpl); |
|
656 | - |
|
657 | - dol_delete_file($filetpl); |
|
658 | - |
|
659 | - $shortlangcode = ''; |
|
660 | - if ($objectpage->lang) $shortlangcode=preg_replace('/[_-].*$/', '', $objectpage->lang); // en_US or en-US -> en |
|
661 | - |
|
662 | - $tplcontent =''; |
|
663 | - $tplcontent.= "<?php // BEGIN PHP\n"; |
|
664 | - $tplcontent.= '$websitekey=basename(dirname(__FILE__)); if (empty($websitepagefile)) $websitepagefile=__FILE__;'."\n"; |
|
665 | - $tplcontent.= "if (! defined('USEDOLIBARRSERVER') && ! defined('USEDOLIBARREDITOR')) { require_once './master.inc.php'; } // Not already loaded"."\n"; |
|
666 | - $tplcontent.= "require_once DOL_DOCUMENT_ROOT.'/core/lib/website.lib.php';\n"; |
|
667 | - $tplcontent.= "require_once DOL_DOCUMENT_ROOT.'/core/website.inc.php';\n"; |
|
668 | - $tplcontent.= "ob_start();\n"; |
|
669 | - $tplcontent.= "// END PHP ?>\n"; |
|
670 | - $tplcontent.= '<html'.($shortlangcode ? ' lang="'.$shortlangcode.'"':'').'>'."\n"; |
|
671 | - $tplcontent.= '<head>'."\n"; |
|
672 | - $tplcontent.= '<title>'.dol_string_nohtmltag($objectpage->title, 0, 'UTF-8').'</title>'."\n"; |
|
673 | - $tplcontent.= '<meta charset="UTF-8">'."\n"; |
|
674 | - $tplcontent.= '<meta http-equiv="content-type" content="text/html; charset=utf-8" />'."\n"; |
|
675 | - $tplcontent.= '<meta name="robots" content="index, follow" />'."\n"; |
|
676 | - $tplcontent.= '<meta name="viewport" content="width=device-width, initial-scale=1.0">'."\n"; |
|
677 | - $tplcontent.= '<meta name="keywords" content="'.dol_string_nohtmltag($objectpage->keywords).'" />'."\n"; |
|
678 | - $tplcontent.= '<meta name="title" content="'.dol_string_nohtmltag($objectpage->title, 0, 'UTF-8').'" />'."\n"; |
|
679 | - $tplcontent.= '<meta name="description" content="'.dol_string_nohtmltag($objectpage->description, 0, 'UTF-8').'" />'."\n"; |
|
680 | - $tplcontent.= '<meta name="generator" content="'.DOL_APPLICATION_TITLE.' '.DOL_VERSION.' (https://www.dolibarr.org)" />'."\n"; |
|
681 | - $tplcontent.= '<link href="/'.(($objectpage->id == $object->fk_default_home) ? '' : ($objectpage->pageurl.'.php')).'" rel="canonical" />'."\n"; |
|
682 | - $tplcontent.= '<!-- Include link to CSS file -->'."\n"; |
|
683 | - $tplcontent.= '<link rel="stylesheet" href="styles.css.php?website=<?php echo $websitekey; ?>" type="text/css" />'."\n"; |
|
684 | - $tplcontent.= '<!-- Include HTML header from common file -->'."\n"; |
|
685 | - $tplcontent.= '<?php print preg_replace(\'/<\/?html>/ims\', \'\', file_get_contents(DOL_DATA_ROOT."/website/".$websitekey."/htmlheader.html")); ?>'."\n"; |
|
686 | - $tplcontent.= '<!-- Include HTML header from page header block -->'."\n"; |
|
687 | - $tplcontent.= preg_replace('/<\/?html>/ims', '', $objectpage->htmlheader)."\n"; |
|
688 | - $tplcontent.= '</head>'."\n"; |
|
689 | - |
|
690 | - $tplcontent.= '<!-- File generated by Dolibarr website module editor -->'."\n"; |
|
691 | - $tplcontent.= '<body id="bodywebsite" class="bodywebsite">'."\n"; |
|
692 | - $tplcontent.= $objectpage->content."\n"; |
|
693 | - $tplcontent.= '</body>'."\n"; |
|
694 | - $tplcontent.= '</html>'."\n"; |
|
695 | - |
|
696 | - $tplcontent.= '<?php // BEGIN PHP'."\n"; |
|
697 | - $tplcontent.= '$tmp = ob_get_contents(); ob_end_clean(); dolWebsiteOutput($tmp);'."\n"; |
|
698 | - $tplcontent.= "// END PHP ?>"."\n"; |
|
699 | - |
|
700 | - //var_dump($filetpl);exit; |
|
701 | - $result = file_put_contents($filetpl, $tplcontent); |
|
702 | - if (! empty($conf->global->MAIN_UMASK)) |
|
703 | - @chmod($filetpl, octdec($conf->global->MAIN_UMASK)); |
|
704 | - |
|
705 | - return $result; |
|
652 | + global $conf; |
|
653 | + |
|
654 | + // Now create the .tpl file (duplicate code with actions updatesource or updatecontent but we need this to save new header) |
|
655 | + dol_syslog("We regenerate the tpl page filetpl=".$filetpl); |
|
656 | + |
|
657 | + dol_delete_file($filetpl); |
|
658 | + |
|
659 | + $shortlangcode = ''; |
|
660 | + if ($objectpage->lang) $shortlangcode=preg_replace('/[_-].*$/', '', $objectpage->lang); // en_US or en-US -> en |
|
661 | + |
|
662 | + $tplcontent =''; |
|
663 | + $tplcontent.= "<?php // BEGIN PHP\n"; |
|
664 | + $tplcontent.= '$websitekey=basename(dirname(__FILE__)); if (empty($websitepagefile)) $websitepagefile=__FILE__;'."\n"; |
|
665 | + $tplcontent.= "if (! defined('USEDOLIBARRSERVER') && ! defined('USEDOLIBARREDITOR')) { require_once './master.inc.php'; } // Not already loaded"."\n"; |
|
666 | + $tplcontent.= "require_once DOL_DOCUMENT_ROOT.'/core/lib/website.lib.php';\n"; |
|
667 | + $tplcontent.= "require_once DOL_DOCUMENT_ROOT.'/core/website.inc.php';\n"; |
|
668 | + $tplcontent.= "ob_start();\n"; |
|
669 | + $tplcontent.= "// END PHP ?>\n"; |
|
670 | + $tplcontent.= '<html'.($shortlangcode ? ' lang="'.$shortlangcode.'"':'').'>'."\n"; |
|
671 | + $tplcontent.= '<head>'."\n"; |
|
672 | + $tplcontent.= '<title>'.dol_string_nohtmltag($objectpage->title, 0, 'UTF-8').'</title>'."\n"; |
|
673 | + $tplcontent.= '<meta charset="UTF-8">'."\n"; |
|
674 | + $tplcontent.= '<meta http-equiv="content-type" content="text/html; charset=utf-8" />'."\n"; |
|
675 | + $tplcontent.= '<meta name="robots" content="index, follow" />'."\n"; |
|
676 | + $tplcontent.= '<meta name="viewport" content="width=device-width, initial-scale=1.0">'."\n"; |
|
677 | + $tplcontent.= '<meta name="keywords" content="'.dol_string_nohtmltag($objectpage->keywords).'" />'."\n"; |
|
678 | + $tplcontent.= '<meta name="title" content="'.dol_string_nohtmltag($objectpage->title, 0, 'UTF-8').'" />'."\n"; |
|
679 | + $tplcontent.= '<meta name="description" content="'.dol_string_nohtmltag($objectpage->description, 0, 'UTF-8').'" />'."\n"; |
|
680 | + $tplcontent.= '<meta name="generator" content="'.DOL_APPLICATION_TITLE.' '.DOL_VERSION.' (https://www.dolibarr.org)" />'."\n"; |
|
681 | + $tplcontent.= '<link href="/'.(($objectpage->id == $object->fk_default_home) ? '' : ($objectpage->pageurl.'.php')).'" rel="canonical" />'."\n"; |
|
682 | + $tplcontent.= '<!-- Include link to CSS file -->'."\n"; |
|
683 | + $tplcontent.= '<link rel="stylesheet" href="styles.css.php?website=<?php echo $websitekey; ?>" type="text/css" />'."\n"; |
|
684 | + $tplcontent.= '<!-- Include HTML header from common file -->'."\n"; |
|
685 | + $tplcontent.= '<?php print preg_replace(\'/<\/?html>/ims\', \'\', file_get_contents(DOL_DATA_ROOT."/website/".$websitekey."/htmlheader.html")); ?>'."\n"; |
|
686 | + $tplcontent.= '<!-- Include HTML header from page header block -->'."\n"; |
|
687 | + $tplcontent.= preg_replace('/<\/?html>/ims', '', $objectpage->htmlheader)."\n"; |
|
688 | + $tplcontent.= '</head>'."\n"; |
|
689 | + |
|
690 | + $tplcontent.= '<!-- File generated by Dolibarr website module editor -->'."\n"; |
|
691 | + $tplcontent.= '<body id="bodywebsite" class="bodywebsite">'."\n"; |
|
692 | + $tplcontent.= $objectpage->content."\n"; |
|
693 | + $tplcontent.= '</body>'."\n"; |
|
694 | + $tplcontent.= '</html>'."\n"; |
|
695 | + |
|
696 | + $tplcontent.= '<?php // BEGIN PHP'."\n"; |
|
697 | + $tplcontent.= '$tmp = ob_get_contents(); ob_end_clean(); dolWebsiteOutput($tmp);'."\n"; |
|
698 | + $tplcontent.= "// END PHP ?>"."\n"; |
|
699 | + |
|
700 | + //var_dump($filetpl);exit; |
|
701 | + $result = file_put_contents($filetpl, $tplcontent); |
|
702 | + if (! empty($conf->global->MAIN_UMASK)) |
|
703 | + @chmod($filetpl, octdec($conf->global->MAIN_UMASK)); |
|
704 | + |
|
705 | + return $result; |
|
706 | 706 | } |
707 | 707 | |
708 | 708 | |
@@ -717,38 +717,38 @@ discard block |
||
717 | 717 | */ |
718 | 718 | function dolSaveIndexPage($pathofwebsite, $fileindex, $filetpl, $filewrapper) |
719 | 719 | { |
720 | - global $conf; |
|
721 | - |
|
722 | - $result1=false; |
|
723 | - $result2=false; |
|
724 | - |
|
725 | - dol_mkdir($pathofwebsite); |
|
726 | - |
|
727 | - dol_delete_file($fileindex); |
|
728 | - $indexcontent = '<?php'."\n"; |
|
729 | - $indexcontent.= "// BEGIN PHP File generated to provide an index.php as Home Page or alias redirector - DO NOT MODIFY - It is just a generated wrapper.\n"; |
|
730 | - $indexcontent.= '$websitekey=basename(dirname(__FILE__)); if (empty($websitepagefile)) $websitepagefile=__FILE__;'."\n"; |
|
731 | - $indexcontent.= "if (! defined('USEDOLIBARRSERVER') && ! defined('USEDOLIBARREDITOR')) { require_once './master.inc.php'; } // Load master if not already loaded\n"; |
|
732 | - $indexcontent.= 'if (! empty($_GET[\'pageref\']) || ! empty($_GET[\'pagealiasalt\']) || ! empty($_GET[\'pageid\'])) {'."\n"; |
|
733 | - $indexcontent.= " require_once DOL_DOCUMENT_ROOT.'/core/lib/website.lib.php';\n"; |
|
734 | - $indexcontent.= " require_once DOL_DOCUMENT_ROOT.'/core/website.inc.php';\n"; |
|
735 | - $indexcontent.= ' redirectToContainer($_GET[\'pageref\'], $_GET[\'pagealiasalt\'], $_GET[\'pageid\']);'."\n"; |
|
736 | - $indexcontent.= "}\n"; |
|
737 | - $indexcontent.= "include_once './".basename($filetpl)."'\n"; |
|
738 | - $indexcontent.= '// END PHP ?>'."\n"; |
|
739 | - $result1 = file_put_contents($fileindex, $indexcontent); |
|
740 | - if (! empty($conf->global->MAIN_UMASK)) |
|
741 | - @chmod($fileindex, octdec($conf->global->MAIN_UMASK)); |
|
742 | - |
|
743 | - dol_delete_file($filewrapper); |
|
744 | - |
|
745 | - $wrappercontent=file_get_contents(DOL_DOCUMENT_ROOT.'/website/samples/wrapper.html'); |
|
746 | - |
|
747 | - $result2 = file_put_contents($filewrapper, $wrappercontent); |
|
748 | - if (! empty($conf->global->MAIN_UMASK)) |
|
749 | - @chmod($filewrapper, octdec($conf->global->MAIN_UMASK)); |
|
750 | - |
|
751 | - return ($result1 && $result2); |
|
720 | + global $conf; |
|
721 | + |
|
722 | + $result1=false; |
|
723 | + $result2=false; |
|
724 | + |
|
725 | + dol_mkdir($pathofwebsite); |
|
726 | + |
|
727 | + dol_delete_file($fileindex); |
|
728 | + $indexcontent = '<?php'."\n"; |
|
729 | + $indexcontent.= "// BEGIN PHP File generated to provide an index.php as Home Page or alias redirector - DO NOT MODIFY - It is just a generated wrapper.\n"; |
|
730 | + $indexcontent.= '$websitekey=basename(dirname(__FILE__)); if (empty($websitepagefile)) $websitepagefile=__FILE__;'."\n"; |
|
731 | + $indexcontent.= "if (! defined('USEDOLIBARRSERVER') && ! defined('USEDOLIBARREDITOR')) { require_once './master.inc.php'; } // Load master if not already loaded\n"; |
|
732 | + $indexcontent.= 'if (! empty($_GET[\'pageref\']) || ! empty($_GET[\'pagealiasalt\']) || ! empty($_GET[\'pageid\'])) {'."\n"; |
|
733 | + $indexcontent.= " require_once DOL_DOCUMENT_ROOT.'/core/lib/website.lib.php';\n"; |
|
734 | + $indexcontent.= " require_once DOL_DOCUMENT_ROOT.'/core/website.inc.php';\n"; |
|
735 | + $indexcontent.= ' redirectToContainer($_GET[\'pageref\'], $_GET[\'pagealiasalt\'], $_GET[\'pageid\']);'."\n"; |
|
736 | + $indexcontent.= "}\n"; |
|
737 | + $indexcontent.= "include_once './".basename($filetpl)."'\n"; |
|
738 | + $indexcontent.= '// END PHP ?>'."\n"; |
|
739 | + $result1 = file_put_contents($fileindex, $indexcontent); |
|
740 | + if (! empty($conf->global->MAIN_UMASK)) |
|
741 | + @chmod($fileindex, octdec($conf->global->MAIN_UMASK)); |
|
742 | + |
|
743 | + dol_delete_file($filewrapper); |
|
744 | + |
|
745 | + $wrappercontent=file_get_contents(DOL_DOCUMENT_ROOT.'/website/samples/wrapper.html'); |
|
746 | + |
|
747 | + $result2 = file_put_contents($filewrapper, $wrappercontent); |
|
748 | + if (! empty($conf->global->MAIN_UMASK)) |
|
749 | + @chmod($filewrapper, octdec($conf->global->MAIN_UMASK)); |
|
750 | + |
|
751 | + return ($result1 && $result2); |
|
752 | 752 | } |
753 | 753 | |
754 | 754 | |
@@ -761,22 +761,22 @@ discard block |
||
761 | 761 | */ |
762 | 762 | function dolSaveHtmlHeader($filehtmlheader, $htmlheadercontent) |
763 | 763 | { |
764 | - global $conf, $pathofwebsite; |
|
764 | + global $conf, $pathofwebsite; |
|
765 | 765 | |
766 | - dol_syslog("Save html header into ".$filehtmlheader); |
|
766 | + dol_syslog("Save html header into ".$filehtmlheader); |
|
767 | 767 | |
768 | - dol_mkdir($pathofwebsite); |
|
769 | - $result = file_put_contents($filehtmlheader, $htmlheadercontent); |
|
770 | - if (! empty($conf->global->MAIN_UMASK)) |
|
771 | - @chmod($filehtmlheader, octdec($conf->global->MAIN_UMASK)); |
|
768 | + dol_mkdir($pathofwebsite); |
|
769 | + $result = file_put_contents($filehtmlheader, $htmlheadercontent); |
|
770 | + if (! empty($conf->global->MAIN_UMASK)) |
|
771 | + @chmod($filehtmlheader, octdec($conf->global->MAIN_UMASK)); |
|
772 | 772 | |
773 | - if (! $result) |
|
774 | - { |
|
775 | - setEventMessages('Failed to write file '.$filehtmlheader, null, 'errors'); |
|
776 | - return false; |
|
777 | - } |
|
773 | + if (! $result) |
|
774 | + { |
|
775 | + setEventMessages('Failed to write file '.$filehtmlheader, null, 'errors'); |
|
776 | + return false; |
|
777 | + } |
|
778 | 778 | |
779 | - return true; |
|
779 | + return true; |
|
780 | 780 | } |
781 | 781 | |
782 | 782 | /** |
@@ -788,22 +788,22 @@ discard block |
||
788 | 788 | */ |
789 | 789 | function dolSaveCssFile($filecss, $csscontent) |
790 | 790 | { |
791 | - global $conf, $pathofwebsite; |
|
791 | + global $conf, $pathofwebsite; |
|
792 | 792 | |
793 | - dol_syslog("Save css file into ".$filecss); |
|
793 | + dol_syslog("Save css file into ".$filecss); |
|
794 | 794 | |
795 | - dol_mkdir($pathofwebsite); |
|
796 | - $result = file_put_contents($filecss, $csscontent); |
|
797 | - if (! empty($conf->global->MAIN_UMASK)) |
|
798 | - @chmod($filecss, octdec($conf->global->MAIN_UMASK)); |
|
795 | + dol_mkdir($pathofwebsite); |
|
796 | + $result = file_put_contents($filecss, $csscontent); |
|
797 | + if (! empty($conf->global->MAIN_UMASK)) |
|
798 | + @chmod($filecss, octdec($conf->global->MAIN_UMASK)); |
|
799 | 799 | |
800 | - if (! $result) |
|
801 | - { |
|
802 | - setEventMessages('Failed to write file '.$filecss, null, 'errors'); |
|
803 | - return false; |
|
804 | - } |
|
800 | + if (! $result) |
|
801 | + { |
|
802 | + setEventMessages('Failed to write file '.$filecss, null, 'errors'); |
|
803 | + return false; |
|
804 | + } |
|
805 | 805 | |
806 | - return true; |
|
806 | + return true; |
|
807 | 807 | } |
808 | 808 | |
809 | 809 | /** |
@@ -815,22 +815,22 @@ discard block |
||
815 | 815 | */ |
816 | 816 | function dolSaveJsFile($filejs, $jscontent) |
817 | 817 | { |
818 | - global $conf, $pathofwebsite; |
|
818 | + global $conf, $pathofwebsite; |
|
819 | 819 | |
820 | - dol_syslog("Save js file into ".$filejs); |
|
820 | + dol_syslog("Save js file into ".$filejs); |
|
821 | 821 | |
822 | - dol_mkdir($pathofwebsite); |
|
823 | - $result = file_put_contents($filejs, $jscontent); |
|
824 | - if (! empty($conf->global->MAIN_UMASK)) |
|
825 | - @chmod($filejs, octdec($conf->global->MAIN_UMASK)); |
|
822 | + dol_mkdir($pathofwebsite); |
|
823 | + $result = file_put_contents($filejs, $jscontent); |
|
824 | + if (! empty($conf->global->MAIN_UMASK)) |
|
825 | + @chmod($filejs, octdec($conf->global->MAIN_UMASK)); |
|
826 | 826 | |
827 | - if (! $result) |
|
828 | - { |
|
829 | - setEventMessages('Failed to write file '.$filejs, null, 'errors'); |
|
830 | - return false; |
|
831 | - } |
|
827 | + if (! $result) |
|
828 | + { |
|
829 | + setEventMessages('Failed to write file '.$filejs, null, 'errors'); |
|
830 | + return false; |
|
831 | + } |
|
832 | 832 | |
833 | - return true; |
|
833 | + return true; |
|
834 | 834 | } |
835 | 835 | |
836 | 836 | /** |
@@ -842,22 +842,22 @@ discard block |
||
842 | 842 | */ |
843 | 843 | function dolSaveRobotFile($filerobot, $robotcontent) |
844 | 844 | { |
845 | - global $conf, $pathofwebsite; |
|
845 | + global $conf, $pathofwebsite; |
|
846 | 846 | |
847 | - dol_syslog("Save robot file into ".$filerobot); |
|
847 | + dol_syslog("Save robot file into ".$filerobot); |
|
848 | 848 | |
849 | - dol_mkdir($pathofwebsite); |
|
850 | - $result = file_put_contents($filerobot, $robotcontent); |
|
851 | - if (! empty($conf->global->MAIN_UMASK)) |
|
852 | - @chmod($filerobot, octdec($conf->global->MAIN_UMASK)); |
|
849 | + dol_mkdir($pathofwebsite); |
|
850 | + $result = file_put_contents($filerobot, $robotcontent); |
|
851 | + if (! empty($conf->global->MAIN_UMASK)) |
|
852 | + @chmod($filerobot, octdec($conf->global->MAIN_UMASK)); |
|
853 | 853 | |
854 | - if (! $result) |
|
855 | - { |
|
856 | - setEventMessages('Failed to write file '.$filerobot, null, 'errors'); |
|
857 | - return false; |
|
858 | - } |
|
854 | + if (! $result) |
|
855 | + { |
|
856 | + setEventMessages('Failed to write file '.$filerobot, null, 'errors'); |
|
857 | + return false; |
|
858 | + } |
|
859 | 859 | |
860 | - return true; |
|
860 | + return true; |
|
861 | 861 | } |
862 | 862 | |
863 | 863 | /** |
@@ -869,20 +869,20 @@ discard block |
||
869 | 869 | */ |
870 | 870 | function dolSaveHtaccessFile($filehtaccess, $htaccess) |
871 | 871 | { |
872 | - global $conf, $pathofwebsite; |
|
872 | + global $conf, $pathofwebsite; |
|
873 | 873 | |
874 | - dol_syslog("Save htaccess file into ".$filehtaccess); |
|
874 | + dol_syslog("Save htaccess file into ".$filehtaccess); |
|
875 | 875 | |
876 | - dol_mkdir($pathofwebsite); |
|
877 | - $result = file_put_contents($filehtaccess, $htaccess); |
|
878 | - if (! empty($conf->global->MAIN_UMASK)) |
|
879 | - @chmod($filehtaccess, octdec($conf->global->MAIN_UMASK)); |
|
876 | + dol_mkdir($pathofwebsite); |
|
877 | + $result = file_put_contents($filehtaccess, $htaccess); |
|
878 | + if (! empty($conf->global->MAIN_UMASK)) |
|
879 | + @chmod($filehtaccess, octdec($conf->global->MAIN_UMASK)); |
|
880 | 880 | |
881 | - if (! $result) |
|
882 | - { |
|
883 | - setEventMessages('Failed to write file '.$filehtaccess, null, 'errors'); |
|
884 | - return false; |
|
885 | - } |
|
881 | + if (! $result) |
|
882 | + { |
|
883 | + setEventMessages('Failed to write file '.$filehtaccess, null, 'errors'); |
|
884 | + return false; |
|
885 | + } |
|
886 | 886 | |
887 | - return true; |
|
887 | + return true; |
|
888 | 888 | } |
@@ -31,28 +31,28 @@ discard block |
||
31 | 31 | */ |
32 | 32 | function supplier_proposal_prepare_head($object) |
33 | 33 | { |
34 | - global $db, $langs, $conf, $user; |
|
34 | + global $db, $langs, $conf, $user; |
|
35 | 35 | |
36 | - // Load translation files required by the page |
|
36 | + // Load translation files required by the page |
|
37 | 37 | $langs->loadLangs(array("supplier_proposal","compta")); |
38 | 38 | |
39 | - $h = 0; |
|
40 | - $head = array(); |
|
39 | + $h = 0; |
|
40 | + $head = array(); |
|
41 | 41 | |
42 | - $head[$h][0] = DOL_URL_ROOT.'/supplier_proposal/card.php?id='.$object->id; |
|
43 | - $head[$h][1] = $langs->trans('SupplierProposalCard'); |
|
44 | - $head[$h][2] = 'comm'; |
|
45 | - $h++; |
|
42 | + $head[$h][0] = DOL_URL_ROOT.'/supplier_proposal/card.php?id='.$object->id; |
|
43 | + $head[$h][1] = $langs->trans('SupplierProposalCard'); |
|
44 | + $head[$h][2] = 'comm'; |
|
45 | + $h++; |
|
46 | 46 | |
47 | - if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) |
|
48 | - { |
|
49 | - $nbContact = count($object->liste_contact(-1,'internal')) + count($object->liste_contact(-1,'external')); |
|
50 | - $head[$h][0] = DOL_URL_ROOT.'/supplier_proposal/contact.php?id='.$object->id; |
|
51 | - $head[$h][1] = $langs->trans('ContactsAddresses'); |
|
52 | - if ($nbContact > 0) $head[$h][1].= ' <span class="badge">'.$nbContact.'</span>'; |
|
53 | - $head[$h][2] = 'contact'; |
|
54 | - $h++; |
|
55 | - } |
|
47 | + if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) |
|
48 | + { |
|
49 | + $nbContact = count($object->liste_contact(-1,'internal')) + count($object->liste_contact(-1,'external')); |
|
50 | + $head[$h][0] = DOL_URL_ROOT.'/supplier_proposal/contact.php?id='.$object->id; |
|
51 | + $head[$h][1] = $langs->trans('ContactsAddresses'); |
|
52 | + if ($nbContact > 0) $head[$h][1].= ' <span class="badge">'.$nbContact.'</span>'; |
|
53 | + $head[$h][2] = 'contact'; |
|
54 | + $h++; |
|
55 | + } |
|
56 | 56 | |
57 | 57 | // Show more tabs from modules |
58 | 58 | // Entries must be declared in modules descriptor with line |
@@ -62,35 +62,35 @@ discard block |
||
62 | 62 | |
63 | 63 | if (empty($conf->global->MAIN_DISABLE_NOTES_TAB)) |
64 | 64 | { |
65 | - $nbNote = 0; |
|
65 | + $nbNote = 0; |
|
66 | 66 | if(!empty($object->note_private)) $nbNote++; |
67 | - if(!empty($object->note_public)) $nbNote++; |
|
68 | - $head[$h][0] = DOL_URL_ROOT.'/supplier_proposal/note.php?id='.$object->id; |
|
69 | - $head[$h][1] = $langs->trans('Notes'); |
|
70 | - if ($nbNote > 0) $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>'; |
|
71 | - $head[$h][2] = 'note'; |
|
72 | - $h++; |
|
67 | + if(!empty($object->note_public)) $nbNote++; |
|
68 | + $head[$h][0] = DOL_URL_ROOT.'/supplier_proposal/note.php?id='.$object->id; |
|
69 | + $head[$h][1] = $langs->trans('Notes'); |
|
70 | + if ($nbNote > 0) $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>'; |
|
71 | + $head[$h][2] = 'note'; |
|
72 | + $h++; |
|
73 | 73 | } |
74 | 74 | |
75 | - require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; |
|
75 | + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; |
|
76 | 76 | require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php'; |
77 | - $upload_dir = $conf->supplier_proposal->dir_output . "/" . dol_sanitizeFileName($object->ref); |
|
78 | - $nbFiles = count(dol_dir_list($upload_dir,'files',0,'','(\.meta|_preview.*\.png)$')); |
|
77 | + $upload_dir = $conf->supplier_proposal->dir_output . "/" . dol_sanitizeFileName($object->ref); |
|
78 | + $nbFiles = count(dol_dir_list($upload_dir,'files',0,'','(\.meta|_preview.*\.png)$')); |
|
79 | 79 | $nbLinks=Link::count($db, $object->element, $object->id); |
80 | - $head[$h][0] = DOL_URL_ROOT.'/supplier_proposal/document.php?id='.$object->id; |
|
81 | - $head[$h][1] = $langs->trans('Documents'); |
|
82 | - if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>'; |
|
83 | - $head[$h][2] = 'document'; |
|
84 | - $h++; |
|
80 | + $head[$h][0] = DOL_URL_ROOT.'/supplier_proposal/document.php?id='.$object->id; |
|
81 | + $head[$h][1] = $langs->trans('Documents'); |
|
82 | + if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>'; |
|
83 | + $head[$h][2] = 'document'; |
|
84 | + $h++; |
|
85 | 85 | |
86 | - $head[$h][0] = DOL_URL_ROOT.'/supplier_proposal/info.php?id='.$object->id; |
|
87 | - $head[$h][1] = $langs->trans('Info'); |
|
88 | - $head[$h][2] = 'info'; |
|
89 | - $h++; |
|
86 | + $head[$h][0] = DOL_URL_ROOT.'/supplier_proposal/info.php?id='.$object->id; |
|
87 | + $head[$h][1] = $langs->trans('Info'); |
|
88 | + $head[$h][2] = 'info'; |
|
89 | + $h++; |
|
90 | 90 | |
91 | - complete_head_from_modules($conf,$langs,$object,$head,$h,'supplier_proposal','remove'); |
|
91 | + complete_head_from_modules($conf,$langs,$object,$head,$h,'supplier_proposal','remove'); |
|
92 | 92 | |
93 | - return $head; |
|
93 | + return $head; |
|
94 | 94 | } |
95 | 95 | |
96 | 96 | /** |
@@ -100,24 +100,24 @@ discard block |
||
100 | 100 | */ |
101 | 101 | function supplier_proposal_admin_prepare_head() |
102 | 102 | { |
103 | - global $langs, $conf, $user; |
|
103 | + global $langs, $conf, $user; |
|
104 | 104 | |
105 | - $h = 0; |
|
106 | - $head = array(); |
|
105 | + $h = 0; |
|
106 | + $head = array(); |
|
107 | 107 | |
108 | - $head[$h][0] = DOL_URL_ROOT.'/admin/supplier_proposal.php'; |
|
109 | - $head[$h][1] = $langs->trans("Miscellaneous"); |
|
110 | - $head[$h][2] = 'general'; |
|
111 | - $h++; |
|
108 | + $head[$h][0] = DOL_URL_ROOT.'/admin/supplier_proposal.php'; |
|
109 | + $head[$h][1] = $langs->trans("Miscellaneous"); |
|
110 | + $head[$h][2] = 'general'; |
|
111 | + $h++; |
|
112 | 112 | |
113 | - // Show more tabs from modules |
|
114 | - // Entries must be declared in modules descriptor with line |
|
115 | - // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab |
|
116 | - // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab |
|
117 | - complete_head_from_modules($conf,$langs,null,$head,$h,'supplier_proposal_admin'); |
|
113 | + // Show more tabs from modules |
|
114 | + // Entries must be declared in modules descriptor with line |
|
115 | + // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab |
|
116 | + // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab |
|
117 | + complete_head_from_modules($conf,$langs,null,$head,$h,'supplier_proposal_admin'); |
|
118 | 118 | |
119 | - $head[$h][0] = DOL_URL_ROOT.'/supplier_proposal/admin/supplier_proposal_extrafields.php'; |
|
120 | - $head[$h][1] = $langs->trans("ExtraFields"); |
|
119 | + $head[$h][0] = DOL_URL_ROOT.'/supplier_proposal/admin/supplier_proposal_extrafields.php'; |
|
120 | + $head[$h][1] = $langs->trans("ExtraFields"); |
|
121 | 121 | $head[$h][2] = 'attributes'; |
122 | 122 | $h++; |
123 | 123 | |
@@ -126,9 +126,9 @@ discard block |
||
126 | 126 | $head[$h][2] = 'attributeslines'; |
127 | 127 | $h++; |
128 | 128 | |
129 | - complete_head_from_modules($conf,$langs,null,$head,$h,'supplier_proposal_admin','remove'); |
|
129 | + complete_head_from_modules($conf,$langs,null,$head,$h,'supplier_proposal_admin','remove'); |
|
130 | 130 | |
131 | - return $head; |
|
131 | + return $head; |
|
132 | 132 | } |
133 | 133 | |
134 | 134 |
@@ -98,8 +98,8 @@ discard block |
||
98 | 98 | } |
99 | 99 | else |
100 | 100 | { |
101 | - $tmp=0; |
|
102 | - dol_print_error('','PHP version must be 5.3+'); |
|
101 | + $tmp=0; |
|
102 | + dol_print_error('','PHP version must be 5.3+'); |
|
103 | 103 | } |
104 | 104 | $tz=round(($tmp<0?1:-1)*abs($tmp/3600)); |
105 | 105 | return $tz; |
@@ -116,29 +116,29 @@ discard block |
||
116 | 116 | */ |
117 | 117 | function dol_time_plus_duree($time, $duration_value, $duration_unit) |
118 | 118 | { |
119 | - global $conf; |
|
119 | + global $conf; |
|
120 | 120 | |
121 | - if ($duration_value == 0) return $time; |
|
122 | - if ($duration_unit == 'h') return $time + (3600*$duration_value); |
|
123 | - if ($duration_unit == 'w') return $time + (3600*24*7*$duration_value); |
|
121 | + if ($duration_value == 0) return $time; |
|
122 | + if ($duration_unit == 'h') return $time + (3600*$duration_value); |
|
123 | + if ($duration_unit == 'w') return $time + (3600*24*7*$duration_value); |
|
124 | 124 | |
125 | - $deltastring='P'; |
|
125 | + $deltastring='P'; |
|
126 | 126 | |
127 | - if ($duration_value > 0){ $deltastring.=abs($duration_value); $sub= false; } |
|
128 | - if ($duration_value < 0){ $deltastring.=abs($duration_value); $sub= true; } |
|
129 | - if ($duration_unit == 'd') { $deltastring.="D"; } |
|
130 | - if ($duration_unit == 'm') { $deltastring.="M"; } |
|
131 | - if ($duration_unit == 'y') { $deltastring.="Y"; } |
|
127 | + if ($duration_value > 0){ $deltastring.=abs($duration_value); $sub= false; } |
|
128 | + if ($duration_value < 0){ $deltastring.=abs($duration_value); $sub= true; } |
|
129 | + if ($duration_unit == 'd') { $deltastring.="D"; } |
|
130 | + if ($duration_unit == 'm') { $deltastring.="M"; } |
|
131 | + if ($duration_unit == 'y') { $deltastring.="Y"; } |
|
132 | 132 | |
133 | - $date = new DateTime(); |
|
134 | - if (! empty($conf->global->MAIN_DATE_IN_MEMORY_ARE_GMT)) $date->setTimezone(new DateTimeZone('UTC')); |
|
135 | - $date->setTimestamp($time); |
|
136 | - $interval = new DateInterval($deltastring); |
|
133 | + $date = new DateTime(); |
|
134 | + if (! empty($conf->global->MAIN_DATE_IN_MEMORY_ARE_GMT)) $date->setTimezone(new DateTimeZone('UTC')); |
|
135 | + $date->setTimestamp($time); |
|
136 | + $interval = new DateInterval($deltastring); |
|
137 | 137 | |
138 | - if($sub) $date->sub($interval); |
|
139 | - else $date->add( $interval ); |
|
138 | + if($sub) $date->sub($interval); |
|
139 | + else $date->add( $interval ); |
|
140 | 140 | |
141 | - return $date->getTimestamp(); |
|
141 | + return $date->getTimestamp(); |
|
142 | 142 | } |
143 | 143 | |
144 | 144 | |
@@ -153,8 +153,8 @@ discard block |
||
153 | 153 | */ |
154 | 154 | function convertTime2Seconds($iHours=0, $iMinutes=0, $iSeconds=0) |
155 | 155 | { |
156 | - $iResult=($iHours*3600)+($iMinutes*60)+$iSeconds; |
|
157 | - return $iResult; |
|
156 | + $iResult=($iHours*3600)+($iMinutes*60)+$iSeconds; |
|
157 | + return $iResult; |
|
158 | 158 | } |
159 | 159 | |
160 | 160 | |
@@ -180,33 +180,33 @@ discard block |
||
180 | 180 | */ |
181 | 181 | function convertSecondToTime($iSecond, $format='all', $lengthOfDay=86400, $lengthOfWeek=7) |
182 | 182 | { |
183 | - global $langs; |
|
183 | + global $langs; |
|
184 | 184 | |
185 | - if (empty($lengthOfDay)) $lengthOfDay = 86400; // 1 day = 24 hours |
|
185 | + if (empty($lengthOfDay)) $lengthOfDay = 86400; // 1 day = 24 hours |
|
186 | 186 | if (empty($lengthOfWeek)) $lengthOfWeek = 7; // 1 week = 7 days |
187 | 187 | |
188 | - if ($format == 'all' || $format == 'allwithouthour' || $format == 'allhour' || $format == 'allhourmin') |
|
189 | - { |
|
190 | - if ((int) $iSecond === 0) return '0'; // This is to avoid having 0 return a 12:00 AM for en_US |
|
188 | + if ($format == 'all' || $format == 'allwithouthour' || $format == 'allhour' || $format == 'allhourmin') |
|
189 | + { |
|
190 | + if ((int) $iSecond === 0) return '0'; // This is to avoid having 0 return a 12:00 AM for en_US |
|
191 | 191 | |
192 | 192 | $sTime=''; |
193 | 193 | $sDay=0; |
194 | 194 | $sWeek=0; |
195 | 195 | |
196 | - if ($iSecond >= $lengthOfDay) |
|
197 | - { |
|
198 | - for($i = $iSecond; $i >= $lengthOfDay; $i -= $lengthOfDay ) |
|
199 | - { |
|
200 | - $sDay++; |
|
201 | - $iSecond-=$lengthOfDay; |
|
202 | - } |
|
203 | - $dayTranslate = $langs->trans("Day"); |
|
204 | - if ($iSecond >= ($lengthOfDay*2)) $dayTranslate = $langs->trans("Days"); |
|
205 | - } |
|
206 | - |
|
207 | - if ($lengthOfWeek < 7) |
|
208 | - { |
|
209 | - if ($sDay) |
|
196 | + if ($iSecond >= $lengthOfDay) |
|
197 | + { |
|
198 | + for($i = $iSecond; $i >= $lengthOfDay; $i -= $lengthOfDay ) |
|
199 | + { |
|
200 | + $sDay++; |
|
201 | + $iSecond-=$lengthOfDay; |
|
202 | + } |
|
203 | + $dayTranslate = $langs->trans("Day"); |
|
204 | + if ($iSecond >= ($lengthOfDay*2)) $dayTranslate = $langs->trans("Days"); |
|
205 | + } |
|
206 | + |
|
207 | + if ($lengthOfWeek < 7) |
|
208 | + { |
|
209 | + if ($sDay) |
|
210 | 210 | { |
211 | 211 | if ($sDay >= $lengthOfWeek) |
212 | 212 | { |
@@ -217,48 +217,48 @@ discard block |
||
217 | 217 | $sTime.=$sWeek.' '.$weekTranslate.' '; |
218 | 218 | } |
219 | 219 | } |
220 | - } |
|
221 | - if ($sDay>0) |
|
222 | - { |
|
223 | - $dayTranslate = $langs->trans("Day"); |
|
224 | - if ($sDay > 1) $dayTranslate = $langs->trans("Days"); |
|
225 | - $sTime.=$sDay.' '.$dayTranslate.' '; |
|
226 | - } |
|
227 | - |
|
228 | - if ($format == 'all') |
|
229 | - { |
|
230 | - if ($iSecond || empty($sDay)) |
|
231 | - { |
|
232 | - $sTime.= dol_print_date($iSecond,'hourduration',true); |
|
233 | - } |
|
234 | - } |
|
235 | - if ($format == 'allhourmin') |
|
236 | - { |
|
237 | - return sprintf("%02d",($sWeek*$lengthOfWeek*24 + $sDay*24 + (int) floor($iSecond/3600))).':'.sprintf("%02d",((int) floor(($iSecond % 3600)/60))); |
|
238 | - } |
|
239 | - if ($format == 'allhour') |
|
240 | - { |
|
241 | - return sprintf("%02d",($sWeek*$lengthOfWeek*24 + $sDay*24 + (int) floor($iSecond/3600))); |
|
242 | - } |
|
243 | - } |
|
244 | - else if ($format == 'hour') // only hour part |
|
245 | - { |
|
246 | - $sTime=dol_print_date($iSecond,'%H',true); |
|
247 | - } |
|
248 | - else if ($format == 'fullhour') |
|
249 | - { |
|
250 | - if (!empty($iSecond)) { |
|
251 | - $iSecond=$iSecond/3600; |
|
252 | - } |
|
253 | - else { |
|
254 | - $iSecond=0; |
|
255 | - } |
|
256 | - $sTime=$iSecond; |
|
257 | - } |
|
258 | - else if ($format == 'min') // only min part |
|
259 | - { |
|
260 | - $sTime=dol_print_date($iSecond,'%M',true); |
|
261 | - } |
|
220 | + } |
|
221 | + if ($sDay>0) |
|
222 | + { |
|
223 | + $dayTranslate = $langs->trans("Day"); |
|
224 | + if ($sDay > 1) $dayTranslate = $langs->trans("Days"); |
|
225 | + $sTime.=$sDay.' '.$dayTranslate.' '; |
|
226 | + } |
|
227 | + |
|
228 | + if ($format == 'all') |
|
229 | + { |
|
230 | + if ($iSecond || empty($sDay)) |
|
231 | + { |
|
232 | + $sTime.= dol_print_date($iSecond,'hourduration',true); |
|
233 | + } |
|
234 | + } |
|
235 | + if ($format == 'allhourmin') |
|
236 | + { |
|
237 | + return sprintf("%02d",($sWeek*$lengthOfWeek*24 + $sDay*24 + (int) floor($iSecond/3600))).':'.sprintf("%02d",((int) floor(($iSecond % 3600)/60))); |
|
238 | + } |
|
239 | + if ($format == 'allhour') |
|
240 | + { |
|
241 | + return sprintf("%02d",($sWeek*$lengthOfWeek*24 + $sDay*24 + (int) floor($iSecond/3600))); |
|
242 | + } |
|
243 | + } |
|
244 | + else if ($format == 'hour') // only hour part |
|
245 | + { |
|
246 | + $sTime=dol_print_date($iSecond,'%H',true); |
|
247 | + } |
|
248 | + else if ($format == 'fullhour') |
|
249 | + { |
|
250 | + if (!empty($iSecond)) { |
|
251 | + $iSecond=$iSecond/3600; |
|
252 | + } |
|
253 | + else { |
|
254 | + $iSecond=0; |
|
255 | + } |
|
256 | + $sTime=$iSecond; |
|
257 | + } |
|
258 | + else if ($format == 'min') // only min part |
|
259 | + { |
|
260 | + $sTime=dol_print_date($iSecond,'%M',true); |
|
261 | + } |
|
262 | 262 | else if ($format == 'sec') // only sec part |
263 | 263 | { |
264 | 264 | $sTime=dol_print_date($iSecond,'%S',true); |
@@ -286,22 +286,22 @@ discard block |
||
286 | 286 | */ |
287 | 287 | function dolSqlDateFilter($datefield, $day_date, $month_date, $year_date) |
288 | 288 | { |
289 | - global $db; |
|
290 | - $sqldate=""; |
|
291 | - if ($month_date > 0) { |
|
292 | - if ($year_date > 0 && empty($day_date)) { |
|
293 | - $sqldate.= " AND ".$datefield." BETWEEN '".$db->idate(dol_get_first_day($year_date, $month_date, false)); |
|
294 | - $sqldate.= "' AND '".$db->idate(dol_get_last_day($year_date, $month_date, false))."'"; |
|
295 | - } else if ($year_date > 0 && ! empty($day_date)) { |
|
296 | - $sqldate.= " AND ".$datefield." BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month_date, $day_date, $year_date)); |
|
297 | - $sqldate.= "' AND '".$db->idate(dol_mktime(23, 59, 59, $month_date, $day_date, $year_date))."'"; |
|
298 | - } else |
|
299 | - $sqldate.= " AND date_format( ".$datefield.", '%m') = '".$db->escape($month_date)."'"; |
|
300 | - } else if ($year_date > 0){ |
|
301 | - $sqldate.= " AND ".$datefield." BETWEEN '".$db->idate(dol_get_first_day($year_date, 1, false)); |
|
302 | - $sqldate.= "' AND '".$db->idate(dol_get_last_day($year_date, 12, false))."'"; |
|
303 | - } |
|
304 | - return $sqldate; |
|
289 | + global $db; |
|
290 | + $sqldate=""; |
|
291 | + if ($month_date > 0) { |
|
292 | + if ($year_date > 0 && empty($day_date)) { |
|
293 | + $sqldate.= " AND ".$datefield." BETWEEN '".$db->idate(dol_get_first_day($year_date, $month_date, false)); |
|
294 | + $sqldate.= "' AND '".$db->idate(dol_get_last_day($year_date, $month_date, false))."'"; |
|
295 | + } else if ($year_date > 0 && ! empty($day_date)) { |
|
296 | + $sqldate.= " AND ".$datefield." BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month_date, $day_date, $year_date)); |
|
297 | + $sqldate.= "' AND '".$db->idate(dol_mktime(23, 59, 59, $month_date, $day_date, $year_date))."'"; |
|
298 | + } else |
|
299 | + $sqldate.= " AND date_format( ".$datefield.", '%m') = '".$db->escape($month_date)."'"; |
|
300 | + } else if ($year_date > 0){ |
|
301 | + $sqldate.= " AND ".$datefield." BETWEEN '".$db->idate(dol_get_first_day($year_date, 1, false)); |
|
302 | + $sqldate.= "' AND '".$db->idate(dol_get_last_day($year_date, 12, false))."'"; |
|
303 | + } |
|
304 | + return $sqldate; |
|
305 | 305 | } |
306 | 306 | |
307 | 307 | /** |
@@ -341,9 +341,9 @@ discard block |
||
341 | 341 | $string=sprintf("%04d%02d%02d%02d%02d%02d",$syear,$smonth,$sday,$shour,$smin,$ssec); |
342 | 342 | } |
343 | 343 | else if ( |
344 | - preg_match('/^([0-9]{4})-([0-9]{2})-([0-9]{2})T([0-9]{2}):([0-9]{2}):([0-9]{2})Z$/i',$string,$reg) // Convert date with format YYYY-MM-DDTHH:MM:SSZ (RFC3339) |
|
345 | - || preg_match('/^([0-9]{4})-([0-9]{2})-([0-9]{2}) ([0-9]{2}):([0-9]{2}):([0-9]{2})$/i',$string,$reg) // Convert date with format YYYY-MM-DD HH:MM:SS |
|
346 | - || preg_match('/^([0-9]{4})([0-9]{2})([0-9]{2})T([0-9]{2})([0-9]{2})([0-9]{2})Z$/i',$string,$reg) // Convert date with format YYYYMMDDTHHMMSSZ |
|
344 | + preg_match('/^([0-9]{4})-([0-9]{2})-([0-9]{2})T([0-9]{2}):([0-9]{2}):([0-9]{2})Z$/i',$string,$reg) // Convert date with format YYYY-MM-DDTHH:MM:SSZ (RFC3339) |
|
345 | + || preg_match('/^([0-9]{4})-([0-9]{2})-([0-9]{2}) ([0-9]{2}):([0-9]{2}):([0-9]{2})$/i',$string,$reg) // Convert date with format YYYY-MM-DD HH:MM:SS |
|
346 | + || preg_match('/^([0-9]{4})([0-9]{2})([0-9]{2})T([0-9]{2})([0-9]{2})([0-9]{2})Z$/i',$string,$reg) // Convert date with format YYYYMMDDTHHMMSSZ |
|
347 | 347 | ) |
348 | 348 | { |
349 | 349 | $syear = $reg[1]; |
@@ -371,10 +371,10 @@ discard block |
||
371 | 371 | */ |
372 | 372 | function dol_get_prev_day($day, $month, $year) |
373 | 373 | { |
374 | - $time=dol_mktime(12,0,0,$month,$day,$year,1,0); |
|
375 | - $time-=24*60*60; |
|
376 | - $tmparray=dol_getdate($time,true); |
|
377 | - return array('year' => $tmparray['year'], 'month' => $tmparray['mon'], 'day' => $tmparray['mday']); |
|
374 | + $time=dol_mktime(12,0,0,$month,$day,$year,1,0); |
|
375 | + $time-=24*60*60; |
|
376 | + $tmparray=dol_getdate($time,true); |
|
377 | + return array('year' => $tmparray['year'], 'month' => $tmparray['mon'], 'day' => $tmparray['mday']); |
|
378 | 378 | } |
379 | 379 | |
380 | 380 | /** Return next day |
@@ -386,10 +386,10 @@ discard block |
||
386 | 386 | */ |
387 | 387 | function dol_get_next_day($day, $month, $year) |
388 | 388 | { |
389 | - $time=dol_mktime(12,0,0,$month,$day,$year,1,0); |
|
390 | - $time+=24*60*60; |
|
391 | - $tmparray=dol_getdate($time,true); |
|
392 | - return array('year' => $tmparray['year'], 'month' => $tmparray['mon'], 'day' => $tmparray['mday']); |
|
389 | + $time=dol_mktime(12,0,0,$month,$day,$year,1,0); |
|
390 | + $time+=24*60*60; |
|
391 | + $tmparray=dol_getdate($time,true); |
|
392 | + return array('year' => $tmparray['year'], 'month' => $tmparray['mon'], 'day' => $tmparray['mday']); |
|
393 | 393 | } |
394 | 394 | |
395 | 395 | /** Return previous month |
@@ -400,17 +400,17 @@ discard block |
||
400 | 400 | */ |
401 | 401 | function dol_get_prev_month($month, $year) |
402 | 402 | { |
403 | - if ($month == 1) |
|
404 | - { |
|
405 | - $prev_month = 12; |
|
406 | - $prev_year = $year - 1; |
|
407 | - } |
|
408 | - else |
|
409 | - { |
|
410 | - $prev_month = $month-1; |
|
411 | - $prev_year = $year; |
|
412 | - } |
|
413 | - return array('year' => $prev_year, 'month' => $prev_month); |
|
403 | + if ($month == 1) |
|
404 | + { |
|
405 | + $prev_month = 12; |
|
406 | + $prev_year = $year - 1; |
|
407 | + } |
|
408 | + else |
|
409 | + { |
|
410 | + $prev_month = $month-1; |
|
411 | + $prev_year = $year; |
|
412 | + } |
|
413 | + return array('year' => $prev_year, 'month' => $prev_month); |
|
414 | 414 | } |
415 | 415 | |
416 | 416 | /** Return next month |
@@ -421,17 +421,17 @@ discard block |
||
421 | 421 | */ |
422 | 422 | function dol_get_next_month($month, $year) |
423 | 423 | { |
424 | - if ($month == 12) |
|
425 | - { |
|
426 | - $next_month = 1; |
|
427 | - $next_year = $year + 1; |
|
428 | - } |
|
429 | - else |
|
430 | - { |
|
431 | - $next_month = $month + 1; |
|
432 | - $next_year = $year; |
|
433 | - } |
|
434 | - return array('year' => $next_year, 'month' => $next_month); |
|
424 | + if ($month == 12) |
|
425 | + { |
|
426 | + $next_month = 1; |
|
427 | + $next_year = $year + 1; |
|
428 | + } |
|
429 | + else |
|
430 | + { |
|
431 | + $next_month = $month + 1; |
|
432 | + $next_year = $year; |
|
433 | + } |
|
434 | + return array('year' => $next_year, 'month' => $next_month); |
|
435 | 435 | } |
436 | 436 | |
437 | 437 | /** Return previous week |
@@ -444,12 +444,12 @@ discard block |
||
444 | 444 | */ |
445 | 445 | function dol_get_prev_week($day, $week, $month, $year) |
446 | 446 | { |
447 | - $tmparray = dol_get_first_day_week($day, $month, $year); |
|
447 | + $tmparray = dol_get_first_day_week($day, $month, $year); |
|
448 | 448 | |
449 | - $time=dol_mktime(12,0,0,$month,$tmparray['first_day'],$year,1,0); |
|
450 | - $time-=24*60*60*7; |
|
451 | - $tmparray=dol_getdate($time,true); |
|
452 | - return array('year' => $tmparray['year'], 'month' => $tmparray['mon'], 'day' => $tmparray['mday']); |
|
449 | + $time=dol_mktime(12,0,0,$month,$tmparray['first_day'],$year,1,0); |
|
450 | + $time-=24*60*60*7; |
|
451 | + $tmparray=dol_getdate($time,true); |
|
452 | + return array('year' => $tmparray['year'], 'month' => $tmparray['mon'], 'day' => $tmparray['mday']); |
|
453 | 453 | } |
454 | 454 | |
455 | 455 | /** Return next week |
@@ -462,13 +462,13 @@ discard block |
||
462 | 462 | */ |
463 | 463 | function dol_get_next_week($day, $week, $month, $year) |
464 | 464 | { |
465 | - $tmparray = dol_get_first_day_week($day, $month, $year); |
|
465 | + $tmparray = dol_get_first_day_week($day, $month, $year); |
|
466 | 466 | |
467 | - $time=dol_mktime(12,0,0,$tmparray['first_month'],$tmparray['first_day'],$tmparray['first_year'],1,0); |
|
468 | - $time+=24*60*60*7; |
|
469 | - $tmparray=dol_getdate($time,true); |
|
467 | + $time=dol_mktime(12,0,0,$tmparray['first_month'],$tmparray['first_day'],$tmparray['first_year'],1,0); |
|
468 | + $time+=24*60*60*7; |
|
469 | + $tmparray=dol_getdate($time,true); |
|
470 | 470 | |
471 | - return array('year' => $tmparray['year'], 'month' => $tmparray['mon'], 'day' => $tmparray['mday']); |
|
471 | + return array('year' => $tmparray['year'], 'month' => $tmparray['mon'], 'day' => $tmparray['mday']); |
|
472 | 472 | } |
473 | 473 | |
474 | 474 | /** Return GMT time for first day of a month or year |
@@ -482,8 +482,8 @@ discard block |
||
482 | 482 | */ |
483 | 483 | function dol_get_first_day($year,$month=1,$gm=false) |
484 | 484 | { |
485 | - if ($year > 9999) return ''; |
|
486 | - return dol_mktime(0,0,0,$month,1,$year,$gm); |
|
485 | + if ($year > 9999) return ''; |
|
486 | + return dol_mktime(0,0,0,$month,1,$year,$gm); |
|
487 | 487 | } |
488 | 488 | |
489 | 489 | |
@@ -496,22 +496,22 @@ discard block |
||
496 | 496 | */ |
497 | 497 | function dol_get_last_day($year,$month=12,$gm=false) |
498 | 498 | { |
499 | - if ($year > 9999) return ''; |
|
500 | - if ($month == 12) |
|
501 | - { |
|
502 | - $month = 1; |
|
503 | - $year += 1; |
|
504 | - } |
|
505 | - else |
|
506 | - { |
|
507 | - $month += 1; |
|
508 | - } |
|
509 | - |
|
510 | - // On se deplace au debut du mois suivant, et on retire un jour |
|
511 | - $datelim=dol_mktime(23,59,59,$month,1,$year,$gm); |
|
512 | - $datelim -= (3600 * 24); |
|
513 | - |
|
514 | - return $datelim; |
|
499 | + if ($year > 9999) return ''; |
|
500 | + if ($month == 12) |
|
501 | + { |
|
502 | + $month = 1; |
|
503 | + $year += 1; |
|
504 | + } |
|
505 | + else |
|
506 | + { |
|
507 | + $month += 1; |
|
508 | + } |
|
509 | + |
|
510 | + // On se deplace au debut du mois suivant, et on retire un jour |
|
511 | + $datelim=dol_mktime(23,59,59,$month,1,$year,$gm); |
|
512 | + $datelim -= (3600 * 24); |
|
513 | + |
|
514 | + return $datelim; |
|
515 | 515 | } |
516 | 516 | |
517 | 517 | /** Return first day of week for a date. First day of week may be monday if option MAIN_START_WEEK is 1. |
@@ -524,69 +524,69 @@ discard block |
||
524 | 524 | */ |
525 | 525 | function dol_get_first_day_week($day,$month,$year,$gm=false) |
526 | 526 | { |
527 | - global $conf; |
|
527 | + global $conf; |
|
528 | 528 | |
529 | - //$day=2; $month=2; $year=2015; |
|
530 | - $date = dol_mktime(0,0,0,$month,$day,$year,$gm); |
|
529 | + //$day=2; $month=2; $year=2015; |
|
530 | + $date = dol_mktime(0,0,0,$month,$day,$year,$gm); |
|
531 | 531 | |
532 | - //Checking conf of start week |
|
533 | - $start_week = (isset($conf->global->MAIN_START_WEEK)?$conf->global->MAIN_START_WEEK:1); |
|
532 | + //Checking conf of start week |
|
533 | + $start_week = (isset($conf->global->MAIN_START_WEEK)?$conf->global->MAIN_START_WEEK:1); |
|
534 | 534 | |
535 | - $tmparray = dol_getdate($date,true); // detail of current day |
|
535 | + $tmparray = dol_getdate($date,true); // detail of current day |
|
536 | 536 | |
537 | - //Calculate days = offset from current day |
|
538 | - $days = $start_week - $tmparray['wday']; |
|
539 | - if ($days>=1) $days=7-$days; |
|
540 | - $days = abs($days); |
|
537 | + //Calculate days = offset from current day |
|
538 | + $days = $start_week - $tmparray['wday']; |
|
539 | + if ($days>=1) $days=7-$days; |
|
540 | + $days = abs($days); |
|
541 | 541 | $seconds = $days*24*60*60; |
542 | - //print 'start_week='.$start_week.' tmparray[wday]='.$tmparray['wday'].' day offset='.$days.' seconds offset='.$seconds.'<br>'; |
|
542 | + //print 'start_week='.$start_week.' tmparray[wday]='.$tmparray['wday'].' day offset='.$days.' seconds offset='.$seconds.'<br>'; |
|
543 | 543 | |
544 | 544 | //Get first day of week |
545 | 545 | $tmpdaytms = date($tmparray[0])-$seconds; // $tmparray[0] is day of parameters |
546 | - $tmpday = date("d",$tmpdaytms); |
|
546 | + $tmpday = date("d",$tmpdaytms); |
|
547 | 547 | |
548 | - //Check first day of week is in same month than current day or not |
|
549 | - if ($tmpday>$day) |
|
548 | + //Check first day of week is in same month than current day or not |
|
549 | + if ($tmpday>$day) |
|
550 | 550 | { |
551 | - $prev_month = $month-1; |
|
552 | - $prev_year = $year; |
|
553 | - |
|
554 | - if ($prev_month==0) |
|
555 | - { |
|
556 | - $prev_month = 12; |
|
557 | - $prev_year = $year-1; |
|
558 | - } |
|
551 | + $prev_month = $month-1; |
|
552 | + $prev_year = $year; |
|
553 | + |
|
554 | + if ($prev_month==0) |
|
555 | + { |
|
556 | + $prev_month = 12; |
|
557 | + $prev_year = $year-1; |
|
558 | + } |
|
559 | 559 | } |
560 | 560 | else |
561 | 561 | { |
562 | - $prev_month = $month; |
|
563 | - $prev_year = $year; |
|
562 | + $prev_month = $month; |
|
563 | + $prev_year = $year; |
|
564 | 564 | } |
565 | - $tmpmonth = $prev_month; |
|
566 | - $tmpyear = $prev_year; |
|
565 | + $tmpmonth = $prev_month; |
|
566 | + $tmpyear = $prev_year; |
|
567 | 567 | |
568 | - //Get first day of next week |
|
569 | - $tmptime=dol_mktime(12,0,0,$month,$tmpday,$year,1,0); |
|
570 | - $tmptime-=24*60*60*7; |
|
571 | - $tmparray=dol_getdate($tmptime,true); |
|
568 | + //Get first day of next week |
|
569 | + $tmptime=dol_mktime(12,0,0,$month,$tmpday,$year,1,0); |
|
570 | + $tmptime-=24*60*60*7; |
|
571 | + $tmparray=dol_getdate($tmptime,true); |
|
572 | 572 | $prev_day = $tmparray['mday']; |
573 | 573 | |
574 | 574 | //Check prev day of week is in same month than first day or not |
575 | - if ($prev_day > $tmpday) |
|
575 | + if ($prev_day > $tmpday) |
|
576 | 576 | { |
577 | - $prev_month = $month-1; |
|
578 | - $prev_year = $year; |
|
579 | - |
|
580 | - if ($prev_month==0) |
|
581 | - { |
|
582 | - $prev_month = 12; |
|
583 | - $prev_year = $year-1; |
|
584 | - } |
|
577 | + $prev_month = $month-1; |
|
578 | + $prev_year = $year; |
|
579 | + |
|
580 | + if ($prev_month==0) |
|
581 | + { |
|
582 | + $prev_month = 12; |
|
583 | + $prev_year = $year-1; |
|
584 | + } |
|
585 | 585 | } |
586 | 586 | |
587 | 587 | $week = date("W",dol_mktime(0,0,0,$tmpmonth,$tmpday,$tmpyear,$gm)); |
588 | 588 | |
589 | - return array('year' => $year, 'month' => $month, 'week' => $week, 'first_day' => $tmpday, 'first_month' => $tmpmonth, 'first_year' => $tmpyear, 'prev_year' => $prev_year, 'prev_month' => $prev_month, 'prev_day' => $prev_day); |
|
589 | + return array('year' => $year, 'month' => $month, 'week' => $week, 'first_day' => $tmpday, 'first_month' => $tmpmonth, 'first_year' => $tmpyear, 'prev_year' => $prev_year, 'prev_month' => $prev_month, 'prev_day' => $prev_day); |
|
590 | 590 | } |
591 | 591 | |
592 | 592 | /** |
@@ -602,66 +602,66 @@ discard block |
||
602 | 602 | */ |
603 | 603 | function num_public_holiday($timestampStart, $timestampEnd, $countrycode='FR', $lastday=0) |
604 | 604 | { |
605 | - global $conf; |
|
606 | - |
|
607 | - $nbFerie = 0; |
|
608 | - |
|
609 | - // Check to ensure we use correct parameters |
|
610 | - if ((($timestampEnd - $timestampStart) % 86400) != 0) return 'ErrorDates must use same hours and must be GMT dates'; |
|
611 | - |
|
612 | - $i=0; |
|
613 | - while (( ($lastday == 0 && $timestampStart < $timestampEnd) || ($lastday && $timestampStart <= $timestampEnd) ) |
|
614 | - && ($i < 50000)) // Loop end when equals (Test on i is a security loop to avoid infinite loop) |
|
615 | - { |
|
616 | - $ferie=false; |
|
617 | - $countryfound=0; |
|
618 | - $includesaturdayandsunday=1; |
|
619 | - |
|
620 | - $jour = date("d", $timestampStart); |
|
621 | - $mois = date("m", $timestampStart); |
|
622 | - $annee = date("Y", $timestampStart); |
|
623 | - |
|
624 | - |
|
625 | - // Check into var $conf->global->HOLIDAY_MORE_DAYS MM-DD,YYYY-MM-DD, ... |
|
626 | - if (! empty($conf->global->HOLIDAY_MORE_PUBLIC_HOLIDAYS)) |
|
627 | - { |
|
628 | - $arrayofdaystring=explode(',',$conf->global->HOLIDAY_MORE_PUBLIC_HOLIDAYS); |
|
629 | - foreach($arrayofdaystring as $daystring) |
|
630 | - { |
|
631 | - $tmp=explode('-',$daystring); |
|
632 | - if ($tmp[2]) |
|
633 | - { |
|
634 | - if ($tmp[0] == $annee && $tmp[1] == $mois && $tmp[2] == $jour) $ferie=true; |
|
635 | - } |
|
636 | - else |
|
637 | - { |
|
638 | - if ($tmp[0] == $mois && $tmp[1] == $jour) $ferie=true; |
|
639 | - } |
|
640 | - } |
|
641 | - } |
|
642 | - |
|
643 | - if ($countrycode == 'FR') |
|
644 | - { |
|
645 | - $countryfound=1; |
|
646 | - |
|
647 | - // Definition of fixed working days |
|
648 | - if($jour == 1 && $mois == 1) $ferie=true; // 1er january |
|
649 | - if($jour == 1 && $mois == 5) $ferie=true; // 1er may |
|
650 | - if($jour == 8 && $mois == 5) $ferie=true; // 5 may |
|
651 | - if($jour == 14 && $mois == 7) $ferie=true; // 14 july |
|
652 | - if($jour == 15 && $mois == 8) $ferie=true; // 15 august |
|
653 | - if($jour == 1 && $mois == 11) $ferie=true; // 1 november |
|
654 | - if($jour == 11 && $mois == 11) $ferie=true; // 11 november |
|
655 | - if($jour == 25 && $mois == 12) $ferie=true; // 25 december |
|
656 | - |
|
657 | - // Calculation for easter date |
|
658 | - $date_paques = easter_date($annee); |
|
659 | - $jour_paques = date("d", $date_paques); |
|
660 | - $mois_paques = date("m", $date_paques); |
|
661 | - if($jour_paques == $jour && $mois_paques == $mois) $ferie=true; |
|
662 | - // Pâques |
|
663 | - |
|
664 | - // Calculation for the monday of easter date |
|
605 | + global $conf; |
|
606 | + |
|
607 | + $nbFerie = 0; |
|
608 | + |
|
609 | + // Check to ensure we use correct parameters |
|
610 | + if ((($timestampEnd - $timestampStart) % 86400) != 0) return 'ErrorDates must use same hours and must be GMT dates'; |
|
611 | + |
|
612 | + $i=0; |
|
613 | + while (( ($lastday == 0 && $timestampStart < $timestampEnd) || ($lastday && $timestampStart <= $timestampEnd) ) |
|
614 | + && ($i < 50000)) // Loop end when equals (Test on i is a security loop to avoid infinite loop) |
|
615 | + { |
|
616 | + $ferie=false; |
|
617 | + $countryfound=0; |
|
618 | + $includesaturdayandsunday=1; |
|
619 | + |
|
620 | + $jour = date("d", $timestampStart); |
|
621 | + $mois = date("m", $timestampStart); |
|
622 | + $annee = date("Y", $timestampStart); |
|
623 | + |
|
624 | + |
|
625 | + // Check into var $conf->global->HOLIDAY_MORE_DAYS MM-DD,YYYY-MM-DD, ... |
|
626 | + if (! empty($conf->global->HOLIDAY_MORE_PUBLIC_HOLIDAYS)) |
|
627 | + { |
|
628 | + $arrayofdaystring=explode(',',$conf->global->HOLIDAY_MORE_PUBLIC_HOLIDAYS); |
|
629 | + foreach($arrayofdaystring as $daystring) |
|
630 | + { |
|
631 | + $tmp=explode('-',$daystring); |
|
632 | + if ($tmp[2]) |
|
633 | + { |
|
634 | + if ($tmp[0] == $annee && $tmp[1] == $mois && $tmp[2] == $jour) $ferie=true; |
|
635 | + } |
|
636 | + else |
|
637 | + { |
|
638 | + if ($tmp[0] == $mois && $tmp[1] == $jour) $ferie=true; |
|
639 | + } |
|
640 | + } |
|
641 | + } |
|
642 | + |
|
643 | + if ($countrycode == 'FR') |
|
644 | + { |
|
645 | + $countryfound=1; |
|
646 | + |
|
647 | + // Definition of fixed working days |
|
648 | + if($jour == 1 && $mois == 1) $ferie=true; // 1er january |
|
649 | + if($jour == 1 && $mois == 5) $ferie=true; // 1er may |
|
650 | + if($jour == 8 && $mois == 5) $ferie=true; // 5 may |
|
651 | + if($jour == 14 && $mois == 7) $ferie=true; // 14 july |
|
652 | + if($jour == 15 && $mois == 8) $ferie=true; // 15 august |
|
653 | + if($jour == 1 && $mois == 11) $ferie=true; // 1 november |
|
654 | + if($jour == 11 && $mois == 11) $ferie=true; // 11 november |
|
655 | + if($jour == 25 && $mois == 12) $ferie=true; // 25 december |
|
656 | + |
|
657 | + // Calculation for easter date |
|
658 | + $date_paques = easter_date($annee); |
|
659 | + $jour_paques = date("d", $date_paques); |
|
660 | + $mois_paques = date("m", $date_paques); |
|
661 | + if($jour_paques == $jour && $mois_paques == $mois) $ferie=true; |
|
662 | + // Pâques |
|
663 | + |
|
664 | + // Calculation for the monday of easter date |
|
665 | 665 | $date_lundi_paques = mktime( |
666 | 666 | date("H", $date_paques), |
667 | 667 | date("i", $date_paques), |
@@ -670,12 +670,12 @@ discard block |
||
670 | 670 | date("d", $date_paques) + 1, |
671 | 671 | date("Y", $date_paques) |
672 | 672 | ); |
673 | - $jour_lundi_ascension = date("d", $date_lundi_paques); |
|
674 | - $mois_lundi_ascension = date("m", $date_lundi_paques); |
|
675 | - if($jour_lundi_ascension == $jour && $mois_lundi_ascension == $mois) $ferie=true; |
|
676 | - // Lundi de Pâques |
|
673 | + $jour_lundi_ascension = date("d", $date_lundi_paques); |
|
674 | + $mois_lundi_ascension = date("m", $date_lundi_paques); |
|
675 | + if($jour_lundi_ascension == $jour && $mois_lundi_ascension == $mois) $ferie=true; |
|
676 | + // Lundi de Pâques |
|
677 | 677 | |
678 | - // Calcul du jour de l'ascension (38 days after easter day) |
|
678 | + // Calcul du jour de l'ascension (38 days after easter day) |
|
679 | 679 | $date_ascension = mktime( |
680 | 680 | date("H", $date_paques), |
681 | 681 | date("i", $date_paques), |
@@ -684,12 +684,12 @@ discard block |
||
684 | 684 | date("d", $date_paques) + 39, |
685 | 685 | date("Y", $date_paques) |
686 | 686 | ); |
687 | - $jour_ascension = date("d", $date_ascension); |
|
688 | - $mois_ascension = date("m", $date_ascension); |
|
689 | - if($jour_ascension == $jour && $mois_ascension == $mois) $ferie=true; |
|
690 | - // Ascension |
|
687 | + $jour_ascension = date("d", $date_ascension); |
|
688 | + $mois_ascension = date("m", $date_ascension); |
|
689 | + if($jour_ascension == $jour && $mois_ascension == $mois) $ferie=true; |
|
690 | + // Ascension |
|
691 | 691 | |
692 | - // Calculation of "Pentecote" (11 days after easter day) |
|
692 | + // Calculation of "Pentecote" (11 days after easter day) |
|
693 | 693 | $date_pentecote = mktime( |
694 | 694 | date("H", $date_paques), |
695 | 695 | date("i", $date_paques), |
@@ -698,73 +698,73 @@ discard block |
||
698 | 698 | date("d", $date_paques) + 49, |
699 | 699 | date("Y", $date_paques) |
700 | 700 | ); |
701 | - $jour_pentecote = date("d", $date_pentecote); |
|
702 | - $mois_pentecote = date("m", $date_pentecote); |
|
703 | - if($jour_pentecote == $jour && $mois_pentecote == $mois) $ferie=true; |
|
704 | - // "Pentecote" |
|
705 | - } |
|
706 | - |
|
707 | - // Pentecoste and Ascensione in Italy go to the sunday after: isn't holiday. |
|
708 | - // Pentecoste is 50 days after Easter, Ascensione 40 |
|
709 | - if ($countrycode == 'IT') |
|
710 | - { |
|
711 | - $countryfound=1; |
|
712 | - |
|
713 | - // Definition des dates feriees fixes |
|
714 | - if($jour == 1 && $mois == 1) $ferie=true; // Capodanno |
|
715 | - if($jour == 6 && $mois == 1) $ferie=true; // Epifania |
|
716 | - if($jour == 25 && $mois == 4) $ferie=true; // Anniversario Liberazione |
|
717 | - if($jour == 1 && $mois == 5) $ferie=true; // Festa del Lavoro |
|
718 | - if($jour == 2 && $mois == 6) $ferie=true; // Festa della Repubblica |
|
719 | - if($jour == 15 && $mois == 8) $ferie=true; // Ferragosto |
|
720 | - if($jour == 1 && $mois == 11) $ferie=true; // Tutti i Santi |
|
721 | - if($jour == 8 && $mois == 12) $ferie=true; // Immacolata Concezione |
|
722 | - if($jour == 25 && $mois == 12) $ferie=true; // 25 decembre |
|
723 | - if($jour == 26 && $mois == 12) $ferie=true; // Santo Stefano |
|
724 | - |
|
725 | - // Calcul du jour de paques |
|
726 | - $date_paques = easter_date($annee); |
|
727 | - $jour_paques = date("d", $date_paques); |
|
728 | - $mois_paques = date("m", $date_paques); |
|
729 | - if($jour_paques == $jour && $mois_paques == $mois) $ferie=true; |
|
730 | - // Paques |
|
731 | - } |
|
732 | - |
|
733 | - if ($countrycode == 'IN') |
|
734 | - { |
|
735 | - $countryfound=1; |
|
736 | - |
|
737 | - if($jour == 1 && $mois == 1) $ferie=true; // New Year's Day |
|
738 | - if($jour == 26 && $mois == 1) $ferie=true; // Republic Day |
|
739 | - if($jour == 1 && $mois == 5) $ferie=true; // May Day |
|
740 | - if($jour == 15 && $mois == 8) $ferie=true; // Independence Day |
|
741 | - if($jour == 2 && $mois == 10) $ferie=true; // Gandhi Jayanti |
|
742 | - if($jour == 25 && $mois == 12) $ferie=true; // Christmas |
|
743 | - } |
|
744 | - |
|
745 | - if ($countrycode == 'ES') |
|
746 | - { |
|
747 | - $countryfound=1; |
|
748 | - |
|
749 | - // Definition des dates feriees fixes |
|
750 | - if($jour == 1 && $mois == 1) $ferie=true; // Año nuevo |
|
751 | - if($jour == 6 && $mois == 1) $ferie=true; // Día Reyes |
|
752 | - if($jour == 1 && $mois == 5) $ferie=true; // 1 Mayo |
|
753 | - if($jour == 15 && $mois == 8) $ferie=true; // 15 Agosto |
|
754 | - if($jour == 12 && $mois == 10) $ferie=true; // Día Hispanidad |
|
755 | - if($jour == 1 && $mois == 11) $ferie=true; // 1 noviembre |
|
756 | - if($jour == 6 && $mois == 12) $ferie=true; // Constitución |
|
757 | - if($jour == 8 && $mois == 12) $ferie=true; // Inmaculada |
|
758 | - if($jour == 25 && $mois == 12) $ferie=true; // 25 diciembre |
|
759 | - |
|
760 | - // Calcul día de Pascua |
|
761 | - $date_paques = easter_date($annee); |
|
762 | - $jour_paques = date("d", $date_paques); |
|
763 | - $mois_paques = date("m", $date_paques); |
|
764 | - if($jour_paques == $jour && $mois_paques == $mois) $ferie=true; |
|
765 | - // Paques |
|
766 | - |
|
767 | - // Viernes Santo |
|
701 | + $jour_pentecote = date("d", $date_pentecote); |
|
702 | + $mois_pentecote = date("m", $date_pentecote); |
|
703 | + if($jour_pentecote == $jour && $mois_pentecote == $mois) $ferie=true; |
|
704 | + // "Pentecote" |
|
705 | + } |
|
706 | + |
|
707 | + // Pentecoste and Ascensione in Italy go to the sunday after: isn't holiday. |
|
708 | + // Pentecoste is 50 days after Easter, Ascensione 40 |
|
709 | + if ($countrycode == 'IT') |
|
710 | + { |
|
711 | + $countryfound=1; |
|
712 | + |
|
713 | + // Definition des dates feriees fixes |
|
714 | + if($jour == 1 && $mois == 1) $ferie=true; // Capodanno |
|
715 | + if($jour == 6 && $mois == 1) $ferie=true; // Epifania |
|
716 | + if($jour == 25 && $mois == 4) $ferie=true; // Anniversario Liberazione |
|
717 | + if($jour == 1 && $mois == 5) $ferie=true; // Festa del Lavoro |
|
718 | + if($jour == 2 && $mois == 6) $ferie=true; // Festa della Repubblica |
|
719 | + if($jour == 15 && $mois == 8) $ferie=true; // Ferragosto |
|
720 | + if($jour == 1 && $mois == 11) $ferie=true; // Tutti i Santi |
|
721 | + if($jour == 8 && $mois == 12) $ferie=true; // Immacolata Concezione |
|
722 | + if($jour == 25 && $mois == 12) $ferie=true; // 25 decembre |
|
723 | + if($jour == 26 && $mois == 12) $ferie=true; // Santo Stefano |
|
724 | + |
|
725 | + // Calcul du jour de paques |
|
726 | + $date_paques = easter_date($annee); |
|
727 | + $jour_paques = date("d", $date_paques); |
|
728 | + $mois_paques = date("m", $date_paques); |
|
729 | + if($jour_paques == $jour && $mois_paques == $mois) $ferie=true; |
|
730 | + // Paques |
|
731 | + } |
|
732 | + |
|
733 | + if ($countrycode == 'IN') |
|
734 | + { |
|
735 | + $countryfound=1; |
|
736 | + |
|
737 | + if($jour == 1 && $mois == 1) $ferie=true; // New Year's Day |
|
738 | + if($jour == 26 && $mois == 1) $ferie=true; // Republic Day |
|
739 | + if($jour == 1 && $mois == 5) $ferie=true; // May Day |
|
740 | + if($jour == 15 && $mois == 8) $ferie=true; // Independence Day |
|
741 | + if($jour == 2 && $mois == 10) $ferie=true; // Gandhi Jayanti |
|
742 | + if($jour == 25 && $mois == 12) $ferie=true; // Christmas |
|
743 | + } |
|
744 | + |
|
745 | + if ($countrycode == 'ES') |
|
746 | + { |
|
747 | + $countryfound=1; |
|
748 | + |
|
749 | + // Definition des dates feriees fixes |
|
750 | + if($jour == 1 && $mois == 1) $ferie=true; // Año nuevo |
|
751 | + if($jour == 6 && $mois == 1) $ferie=true; // Día Reyes |
|
752 | + if($jour == 1 && $mois == 5) $ferie=true; // 1 Mayo |
|
753 | + if($jour == 15 && $mois == 8) $ferie=true; // 15 Agosto |
|
754 | + if($jour == 12 && $mois == 10) $ferie=true; // Día Hispanidad |
|
755 | + if($jour == 1 && $mois == 11) $ferie=true; // 1 noviembre |
|
756 | + if($jour == 6 && $mois == 12) $ferie=true; // Constitución |
|
757 | + if($jour == 8 && $mois == 12) $ferie=true; // Inmaculada |
|
758 | + if($jour == 25 && $mois == 12) $ferie=true; // 25 diciembre |
|
759 | + |
|
760 | + // Calcul día de Pascua |
|
761 | + $date_paques = easter_date($annee); |
|
762 | + $jour_paques = date("d", $date_paques); |
|
763 | + $mois_paques = date("m", $date_paques); |
|
764 | + if($jour_paques == $jour && $mois_paques == $mois) $ferie=true; |
|
765 | + // Paques |
|
766 | + |
|
767 | + // Viernes Santo |
|
768 | 768 | $date_viernes = mktime( |
769 | 769 | date("H", $date_paques), |
770 | 770 | date("i", $date_paques), |
@@ -773,113 +773,113 @@ discard block |
||
773 | 773 | date("d", $date_paques) -2, |
774 | 774 | date("Y", $date_paques) |
775 | 775 | ); |
776 | - $jour_viernes = date("d", $date_viernes); |
|
777 | - $mois_viernes = date("m", $date_viernes); |
|
778 | - if($jour_viernes == $jour && $mois_viernes == $mois) $ferie=true; |
|
779 | - //Viernes Santo |
|
780 | - } |
|
781 | - |
|
782 | - if ($countrycode == 'AT') |
|
783 | - { |
|
784 | - $countryfound=1; |
|
785 | - |
|
786 | - // Definition des dates feriees fixes |
|
787 | - if($jour == 1 && $mois == 1) $ferie=true; // Neujahr |
|
788 | - if($jour == 6 && $mois == 1) $ferie=true; // Hl. 3 Koenige |
|
789 | - if($jour == 1 && $mois == 5) $ferie=true; // 1. Mai |
|
790 | - if($jour == 15 && $mois == 8) $ferie=true; // Mariae Himmelfahrt |
|
791 | - if($jour == 26 && $mois == 10) $ferie=true; // 26. Oktober |
|
792 | - if($jour == 1 && $mois == 11) $ferie=true; // Allerheiligen |
|
793 | - if($jour == 8 && $mois == 12) $ferie=true; // Mariae Empfaengnis |
|
794 | - if($jour == 24 && $mois == 12) $ferie=true; // Heilig abend |
|
795 | - if($jour == 25 && $mois == 12) $ferie=true; // Christtag |
|
796 | - if($jour == 26 && $mois == 12) $ferie=true; // Stefanietag |
|
797 | - if($jour == 31 && $mois == 12) $ferie=true; // Silvester |
|
798 | - |
|
799 | - // Easter calculation |
|
800 | - $date_paques = easter_date($annee); |
|
801 | - $jour_paques = date("d", $date_paques); |
|
802 | - $mois_paques = date("m", $date_paques); |
|
803 | - if($jour_paques == $jour && $mois_paques == $mois) $ferie=true; |
|
804 | - // Easter sunday |
|
805 | - |
|
806 | - // Monday after easter |
|
807 | - $date_eastermonday = mktime( |
|
808 | - date("H", $date_paques), |
|
809 | - date("i", $date_paques), |
|
810 | - date("s", $date_paques), |
|
811 | - date("m", $date_paques), |
|
812 | - date("d", $date_paques) + 1, |
|
813 | - date("Y", $date_paques) |
|
814 | - ); |
|
815 | - $jour_eastermonday = date("d", $date_eastermonday); |
|
816 | - $mois_eastermonday = date("m", $date_eastermonday); |
|
817 | - if($jour_eastermonday == $jour && $mois_eastermonday == $mois) $ferie=true; |
|
818 | - // Easter monday |
|
819 | - |
|
820 | - // Christi Himmelfahrt (39 days after easter sunday) |
|
821 | - $date_ch = mktime( |
|
822 | - date("H", $date_paques), |
|
823 | - date("i", $date_paques), |
|
824 | - date("s", $date_paques), |
|
825 | - date("m", $date_paques), |
|
826 | - date("d", $date_paques) + 39, |
|
827 | - date("Y", $date_paques) |
|
828 | - ); |
|
829 | - $jour_ch = date("d", $date_ch); |
|
830 | - $mois_ch = date("m", $date_ch); |
|
831 | - if($jour_ch == $jour && $mois_ch == $mois) $ferie=true; |
|
832 | - // Christi Himmelfahrt |
|
833 | - |
|
834 | - // Pfingsten (50 days after easter sunday) |
|
835 | - $date_pentecote = mktime( |
|
836 | - date("H", $date_paques), |
|
837 | - date("i", $date_paques), |
|
838 | - date("s", $date_paques), |
|
839 | - date("m", $date_paques), |
|
840 | - date("d", $date_paques) + 50, |
|
841 | - date("Y", $date_paques) |
|
842 | - ); |
|
843 | - $jour_pentecote = date("d", $date_pentecote); |
|
844 | - $mois_pentecote = date("m", $date_pentecote); |
|
845 | - if($jour_pentecote == $jour && $mois_pentecote == $mois) $ferie=true; |
|
846 | - // Pfingsten |
|
847 | - |
|
848 | - // Fronleichnam (60 days after easter sunday) |
|
849 | - $date_fronleichnam = mktime( |
|
850 | - date("H", $date_paques), |
|
851 | - date("i", $date_paques), |
|
852 | - date("s", $date_paques), |
|
853 | - date("m", $date_paques), |
|
854 | - date("d", $date_paques) + 60, |
|
855 | - date("Y", $date_paques) |
|
856 | - ); |
|
857 | - $jour_fronleichnam = date("d", $date_fronleichnam); |
|
858 | - $mois_fronleichnam = date("m", $date_fronleichnam); |
|
859 | - if($jour_fronleichnam == $jour && $mois_fronleichnam == $mois) $ferie=true; |
|
860 | - // Fronleichnam |
|
861 | - } |
|
862 | - |
|
863 | - // If we have to include saturday and sunday |
|
864 | - if ($includesaturdayandsunday) |
|
865 | - { |
|
866 | - $jour_julien = unixtojd($timestampStart); |
|
867 | - $jour_semaine = jddayofweek($jour_julien, 0); |
|
868 | - if($jour_semaine == 0 || $jour_semaine == 6) $ferie=true; |
|
869 | - //Saturday (6) and Sunday (0) |
|
870 | - } |
|
871 | - |
|
872 | - // On incremente compteur |
|
873 | - if ($ferie) $nbFerie++; |
|
874 | - |
|
875 | - // Increase number of days (on go up into loop) |
|
876 | - $timestampStart=dol_time_plus_duree($timestampStart, 1, 'd'); |
|
877 | - //var_dump($jour.' '.$mois.' '.$annee.' '.$timestampStart); |
|
878 | - |
|
879 | - $i++; |
|
880 | - } |
|
881 | - |
|
882 | - return $nbFerie; |
|
776 | + $jour_viernes = date("d", $date_viernes); |
|
777 | + $mois_viernes = date("m", $date_viernes); |
|
778 | + if($jour_viernes == $jour && $mois_viernes == $mois) $ferie=true; |
|
779 | + //Viernes Santo |
|
780 | + } |
|
781 | + |
|
782 | + if ($countrycode == 'AT') |
|
783 | + { |
|
784 | + $countryfound=1; |
|
785 | + |
|
786 | + // Definition des dates feriees fixes |
|
787 | + if($jour == 1 && $mois == 1) $ferie=true; // Neujahr |
|
788 | + if($jour == 6 && $mois == 1) $ferie=true; // Hl. 3 Koenige |
|
789 | + if($jour == 1 && $mois == 5) $ferie=true; // 1. Mai |
|
790 | + if($jour == 15 && $mois == 8) $ferie=true; // Mariae Himmelfahrt |
|
791 | + if($jour == 26 && $mois == 10) $ferie=true; // 26. Oktober |
|
792 | + if($jour == 1 && $mois == 11) $ferie=true; // Allerheiligen |
|
793 | + if($jour == 8 && $mois == 12) $ferie=true; // Mariae Empfaengnis |
|
794 | + if($jour == 24 && $mois == 12) $ferie=true; // Heilig abend |
|
795 | + if($jour == 25 && $mois == 12) $ferie=true; // Christtag |
|
796 | + if($jour == 26 && $mois == 12) $ferie=true; // Stefanietag |
|
797 | + if($jour == 31 && $mois == 12) $ferie=true; // Silvester |
|
798 | + |
|
799 | + // Easter calculation |
|
800 | + $date_paques = easter_date($annee); |
|
801 | + $jour_paques = date("d", $date_paques); |
|
802 | + $mois_paques = date("m", $date_paques); |
|
803 | + if($jour_paques == $jour && $mois_paques == $mois) $ferie=true; |
|
804 | + // Easter sunday |
|
805 | + |
|
806 | + // Monday after easter |
|
807 | + $date_eastermonday = mktime( |
|
808 | + date("H", $date_paques), |
|
809 | + date("i", $date_paques), |
|
810 | + date("s", $date_paques), |
|
811 | + date("m", $date_paques), |
|
812 | + date("d", $date_paques) + 1, |
|
813 | + date("Y", $date_paques) |
|
814 | + ); |
|
815 | + $jour_eastermonday = date("d", $date_eastermonday); |
|
816 | + $mois_eastermonday = date("m", $date_eastermonday); |
|
817 | + if($jour_eastermonday == $jour && $mois_eastermonday == $mois) $ferie=true; |
|
818 | + // Easter monday |
|
819 | + |
|
820 | + // Christi Himmelfahrt (39 days after easter sunday) |
|
821 | + $date_ch = mktime( |
|
822 | + date("H", $date_paques), |
|
823 | + date("i", $date_paques), |
|
824 | + date("s", $date_paques), |
|
825 | + date("m", $date_paques), |
|
826 | + date("d", $date_paques) + 39, |
|
827 | + date("Y", $date_paques) |
|
828 | + ); |
|
829 | + $jour_ch = date("d", $date_ch); |
|
830 | + $mois_ch = date("m", $date_ch); |
|
831 | + if($jour_ch == $jour && $mois_ch == $mois) $ferie=true; |
|
832 | + // Christi Himmelfahrt |
|
833 | + |
|
834 | + // Pfingsten (50 days after easter sunday) |
|
835 | + $date_pentecote = mktime( |
|
836 | + date("H", $date_paques), |
|
837 | + date("i", $date_paques), |
|
838 | + date("s", $date_paques), |
|
839 | + date("m", $date_paques), |
|
840 | + date("d", $date_paques) + 50, |
|
841 | + date("Y", $date_paques) |
|
842 | + ); |
|
843 | + $jour_pentecote = date("d", $date_pentecote); |
|
844 | + $mois_pentecote = date("m", $date_pentecote); |
|
845 | + if($jour_pentecote == $jour && $mois_pentecote == $mois) $ferie=true; |
|
846 | + // Pfingsten |
|
847 | + |
|
848 | + // Fronleichnam (60 days after easter sunday) |
|
849 | + $date_fronleichnam = mktime( |
|
850 | + date("H", $date_paques), |
|
851 | + date("i", $date_paques), |
|
852 | + date("s", $date_paques), |
|
853 | + date("m", $date_paques), |
|
854 | + date("d", $date_paques) + 60, |
|
855 | + date("Y", $date_paques) |
|
856 | + ); |
|
857 | + $jour_fronleichnam = date("d", $date_fronleichnam); |
|
858 | + $mois_fronleichnam = date("m", $date_fronleichnam); |
|
859 | + if($jour_fronleichnam == $jour && $mois_fronleichnam == $mois) $ferie=true; |
|
860 | + // Fronleichnam |
|
861 | + } |
|
862 | + |
|
863 | + // If we have to include saturday and sunday |
|
864 | + if ($includesaturdayandsunday) |
|
865 | + { |
|
866 | + $jour_julien = unixtojd($timestampStart); |
|
867 | + $jour_semaine = jddayofweek($jour_julien, 0); |
|
868 | + if($jour_semaine == 0 || $jour_semaine == 6) $ferie=true; |
|
869 | + //Saturday (6) and Sunday (0) |
|
870 | + } |
|
871 | + |
|
872 | + // On incremente compteur |
|
873 | + if ($ferie) $nbFerie++; |
|
874 | + |
|
875 | + // Increase number of days (on go up into loop) |
|
876 | + $timestampStart=dol_time_plus_duree($timestampStart, 1, 'd'); |
|
877 | + //var_dump($jour.' '.$mois.' '.$annee.' '.$timestampStart); |
|
878 | + |
|
879 | + $i++; |
|
880 | + } |
|
881 | + |
|
882 | + return $nbFerie; |
|
883 | 883 | } |
884 | 884 | |
885 | 885 | /** |
@@ -894,20 +894,20 @@ discard block |
||
894 | 894 | */ |
895 | 895 | function num_between_day($timestampStart, $timestampEnd, $lastday=0) |
896 | 896 | { |
897 | - if ($timestampStart < $timestampEnd) |
|
898 | - { |
|
899 | - if ($lastday == 1) |
|
900 | - { |
|
901 | - $bit = 0; |
|
902 | - } |
|
903 | - else |
|
904 | - { |
|
905 | - $bit = 1; |
|
906 | - } |
|
907 | - $nbjours = (int) floor(($timestampEnd - $timestampStart)/(60*60*24)) + 1 - $bit; |
|
908 | - } |
|
909 | - //print ($timestampEnd - $timestampStart) - $lastday; |
|
910 | - return $nbjours; |
|
897 | + if ($timestampStart < $timestampEnd) |
|
898 | + { |
|
899 | + if ($lastday == 1) |
|
900 | + { |
|
901 | + $bit = 0; |
|
902 | + } |
|
903 | + else |
|
904 | + { |
|
905 | + $bit = 1; |
|
906 | + } |
|
907 | + $nbjours = (int) floor(($timestampEnd - $timestampStart)/(60*60*24)) + 1 - $bit; |
|
908 | + } |
|
909 | + //print ($timestampEnd - $timestampStart) - $lastday; |
|
910 | + return $nbjours; |
|
911 | 911 | } |
912 | 912 | |
913 | 913 | /** |
@@ -924,36 +924,36 @@ discard block |
||
924 | 924 | */ |
925 | 925 | function num_open_day($timestampStart, $timestampEnd, $inhour=0, $lastday=0, $halfday=0, $country_code='') |
926 | 926 | { |
927 | - global $langs,$mysoc; |
|
928 | - |
|
929 | - if (empty($country_code)) $country_code=$mysoc->country_code; |
|
930 | - |
|
931 | - dol_syslog('num_open_day timestampStart='.$timestampStart.' timestampEnd='.$timestampEnd.' bit='.$lastday.' country_code='.$country_code); |
|
932 | - |
|
933 | - // Check parameters |
|
934 | - if (! is_int($timestampStart) && ! is_float($timestampStart)) return 'ErrorBadParameter_num_open_day'; |
|
935 | - if (! is_int($timestampEnd) && ! is_float($timestampEnd)) return 'ErrorBadParameter_num_open_day'; |
|
936 | - |
|
937 | - //print 'num_open_day timestampStart='.$timestampStart.' timestampEnd='.$timestampEnd.' bit='.$lastday; |
|
938 | - if ($timestampStart < $timestampEnd) |
|
939 | - { |
|
940 | - $numdays = num_between_day($timestampStart, $timestampEnd, $lastday); |
|
941 | - $numholidays = num_public_holiday($timestampStart, $timestampEnd, $country_code, $lastday); |
|
942 | - $nbOpenDay = $numdays - $numholidays; |
|
943 | - $nbOpenDay.= " " . $langs->trans("Days"); |
|
944 | - if ($inhour == 1 && $nbOpenDay <= 3) $nbOpenDay = $nbOpenDay*24 . $langs->trans("HourShort"); |
|
945 | - return $nbOpenDay - (($inhour == 1 ? 12 : 0.5) * abs($halfday)); |
|
946 | - } |
|
947 | - elseif ($timestampStart == $timestampEnd) |
|
948 | - { |
|
949 | - $nbOpenDay=$lastday; |
|
950 | - if ($inhour == 1) $nbOpenDay = $nbOpenDay*24 . $langs->trans("HourShort"); |
|
951 | - return $nbOpenDay - (($inhour == 1 ? 12 : 0.5) * abs($halfday)); |
|
952 | - } |
|
953 | - else |
|
954 | - { |
|
955 | - return $langs->trans("Error"); |
|
956 | - } |
|
927 | + global $langs,$mysoc; |
|
928 | + |
|
929 | + if (empty($country_code)) $country_code=$mysoc->country_code; |
|
930 | + |
|
931 | + dol_syslog('num_open_day timestampStart='.$timestampStart.' timestampEnd='.$timestampEnd.' bit='.$lastday.' country_code='.$country_code); |
|
932 | + |
|
933 | + // Check parameters |
|
934 | + if (! is_int($timestampStart) && ! is_float($timestampStart)) return 'ErrorBadParameter_num_open_day'; |
|
935 | + if (! is_int($timestampEnd) && ! is_float($timestampEnd)) return 'ErrorBadParameter_num_open_day'; |
|
936 | + |
|
937 | + //print 'num_open_day timestampStart='.$timestampStart.' timestampEnd='.$timestampEnd.' bit='.$lastday; |
|
938 | + if ($timestampStart < $timestampEnd) |
|
939 | + { |
|
940 | + $numdays = num_between_day($timestampStart, $timestampEnd, $lastday); |
|
941 | + $numholidays = num_public_holiday($timestampStart, $timestampEnd, $country_code, $lastday); |
|
942 | + $nbOpenDay = $numdays - $numholidays; |
|
943 | + $nbOpenDay.= " " . $langs->trans("Days"); |
|
944 | + if ($inhour == 1 && $nbOpenDay <= 3) $nbOpenDay = $nbOpenDay*24 . $langs->trans("HourShort"); |
|
945 | + return $nbOpenDay - (($inhour == 1 ? 12 : 0.5) * abs($halfday)); |
|
946 | + } |
|
947 | + elseif ($timestampStart == $timestampEnd) |
|
948 | + { |
|
949 | + $nbOpenDay=$lastday; |
|
950 | + if ($inhour == 1) $nbOpenDay = $nbOpenDay*24 . $langs->trans("HourShort"); |
|
951 | + return $nbOpenDay - (($inhour == 1 ? 12 : 0.5) * abs($halfday)); |
|
952 | + } |
|
953 | + else |
|
954 | + { |
|
955 | + return $langs->trans("Error"); |
|
956 | + } |
|
957 | 957 | } |
958 | 958 | |
959 | 959 | |
@@ -968,38 +968,38 @@ discard block |
||
968 | 968 | */ |
969 | 969 | function monthArray($outputlangs,$short=0) |
970 | 970 | { |
971 | - $montharray = array ( |
|
972 | - 1 => $outputlangs->trans("Month01"), |
|
973 | - 2 => $outputlangs->trans("Month02"), |
|
974 | - 3 => $outputlangs->trans("Month03"), |
|
975 | - 4 => $outputlangs->trans("Month04"), |
|
976 | - 5 => $outputlangs->trans("Month05"), |
|
977 | - 6 => $outputlangs->trans("Month06"), |
|
978 | - 7 => $outputlangs->trans("Month07"), |
|
979 | - 8 => $outputlangs->trans("Month08"), |
|
980 | - 9 => $outputlangs->trans("Month09"), |
|
981 | - 10 => $outputlangs->trans("Month10"), |
|
982 | - 11 => $outputlangs->trans("Month11"), |
|
983 | - 12 => $outputlangs->trans("Month12") |
|
971 | + $montharray = array ( |
|
972 | + 1 => $outputlangs->trans("Month01"), |
|
973 | + 2 => $outputlangs->trans("Month02"), |
|
974 | + 3 => $outputlangs->trans("Month03"), |
|
975 | + 4 => $outputlangs->trans("Month04"), |
|
976 | + 5 => $outputlangs->trans("Month05"), |
|
977 | + 6 => $outputlangs->trans("Month06"), |
|
978 | + 7 => $outputlangs->trans("Month07"), |
|
979 | + 8 => $outputlangs->trans("Month08"), |
|
980 | + 9 => $outputlangs->trans("Month09"), |
|
981 | + 10 => $outputlangs->trans("Month10"), |
|
982 | + 11 => $outputlangs->trans("Month11"), |
|
983 | + 12 => $outputlangs->trans("Month12") |
|
984 | 984 | ); |
985 | 985 | |
986 | - if (! empty($short)) |
|
987 | - { |
|
988 | - $montharray = array ( |
|
989 | - 1 => $outputlangs->trans("MonthShort01"), |
|
990 | - 2 => $outputlangs->trans("MonthShort02"), |
|
991 | - 3 => $outputlangs->trans("MonthShort03"), |
|
992 | - 4 => $outputlangs->trans("MonthShort04"), |
|
993 | - 5 => $outputlangs->trans("MonthShort05"), |
|
994 | - 6 => $outputlangs->trans("MonthShort06"), |
|
995 | - 7 => $outputlangs->trans("MonthShort07"), |
|
996 | - 8 => $outputlangs->trans("MonthShort08"), |
|
997 | - 9 => $outputlangs->trans("MonthShort09"), |
|
998 | - 10 => $outputlangs->trans("MonthShort10"), |
|
999 | - 11 => $outputlangs->trans("MonthShort11"), |
|
1000 | - 12 => $outputlangs->trans("MonthShort12") |
|
1001 | - ); |
|
1002 | - } |
|
1003 | - |
|
1004 | - return $montharray; |
|
986 | + if (! empty($short)) |
|
987 | + { |
|
988 | + $montharray = array ( |
|
989 | + 1 => $outputlangs->trans("MonthShort01"), |
|
990 | + 2 => $outputlangs->trans("MonthShort02"), |
|
991 | + 3 => $outputlangs->trans("MonthShort03"), |
|
992 | + 4 => $outputlangs->trans("MonthShort04"), |
|
993 | + 5 => $outputlangs->trans("MonthShort05"), |
|
994 | + 6 => $outputlangs->trans("MonthShort06"), |
|
995 | + 7 => $outputlangs->trans("MonthShort07"), |
|
996 | + 8 => $outputlangs->trans("MonthShort08"), |
|
997 | + 9 => $outputlangs->trans("MonthShort09"), |
|
998 | + 10 => $outputlangs->trans("MonthShort10"), |
|
999 | + 11 => $outputlangs->trans("MonthShort11"), |
|
1000 | + 12 => $outputlangs->trans("MonthShort12") |
|
1001 | + ); |
|
1002 | + } |
|
1003 | + |
|
1004 | + return $montharray; |
|
1005 | 1005 | } |
@@ -34,88 +34,88 @@ discard block |
||
34 | 34 | */ |
35 | 35 | function product_prepare_head($object) |
36 | 36 | { |
37 | - global $db, $langs, $conf, $user; |
|
38 | - $langs->load("products"); |
|
39 | - |
|
40 | - $h = 0; |
|
41 | - $head = array(); |
|
42 | - |
|
43 | - $head[$h][0] = DOL_URL_ROOT."/product/card.php?id=".$object->id; |
|
44 | - $head[$h][1] = $langs->trans("Card"); |
|
45 | - $head[$h][2] = 'card'; |
|
46 | - $h++; |
|
47 | - |
|
48 | - if (! empty($object->status)) |
|
49 | - { |
|
50 | - $head[$h][0] = DOL_URL_ROOT."/product/price.php?id=".$object->id; |
|
51 | - $head[$h][1] = $langs->trans("SellingPrices"); |
|
52 | - $head[$h][2] = 'price'; |
|
53 | - $h++; |
|
54 | - } |
|
55 | - |
|
56 | - if (! empty($object->status_buy) || (! empty($conf->margin->enabled) && ! empty($object->status))) // If margin is on and product on sell, we may need the cost price even if product os not on purchase |
|
57 | - { |
|
58 | - if ((! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->lire) |
|
59 | - || (! empty($conf->margin->enabled) && $user->rights->margin->liretous) |
|
60 | - ) |
|
61 | - { |
|
62 | - $head[$h][0] = DOL_URL_ROOT."/product/fournisseurs.php?id=".$object->id; |
|
63 | - $head[$h][1] = $langs->trans("BuyingPrices"); |
|
64 | - $head[$h][2] = 'suppliers'; |
|
65 | - $h++; |
|
66 | - } |
|
67 | - } |
|
68 | - |
|
69 | - // Multilangs |
|
70 | - if (! empty($conf->global->MAIN_MULTILANGS)) |
|
71 | - { |
|
72 | - $head[$h][0] = DOL_URL_ROOT."/product/traduction.php?id=".$object->id; |
|
73 | - $head[$h][1] = $langs->trans("Translation"); |
|
74 | - $head[$h][2] = 'translation'; |
|
75 | - $h++; |
|
76 | - } |
|
77 | - |
|
78 | - // Sub products |
|
79 | - if (! empty($conf->global->PRODUIT_SOUSPRODUITS)) |
|
80 | - { |
|
81 | - $head[$h][0] = DOL_URL_ROOT."/product/composition/card.php?id=".$object->id; |
|
82 | - $head[$h][1] = $langs->trans('AssociatedProducts'); |
|
83 | - |
|
84 | - $nbFatherAndChild = $object->hasFatherOrChild(); |
|
85 | - if ($nbFatherAndChild > 0) $head[$h][1].= ' <span class="badge">'.$nbFatherAndChild.'</span>'; |
|
86 | - $head[$h][2] = 'subproduct'; |
|
87 | - $h++; |
|
88 | - } |
|
89 | - |
|
90 | - $head[$h][0] = DOL_URL_ROOT."/product/stats/card.php?id=".$object->id; |
|
91 | - $head[$h][1] = $langs->trans('Statistics'); |
|
92 | - $head[$h][2] = 'stats'; |
|
93 | - $h++; |
|
94 | - |
|
95 | - $head[$h][0] = DOL_URL_ROOT."/product/stats/facture.php?showmessage=1&id=".$object->id; |
|
96 | - $head[$h][1] = $langs->trans('Referers'); |
|
97 | - $head[$h][2] = 'referers'; |
|
98 | - $h++; |
|
99 | - |
|
100 | - if (!empty($conf->variants->enabled) && ($object->isProduct() || $object->isService())) { |
|
101 | - |
|
102 | - global $db; |
|
103 | - |
|
104 | - require_once DOL_DOCUMENT_ROOT.'/variants/class/ProductCombination.class.php'; |
|
105 | - |
|
106 | - $prodcomb = new ProductCombination($db); |
|
107 | - |
|
108 | - if ($prodcomb->fetchByFkProductChild($object->id) == -1) |
|
109 | - { |
|
110 | - $head[$h][0] = DOL_URL_ROOT."/variants/combinations.php?id=".$object->id; |
|
111 | - $head[$h][1] = $langs->trans('ProductCombinations'); |
|
112 | - $head[$h][2] = 'combinations'; |
|
113 | - $nbVariant = $prodcomb->countNbOfCombinationForFkProductParent($object->id); |
|
37 | + global $db, $langs, $conf, $user; |
|
38 | + $langs->load("products"); |
|
39 | + |
|
40 | + $h = 0; |
|
41 | + $head = array(); |
|
42 | + |
|
43 | + $head[$h][0] = DOL_URL_ROOT."/product/card.php?id=".$object->id; |
|
44 | + $head[$h][1] = $langs->trans("Card"); |
|
45 | + $head[$h][2] = 'card'; |
|
46 | + $h++; |
|
47 | + |
|
48 | + if (! empty($object->status)) |
|
49 | + { |
|
50 | + $head[$h][0] = DOL_URL_ROOT."/product/price.php?id=".$object->id; |
|
51 | + $head[$h][1] = $langs->trans("SellingPrices"); |
|
52 | + $head[$h][2] = 'price'; |
|
53 | + $h++; |
|
54 | + } |
|
55 | + |
|
56 | + if (! empty($object->status_buy) || (! empty($conf->margin->enabled) && ! empty($object->status))) // If margin is on and product on sell, we may need the cost price even if product os not on purchase |
|
57 | + { |
|
58 | + if ((! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->lire) |
|
59 | + || (! empty($conf->margin->enabled) && $user->rights->margin->liretous) |
|
60 | + ) |
|
61 | + { |
|
62 | + $head[$h][0] = DOL_URL_ROOT."/product/fournisseurs.php?id=".$object->id; |
|
63 | + $head[$h][1] = $langs->trans("BuyingPrices"); |
|
64 | + $head[$h][2] = 'suppliers'; |
|
65 | + $h++; |
|
66 | + } |
|
67 | + } |
|
68 | + |
|
69 | + // Multilangs |
|
70 | + if (! empty($conf->global->MAIN_MULTILANGS)) |
|
71 | + { |
|
72 | + $head[$h][0] = DOL_URL_ROOT."/product/traduction.php?id=".$object->id; |
|
73 | + $head[$h][1] = $langs->trans("Translation"); |
|
74 | + $head[$h][2] = 'translation'; |
|
75 | + $h++; |
|
76 | + } |
|
77 | + |
|
78 | + // Sub products |
|
79 | + if (! empty($conf->global->PRODUIT_SOUSPRODUITS)) |
|
80 | + { |
|
81 | + $head[$h][0] = DOL_URL_ROOT."/product/composition/card.php?id=".$object->id; |
|
82 | + $head[$h][1] = $langs->trans('AssociatedProducts'); |
|
83 | + |
|
84 | + $nbFatherAndChild = $object->hasFatherOrChild(); |
|
85 | + if ($nbFatherAndChild > 0) $head[$h][1].= ' <span class="badge">'.$nbFatherAndChild.'</span>'; |
|
86 | + $head[$h][2] = 'subproduct'; |
|
87 | + $h++; |
|
88 | + } |
|
89 | + |
|
90 | + $head[$h][0] = DOL_URL_ROOT."/product/stats/card.php?id=".$object->id; |
|
91 | + $head[$h][1] = $langs->trans('Statistics'); |
|
92 | + $head[$h][2] = 'stats'; |
|
93 | + $h++; |
|
94 | + |
|
95 | + $head[$h][0] = DOL_URL_ROOT."/product/stats/facture.php?showmessage=1&id=".$object->id; |
|
96 | + $head[$h][1] = $langs->trans('Referers'); |
|
97 | + $head[$h][2] = 'referers'; |
|
98 | + $h++; |
|
99 | + |
|
100 | + if (!empty($conf->variants->enabled) && ($object->isProduct() || $object->isService())) { |
|
101 | + |
|
102 | + global $db; |
|
103 | + |
|
104 | + require_once DOL_DOCUMENT_ROOT.'/variants/class/ProductCombination.class.php'; |
|
105 | + |
|
106 | + $prodcomb = new ProductCombination($db); |
|
107 | + |
|
108 | + if ($prodcomb->fetchByFkProductChild($object->id) == -1) |
|
109 | + { |
|
110 | + $head[$h][0] = DOL_URL_ROOT."/variants/combinations.php?id=".$object->id; |
|
111 | + $head[$h][1] = $langs->trans('ProductCombinations'); |
|
112 | + $head[$h][2] = 'combinations'; |
|
113 | + $nbVariant = $prodcomb->countNbOfCombinationForFkProductParent($object->id); |
|
114 | 114 | if ($nbVariant > 0) $head[$h][1].= ' <span class="badge">'.$nbVariant.'</span>'; |
115 | - } |
|
115 | + } |
|
116 | 116 | |
117 | - $h++; |
|
118 | - } |
|
117 | + $h++; |
|
118 | + } |
|
119 | 119 | |
120 | 120 | if ($object->isProduct() || ($object->isService() && ! empty($conf->global->STOCK_SUPPORTS_SERVICES))) // If physical product we can stock (or service with option) |
121 | 121 | { |
@@ -148,7 +148,7 @@ discard block |
||
148 | 148 | } |
149 | 149 | |
150 | 150 | // Attachments |
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 | 153 | if (! empty($conf->product->enabled) && ($object->type==Product::TYPE_PRODUCT)) $upload_dir = $conf->product->multidir_output[$object->entity].'/'.dol_sanitizeFileName($object->ref); |
154 | 154 | if (! empty($conf->service->enabled) && ($object->type==Product::TYPE_SERVICE)) $upload_dir = $conf->service->multidir_output[$object->entity].'/'.dol_sanitizeFileName($object->ref); |
@@ -159,11 +159,11 @@ discard block |
||
159 | 159 | $nbFiles += count(dol_dir_list($upload_dir,'files',0,'','(\.meta|_preview.*\.png)$')); |
160 | 160 | } |
161 | 161 | $nbLinks=Link::count($db, $object->element, $object->id); |
162 | - $head[$h][0] = DOL_URL_ROOT.'/product/document.php?id='.$object->id; |
|
163 | - $head[$h][1] = $langs->trans('Documents'); |
|
164 | - if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>'; |
|
165 | - $head[$h][2] = 'documents'; |
|
166 | - $h++; |
|
162 | + $head[$h][0] = DOL_URL_ROOT.'/product/document.php?id='.$object->id; |
|
163 | + $head[$h][1] = $langs->trans('Documents'); |
|
164 | + if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>'; |
|
165 | + $head[$h][2] = 'documents'; |
|
166 | + $h++; |
|
167 | 167 | |
168 | 168 | complete_head_from_modules($conf,$langs,$object,$head,$h,'product', 'remove'); |
169 | 169 | |
@@ -172,13 +172,13 @@ discard block |
||
172 | 172 | $head[$h][1] = $langs->trans("Events"); |
173 | 173 | if (! empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read) )) |
174 | 174 | { |
175 | - $head[$h][1].= '/'; |
|
176 | - $head[$h][1].= $langs->trans("Agenda"); |
|
175 | + $head[$h][1].= '/'; |
|
176 | + $head[$h][1].= $langs->trans("Agenda"); |
|
177 | 177 | } |
178 | 178 | $head[$h][2] = 'agenda'; |
179 | 179 | $h++; |
180 | 180 | |
181 | - return $head; |
|
181 | + return $head; |
|
182 | 182 | } |
183 | 183 | |
184 | 184 | /** |
@@ -200,19 +200,19 @@ discard block |
||
200 | 200 | $head[$h][0] = DOL_URL_ROOT."/product/stock/productlot_card.php?id=".$object->id; |
201 | 201 | $head[$h][1] = $langs->trans("Card"); |
202 | 202 | $head[$h][2] = 'card'; |
203 | - $h++; |
|
203 | + $h++; |
|
204 | 204 | |
205 | - // Attachments |
|
206 | - require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; |
|
205 | + // Attachments |
|
206 | + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; |
|
207 | 207 | require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php'; |
208 | 208 | $upload_dir = $conf->productbatch->multidir_output[$object->entity].'/'.dol_sanitizeFileName($object->ref); |
209 | 209 | $nbFiles = count(dol_dir_list($upload_dir,'files',0,'','(\.meta|_preview.*\.png)$')); |
210 | 210 | $nbLinks=Link::count($db, $object->element, $object->id); |
211 | - $head[$h][0] = DOL_URL_ROOT."/product/stock/productlot_document.php?id=".$object->id; |
|
212 | - $head[$h][1] = $langs->trans("Documents"); |
|
213 | - if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>'; |
|
211 | + $head[$h][0] = DOL_URL_ROOT."/product/stock/productlot_document.php?id=".$object->id; |
|
212 | + $head[$h][1] = $langs->trans("Documents"); |
|
213 | + if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>'; |
|
214 | 214 | $head[$h][2] = 'documents'; |
215 | - $h++; |
|
215 | + $h++; |
|
216 | 216 | |
217 | 217 | // Show more tabs from modules |
218 | 218 | // Entries must be declared in modules descriptor with line |
@@ -242,40 +242,40 @@ discard block |
||
242 | 242 | */ |
243 | 243 | function product_admin_prepare_head() |
244 | 244 | { |
245 | - global $langs, $conf, $user; |
|
246 | - |
|
247 | - $h = 0; |
|
248 | - $head = array(); |
|
249 | - |
|
250 | - $head[$h][0] = DOL_URL_ROOT."/product/admin/product.php"; |
|
251 | - $head[$h][1] = $langs->trans('Parameters'); |
|
252 | - $head[$h][2] = 'general'; |
|
253 | - $h++; |
|
254 | - |
|
255 | - if (!empty($conf->global->PRODUIT_MULTIPRICES) && ! empty($conf->global->PRODUIT_MULTIPRICES_ALLOW_AUTOCALC_PRICELEVEL)) |
|
256 | - { |
|
257 | - $head[$h] = array( |
|
258 | - 0 => DOL_URL_ROOT."/product/admin/price_rules.php", |
|
259 | - 1 => $langs->trans('MultipriceRules'), |
|
260 | - 2 => 'generator' |
|
261 | - ); |
|
262 | - $h++; |
|
263 | - } |
|
264 | - |
|
265 | - // Show more tabs from modules |
|
266 | - // Entries must be declared in modules descriptor with line |
|
245 | + global $langs, $conf, $user; |
|
246 | + |
|
247 | + $h = 0; |
|
248 | + $head = array(); |
|
249 | + |
|
250 | + $head[$h][0] = DOL_URL_ROOT."/product/admin/product.php"; |
|
251 | + $head[$h][1] = $langs->trans('Parameters'); |
|
252 | + $head[$h][2] = 'general'; |
|
253 | + $h++; |
|
254 | + |
|
255 | + if (!empty($conf->global->PRODUIT_MULTIPRICES) && ! empty($conf->global->PRODUIT_MULTIPRICES_ALLOW_AUTOCALC_PRICELEVEL)) |
|
256 | + { |
|
257 | + $head[$h] = array( |
|
258 | + 0 => DOL_URL_ROOT."/product/admin/price_rules.php", |
|
259 | + 1 => $langs->trans('MultipriceRules'), |
|
260 | + 2 => 'generator' |
|
261 | + ); |
|
262 | + $h++; |
|
263 | + } |
|
264 | + |
|
265 | + // Show more tabs from modules |
|
266 | + // Entries must be declared in modules descriptor with line |
|
267 | 267 | // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab |
268 | 268 | // $this->tabs = array('entity:-tabname); to remove a tab |
269 | - complete_head_from_modules($conf,$langs,null,$head,$h,'product_admin'); |
|
269 | + complete_head_from_modules($conf,$langs,null,$head,$h,'product_admin'); |
|
270 | 270 | |
271 | - $head[$h][0] = DOL_URL_ROOT.'/product/admin/product_extrafields.php'; |
|
272 | - $head[$h][1] = $langs->trans("ExtraFields"); |
|
273 | - $head[$h][2] = 'attributes'; |
|
274 | - $h++; |
|
271 | + $head[$h][0] = DOL_URL_ROOT.'/product/admin/product_extrafields.php'; |
|
272 | + $head[$h][1] = $langs->trans("ExtraFields"); |
|
273 | + $head[$h][2] = 'attributes'; |
|
274 | + $h++; |
|
275 | 275 | |
276 | - complete_head_from_modules($conf,$langs,null,$head,$h,'product_admin','remove'); |
|
276 | + complete_head_from_modules($conf,$langs,null,$head,$h,'product_admin','remove'); |
|
277 | 277 | |
278 | - return $head; |
|
278 | + return $head; |
|
279 | 279 | } |
280 | 280 | |
281 | 281 | |
@@ -319,146 +319,146 @@ discard block |
||
319 | 319 | */ |
320 | 320 | function show_stats_for_company($product,$socid) |
321 | 321 | { |
322 | - global $conf,$langs,$user,$db; |
|
323 | - |
|
324 | - $nblines = 0; |
|
325 | - |
|
326 | - print '<tr class="liste_titre">'; |
|
327 | - print '<td align="left" width="25%">'.$langs->trans("Referers").'</td>'; |
|
328 | - print '<td align="right" width="25%">'.$langs->trans("NbOfThirdParties").'</td>'; |
|
329 | - print '<td align="right" width="25%">'.$langs->trans("NbOfObjectReferers").'</td>'; |
|
330 | - print '<td align="right" width="25%">'.$langs->trans("TotalQuantity").'</td>'; |
|
331 | - print '</tr>'; |
|
332 | - |
|
333 | - // Customer proposals |
|
334 | - if (! empty($conf->propal->enabled) && $user->rights->propale->lire) |
|
335 | - { |
|
336 | - $nblines++; |
|
337 | - $ret=$product->load_stats_propale($socid); |
|
338 | - if ($ret < 0) dol_print_error($db); |
|
339 | - $langs->load("propal"); |
|
340 | - print '<tr><td>'; |
|
341 | - print '<a href="propal.php?id='.$product->id.'">'.img_object('','propal').' '.$langs->trans("Proposals").'</a>'; |
|
342 | - print '</td><td align="right">'; |
|
343 | - print $product->stats_propale['customers']; |
|
344 | - print '</td><td align="right">'; |
|
345 | - print $product->stats_propale['nb']; |
|
346 | - print '</td><td align="right">'; |
|
347 | - print $product->stats_propale['qty']; |
|
348 | - print '</td>'; |
|
349 | - print '</tr>'; |
|
350 | - } |
|
351 | - // Supplier proposals |
|
352 | - if (! empty($conf->supplier_proposal->enabled) && $user->rights->supplier_proposal->lire) |
|
353 | - { |
|
354 | - $nblines++; |
|
355 | - $ret=$product->load_stats_proposal_supplier($socid); |
|
356 | - if ($ret < 0) dol_print_error($db); |
|
357 | - $langs->load("propal"); |
|
358 | - print '<tr><td>'; |
|
359 | - print '<a href="supplier_proposal.php?id='.$product->id.'">'.img_object('','propal').' '.$langs->trans("SupplierProposals").'</a>'; |
|
360 | - print '</td><td align="right">'; |
|
361 | - print $product->stats_proposal_supplier['suppliers']; |
|
362 | - print '</td><td align="right">'; |
|
363 | - print $product->stats_proposal_supplier['nb']; |
|
364 | - print '</td><td align="right">'; |
|
365 | - print $product->stats_proposal_supplier['qty']; |
|
366 | - print '</td>'; |
|
367 | - print '</tr>'; |
|
368 | - } |
|
369 | - // Customer orders |
|
370 | - if (! empty($conf->commande->enabled) && $user->rights->commande->lire) |
|
371 | - { |
|
372 | - $nblines++; |
|
373 | - $ret=$product->load_stats_commande($socid); |
|
374 | - if ($ret < 0) dol_print_error($db); |
|
375 | - $langs->load("orders"); |
|
376 | - print '<tr><td>'; |
|
377 | - print '<a href="commande.php?id='.$product->id.'">'.img_object('','order').' '.$langs->trans("CustomersOrders").'</a>'; |
|
378 | - print '</td><td align="right">'; |
|
379 | - print $product->stats_commande['customers']; |
|
380 | - print '</td><td align="right">'; |
|
381 | - print $product->stats_commande['nb']; |
|
382 | - print '</td><td align="right">'; |
|
383 | - print $product->stats_commande['qty']; |
|
384 | - print '</td>'; |
|
385 | - print '</tr>'; |
|
386 | - } |
|
387 | - // Supplier orders |
|
388 | - if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->commande->lire) |
|
389 | - { |
|
390 | - $nblines++; |
|
391 | - $ret=$product->load_stats_commande_fournisseur($socid); |
|
392 | - if ($ret < 0) dol_print_error($db); |
|
393 | - $langs->load("orders"); |
|
394 | - print '<tr><td>'; |
|
395 | - print '<a href="commande_fournisseur.php?id='.$product->id.'">'.img_object('','order').' '.$langs->trans("SuppliersOrders").'</a>'; |
|
396 | - print '</td><td align="right">'; |
|
397 | - print $product->stats_commande_fournisseur['suppliers']; |
|
398 | - print '</td><td align="right">'; |
|
399 | - print $product->stats_commande_fournisseur['nb']; |
|
400 | - print '</td><td align="right">'; |
|
401 | - print $product->stats_commande_fournisseur['qty']; |
|
402 | - print '</td>'; |
|
403 | - print '</tr>'; |
|
404 | - } |
|
405 | - // Customer invoices |
|
406 | - if (! empty($conf->facture->enabled) && $user->rights->facture->lire) |
|
407 | - { |
|
408 | - $nblines++; |
|
409 | - $ret=$product->load_stats_facture($socid); |
|
410 | - if ($ret < 0) dol_print_error($db); |
|
411 | - $langs->load("bills"); |
|
412 | - print '<tr><td>'; |
|
413 | - print '<a href="facture.php?id='.$product->id.'">'.img_object('','bill').' '.$langs->trans("CustomersInvoices").'</a>'; |
|
414 | - print '</td><td align="right">'; |
|
415 | - print $product->stats_facture['customers']; |
|
416 | - print '</td><td align="right">'; |
|
417 | - print $product->stats_facture['nb']; |
|
418 | - print '</td><td align="right">'; |
|
419 | - print $product->stats_facture['qty']; |
|
420 | - print '</td>'; |
|
421 | - print '</tr>'; |
|
422 | - } |
|
423 | - // Supplier invoices |
|
424 | - if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->facture->lire) |
|
425 | - { |
|
426 | - $nblines++; |
|
427 | - $ret=$product->load_stats_facture_fournisseur($socid); |
|
428 | - if ($ret < 0) dol_print_error($db); |
|
429 | - $langs->load("bills"); |
|
430 | - print '<tr><td>'; |
|
431 | - print '<a href="facture_fournisseur.php?id='.$product->id.'">'.img_object('','bill').' '.$langs->trans("SuppliersInvoices").'</a>'; |
|
432 | - print '</td><td align="right">'; |
|
433 | - print $product->stats_facture_fournisseur['suppliers']; |
|
434 | - print '</td><td align="right">'; |
|
435 | - print $product->stats_facture_fournisseur['nb']; |
|
436 | - print '</td><td align="right">'; |
|
437 | - print $product->stats_facture_fournisseur['qty']; |
|
438 | - print '</td>'; |
|
439 | - print '</tr>'; |
|
440 | - } |
|
441 | - |
|
442 | - // Contracts |
|
443 | - if (! empty($conf->contrat->enabled) && $user->rights->contrat->lire) |
|
444 | - { |
|
445 | - $nblines++; |
|
446 | - $ret=$product->load_stats_contrat($socid); |
|
447 | - if ($ret < 0) dol_print_error($db); |
|
448 | - $langs->load("contracts"); |
|
449 | - print '<tr><td>'; |
|
450 | - print '<a href="contrat.php?id='.$product->id.'">'.img_object('','contract').' '.$langs->trans("Contracts").'</a>'; |
|
451 | - print '</td><td align="right">'; |
|
452 | - print $product->stats_contrat['customers']; |
|
453 | - print '</td><td align="right">'; |
|
454 | - print $product->stats_contrat['nb']; |
|
455 | - print '</td><td align="right">'; |
|
456 | - print $product->stats_contrat['qty']; |
|
457 | - print '</td>'; |
|
458 | - print '</tr>'; |
|
459 | - } |
|
460 | - |
|
461 | - return $nblines++; |
|
322 | + global $conf,$langs,$user,$db; |
|
323 | + |
|
324 | + $nblines = 0; |
|
325 | + |
|
326 | + print '<tr class="liste_titre">'; |
|
327 | + print '<td align="left" width="25%">'.$langs->trans("Referers").'</td>'; |
|
328 | + print '<td align="right" width="25%">'.$langs->trans("NbOfThirdParties").'</td>'; |
|
329 | + print '<td align="right" width="25%">'.$langs->trans("NbOfObjectReferers").'</td>'; |
|
330 | + print '<td align="right" width="25%">'.$langs->trans("TotalQuantity").'</td>'; |
|
331 | + print '</tr>'; |
|
332 | + |
|
333 | + // Customer proposals |
|
334 | + if (! empty($conf->propal->enabled) && $user->rights->propale->lire) |
|
335 | + { |
|
336 | + $nblines++; |
|
337 | + $ret=$product->load_stats_propale($socid); |
|
338 | + if ($ret < 0) dol_print_error($db); |
|
339 | + $langs->load("propal"); |
|
340 | + print '<tr><td>'; |
|
341 | + print '<a href="propal.php?id='.$product->id.'">'.img_object('','propal').' '.$langs->trans("Proposals").'</a>'; |
|
342 | + print '</td><td align="right">'; |
|
343 | + print $product->stats_propale['customers']; |
|
344 | + print '</td><td align="right">'; |
|
345 | + print $product->stats_propale['nb']; |
|
346 | + print '</td><td align="right">'; |
|
347 | + print $product->stats_propale['qty']; |
|
348 | + print '</td>'; |
|
349 | + print '</tr>'; |
|
350 | + } |
|
351 | + // Supplier proposals |
|
352 | + if (! empty($conf->supplier_proposal->enabled) && $user->rights->supplier_proposal->lire) |
|
353 | + { |
|
354 | + $nblines++; |
|
355 | + $ret=$product->load_stats_proposal_supplier($socid); |
|
356 | + if ($ret < 0) dol_print_error($db); |
|
357 | + $langs->load("propal"); |
|
358 | + print '<tr><td>'; |
|
359 | + print '<a href="supplier_proposal.php?id='.$product->id.'">'.img_object('','propal').' '.$langs->trans("SupplierProposals").'</a>'; |
|
360 | + print '</td><td align="right">'; |
|
361 | + print $product->stats_proposal_supplier['suppliers']; |
|
362 | + print '</td><td align="right">'; |
|
363 | + print $product->stats_proposal_supplier['nb']; |
|
364 | + print '</td><td align="right">'; |
|
365 | + print $product->stats_proposal_supplier['qty']; |
|
366 | + print '</td>'; |
|
367 | + print '</tr>'; |
|
368 | + } |
|
369 | + // Customer orders |
|
370 | + if (! empty($conf->commande->enabled) && $user->rights->commande->lire) |
|
371 | + { |
|
372 | + $nblines++; |
|
373 | + $ret=$product->load_stats_commande($socid); |
|
374 | + if ($ret < 0) dol_print_error($db); |
|
375 | + $langs->load("orders"); |
|
376 | + print '<tr><td>'; |
|
377 | + print '<a href="commande.php?id='.$product->id.'">'.img_object('','order').' '.$langs->trans("CustomersOrders").'</a>'; |
|
378 | + print '</td><td align="right">'; |
|
379 | + print $product->stats_commande['customers']; |
|
380 | + print '</td><td align="right">'; |
|
381 | + print $product->stats_commande['nb']; |
|
382 | + print '</td><td align="right">'; |
|
383 | + print $product->stats_commande['qty']; |
|
384 | + print '</td>'; |
|
385 | + print '</tr>'; |
|
386 | + } |
|
387 | + // Supplier orders |
|
388 | + if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->commande->lire) |
|
389 | + { |
|
390 | + $nblines++; |
|
391 | + $ret=$product->load_stats_commande_fournisseur($socid); |
|
392 | + if ($ret < 0) dol_print_error($db); |
|
393 | + $langs->load("orders"); |
|
394 | + print '<tr><td>'; |
|
395 | + print '<a href="commande_fournisseur.php?id='.$product->id.'">'.img_object('','order').' '.$langs->trans("SuppliersOrders").'</a>'; |
|
396 | + print '</td><td align="right">'; |
|
397 | + print $product->stats_commande_fournisseur['suppliers']; |
|
398 | + print '</td><td align="right">'; |
|
399 | + print $product->stats_commande_fournisseur['nb']; |
|
400 | + print '</td><td align="right">'; |
|
401 | + print $product->stats_commande_fournisseur['qty']; |
|
402 | + print '</td>'; |
|
403 | + print '</tr>'; |
|
404 | + } |
|
405 | + // Customer invoices |
|
406 | + if (! empty($conf->facture->enabled) && $user->rights->facture->lire) |
|
407 | + { |
|
408 | + $nblines++; |
|
409 | + $ret=$product->load_stats_facture($socid); |
|
410 | + if ($ret < 0) dol_print_error($db); |
|
411 | + $langs->load("bills"); |
|
412 | + print '<tr><td>'; |
|
413 | + print '<a href="facture.php?id='.$product->id.'">'.img_object('','bill').' '.$langs->trans("CustomersInvoices").'</a>'; |
|
414 | + print '</td><td align="right">'; |
|
415 | + print $product->stats_facture['customers']; |
|
416 | + print '</td><td align="right">'; |
|
417 | + print $product->stats_facture['nb']; |
|
418 | + print '</td><td align="right">'; |
|
419 | + print $product->stats_facture['qty']; |
|
420 | + print '</td>'; |
|
421 | + print '</tr>'; |
|
422 | + } |
|
423 | + // Supplier invoices |
|
424 | + if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->facture->lire) |
|
425 | + { |
|
426 | + $nblines++; |
|
427 | + $ret=$product->load_stats_facture_fournisseur($socid); |
|
428 | + if ($ret < 0) dol_print_error($db); |
|
429 | + $langs->load("bills"); |
|
430 | + print '<tr><td>'; |
|
431 | + print '<a href="facture_fournisseur.php?id='.$product->id.'">'.img_object('','bill').' '.$langs->trans("SuppliersInvoices").'</a>'; |
|
432 | + print '</td><td align="right">'; |
|
433 | + print $product->stats_facture_fournisseur['suppliers']; |
|
434 | + print '</td><td align="right">'; |
|
435 | + print $product->stats_facture_fournisseur['nb']; |
|
436 | + print '</td><td align="right">'; |
|
437 | + print $product->stats_facture_fournisseur['qty']; |
|
438 | + print '</td>'; |
|
439 | + print '</tr>'; |
|
440 | + } |
|
441 | + |
|
442 | + // Contracts |
|
443 | + if (! empty($conf->contrat->enabled) && $user->rights->contrat->lire) |
|
444 | + { |
|
445 | + $nblines++; |
|
446 | + $ret=$product->load_stats_contrat($socid); |
|
447 | + if ($ret < 0) dol_print_error($db); |
|
448 | + $langs->load("contracts"); |
|
449 | + print '<tr><td>'; |
|
450 | + print '<a href="contrat.php?id='.$product->id.'">'.img_object('','contract').' '.$langs->trans("Contracts").'</a>'; |
|
451 | + print '</td><td align="right">'; |
|
452 | + print $product->stats_contrat['customers']; |
|
453 | + print '</td><td align="right">'; |
|
454 | + print $product->stats_contrat['nb']; |
|
455 | + print '</td><td align="right">'; |
|
456 | + print $product->stats_contrat['qty']; |
|
457 | + print '</td>'; |
|
458 | + print '</tr>'; |
|
459 | + } |
|
460 | + |
|
461 | + return $nblines++; |
|
462 | 462 | } |
463 | 463 | |
464 | 464 | |
@@ -472,50 +472,50 @@ discard block |
||
472 | 472 | */ |
473 | 473 | function measuring_units_string($unit,$measuring_style='') |
474 | 474 | { |
475 | - global $langs; |
|
476 | - |
|
477 | - $measuring_units=array(); |
|
478 | - if ($measuring_style == 'weight') |
|
479 | - { |
|
480 | - $measuring_units[3] = $langs->transnoentitiesnoconv("WeightUnitton"); |
|
481 | - $measuring_units[0] = $langs->transnoentitiesnoconv("WeightUnitkg"); |
|
482 | - $measuring_units[-3] = $langs->transnoentitiesnoconv("WeightUnitg"); |
|
483 | - $measuring_units[-6] = $langs->transnoentitiesnoconv("WeightUnitmg"); |
|
484 | - $measuring_units[98] = $langs->transnoentitiesnoconv("WeightUnitounce"); |
|
485 | - $measuring_units[99] = $langs->transnoentitiesnoconv("WeightUnitpound"); |
|
486 | - } |
|
487 | - else if ($measuring_style == 'size') |
|
488 | - { |
|
489 | - $measuring_units[0] = $langs->transnoentitiesnoconv("SizeUnitm"); |
|
490 | - $measuring_units[-1] = $langs->transnoentitiesnoconv("SizeUnitdm"); |
|
491 | - $measuring_units[-2] = $langs->transnoentitiesnoconv("SizeUnitcm"); |
|
492 | - $measuring_units[-3] = $langs->transnoentitiesnoconv("SizeUnitmm"); |
|
475 | + global $langs; |
|
476 | + |
|
477 | + $measuring_units=array(); |
|
478 | + if ($measuring_style == 'weight') |
|
479 | + { |
|
480 | + $measuring_units[3] = $langs->transnoentitiesnoconv("WeightUnitton"); |
|
481 | + $measuring_units[0] = $langs->transnoentitiesnoconv("WeightUnitkg"); |
|
482 | + $measuring_units[-3] = $langs->transnoentitiesnoconv("WeightUnitg"); |
|
483 | + $measuring_units[-6] = $langs->transnoentitiesnoconv("WeightUnitmg"); |
|
484 | + $measuring_units[98] = $langs->transnoentitiesnoconv("WeightUnitounce"); |
|
485 | + $measuring_units[99] = $langs->transnoentitiesnoconv("WeightUnitpound"); |
|
486 | + } |
|
487 | + else if ($measuring_style == 'size') |
|
488 | + { |
|
489 | + $measuring_units[0] = $langs->transnoentitiesnoconv("SizeUnitm"); |
|
490 | + $measuring_units[-1] = $langs->transnoentitiesnoconv("SizeUnitdm"); |
|
491 | + $measuring_units[-2] = $langs->transnoentitiesnoconv("SizeUnitcm"); |
|
492 | + $measuring_units[-3] = $langs->transnoentitiesnoconv("SizeUnitmm"); |
|
493 | 493 | $measuring_units[98] = $langs->transnoentitiesnoconv("SizeUnitfoot"); |
494 | - $measuring_units[99] = $langs->transnoentitiesnoconv("SizeUnitinch"); |
|
495 | - } |
|
496 | - else if ($measuring_style == 'surface') |
|
497 | - { |
|
498 | - $measuring_units[0] = $langs->transnoentitiesnoconv("SurfaceUnitm2"); |
|
499 | - $measuring_units[-2] = $langs->transnoentitiesnoconv("SurfaceUnitdm2"); |
|
500 | - $measuring_units[-4] = $langs->transnoentitiesnoconv("SurfaceUnitcm2"); |
|
501 | - $measuring_units[-6] = $langs->transnoentitiesnoconv("SurfaceUnitmm2"); |
|
494 | + $measuring_units[99] = $langs->transnoentitiesnoconv("SizeUnitinch"); |
|
495 | + } |
|
496 | + else if ($measuring_style == 'surface') |
|
497 | + { |
|
498 | + $measuring_units[0] = $langs->transnoentitiesnoconv("SurfaceUnitm2"); |
|
499 | + $measuring_units[-2] = $langs->transnoentitiesnoconv("SurfaceUnitdm2"); |
|
500 | + $measuring_units[-4] = $langs->transnoentitiesnoconv("SurfaceUnitcm2"); |
|
501 | + $measuring_units[-6] = $langs->transnoentitiesnoconv("SurfaceUnitmm2"); |
|
502 | 502 | $measuring_units[98] = $langs->transnoentitiesnoconv("SurfaceUnitfoot2"); |
503 | - $measuring_units[99] = $langs->transnoentitiesnoconv("SurfaceUnitinch2"); |
|
504 | - } |
|
505 | - else if ($measuring_style == 'volume') |
|
506 | - { |
|
507 | - $measuring_units[0] = $langs->transnoentitiesnoconv("VolumeUnitm3"); |
|
508 | - $measuring_units[-3] = $langs->transnoentitiesnoconv("VolumeUnitdm3"); |
|
509 | - $measuring_units[-6] = $langs->transnoentitiesnoconv("VolumeUnitcm3"); |
|
510 | - $measuring_units[-9] = $langs->transnoentitiesnoconv("VolumeUnitmm3"); |
|
503 | + $measuring_units[99] = $langs->transnoentitiesnoconv("SurfaceUnitinch2"); |
|
504 | + } |
|
505 | + else if ($measuring_style == 'volume') |
|
506 | + { |
|
507 | + $measuring_units[0] = $langs->transnoentitiesnoconv("VolumeUnitm3"); |
|
508 | + $measuring_units[-3] = $langs->transnoentitiesnoconv("VolumeUnitdm3"); |
|
509 | + $measuring_units[-6] = $langs->transnoentitiesnoconv("VolumeUnitcm3"); |
|
510 | + $measuring_units[-9] = $langs->transnoentitiesnoconv("VolumeUnitmm3"); |
|
511 | 511 | $measuring_units[88] = $langs->transnoentitiesnoconv("VolumeUnitfoot3"); |
512 | 512 | $measuring_units[89] = $langs->transnoentitiesnoconv("VolumeUnitinch3"); |
513 | - $measuring_units[97] = $langs->transnoentitiesnoconv("VolumeUnitounce"); |
|
514 | - $measuring_units[98] = $langs->transnoentitiesnoconv("VolumeUnitlitre"); |
|
513 | + $measuring_units[97] = $langs->transnoentitiesnoconv("VolumeUnitounce"); |
|
514 | + $measuring_units[98] = $langs->transnoentitiesnoconv("VolumeUnitlitre"); |
|
515 | 515 | $measuring_units[99] = $langs->transnoentitiesnoconv("VolumeUnitgallon"); |
516 | - } |
|
516 | + } |
|
517 | 517 | |
518 | - return $measuring_units[$unit]; |
|
518 | + return $measuring_units[$unit]; |
|
519 | 519 | } |
520 | 520 | |
521 | 521 | /** |
@@ -527,14 +527,14 @@ discard block |
||
527 | 527 | */ |
528 | 528 | function measuring_units_squared($unit) |
529 | 529 | { |
530 | - $measuring_units=array(); |
|
531 | - $measuring_units[0] = 0; // m -> m3 |
|
532 | - $measuring_units[-1] = -2; // dm-> dm2 |
|
533 | - $measuring_units[-2] = -4; // cm -> cm2 |
|
534 | - $measuring_units[-3] = -6; // mm -> mm2 |
|
535 | - $measuring_units[98] = 98; // foot -> foot2 |
|
536 | - $measuring_units[99] = 99; // inch -> inch2 |
|
537 | - return $measuring_units[$unit]; |
|
530 | + $measuring_units=array(); |
|
531 | + $measuring_units[0] = 0; // m -> m3 |
|
532 | + $measuring_units[-1] = -2; // dm-> dm2 |
|
533 | + $measuring_units[-2] = -4; // cm -> cm2 |
|
534 | + $measuring_units[-3] = -6; // mm -> mm2 |
|
535 | + $measuring_units[98] = 98; // foot -> foot2 |
|
536 | + $measuring_units[99] = 99; // inch -> inch2 |
|
537 | + return $measuring_units[$unit]; |
|
538 | 538 | } |
539 | 539 | |
540 | 540 | |
@@ -547,12 +547,12 @@ discard block |
||
547 | 547 | */ |
548 | 548 | function measuring_units_cubed($unit) |
549 | 549 | { |
550 | - $measuring_units=array(); |
|
551 | - $measuring_units[0] = 0; // m -> m2 |
|
552 | - $measuring_units[-1] = -3; // dm-> dm3 |
|
553 | - $measuring_units[-2] = -6; // cm -> cm3 |
|
554 | - $measuring_units[-3] = -9; // mm -> mm3 |
|
555 | - $measuring_units[98] = 88; // foot -> foot3 |
|
556 | - $measuring_units[99] = 89; // inch -> inch3 |
|
557 | - return $measuring_units[$unit]; |
|
550 | + $measuring_units=array(); |
|
551 | + $measuring_units[0] = 0; // m -> m2 |
|
552 | + $measuring_units[-1] = -3; // dm-> dm3 |
|
553 | + $measuring_units[-2] = -6; // cm -> cm3 |
|
554 | + $measuring_units[-3] = -9; // mm -> mm3 |
|
555 | + $measuring_units[98] = 88; // foot -> foot3 |
|
556 | + $measuring_units[99] = 89; // inch -> inch3 |
|
557 | + return $measuring_units[$unit]; |
|
558 | 558 | } |
@@ -31,26 +31,26 @@ discard block |
||
31 | 31 | */ |
32 | 32 | function ecm_prepare_dasboard_head($object) |
33 | 33 | { |
34 | - global $langs, $conf, $user, $form; |
|
35 | - global $helptext1, $helptext2; |
|
34 | + global $langs, $conf, $user, $form; |
|
35 | + global $helptext1, $helptext2; |
|
36 | 36 | |
37 | - $h = 0; |
|
38 | - $head = array(); |
|
37 | + $h = 0; |
|
38 | + $head = array(); |
|
39 | 39 | $helptext =$langs->trans("ECMAreaDesc").'<br>'; |
40 | 40 | $helptext.=$langs->trans("ECMAreaDesc2"); |
41 | 41 | |
42 | - $head[$h][0] = DOL_URL_ROOT.'/ecm/index.php'; |
|
43 | - $head[$h][1] = $langs->trans("ECMSectionsManual").$form->textwithpicto('', $helptext, 1, 'info', '', 0, 3); |
|
44 | - $head[$h][2] = 'index'; |
|
45 | - $h++; |
|
42 | + $head[$h][0] = DOL_URL_ROOT.'/ecm/index.php'; |
|
43 | + $head[$h][1] = $langs->trans("ECMSectionsManual").$form->textwithpicto('', $helptext, 1, 'info', '', 0, 3); |
|
44 | + $head[$h][2] = 'index'; |
|
45 | + $h++; |
|
46 | 46 | |
47 | - if (! empty($conf->global->ECM_AUTO_TREE_ENABLED)) |
|
48 | - { |
|
49 | - $head[$h][0] = DOL_URL_ROOT.'/ecm/index_auto.php'; |
|
50 | - $head[$h][1] = $langs->trans("ECMSectionsAuto").$form->textwithpicto('', $helptext, 1, 'info', '', 0, 3); |
|
51 | - $head[$h][2] = 'index_auto'; |
|
52 | - $h++; |
|
53 | - } |
|
47 | + if (! empty($conf->global->ECM_AUTO_TREE_ENABLED)) |
|
48 | + { |
|
49 | + $head[$h][0] = DOL_URL_ROOT.'/ecm/index_auto.php'; |
|
50 | + $head[$h][1] = $langs->trans("ECMSectionsAuto").$form->textwithpicto('', $helptext, 1, 'info', '', 0, 3); |
|
51 | + $head[$h][2] = 'index_auto'; |
|
52 | + $h++; |
|
53 | + } |
|
54 | 54 | |
55 | 55 | // Show more tabs from modules |
56 | 56 | // Entries must be declared in modules descriptor with line |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | |
61 | 61 | complete_head_from_modules($conf,$langs,$object,$head,$h,'ecm','remove'); |
62 | 62 | |
63 | - return $head; |
|
63 | + return $head; |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | |
@@ -74,26 +74,26 @@ discard block |
||
74 | 74 | */ |
75 | 75 | function ecm_prepare_head($object, $module='ecm', $section='') |
76 | 76 | { |
77 | - global $langs, $conf, $user; |
|
78 | - $h = 0; |
|
79 | - $head = array(); |
|
80 | - |
|
81 | - if ($module == 'ecm') |
|
82 | - { |
|
83 | - $head[$h][0] = DOL_URL_ROOT.'/ecm/dir_card.php?section='.$object->id; |
|
84 | - $head[$h][1] = $langs->trans("Card"); |
|
85 | - $head[$h][2] = 'card'; |
|
86 | - $h++; |
|
87 | - } |
|
88 | - else |
|
89 | - { |
|
90 | - $head[$h][0] = DOL_URL_ROOT.'/ecm/dir_card.php?section='.$section.'&module='.$module; |
|
91 | - $head[$h][1] = $langs->trans("Card"); |
|
92 | - $head[$h][2] = 'card'; |
|
93 | - $h++; |
|
94 | - } |
|
95 | - |
|
96 | - return $head; |
|
77 | + global $langs, $conf, $user; |
|
78 | + $h = 0; |
|
79 | + $head = array(); |
|
80 | + |
|
81 | + if ($module == 'ecm') |
|
82 | + { |
|
83 | + $head[$h][0] = DOL_URL_ROOT.'/ecm/dir_card.php?section='.$object->id; |
|
84 | + $head[$h][1] = $langs->trans("Card"); |
|
85 | + $head[$h][2] = 'card'; |
|
86 | + $h++; |
|
87 | + } |
|
88 | + else |
|
89 | + { |
|
90 | + $head[$h][0] = DOL_URL_ROOT.'/ecm/dir_card.php?section='.$section.'&module='.$module; |
|
91 | + $head[$h][1] = $langs->trans("Card"); |
|
92 | + $head[$h][2] = 'card'; |
|
93 | + $h++; |
|
94 | + } |
|
95 | + |
|
96 | + return $head; |
|
97 | 97 | } |
98 | 98 | |
99 | 99 | /** |
@@ -124,20 +124,20 @@ discard block |
||
124 | 124 | */ |
125 | 125 | function ecm_prepare_head_fm($object) |
126 | 126 | { |
127 | - global $langs, $conf; |
|
128 | - $h = 0; |
|
129 | - $head = array(); |
|
127 | + global $langs, $conf; |
|
128 | + $h = 0; |
|
129 | + $head = array(); |
|
130 | 130 | |
131 | - $head[$h][0] = DOL_URL_ROOT.'/ecm/index.php?action=file_manager'; |
|
132 | - $head[$h][1] = $langs->trans('ECMFileManager'); |
|
133 | - $head[$h][2] = 'file_manager'; |
|
134 | - $h++; |
|
131 | + $head[$h][0] = DOL_URL_ROOT.'/ecm/index.php?action=file_manager'; |
|
132 | + $head[$h][1] = $langs->trans('ECMFileManager'); |
|
133 | + $head[$h][2] = 'file_manager'; |
|
134 | + $h++; |
|
135 | 135 | |
136 | - $head[$h][0] = DOL_URL_ROOT.'/ecm/search.php'; |
|
137 | - $head[$h][1] = $langs->trans('Search'); |
|
138 | - $head[$h][2] = 'search_form'; |
|
139 | - $h++; |
|
136 | + $head[$h][0] = DOL_URL_ROOT.'/ecm/search.php'; |
|
137 | + $head[$h][1] = $langs->trans('Search'); |
|
138 | + $head[$h][2] = 'search_form'; |
|
139 | + $h++; |
|
140 | 140 | |
141 | - return $head; |
|
141 | + return $head; |
|
142 | 142 | } |
143 | 143 |
@@ -35,31 +35,31 @@ discard block |
||
35 | 35 | */ |
36 | 36 | function dol_convertToWord($num, $langs, $currency=false, $centimes=false) |
37 | 37 | { |
38 | - global $conf; |
|
38 | + global $conf; |
|
39 | 39 | |
40 | 40 | $num = str_replace(array(',', ' '), '', trim($num)); |
41 | 41 | if(! $num) { |
42 | 42 | return false; |
43 | 43 | } |
44 | - if($centimes && strlen($num) == 1) { |
|
45 | - $num = $num*10; |
|
46 | - } |
|
47 | - $TNum = explode('.',$num); |
|
44 | + if($centimes && strlen($num) == 1) { |
|
45 | + $num = $num*10; |
|
46 | + } |
|
47 | + $TNum = explode('.',$num); |
|
48 | 48 | $num = (int) $TNum[0]; |
49 | 49 | $words = array(); |
50 | 50 | $list1 = array( |
51 | - '', |
|
52 | - $langs->transnoentitiesnoconv('one'), |
|
53 | - $langs->transnoentitiesnoconv('two'), |
|
54 | - $langs->transnoentitiesnoconv('three'), |
|
55 | - $langs->transnoentitiesnoconv('four'), |
|
56 | - $langs->transnoentitiesnoconv('five'), |
|
57 | - $langs->transnoentitiesnoconv('six'), |
|
58 | - $langs->transnoentitiesnoconv('seven'), |
|
59 | - $langs->transnoentitiesnoconv('eight'), |
|
60 | - $langs->transnoentitiesnoconv('nine'), |
|
61 | - $langs->transnoentitiesnoconv('ten'), |
|
62 | - $langs->transnoentitiesnoconv('eleven'), |
|
51 | + '', |
|
52 | + $langs->transnoentitiesnoconv('one'), |
|
53 | + $langs->transnoentitiesnoconv('two'), |
|
54 | + $langs->transnoentitiesnoconv('three'), |
|
55 | + $langs->transnoentitiesnoconv('four'), |
|
56 | + $langs->transnoentitiesnoconv('five'), |
|
57 | + $langs->transnoentitiesnoconv('six'), |
|
58 | + $langs->transnoentitiesnoconv('seven'), |
|
59 | + $langs->transnoentitiesnoconv('eight'), |
|
60 | + $langs->transnoentitiesnoconv('nine'), |
|
61 | + $langs->transnoentitiesnoconv('ten'), |
|
62 | + $langs->transnoentitiesnoconv('eleven'), |
|
63 | 63 | $langs->transnoentitiesnoconv('twelve'), |
64 | 64 | $langs->transnoentitiesnoconv('thirteen'), |
65 | 65 | $langs->transnoentitiesnoconv('fourteen'), |
@@ -70,25 +70,25 @@ discard block |
||
70 | 70 | $langs->transnoentitiesnoconv('nineteen') |
71 | 71 | ); |
72 | 72 | $list2 = array( |
73 | - '', |
|
74 | - $langs->transnoentitiesnoconv('ten'), |
|
75 | - $langs->transnoentitiesnoconv('twenty'), |
|
76 | - $langs->transnoentitiesnoconv('thirty'), |
|
77 | - $langs->transnoentitiesnoconv('forty'), |
|
78 | - $langs->transnoentitiesnoconv('fifty'), |
|
79 | - $langs->transnoentitiesnoconv('sixty'), |
|
80 | - $langs->transnoentitiesnoconv('seventy'), |
|
81 | - $langs->transnoentitiesnoconv('eighty'), |
|
82 | - $langs->transnoentitiesnoconv('ninety'), |
|
83 | - $langs->transnoentitiesnoconv('hundred') |
|
84 | - ); |
|
73 | + '', |
|
74 | + $langs->transnoentitiesnoconv('ten'), |
|
75 | + $langs->transnoentitiesnoconv('twenty'), |
|
76 | + $langs->transnoentitiesnoconv('thirty'), |
|
77 | + $langs->transnoentitiesnoconv('forty'), |
|
78 | + $langs->transnoentitiesnoconv('fifty'), |
|
79 | + $langs->transnoentitiesnoconv('sixty'), |
|
80 | + $langs->transnoentitiesnoconv('seventy'), |
|
81 | + $langs->transnoentitiesnoconv('eighty'), |
|
82 | + $langs->transnoentitiesnoconv('ninety'), |
|
83 | + $langs->transnoentitiesnoconv('hundred') |
|
84 | + ); |
|
85 | 85 | $list3 = array( |
86 | - '', |
|
87 | - $langs->transnoentitiesnoconv('thousand'), |
|
88 | - $langs->transnoentitiesnoconv('million'), |
|
89 | - $langs->transnoentitiesnoconv('billion'), |
|
90 | - $langs->transnoentitiesnoconv('trillion'), |
|
91 | - $langs->transnoentitiesnoconv('quadrillion') |
|
86 | + '', |
|
87 | + $langs->transnoentitiesnoconv('thousand'), |
|
88 | + $langs->transnoentitiesnoconv('million'), |
|
89 | + $langs->transnoentitiesnoconv('billion'), |
|
90 | + $langs->transnoentitiesnoconv('trillion'), |
|
91 | + $langs->transnoentitiesnoconv('quadrillion') |
|
92 | 92 | ); |
93 | 93 | |
94 | 94 | $num_length = strlen($num); |
@@ -117,20 +117,20 @@ discard block |
||
117 | 117 | if ($commas > 1) { |
118 | 118 | $commas = $commas - 1; |
119 | 119 | } |
120 | - $concatWords = implode(' ', $words); |
|
121 | - // Delete multi whitespaces |
|
122 | - $concatWords = trim(preg_replace('/[ ]+/', ' ', $concatWords)); |
|
120 | + $concatWords = implode(' ', $words); |
|
121 | + // Delete multi whitespaces |
|
122 | + $concatWords = trim(preg_replace('/[ ]+/', ' ', $concatWords)); |
|
123 | 123 | |
124 | - if(!empty($currency)) { |
|
125 | - $concatWords .= ' '.$currency; |
|
126 | - } |
|
124 | + if(!empty($currency)) { |
|
125 | + $concatWords .= ' '.$currency; |
|
126 | + } |
|
127 | 127 | |
128 | - // If we need to write cents call again this function for cents |
|
129 | - if(!empty($TNum[1])) { |
|
130 | - if(!empty($currency)) $concatWords .= ' '.$langs->transnoentities('and'); |
|
131 | - $concatWords .= ' '.dol_convertToWord($TNum[1], $langs, $currency, true); |
|
132 | - if(!empty($currency)) $concatWords .= ' '.$langs->transnoentities('centimes'); |
|
133 | - } |
|
128 | + // If we need to write cents call again this function for cents |
|
129 | + if(!empty($TNum[1])) { |
|
130 | + if(!empty($currency)) $concatWords .= ' '.$langs->transnoentities('and'); |
|
131 | + $concatWords .= ' '.dol_convertToWord($TNum[1], $langs, $currency, true); |
|
132 | + if(!empty($currency)) $concatWords .= ' '.$langs->transnoentities('centimes'); |
|
133 | + } |
|
134 | 134 | return $concatWords; |
135 | 135 | } |
136 | 136 | |
@@ -146,85 +146,85 @@ discard block |
||
146 | 146 | */ |
147 | 147 | function dolNumberToWord($numero, $langs, $numorcurrency='number') |
148 | 148 | { |
149 | - // If the number is negative convert to positive and return -1 if is too long |
|
150 | - if ($numero < 0) $numero *= -1; |
|
151 | - if ($numero >= 1000000000001) |
|
152 | - return -1; |
|
153 | - // Get 2 decimals to cents, another functions round or truncate |
|
154 | - $strnumber = number_format ($numero,10); |
|
155 | - $len=strlen($strnumber); |
|
156 | - for ($i=0; $i<$len; $i++) |
|
157 | - { |
|
158 | - if ($strnumber[$i]=='.') { |
|
159 | - $parte_decimal = $strnumber[$i+1].$strnumber[$i+2]; |
|
160 | - break; |
|
161 | - } |
|
162 | - } |
|
149 | + // If the number is negative convert to positive and return -1 if is too long |
|
150 | + if ($numero < 0) $numero *= -1; |
|
151 | + if ($numero >= 1000000000001) |
|
152 | + return -1; |
|
153 | + // Get 2 decimals to cents, another functions round or truncate |
|
154 | + $strnumber = number_format ($numero,10); |
|
155 | + $len=strlen($strnumber); |
|
156 | + for ($i=0; $i<$len; $i++) |
|
157 | + { |
|
158 | + if ($strnumber[$i]=='.') { |
|
159 | + $parte_decimal = $strnumber[$i+1].$strnumber[$i+2]; |
|
160 | + break; |
|
161 | + } |
|
162 | + } |
|
163 | 163 | |
164 | - /*In dolibarr 3.6.2 (my current version) doesn't have $langs->default and |
|
164 | + /*In dolibarr 3.6.2 (my current version) doesn't have $langs->default and |
|
165 | 165 | in case exist why ask $lang like a parameter?*/ |
166 | - if (((is_object($langs) && $langs->default == 'es_MX') || (! is_object($langs) && $langs == 'es_MX')) && $numorcurrency == 'currency') |
|
167 | - { |
|
168 | - if ($numero>=1 && $numero<2) { |
|
169 | - return ("UN PESO ".$parte_decimal." / 100 M.N."); |
|
170 | - } |
|
171 | - elseif ($numero>=0 && $numero<1){ |
|
172 | - return ("CERO PESOS ".$parte_decimal." / 100 M.N."); |
|
173 | - } |
|
174 | - elseif ($numero>=1000000 && $numero<1000001){ |
|
175 | - return ("UN MILLÓN DE PESOS ".$parte_decimal." / 100 M.N."); |
|
176 | - } |
|
177 | - elseif ($numero>=1000000000000 && $numero<1000000000001){ |
|
178 | - return ("UN BILLÓN DE PESOS ".$parte_decimal." / 100 M.N."); |
|
179 | - } |
|
180 | - else { |
|
181 | - $entexto =""; |
|
182 | - $number = $numero; |
|
183 | - if ($number >= 1000000000){ |
|
184 | - $CdMMillon = (int) ($numero / 100000000000); |
|
185 | - $numero = $numero - $CdMMillon * 100000000000; |
|
186 | - $DdMMillon = (int) ($numero / 10000000000); |
|
187 | - $numero = $numero - $DdMMillon * 10000000000; |
|
188 | - $UdMMillon = (int) ($numero / 1000000000); |
|
189 | - $numero = $numero - $UdMMillon * 1000000000; |
|
190 | - $entexto .= hundreds2text ($CdMMillon, $DdMMillon, $UdMMillon); |
|
191 | - $entexto .= " MIL "; |
|
192 | - } |
|
193 | - if ($number >= 1000000){ |
|
194 | - $CdMILLON = (int) ($numero / 100000000); |
|
195 | - $numero = $numero - $CdMILLON * 100000000; |
|
196 | - $DdMILLON = (int) ($numero / 10000000); |
|
197 | - $numero = $numero - $DdMILLON * 10000000; |
|
198 | - $udMILLON = (int) ($numero / 1000000); |
|
199 | - $numero = $numero - $udMILLON * 1000000; |
|
200 | - $entexto .= hundreds2text ($CdMILLON, $DdMILLON, $udMILLON); |
|
201 | - if (!$CdMMillon && !$DdMMillon && !$UdMMillon && !$CdMILLON && !$DdMILLON && $udMILLON==1) |
|
202 | - $entexto .= " MILLÓN "; |
|
203 | - else |
|
204 | - $entexto .= " MILLONES "; |
|
205 | - } |
|
206 | - if ($number >= 1000) { |
|
207 | - $cdm = (int) ($numero / 100000); |
|
208 | - $numero = $numero - $cdm * 100000; |
|
209 | - $ddm = (int) ($numero / 10000); |
|
210 | - $numero = $numero - $ddm * 10000; |
|
211 | - $udm = (int) ($numero / 1000); |
|
212 | - $numero = $numero - $udm * 1000; |
|
213 | - $entexto .= hundreds2text ($cdm, $ddm, $udm); |
|
214 | - if ($cdm || $ddm || $udm) |
|
215 | - $entexto .= " MIL "; |
|
216 | - } |
|
217 | - $c = (int) ($numero / 100); |
|
218 | - $numero = $numero - $c * 100; |
|
219 | - $d = (int) ($numero / 10); |
|
220 | - $u = (int) $numero - $d * 10; |
|
221 | - $entexto .= hundreds2text ($c, $d, $u); |
|
222 | - if (!$cdm && !$ddm && !$udm && !$c && !$d && !$u && $number>1000000) |
|
223 | - $entexto .= " DE"; |
|
224 | - $entexto .= " PESOS ".$parte_decimal." / 100 M.N."; |
|
225 | - } |
|
226 | - return $entexto; |
|
227 | - } |
|
166 | + if (((is_object($langs) && $langs->default == 'es_MX') || (! is_object($langs) && $langs == 'es_MX')) && $numorcurrency == 'currency') |
|
167 | + { |
|
168 | + if ($numero>=1 && $numero<2) { |
|
169 | + return ("UN PESO ".$parte_decimal." / 100 M.N."); |
|
170 | + } |
|
171 | + elseif ($numero>=0 && $numero<1){ |
|
172 | + return ("CERO PESOS ".$parte_decimal." / 100 M.N."); |
|
173 | + } |
|
174 | + elseif ($numero>=1000000 && $numero<1000001){ |
|
175 | + return ("UN MILLÓN DE PESOS ".$parte_decimal." / 100 M.N."); |
|
176 | + } |
|
177 | + elseif ($numero>=1000000000000 && $numero<1000000000001){ |
|
178 | + return ("UN BILLÓN DE PESOS ".$parte_decimal." / 100 M.N."); |
|
179 | + } |
|
180 | + else { |
|
181 | + $entexto =""; |
|
182 | + $number = $numero; |
|
183 | + if ($number >= 1000000000){ |
|
184 | + $CdMMillon = (int) ($numero / 100000000000); |
|
185 | + $numero = $numero - $CdMMillon * 100000000000; |
|
186 | + $DdMMillon = (int) ($numero / 10000000000); |
|
187 | + $numero = $numero - $DdMMillon * 10000000000; |
|
188 | + $UdMMillon = (int) ($numero / 1000000000); |
|
189 | + $numero = $numero - $UdMMillon * 1000000000; |
|
190 | + $entexto .= hundreds2text ($CdMMillon, $DdMMillon, $UdMMillon); |
|
191 | + $entexto .= " MIL "; |
|
192 | + } |
|
193 | + if ($number >= 1000000){ |
|
194 | + $CdMILLON = (int) ($numero / 100000000); |
|
195 | + $numero = $numero - $CdMILLON * 100000000; |
|
196 | + $DdMILLON = (int) ($numero / 10000000); |
|
197 | + $numero = $numero - $DdMILLON * 10000000; |
|
198 | + $udMILLON = (int) ($numero / 1000000); |
|
199 | + $numero = $numero - $udMILLON * 1000000; |
|
200 | + $entexto .= hundreds2text ($CdMILLON, $DdMILLON, $udMILLON); |
|
201 | + if (!$CdMMillon && !$DdMMillon && !$UdMMillon && !$CdMILLON && !$DdMILLON && $udMILLON==1) |
|
202 | + $entexto .= " MILLÓN "; |
|
203 | + else |
|
204 | + $entexto .= " MILLONES "; |
|
205 | + } |
|
206 | + if ($number >= 1000) { |
|
207 | + $cdm = (int) ($numero / 100000); |
|
208 | + $numero = $numero - $cdm * 100000; |
|
209 | + $ddm = (int) ($numero / 10000); |
|
210 | + $numero = $numero - $ddm * 10000; |
|
211 | + $udm = (int) ($numero / 1000); |
|
212 | + $numero = $numero - $udm * 1000; |
|
213 | + $entexto .= hundreds2text ($cdm, $ddm, $udm); |
|
214 | + if ($cdm || $ddm || $udm) |
|
215 | + $entexto .= " MIL "; |
|
216 | + } |
|
217 | + $c = (int) ($numero / 100); |
|
218 | + $numero = $numero - $c * 100; |
|
219 | + $d = (int) ($numero / 10); |
|
220 | + $u = (int) $numero - $d * 10; |
|
221 | + $entexto .= hundreds2text ($c, $d, $u); |
|
222 | + if (!$cdm && !$ddm && !$udm && !$c && !$d && !$u && $number>1000000) |
|
223 | + $entexto .= " DE"; |
|
224 | + $entexto .= " PESOS ".$parte_decimal." / 100 M.N."; |
|
225 | + } |
|
226 | + return $entexto; |
|
227 | + } |
|
228 | 228 | } |
229 | 229 | |
230 | 230 | /** |
@@ -237,40 +237,40 @@ discard block |
||
237 | 237 | */ |
238 | 238 | function hundreds2text($hundreds, $tens, $units) |
239 | 239 | { |
240 | - if ($hundreds==1 && $tens==0 && $units==0){ |
|
241 | - return "CIEN"; |
|
242 | - } |
|
243 | - $centenas = array("CIENTO","DOSCIENTOS","TRESCIENTOS","CUATROCIENTOS","QUINIENTOS","SEISCIENTOS","SETECIENTOS","OCHOCIENTOS","NOVECIENTOS"); |
|
244 | - $decenas = array("","","TREINTA ","CUARENTA ","CINCUENTA ","SESENTA ","SETENTA ","OCHENTA ","NOVENTA "); |
|
245 | - $veintis = array("VEINTE","VEINTIUN","VEINTIDÓS","VEINTITRÉS","VEINTICUATRO","VEINTICINCO","VEINTISÉIS","VEINTISIETE","VEINTIOCHO","VEINTINUEVE"); |
|
246 | - $diecis = array("DIEZ","ONCE","DOCE","TRECE","CATORCE","QUINCE","DIECISÉIS","DIECISIETE","DIECIOCHO","DIECINUEVE"); |
|
240 | + if ($hundreds==1 && $tens==0 && $units==0){ |
|
241 | + return "CIEN"; |
|
242 | + } |
|
243 | + $centenas = array("CIENTO","DOSCIENTOS","TRESCIENTOS","CUATROCIENTOS","QUINIENTOS","SEISCIENTOS","SETECIENTOS","OCHOCIENTOS","NOVECIENTOS"); |
|
244 | + $decenas = array("","","TREINTA ","CUARENTA ","CINCUENTA ","SESENTA ","SETENTA ","OCHENTA ","NOVENTA "); |
|
245 | + $veintis = array("VEINTE","VEINTIUN","VEINTIDÓS","VEINTITRÉS","VEINTICUATRO","VEINTICINCO","VEINTISÉIS","VEINTISIETE","VEINTIOCHO","VEINTINUEVE"); |
|
246 | + $diecis = array("DIEZ","ONCE","DOCE","TRECE","CATORCE","QUINCE","DIECISÉIS","DIECISIETE","DIECIOCHO","DIECINUEVE"); |
|
247 | 247 | $unidades = array("UN","DOS","TRES","CUATRO","CINCO","SEIS","SIETE","OCHO","NUEVE"); |
248 | - $entexto = ""; |
|
249 | - if ($hundreds!=0){ |
|
250 | - $entexto .= $centenas[$hundreds-1]; |
|
251 | - } |
|
252 | - if ($tens>2){ |
|
253 | - if ($hundreds!=0) $entexto .= " "; |
|
254 | - $entexto .= $decenas[$tens-1]; |
|
255 | - if ($units!=0){ |
|
256 | - $entexto .= " Y "; |
|
257 | - $entexto .= $unidades[$units-1]; |
|
258 | - } |
|
259 | - return $entexto; |
|
260 | - } |
|
261 | - elseif ($tens==2){ |
|
262 | - if ($hundreds!=0) $entexto .= " "; |
|
263 | - $entexto .= " ".$veintis[$units]; |
|
264 | - return $entexto; |
|
265 | - } |
|
266 | - elseif ($tens==1){ |
|
267 | - if ($hundreds!=0) $entexto .= " "; |
|
268 | - $entexto .= $diecis[$units]; |
|
269 | - return $entexto; |
|
270 | - } |
|
271 | - if ($units!=0) { |
|
272 | - if ($hundreds!=0 || $tens!=0) $entexto .= " "; |
|
273 | - $entexto .= $unidades[$units-1]; |
|
274 | - } |
|
275 | - return $entexto; |
|
248 | + $entexto = ""; |
|
249 | + if ($hundreds!=0){ |
|
250 | + $entexto .= $centenas[$hundreds-1]; |
|
251 | + } |
|
252 | + if ($tens>2){ |
|
253 | + if ($hundreds!=0) $entexto .= " "; |
|
254 | + $entexto .= $decenas[$tens-1]; |
|
255 | + if ($units!=0){ |
|
256 | + $entexto .= " Y "; |
|
257 | + $entexto .= $unidades[$units-1]; |
|
258 | + } |
|
259 | + return $entexto; |
|
260 | + } |
|
261 | + elseif ($tens==2){ |
|
262 | + if ($hundreds!=0) $entexto .= " "; |
|
263 | + $entexto .= " ".$veintis[$units]; |
|
264 | + return $entexto; |
|
265 | + } |
|
266 | + elseif ($tens==1){ |
|
267 | + if ($hundreds!=0) $entexto .= " "; |
|
268 | + $entexto .= $diecis[$units]; |
|
269 | + return $entexto; |
|
270 | + } |
|
271 | + if ($units!=0) { |
|
272 | + if ($hundreds!=0 || $tens!=0) $entexto .= " "; |
|
273 | + $entexto .= $unidades[$units-1]; |
|
274 | + } |
|
275 | + return $entexto; |
|
276 | 276 | } |