@@ -65,32 +65,32 @@ |
||
65 | 65 | $errorcode='BAD_CREDENTIALS'; $errorlabel='Bad value for login or password'; |
66 | 66 | } |
67 | 67 | |
68 | - if (! $error && $fuser->statut == 0) |
|
69 | - { |
|
70 | - $error++; |
|
71 | - $errorcode='ERROR_USER_DISABLED'; $errorlabel='This user has been locked or disabled'; |
|
72 | - } |
|
68 | + if (! $error && $fuser->statut == 0) |
|
69 | + { |
|
70 | + $error++; |
|
71 | + $errorcode='ERROR_USER_DISABLED'; $errorlabel='This user has been locked or disabled'; |
|
72 | + } |
|
73 | 73 | |
74 | - // Validation of login |
|
75 | - if (! $error) |
|
76 | - { |
|
77 | - $fuser->getrights(); // Load permission of user |
|
74 | + // Validation of login |
|
75 | + if (! $error) |
|
76 | + { |
|
77 | + $fuser->getrights(); // Load permission of user |
|
78 | 78 | |
79 | - // Authentication mode |
|
80 | - if (empty($dolibarr_main_authentication)) $dolibarr_main_authentication='http,dolibarr'; |
|
81 | - // Authentication mode: forceuser |
|
82 | - if ($dolibarr_main_authentication == 'forceuser' && empty($dolibarr_auto_user)) $dolibarr_auto_user='auto'; |
|
83 | - // Set authmode |
|
84 | - $authmode=explode(',',$dolibarr_main_authentication); |
|
79 | + // Authentication mode |
|
80 | + if (empty($dolibarr_main_authentication)) $dolibarr_main_authentication='http,dolibarr'; |
|
81 | + // Authentication mode: forceuser |
|
82 | + if ($dolibarr_main_authentication == 'forceuser' && empty($dolibarr_auto_user)) $dolibarr_auto_user='auto'; |
|
83 | + // Set authmode |
|
84 | + $authmode=explode(',',$dolibarr_main_authentication); |
|
85 | 85 | |
86 | 86 | include_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php'; |
87 | - $login = checkLoginPassEntity($authentication['login'],$authentication['password'],$authentication['entity'],$authmode); |
|
88 | - if (empty($login)) |
|
89 | - { |
|
90 | - $error++; |
|
87 | + $login = checkLoginPassEntity($authentication['login'],$authentication['password'],$authentication['entity'],$authmode); |
|
88 | + if (empty($login)) |
|
89 | + { |
|
90 | + $error++; |
|
91 | 91 | $errorcode='BAD_CREDENTIALS'; $errorlabel='Bad value for login or password'; |
92 | - } |
|
93 | - } |
|
92 | + } |
|
93 | + } |
|
94 | 94 | } |
95 | 95 | |
96 | 96 | return $fuser; |
@@ -32,63 +32,63 @@ |
||
32 | 32 | * @param string $errorlabel Error string label |
33 | 33 | * @return User Return user object identified by login/pass/entity into authentication array |
34 | 34 | */ |
35 | -function check_authentication($authentication,&$error,&$errorcode,&$errorlabel) |
|
35 | +function check_authentication($authentication, &$error, &$errorcode, &$errorlabel) |
|
36 | 36 | { |
37 | - global $db,$conf,$langs; |
|
38 | - global $dolibarr_main_authentication,$dolibarr_auto_user; |
|
37 | + global $db, $conf, $langs; |
|
38 | + global $dolibarr_main_authentication, $dolibarr_auto_user; |
|
39 | 39 | |
40 | - $fuser=new User($db); |
|
40 | + $fuser = new User($db); |
|
41 | 41 | |
42 | - if (! $error && ($authentication['dolibarrkey'] != $conf->global->WEBSERVICES_KEY)) |
|
42 | + if (!$error && ($authentication['dolibarrkey'] != $conf->global->WEBSERVICES_KEY)) |
|
43 | 43 | { |
44 | 44 | $error++; |
45 | - $errorcode='BAD_VALUE_FOR_SECURITY_KEY'; $errorlabel='Value provided into dolibarrkey entry field does not match security key defined in Webservice module setup'; |
|
45 | + $errorcode = 'BAD_VALUE_FOR_SECURITY_KEY'; $errorlabel = 'Value provided into dolibarrkey entry field does not match security key defined in Webservice module setup'; |
|
46 | 46 | } |
47 | 47 | |
48 | - if (! $error && ! empty($authentication['entity']) && ! is_numeric($authentication['entity'])) |
|
48 | + if (!$error && !empty($authentication['entity']) && !is_numeric($authentication['entity'])) |
|
49 | 49 | { |
50 | 50 | $error++; |
51 | - $errorcode='BAD_PARAMETERS'; $errorlabel="The entity parameter must be empty (or filled with numeric id of instance if multicompany module is used)."; |
|
51 | + $errorcode = 'BAD_PARAMETERS'; $errorlabel = "The entity parameter must be empty (or filled with numeric id of instance if multicompany module is used)."; |
|
52 | 52 | } |
53 | 53 | |
54 | - if (! $error) |
|
54 | + if (!$error) |
|
55 | 55 | { |
56 | - $result=$fuser->fetch('',$authentication['login'],'',0); |
|
56 | + $result = $fuser->fetch('', $authentication['login'], '', 0); |
|
57 | 57 | if ($result < 0) |
58 | 58 | { |
59 | 59 | $error++; |
60 | - $errorcode='ERROR_FETCH_USER'; $errorlabel='A technical error occurred during fetch of user'; |
|
60 | + $errorcode = 'ERROR_FETCH_USER'; $errorlabel = 'A technical error occurred during fetch of user'; |
|
61 | 61 | } |
62 | 62 | else if ($result == 0) |
63 | 63 | { |
64 | 64 | $error++; |
65 | - $errorcode='BAD_CREDENTIALS'; $errorlabel='Bad value for login or password'; |
|
65 | + $errorcode = 'BAD_CREDENTIALS'; $errorlabel = 'Bad value for login or password'; |
|
66 | 66 | } |
67 | 67 | |
68 | - if (! $error && $fuser->statut == 0) |
|
68 | + if (!$error && $fuser->statut == 0) |
|
69 | 69 | { |
70 | 70 | $error++; |
71 | - $errorcode='ERROR_USER_DISABLED'; $errorlabel='This user has been locked or disabled'; |
|
71 | + $errorcode = 'ERROR_USER_DISABLED'; $errorlabel = 'This user has been locked or disabled'; |
|
72 | 72 | } |
73 | 73 | |
74 | 74 | // Validation of login |
75 | - if (! $error) |
|
75 | + if (!$error) |
|
76 | 76 | { |
77 | - $fuser->getrights(); // Load permission of user |
|
77 | + $fuser->getrights(); // Load permission of user |
|
78 | 78 | |
79 | 79 | // Authentication mode |
80 | - if (empty($dolibarr_main_authentication)) $dolibarr_main_authentication='http,dolibarr'; |
|
80 | + if (empty($dolibarr_main_authentication)) $dolibarr_main_authentication = 'http,dolibarr'; |
|
81 | 81 | // Authentication mode: forceuser |
82 | - if ($dolibarr_main_authentication == 'forceuser' && empty($dolibarr_auto_user)) $dolibarr_auto_user='auto'; |
|
82 | + if ($dolibarr_main_authentication == 'forceuser' && empty($dolibarr_auto_user)) $dolibarr_auto_user = 'auto'; |
|
83 | 83 | // Set authmode |
84 | - $authmode=explode(',',$dolibarr_main_authentication); |
|
84 | + $authmode = explode(',', $dolibarr_main_authentication); |
|
85 | 85 | |
86 | 86 | include_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php'; |
87 | - $login = checkLoginPassEntity($authentication['login'],$authentication['password'],$authentication['entity'],$authmode); |
|
87 | + $login = checkLoginPassEntity($authentication['login'], $authentication['password'], $authentication['entity'], $authmode); |
|
88 | 88 | if (empty($login)) |
89 | 89 | { |
90 | 90 | $error++; |
91 | - $errorcode='BAD_CREDENTIALS'; $errorlabel='Bad value for login or password'; |
|
91 | + $errorcode = 'BAD_CREDENTIALS'; $errorlabel = 'Bad value for login or password'; |
|
92 | 92 | } |
93 | 93 | } |
94 | 94 | } |
@@ -58,8 +58,7 @@ discard block |
||
58 | 58 | { |
59 | 59 | $error++; |
60 | 60 | $errorcode='ERROR_FETCH_USER'; $errorlabel='A technical error occurred during fetch of user'; |
61 | - } |
|
62 | - else if ($result == 0) |
|
61 | + } else if ($result == 0) |
|
63 | 62 | { |
64 | 63 | $error++; |
65 | 64 | $errorcode='BAD_CREDENTIALS'; $errorlabel='Bad value for login or password'; |
@@ -77,9 +76,13 @@ discard block |
||
77 | 76 | $fuser->getrights(); // Load permission of user |
78 | 77 | |
79 | 78 | // Authentication mode |
80 | - if (empty($dolibarr_main_authentication)) $dolibarr_main_authentication='http,dolibarr'; |
|
79 | + if (empty($dolibarr_main_authentication)) { |
|
80 | + $dolibarr_main_authentication='http,dolibarr'; |
|
81 | + } |
|
81 | 82 | // Authentication mode: forceuser |
82 | - if ($dolibarr_main_authentication == 'forceuser' && empty($dolibarr_auto_user)) $dolibarr_auto_user='auto'; |
|
83 | + if ($dolibarr_main_authentication == 'forceuser' && empty($dolibarr_auto_user)) { |
|
84 | + $dolibarr_auto_user='auto'; |
|
85 | + } |
|
83 | 86 | // Set authmode |
84 | 87 | $authmode=explode(',',$dolibarr_main_authentication); |
85 | 88 |
@@ -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 | } |
@@ -48,10 +48,10 @@ discard block |
||
48 | 48 | |
49 | 49 | if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) |
50 | 50 | { |
51 | - $nbContact = count($object->liste_contact(-1,'internal')) + count($object->liste_contact(-1,'external')); |
|
51 | + $nbContact = count($object->liste_contact(-1, 'internal')) + count($object->liste_contact(-1, 'external')); |
|
52 | 52 | $head[$h][0] = DOL_URL_ROOT.'/fichinter/contact.php?id='.$object->id; |
53 | 53 | $head[$h][1] = $langs->trans('InterventionContact'); |
54 | - if ($nbContact > 0) $head[$h][1].= ' <span class="badge">'.$nbContact.'</span>'; |
|
54 | + if ($nbContact > 0) $head[$h][1] .= ' <span class="badge">'.$nbContact.'</span>'; |
|
55 | 55 | $head[$h][2] = 'contact'; |
56 | 56 | $h++; |
57 | 57 | } |
@@ -60,29 +60,29 @@ discard block |
||
60 | 60 | // Entries must be declared in modules descriptor with line |
61 | 61 | // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab |
62 | 62 | // $this->tabs = array('entity:-tabname); to remove a tab |
63 | - complete_head_from_modules($conf,$langs,$object,$head,$h,'intervention'); |
|
63 | + complete_head_from_modules($conf, $langs, $object, $head, $h, 'intervention'); |
|
64 | 64 | |
65 | 65 | // Tab to link resources |
66 | 66 | if ($conf->resource->enabled) |
67 | 67 | { |
68 | 68 | require_once DOL_DOCUMENT_ROOT.'/resource/class/dolresource.class.php'; |
69 | 69 | $nbResource = 0; |
70 | - $objectres=new Dolresource($db); |
|
70 | + $objectres = new Dolresource($db); |
|
71 | 71 | if (is_array($objectres->available_resources)) |
72 | 72 | { |
73 | 73 | foreach ($objectres->available_resources as $modresources => $resources) |
74 | 74 | { |
75 | - $resources=(array) $resources; // To be sure $resources is an array |
|
76 | - foreach($resources as $resource_obj) |
|
75 | + $resources = (array) $resources; // To be sure $resources is an array |
|
76 | + foreach ($resources as $resource_obj) |
|
77 | 77 | { |
78 | - $linked_resources = $object->getElementResources('fichinter',$object->id,$resource_obj); |
|
78 | + $linked_resources = $object->getElementResources('fichinter', $object->id, $resource_obj); |
|
79 | 79 | } |
80 | 80 | } |
81 | 81 | } |
82 | 82 | |
83 | 83 | $head[$h][0] = DOL_URL_ROOT.'/resource/element_resource.php?element=fichinter&element_id='.$object->id; |
84 | 84 | $head[$h][1] = $langs->trans("Resources"); |
85 | - if ($nbResource > 0) $head[$h][1].= ' <span class="badge">'.$nbResource.'</span>'; |
|
85 | + if ($nbResource > 0) $head[$h][1] .= ' <span class="badge">'.$nbResource.'</span>'; |
|
86 | 86 | $head[$h][2] = 'resource'; |
87 | 87 | $h++; |
88 | 88 | } |
@@ -90,23 +90,23 @@ discard block |
||
90 | 90 | if (empty($conf->global->MAIN_DISABLE_NOTES_TAB)) |
91 | 91 | { |
92 | 92 | $nbNote = 0; |
93 | - if(!empty($object->note_private)) $nbNote++; |
|
94 | - if(!empty($object->note_public)) $nbNote++; |
|
93 | + if (!empty($object->note_private)) $nbNote++; |
|
94 | + if (!empty($object->note_public)) $nbNote++; |
|
95 | 95 | $head[$h][0] = DOL_URL_ROOT.'/fichinter/note.php?id='.$object->id; |
96 | 96 | $head[$h][1] = $langs->trans('Notes'); |
97 | - if ($nbNote > 0) $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>'; |
|
97 | + if ($nbNote > 0) $head[$h][1] .= ' <span class="badge">'.$nbNote.'</span>'; |
|
98 | 98 | $head[$h][2] = 'note'; |
99 | 99 | $h++; |
100 | 100 | } |
101 | 101 | |
102 | 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)$')); |
|
106 | - $nbLinks=Link::count($db, $object->element, $object->id); |
|
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 | + $nbLinks = Link::count($db, $object->element, $object->id); |
|
107 | 107 | $head[$h][0] = DOL_URL_ROOT.'/fichinter/document.php?id='.$object->id; |
108 | 108 | $head[$h][1] = $langs->trans("Documents"); |
109 | - if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>'; |
|
109 | + if (($nbFiles + $nbLinks) > 0) $head[$h][1] .= ' <span class="badge">'.($nbFiles + $nbLinks).'</span>'; |
|
110 | 110 | $head[$h][2] = 'documents'; |
111 | 111 | $h++; |
112 | 112 | |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | $head[$h][2] = 'info'; |
116 | 116 | $h++; |
117 | 117 | |
118 | - complete_head_from_modules($conf,$langs,$object,$head,$h,'intervention','remove'); |
|
118 | + complete_head_from_modules($conf, $langs, $object, $head, $h, 'intervention', 'remove'); |
|
119 | 119 | |
120 | 120 | return $head; |
121 | 121 | } |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | // Entries must be declared in modules descriptor with line |
144 | 144 | // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab |
145 | 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'); |
|
146 | + complete_head_from_modules($conf, $langs, null, $head, $h, 'fichinter_admin'); |
|
147 | 147 | |
148 | 148 | $head[$h][0] = DOL_URL_ROOT.'/fichinter/admin/fichinter_extrafields.php'; |
149 | 149 | $head[$h][1] = $langs->trans("ExtraFields"); |
@@ -157,7 +157,7 @@ discard block |
||
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 | 162 | return $head; |
163 | 163 | } |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | |
183 | 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 | 188 | return $head; |
@@ -51,7 +51,9 @@ discard block |
||
51 | 51 | $nbContact = count($object->liste_contact(-1,'internal')) + count($object->liste_contact(-1,'external')); |
52 | 52 | $head[$h][0] = DOL_URL_ROOT.'/fichinter/contact.php?id='.$object->id; |
53 | 53 | $head[$h][1] = $langs->trans('InterventionContact'); |
54 | - if ($nbContact > 0) $head[$h][1].= ' <span class="badge">'.$nbContact.'</span>'; |
|
54 | + if ($nbContact > 0) { |
|
55 | + $head[$h][1].= ' <span class="badge">'.$nbContact.'</span>'; |
|
56 | + } |
|
55 | 57 | $head[$h][2] = 'contact'; |
56 | 58 | $h++; |
57 | 59 | } |
@@ -82,7 +84,9 @@ discard block |
||
82 | 84 | |
83 | 85 | $head[$h][0] = DOL_URL_ROOT.'/resource/element_resource.php?element=fichinter&element_id='.$object->id; |
84 | 86 | $head[$h][1] = $langs->trans("Resources"); |
85 | - if ($nbResource > 0) $head[$h][1].= ' <span class="badge">'.$nbResource.'</span>'; |
|
87 | + if ($nbResource > 0) { |
|
88 | + $head[$h][1].= ' <span class="badge">'.$nbResource.'</span>'; |
|
89 | + } |
|
86 | 90 | $head[$h][2] = 'resource'; |
87 | 91 | $h++; |
88 | 92 | } |
@@ -90,11 +94,17 @@ discard block |
||
90 | 94 | if (empty($conf->global->MAIN_DISABLE_NOTES_TAB)) |
91 | 95 | { |
92 | 96 | $nbNote = 0; |
93 | - if(!empty($object->note_private)) $nbNote++; |
|
94 | - if(!empty($object->note_public)) $nbNote++; |
|
97 | + if(!empty($object->note_private)) { |
|
98 | + $nbNote++; |
|
99 | + } |
|
100 | + if(!empty($object->note_public)) { |
|
101 | + $nbNote++; |
|
102 | + } |
|
95 | 103 | $head[$h][0] = DOL_URL_ROOT.'/fichinter/note.php?id='.$object->id; |
96 | 104 | $head[$h][1] = $langs->trans('Notes'); |
97 | - if ($nbNote > 0) $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>'; |
|
105 | + if ($nbNote > 0) { |
|
106 | + $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>'; |
|
107 | + } |
|
98 | 108 | $head[$h][2] = 'note'; |
99 | 109 | $h++; |
100 | 110 | } |
@@ -106,7 +116,9 @@ discard block |
||
106 | 116 | $nbLinks=Link::count($db, $object->element, $object->id); |
107 | 117 | $head[$h][0] = DOL_URL_ROOT.'/fichinter/document.php?id='.$object->id; |
108 | 118 | $head[$h][1] = $langs->trans("Documents"); |
109 | - if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>'; |
|
119 | + if (($nbFiles+$nbLinks) > 0) { |
|
120 | + $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>'; |
|
121 | + } |
|
110 | 122 | $head[$h][2] = 'documents'; |
111 | 123 | $h++; |
112 | 124 |
@@ -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 |
@@ -39,16 +39,16 @@ discard block |
||
39 | 39 | $head[$h][2] = 'card'; |
40 | 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)) |
|
42 | + if (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->mailing->mailing_advance->recipient)) |
|
43 | 43 | { |
44 | 44 | $head[$h][0] = DOL_URL_ROOT."/comm/mailing/cibles.php?id=".$object->id; |
45 | 45 | $head[$h][1] = $langs->trans("MailRecipients"); |
46 | - if ($object->nbemail > 0) $head[$h][1].= ' <span class="badge">'.$object->nbemail.'</span>'; |
|
46 | + if ($object->nbemail > 0) $head[$h][1] .= ' <span class="badge">'.$object->nbemail.'</span>'; |
|
47 | 47 | $head[$h][2] = 'targets'; |
48 | 48 | $h++; |
49 | 49 | } |
50 | 50 | |
51 | - if (! empty($conf->global->EMAILING_USE_ADVANCED_SELECTOR)) |
|
51 | + if (!empty($conf->global->EMAILING_USE_ADVANCED_SELECTOR)) |
|
52 | 52 | { |
53 | 53 | $head[$h][0] = DOL_URL_ROOT."/comm/mailing/advtargetemailing.php?id=".$object->id; |
54 | 54 | $head[$h][1] = $langs->trans("MailAdvTargetRecipients"); |
@@ -61,9 +61,9 @@ discard block |
||
61 | 61 | $head[$h][2] = 'info'; |
62 | 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 | 68 | return $head; |
69 | 69 | } |
@@ -43,7 +43,9 @@ |
||
43 | 43 | { |
44 | 44 | $head[$h][0] = DOL_URL_ROOT."/comm/mailing/cibles.php?id=".$object->id; |
45 | 45 | $head[$h][1] = $langs->trans("MailRecipients"); |
46 | - if ($object->nbemail > 0) $head[$h][1].= ' <span class="badge">'.$object->nbemail.'</span>'; |
|
46 | + if ($object->nbemail > 0) { |
|
47 | + $head[$h][1].= ' <span class="badge">'.$object->nbemail.'</span>'; |
|
48 | + } |
|
47 | 49 | $head[$h][2] = 'targets'; |
48 | 50 | $h++; |
49 | 51 | } |
@@ -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 |
@@ -34,13 +34,13 @@ discard block |
||
34 | 34 | function commande_prepare_head(Commande $object) |
35 | 35 | { |
36 | 36 | global $db, $langs, $conf, $user; |
37 | - if (! empty($conf->expedition->enabled)) $langs->load("sendings"); |
|
37 | + if (!empty($conf->expedition->enabled)) $langs->load("sendings"); |
|
38 | 38 | $langs->load("orders"); |
39 | 39 | |
40 | 40 | $h = 0; |
41 | 41 | $head = array(); |
42 | 42 | |
43 | - if (! empty($conf->commande->enabled) && $user->rights->commande->lire) |
|
43 | + if (!empty($conf->commande->enabled) && $user->rights->commande->lire) |
|
44 | 44 | { |
45 | 45 | $head[$h][0] = DOL_URL_ROOT.'/commande/card.php?id='.$object->id; |
46 | 46 | $head[$h][1] = $langs->trans("OrderCard"); |
@@ -50,10 +50,10 @@ discard block |
||
50 | 50 | |
51 | 51 | if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) |
52 | 52 | { |
53 | - $nbContact = count($object->liste_contact(-1,'internal')) + count($object->liste_contact(-1,'external')); |
|
53 | + $nbContact = count($object->liste_contact(-1, 'internal')) + count($object->liste_contact(-1, 'external')); |
|
54 | 54 | $head[$h][0] = DOL_URL_ROOT.'/commande/contact.php?id='.$object->id; |
55 | 55 | $head[$h][1] = $langs->trans('ContactsAddresses'); |
56 | - if ($nbContact > 0) $head[$h][1].= ' <span class="badge">'.$nbContact.'</span>'; |
|
56 | + if ($nbContact > 0) $head[$h][1] .= ' <span class="badge">'.$nbContact.'</span>'; |
|
57 | 57 | $head[$h][2] = 'contact'; |
58 | 58 | $h++; |
59 | 59 | } |
@@ -61,16 +61,16 @@ discard block |
||
61 | 61 | if (($conf->expedition_bon->enabled && $user->rights->expedition->lire) |
62 | 62 | || ($conf->livraison_bon->enabled && $user->rights->expedition->livraison->lire)) |
63 | 63 | { |
64 | - $nbShipments=$object->getNbOfShipments(); $nbReceiption=0; |
|
64 | + $nbShipments = $object->getNbOfShipments(); $nbReceiption = 0; |
|
65 | 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>'; |
|
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 | 74 | $head[$h][1] = $text; |
75 | 75 | $head[$h][2] = 'shipping'; |
76 | 76 | $h++; |
@@ -80,28 +80,28 @@ discard block |
||
80 | 80 | // Entries must be declared in modules descriptor with line |
81 | 81 | // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab |
82 | 82 | // $this->tabs = array('entity:-tabname); to remove a tab |
83 | - complete_head_from_modules($conf,$langs,$object,$head,$h,'order'); |
|
83 | + complete_head_from_modules($conf, $langs, $object, $head, $h, 'order'); |
|
84 | 84 | |
85 | 85 | if (empty($conf->global->MAIN_DISABLE_NOTES_TAB)) |
86 | 86 | { |
87 | 87 | $nbNote = 0; |
88 | - if(!empty($object->note_private)) $nbNote++; |
|
89 | - if(!empty($object->note_public)) $nbNote++; |
|
88 | + if (!empty($object->note_private)) $nbNote++; |
|
89 | + if (!empty($object->note_public)) $nbNote++; |
|
90 | 90 | $head[$h][0] = DOL_URL_ROOT.'/commande/note.php?id='.$object->id; |
91 | 91 | $head[$h][1] = $langs->trans('Notes'); |
92 | - if ($nbNote > 0) $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>'; |
|
92 | + if ($nbNote > 0) $head[$h][1] .= ' <span class="badge">'.$nbNote.'</span>'; |
|
93 | 93 | $head[$h][2] = 'note'; |
94 | 94 | $h++; |
95 | 95 | } |
96 | 96 | |
97 | 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)$')); |
|
101 | - $nbLinks=Link::count($db, $object->element, $object->id); |
|
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 | + $nbLinks = Link::count($db, $object->element, $object->id); |
|
102 | 102 | $head[$h][0] = DOL_URL_ROOT.'/commande/document.php?id='.$object->id; |
103 | 103 | $head[$h][1] = $langs->trans('Documents'); |
104 | - if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>'; |
|
104 | + if (($nbFiles + $nbLinks) > 0) $head[$h][1] .= ' <span class="badge">'.($nbFiles + $nbLinks).'</span>'; |
|
105 | 105 | $head[$h][2] = 'documents'; |
106 | 106 | $h++; |
107 | 107 | |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | $head[$h][2] = 'info'; |
111 | 111 | $h++; |
112 | 112 | |
113 | - complete_head_from_modules($conf,$langs,$object,$head,$h,'order','remove'); |
|
113 | + complete_head_from_modules($conf, $langs, $object, $head, $h, 'order', 'remove'); |
|
114 | 114 | |
115 | 115 | return $head; |
116 | 116 | } |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | $head[$h][2] = 'general'; |
133 | 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 | 137 | $head[$h][0] = DOL_URL_ROOT.'/admin/order_extrafields.php'; |
138 | 138 | $head[$h][1] = $langs->trans("ExtraFields"); |
@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | $head[$h][2] = 'attributeslines'; |
145 | 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 | 149 | return $head; |
150 | 150 | } |
@@ -34,7 +34,9 @@ discard block |
||
34 | 34 | function commande_prepare_head(Commande $object) |
35 | 35 | { |
36 | 36 | global $db, $langs, $conf, $user; |
37 | - if (! empty($conf->expedition->enabled)) $langs->load("sendings"); |
|
37 | + if (! empty($conf->expedition->enabled)) { |
|
38 | + $langs->load("sendings"); |
|
39 | + } |
|
38 | 40 | $langs->load("orders"); |
39 | 41 | |
40 | 42 | $h = 0; |
@@ -53,7 +55,9 @@ discard block |
||
53 | 55 | $nbContact = count($object->liste_contact(-1,'internal')) + count($object->liste_contact(-1,'external')); |
54 | 56 | $head[$h][0] = DOL_URL_ROOT.'/commande/contact.php?id='.$object->id; |
55 | 57 | $head[$h][1] = $langs->trans('ContactsAddresses'); |
56 | - if ($nbContact > 0) $head[$h][1].= ' <span class="badge">'.$nbContact.'</span>'; |
|
58 | + if ($nbContact > 0) { |
|
59 | + $head[$h][1].= ' <span class="badge">'.$nbContact.'</span>'; |
|
60 | + } |
|
57 | 61 | $head[$h][2] = 'contact'; |
58 | 62 | $h++; |
59 | 63 | } |
@@ -64,13 +68,27 @@ discard block |
||
64 | 68 | $nbShipments=$object->getNbOfShipments(); $nbReceiption=0; |
65 | 69 | $head[$h][0] = DOL_URL_ROOT.'/expedition/shipment.php?id='.$object->id; |
66 | 70 | $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>'; |
|
71 | + if ($conf->expedition_bon->enabled) { |
|
72 | + $text.=$langs->trans("Shipments"); |
|
73 | + } |
|
74 | + if ($conf->expedition_bon->enabled && $conf->livraison_bon->enabled) { |
|
75 | + $text.='/'; |
|
76 | + } |
|
77 | + if ($conf->livraison_bon->enabled) { |
|
78 | + $text.=$langs->trans("Receivings"); |
|
79 | + } |
|
80 | + if ($nbShipments > 0 || $nbReceiption > 0) { |
|
81 | + $text.= ' <span class="badge">'.($nbShipments?$nbShipments:0); |
|
82 | + } |
|
83 | + if ($conf->expedition_bon->enabled && $conf->livraison_bon->enabled) { |
|
84 | + $text.='/'; |
|
85 | + } |
|
86 | + if ($conf->expedition_bon->enabled && $conf->livraison_bon->enabled && ($nbShipments > 0 || $nbReceiption > 0)) { |
|
87 | + $text.= ($nbReceiption?$nbReceiption:0); |
|
88 | + } |
|
89 | + if ($nbShipments > 0 || $nbReceiption > 0) { |
|
90 | + $text.= '</span>'; |
|
91 | + } |
|
74 | 92 | $head[$h][1] = $text; |
75 | 93 | $head[$h][2] = 'shipping'; |
76 | 94 | $h++; |
@@ -85,11 +103,17 @@ discard block |
||
85 | 103 | if (empty($conf->global->MAIN_DISABLE_NOTES_TAB)) |
86 | 104 | { |
87 | 105 | $nbNote = 0; |
88 | - if(!empty($object->note_private)) $nbNote++; |
|
89 | - if(!empty($object->note_public)) $nbNote++; |
|
106 | + if(!empty($object->note_private)) { |
|
107 | + $nbNote++; |
|
108 | + } |
|
109 | + if(!empty($object->note_public)) { |
|
110 | + $nbNote++; |
|
111 | + } |
|
90 | 112 | $head[$h][0] = DOL_URL_ROOT.'/commande/note.php?id='.$object->id; |
91 | 113 | $head[$h][1] = $langs->trans('Notes'); |
92 | - if ($nbNote > 0) $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>'; |
|
114 | + if ($nbNote > 0) { |
|
115 | + $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>'; |
|
116 | + } |
|
93 | 117 | $head[$h][2] = 'note'; |
94 | 118 | $h++; |
95 | 119 | } |
@@ -101,7 +125,9 @@ discard block |
||
101 | 125 | $nbLinks=Link::count($db, $object->element, $object->id); |
102 | 126 | $head[$h][0] = DOL_URL_ROOT.'/commande/document.php?id='.$object->id; |
103 | 127 | $head[$h][1] = $langs->trans('Documents'); |
104 | - if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>'; |
|
128 | + if (($nbFiles+$nbLinks) > 0) { |
|
129 | + $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>'; |
|
130 | + } |
|
105 | 131 | $head[$h][2] = 'documents'; |
106 | 132 | $h++; |
107 | 133 |
@@ -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 | } |
@@ -33,34 +33,34 @@ discard block |
||
33 | 33 | * @return boolean True if OK |
34 | 34 | * @see dolWebsiteOutput for function used to replace content in a web server context |
35 | 35 | */ |
36 | -function dolWebsiteReplacementOfLinks($website, $content, $removephppart=0) |
|
36 | +function dolWebsiteReplacementOfLinks($website, $content, $removephppart = 0) |
|
37 | 37 | { |
38 | 38 | $nbrep = 0; |
39 | 39 | |
40 | 40 | // Replace php code. Note $content may come from database and does not contains body tags. |
41 | - $replacewith='...php...'; |
|
42 | - if ($removephppart) $replacewith=''; |
|
41 | + $replacewith = '...php...'; |
|
42 | + if ($removephppart) $replacewith = ''; |
|
43 | 43 | $content = preg_replace('/value="<\?php((?!\?>).)*\?>\n*/ims', 'value="'.$replacewith.'"', $content); |
44 | 44 | |
45 | - $replacewith='"callto=#'; |
|
46 | - if ($removephppart) $replacewith=''; |
|
45 | + $replacewith = '"callto=#'; |
|
46 | + if ($removephppart) $replacewith = ''; |
|
47 | 47 | $content = preg_replace('/"callto:<\?php((?!\?>).)*\?>\n*/ims', $replacewith, $content); |
48 | 48 | |
49 | - $replacewith='"mailto=#'; |
|
50 | - if ($removephppart) $replacewith=''; |
|
49 | + $replacewith = '"mailto=#'; |
|
50 | + if ($removephppart) $replacewith = ''; |
|
51 | 51 | $content = preg_replace('/"mailto:<\?php((?!\?>).)*\?>\n*/ims', $replacewith, $content); |
52 | 52 | |
53 | - $replacewith='src="php'; |
|
54 | - if ($removephppart) $replacewith=''; |
|
53 | + $replacewith = 'src="php'; |
|
54 | + if ($removephppart) $replacewith = ''; |
|
55 | 55 | $content = preg_replace('/src="<\?php((?!\?>).)*\?>\n*/ims', $replacewith, $content); |
56 | 56 | |
57 | - $replacewith='href="php'; |
|
58 | - if ($removephppart) $replacewith=''; |
|
57 | + $replacewith = 'href="php'; |
|
58 | + if ($removephppart) $replacewith = ''; |
|
59 | 59 | $content = preg_replace('/href="<\?php((?!\?>).)*\?>\n*/ims', $replacewith, $content); |
60 | 60 | |
61 | 61 | //$replacewith='<span class="phptag">...php...</span>'; |
62 | - $replacewith='<span class="phptag">...php...</span>'; |
|
63 | - if ($removephppart) $replacewith=''; |
|
62 | + $replacewith = '<span class="phptag">...php...</span>'; |
|
63 | + if ($removephppart) $replacewith = ''; |
|
64 | 64 | //$content = preg_replace('/<\?php((?!\?toremove>).)*\?toremove>\n*/ims', $replacewith, $content); |
65 | 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'; |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | // <img src="medias/image.png... => <img src="dolibarr/viewimage.php/modulepart=medias&file=image.png... |
81 | 81 | $content = preg_replace('/(<img[^>]*src=")(medias\/)/', '\1'.DOL_URL_ROOT.'/viewimage.php?modulepart=medias&file=', $content, -1, $nbrep); |
82 | 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); |
|
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 | 84 | // <img src="viewimage.php/modulepart=medias&file=image.png" => <img src="dolibarr/viewimage.php/modulepart=medias&file=image.png" |
85 | 85 | $content = preg_replace('/(<img[^>]*src=")(\/?viewimage\.php)/', '\1'.DOL_URL_ROOT.'/viewimage.php', $content, -1, $nbrep); |
86 | 86 | |
@@ -88,8 +88,8 @@ discard block |
||
88 | 88 | $content = preg_replace('/(action=")\/?([^:\"]*)(\.php\")/', '\1'.DOL_URL_ROOT.'/website/index.php?website='.$website->ref.'&pageref=\2"', $content, -1, $nbrep); |
89 | 89 | |
90 | 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); |
|
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 | 94 | return $content; |
95 | 95 | } |
@@ -102,16 +102,16 @@ discard block |
||
102 | 102 | * @param string $replacewith String to use as replacement |
103 | 103 | * @return string Result string without php code |
104 | 104 | */ |
105 | -function dolStripPhpCode($str, $replacewith='') |
|
105 | +function dolStripPhpCode($str, $replacewith = '') |
|
106 | 106 | { |
107 | 107 | $newstr = ''; |
108 | 108 | |
109 | 109 | //split on each opening tag |
110 | - $parts = explode('<?php',$str); |
|
110 | + $parts = explode('<?php', $str); |
|
111 | 111 | if (!empty($parts)) |
112 | 112 | { |
113 | - $i=0; |
|
114 | - foreach($parts as $part) |
|
113 | + $i = 0; |
|
114 | + foreach ($parts as $part) |
|
115 | 115 | { |
116 | 116 | if ($i == 0) // The first part is never php code |
117 | 117 | { |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | //remove content before closing tag |
127 | 127 | if (count($partlings) > 1) $partlings[0] = ''; |
128 | 128 | //append to out string |
129 | - $newstr .= $replacewith.implode('',$partlings); |
|
129 | + $newstr .= $replacewith.implode('', $partlings); |
|
130 | 130 | } |
131 | 131 | } |
132 | 132 | } |
@@ -147,11 +147,11 @@ discard block |
||
147 | 147 | global $db, $langs, $conf, $user; |
148 | 148 | global $dolibarr_main_url_root, $dolibarr_main_data_root; |
149 | 149 | |
150 | - dol_syslog("dolWebsiteOutput start (USEDOLIBARRSERVER=".(defined('USEDOLIBARRSERVER')?'1':'')." (USEDOLIBARREDITOR=".(defined('USEDOLIBARREDITOR')?'1':'').')'); |
|
150 | + dol_syslog("dolWebsiteOutput start (USEDOLIBARRSERVER=".(defined('USEDOLIBARRSERVER') ? '1' : '')." (USEDOLIBARREDITOR=".(defined('USEDOLIBARREDITOR') ? '1' : '').')'); |
|
151 | 151 | |
152 | 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 |
|
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 | 155 | //$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current |
156 | 156 | |
157 | 157 | if (defined('USEDOLIBARREDITOR')) // REPLACEMENT OF LINKS When page called from Dolibarr editor |
@@ -166,29 +166,29 @@ discard block |
||
166 | 166 | global $website; |
167 | 167 | |
168 | 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); |
|
169 | + $content = preg_replace('/(href=")\/\"/', '\1'.DOL_URL_ROOT.'/public/website/index.php?website='.$website->ref.'"', $content, -1, $nbrep); |
|
170 | 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); |
|
171 | + $content = preg_replace('/(href=")\/?([^:\"]*)(\.php\")/', '\1'.DOL_URL_ROOT.'/public/website/index.php?website='.$website->ref.'&pageref=\2"', $content, -1, $nbrep); |
|
172 | 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); |
|
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 | 175 | |
176 | 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); |
|
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 | 179 | |
180 | 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); |
|
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 | 183 | |
184 | 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); |
|
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 | 187 | |
188 | 188 | // <img src="medias/image.png... => <img src="dolibarr/viewimage.php/modulepart=medias&file=image.png... |
189 | 189 | $content = preg_replace('/(<img[^>]*src=")(medias\/)/', '\1'.DOL_URL_ROOT.'/viewimage.php?modulepart=medias&file=', $content, -1, $nbrep); |
190 | 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); |
|
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 | 192 | // <img src="viewimage.php/modulepart=medias&file=image.png" => <img src="dolibarr/viewimage.php/modulepart=medias&file=image.png" |
193 | 193 | $content = preg_replace('/(<img[^>]*src=")(\/?viewimage\.php)/', '\1'.DOL_URL_ROOT.'/viewimage.php', $content, -1, $nbrep); |
194 | 194 | |
@@ -197,44 +197,44 @@ discard block |
||
197 | 197 | } |
198 | 198 | else // REPLACEMENT OF LINKS When page called from virtual host |
199 | 199 | { |
200 | - $symlinktomediaexists=1; |
|
200 | + $symlinktomediaexists = 1; |
|
201 | 201 | |
202 | 202 | // Make a change into HTML code to allow to include images from medias directory correct with direct link for virtual server |
203 | 203 | // <img alt="" src="/dolibarr_dev/htdocs/viewimage.php?modulepart=medias&entity=1&file=image/ldestailleur_166x166.jpg" style="height:166px; width:166px" /> |
204 | 204 | // become |
205 | 205 | // <img alt="" src="'.$urlwithroot.'/medias/image/ldestailleur_166x166.jpg" style="height:166px; width:166px" /> |
206 | - $nbrep=0; |
|
207 | - if (! $symlinktomediaexists) |
|
206 | + $nbrep = 0; |
|
207 | + if (!$symlinktomediaexists) |
|
208 | 208 | { |
209 | - $content=preg_replace('/(<script[^>]*src=")[^\"]*document\.php([^\"]*)modulepart=medias([^\"]*)file=([^\"]*)("[^>]*>)/', '\wrapper.php\2modulepart=medias\3file=\4\5', $content, -1, $nbrep); |
|
209 | + $content = preg_replace('/(<script[^>]*src=")[^\"]*document\.php([^\"]*)modulepart=medias([^\"]*)file=([^\"]*)("[^>]*>)/', '\wrapper.php\2modulepart=medias\3file=\4\5', $content, -1, $nbrep); |
|
210 | 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); |
|
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 | 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); |
|
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 | 218 | |
219 | - $content=preg_replace('/(<img[^>]*src=")[^\"]*viewimage\.php([^\"]*)modulepart=mycompany([^\"]*)file=([^\"]*)("[^>]*>)/', '\1/wrapper.php\2modulepart=mycompany\3file=\4\5', $content, -1, $nbrep); |
|
219 | + $content = preg_replace('/(<img[^>]*src=")[^\"]*viewimage\.php([^\"]*)modulepart=mycompany([^\"]*)file=([^\"]*)("[^>]*>)/', '\1/wrapper.php\2modulepart=mycompany\3file=\4\5', $content, -1, $nbrep); |
|
220 | 220 | } |
221 | 221 | else |
222 | 222 | { |
223 | - $content=preg_replace('/(<script[^>]*src=")[^\"]*document\.php([^\"]*)modulepart=medias([^\"]*)file=([^\"]*)("[^>]*>)/', '\1medias/\4\5', $content, -1, $nbrep); |
|
223 | + $content = preg_replace('/(<script[^>]*src=")[^\"]*document\.php([^\"]*)modulepart=medias([^\"]*)file=([^\"]*)("[^>]*>)/', '\1medias/\4\5', $content, -1, $nbrep); |
|
224 | 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); |
|
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 | 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); |
|
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 | 232 | |
233 | - $content=preg_replace('/(<img[^>]*src=")[^\"]*viewimage\.php([^\"]*)modulepart=mycompany([^\"]*)file=([^\"]*)("[^>]*>)/', '\1/wrapper.php\2modulepart=mycompany\3file=\4\5', $content, -1, $nbrep); |
|
233 | + $content = preg_replace('/(<img[^>]*src=")[^\"]*viewimage\.php([^\"]*)modulepart=mycompany([^\"]*)file=([^\"]*)("[^>]*>)/', '\1/wrapper.php\2modulepart=mycompany\3file=\4\5', $content, -1, $nbrep); |
|
234 | 234 | } |
235 | 235 | } |
236 | 236 | |
237 | - $content=preg_replace('/ contenteditable="true"/', ' contenteditable="false"', $content, -1, $nbrep); |
|
237 | + $content = preg_replace('/ contenteditable="true"/', ' contenteditable="false"', $content, -1, $nbrep); |
|
238 | 238 | |
239 | 239 | dol_syslog("dolWebsiteOutput end"); |
240 | 240 | |
@@ -277,18 +277,18 @@ discard block |
||
277 | 277 | * @param int $containerid Id of container. |
278 | 278 | * @return void |
279 | 279 | */ |
280 | -function redirectToContainer($containerref, $containeraliasalt='',$containerid=0) |
|
280 | +function redirectToContainer($containerref, $containeraliasalt = '', $containerid = 0) |
|
281 | 281 | { |
282 | 282 | global $db, $website; |
283 | 283 | |
284 | 284 | $newurl = ''; |
285 | - $result=0; |
|
285 | + $result = 0; |
|
286 | 286 | |
287 | 287 | // We make redirect using the alternative alias, we must find the real $containerref |
288 | 288 | if ($containeraliasalt) |
289 | 289 | { |
290 | 290 | include_once DOL_DOCUMENT_ROOT.'/website/class/websitepage.class.php'; |
291 | - $tmpwebsitepage=new WebsitePage($db); |
|
291 | + $tmpwebsitepage = new WebsitePage($db); |
|
292 | 292 | $result = $tmpwebsitepage->fetch(0, $website->id, '', $containeraliasalt); |
293 | 293 | if ($result > 0) |
294 | 294 | { |
@@ -304,10 +304,10 @@ discard block |
||
304 | 304 | if (defined('USEDOLIBARRSERVER')) // When page called from Dolibarr server |
305 | 305 | { |
306 | 306 | // Check new container exists |
307 | - if (! $containeraliasalt) // If containeraliasalt set, we already did the test |
|
307 | + if (!$containeraliasalt) // If containeraliasalt set, we already did the test |
|
308 | 308 | { |
309 | 309 | include_once DOL_DOCUMENT_ROOT.'/website/class/websitepage.class.php'; |
310 | - $tmpwebsitepage=new WebsitePage($db); |
|
310 | + $tmpwebsitepage = new WebsitePage($db); |
|
311 | 311 | $result = $tmpwebsitepage->fetch(0, $website->id, $containerref); |
312 | 312 | unset($tmpwebsitepage); |
313 | 313 | } |
@@ -359,17 +359,17 @@ 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. |
|
362 | + global $conf, $db, $hookmanager, $langs, $mysoc, $user, $website, $websitepage, $weblangs; // Very important. Required to have var available when running inluded containers. |
|
363 | 363 | global $includehtmlcontentopened; |
364 | 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; |
|
372 | + if (empty($includehtmlcontentopened)) $includehtmlcontentopened = 0; |
|
373 | 373 | $includehtmlcontentopened++; |
374 | 374 | if ($includehtmlcontentopened > $MAXLEVEL) |
375 | 375 | { |
@@ -381,14 +381,14 @@ discard block |
||
381 | 381 | //print preg_replace(array('/^.*<body[^>]*>/ims','/<\/body>.*$/ims'), array('', ''), $content);*/ |
382 | 382 | |
383 | 383 | ob_start(); |
384 | - $res = include $fullpathfile; // Include because we want to execute code content |
|
384 | + $res = include $fullpathfile; // Include because we want to execute code content |
|
385 | 385 | $tmpoutput = ob_get_contents(); |
386 | 386 | ob_end_clean(); |
387 | 387 | |
388 | 388 | print "\n".'<!-- include '.$fullpathfile.' level = '.$includehtmlcontentopened.' -->'."\n"; |
389 | - print preg_replace(array('/^.*<body[^>]*>/ims','/<\/body>.*$/ims'), array('', ''), $tmpoutput); |
|
389 | + print preg_replace(array('/^.*<body[^>]*>/ims', '/<\/body>.*$/ims'), array('', ''), $tmpoutput); |
|
390 | 390 | |
391 | - if (! $res) |
|
391 | + if (!$res) |
|
392 | 392 | { |
393 | 393 | print 'ERROR: FAILED TO INCLUDE PAGE '.$containerref.".\n"; |
394 | 394 | } |
@@ -412,49 +412,49 @@ discard block |
||
412 | 412 | * @param string $grabimagesinto 'root' or 'subpage' |
413 | 413 | * @return void |
414 | 414 | */ |
415 | -function getAllImages($object, $objectpage, $urltograb, &$tmp, &$action, $modifylinks=0, $grabimages=1, $grabimagesinto='subpage') |
|
415 | +function getAllImages($object, $objectpage, $urltograb, &$tmp, &$action, $modifylinks = 0, $grabimages = 1, $grabimagesinto = 'subpage') |
|
416 | 416 | { |
417 | 417 | global $conf; |
418 | 418 | |
419 | - $error=0; |
|
419 | + $error = 0; |
|
420 | 420 | |
421 | 421 | dol_syslog("Call getAllImages with grabimagesinto=".$grabimagesinto); |
422 | 422 | |
423 | - $alreadygrabbed=array(); |
|
423 | + $alreadygrabbed = array(); |
|
424 | 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 |
|
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 | 427 | |
428 | 428 | // Search X in "img...src=X" |
429 | 429 | preg_match_all('/<img([^\.\/]+)src="([^>"]+)"([^>]*)>/i', $tmp, $regs); |
430 | 430 | |
431 | 431 | foreach ($regs[0] as $key => $val) |
432 | 432 | { |
433 | - if (preg_match('/^data:image/i', $regs[2][$key])) continue; // We do nothing for such images |
|
433 | + if (preg_match('/^data:image/i', $regs[2][$key])) continue; // We do nothing for such images |
|
434 | 434 | |
435 | 435 | if (preg_match('/^\//', $regs[2][$key])) |
436 | 436 | { |
437 | 437 | $urltograbdirrootwithoutslash = getRootURLFromURL($urltograb); |
438 | - $urltograbbis = $urltograbdirrootwithoutslash.$regs[2][$key]; // We use dirroot |
|
438 | + $urltograbbis = $urltograbdirrootwithoutslash.$regs[2][$key]; // We use dirroot |
|
439 | 439 | } |
440 | 440 | else |
441 | 441 | { |
442 | - $urltograbbis = $urltograb.'/'.$regs[2][$key]; // We use dir of grabbed file |
|
442 | + $urltograbbis = $urltograb.'/'.$regs[2][$key]; // We use dir of grabbed file |
|
443 | 443 | } |
444 | 444 | |
445 | 445 | $linkwithoutdomain = $regs[2][$key]; |
446 | 446 | $dirforimages = '/'.$objectpage->pageurl; |
447 | - if ($grabimagesinto == 'root') $dirforimages=''; |
|
447 | + if ($grabimagesinto == 'root') $dirforimages = ''; |
|
448 | 448 | |
449 | 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]; |
|
450 | + $filetosave = $conf->medias->multidir_output[$conf->entity].'/image/'.$object->ref.$dirforimages.(preg_match('/^\//', $regs[2][$key]) ? '' : '/').$regs[2][$key]; |
|
451 | 451 | if (preg_match('/^http/', $regs[2][$key])) |
452 | 452 | { |
453 | 453 | $urltograbbis = $regs[2][$key]; |
454 | 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; |
|
455 | + $filetosave = $conf->medias->multidir_output[$conf->entity].'/image/'.$object->ref.$dirforimages.(preg_match('/^\//', $linkwithoutdomain) ? '' : '/').$linkwithoutdomain; |
|
456 | 456 | } |
457 | - $filename = 'image/'.$object->ref.$dirforimages.(preg_match('/^\//', $linkwithoutdomain)?'':'/').$linkwithoutdomain; |
|
457 | + $filename = 'image/'.$object->ref.$dirforimages.(preg_match('/^\//', $linkwithoutdomain) ? '' : '/').$linkwithoutdomain; |
|
458 | 458 | |
459 | 459 | // Clean the aa/bb/../cc into aa/cc |
460 | 460 | $filetosave = preg_replace('/\/[^\/]+\/\.\./', '', $filetosave); |
@@ -473,24 +473,24 @@ discard block |
||
473 | 473 | { |
474 | 474 | $error++; |
475 | 475 | setEventMessages('Error getting '.$urltograbbis.': '.$tmpgeturl['curl_error_msg'], null, 'errors'); |
476 | - $action='create'; |
|
476 | + $action = 'create'; |
|
477 | 477 | } |
478 | 478 | elseif ($tmpgeturl['http_code'] != '200') |
479 | 479 | { |
480 | 480 | $error++; |
481 | 481 | setEventMessages('Error getting '.$urltograbbis.': '.$tmpgeturl['http_code'], null, 'errors'); |
482 | - $action='create'; |
|
482 | + $action = 'create'; |
|
483 | 483 | } |
484 | 484 | else |
485 | 485 | { |
486 | - $alreadygrabbed[$urltograbbis]=1; // Track that file was alreay grabbed. |
|
486 | + $alreadygrabbed[$urltograbbis] = 1; // Track that file was alreay grabbed. |
|
487 | 487 | |
488 | 488 | dol_mkdir(dirname($filetosave)); |
489 | 489 | |
490 | 490 | $fp = fopen($filetosave, "w"); |
491 | 491 | fputs($fp, $tmpgeturl['content']); |
492 | 492 | fclose($fp); |
493 | - if (! empty($conf->global->MAIN_UMASK)) |
|
493 | + if (!empty($conf->global->MAIN_UMASK)) |
|
494 | 494 | @chmod($filetosave, octdec($conf->global->MAIN_UMASK)); |
495 | 495 | } |
496 | 496 | } |
@@ -498,7 +498,7 @@ discard block |
||
498 | 498 | |
499 | 499 | if ($modifylinks) |
500 | 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); |
|
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 | 502 | } |
503 | 503 | } |
504 | 504 | |
@@ -507,33 +507,33 @@ discard block |
||
507 | 507 | |
508 | 508 | foreach ($regs[0] as $key => $val) |
509 | 509 | { |
510 | - if (preg_match('/^data:image/i', $regs[2][$key])) continue; // We do nothing for such images |
|
510 | + if (preg_match('/^data:image/i', $regs[2][$key])) continue; // We do nothing for such images |
|
511 | 511 | |
512 | 512 | if (preg_match('/^\//', $regs[2][$key])) |
513 | 513 | { |
514 | 514 | $urltograbdirrootwithoutslash = getRootURLFromURL($urltograb); |
515 | - $urltograbbis = $urltograbdirrootwithoutslash.$regs[2][$key]; // We use dirroot |
|
515 | + $urltograbbis = $urltograbdirrootwithoutslash.$regs[2][$key]; // We use dirroot |
|
516 | 516 | } |
517 | 517 | else |
518 | 518 | { |
519 | - $urltograbbis = $urltograb.'/'.$regs[2][$key]; // We use dir of grabbed file |
|
519 | + $urltograbbis = $urltograb.'/'.$regs[2][$key]; // We use dir of grabbed file |
|
520 | 520 | } |
521 | 521 | |
522 | 522 | $linkwithoutdomain = $regs[2][$key]; |
523 | 523 | |
524 | 524 | $dirforimages = '/'.$objectpage->pageurl; |
525 | - if ($grabimagesinto == 'root') $dirforimages=''; |
|
525 | + if ($grabimagesinto == 'root') $dirforimages = ''; |
|
526 | 526 | |
527 | - $filetosave = $conf->medias->multidir_output[$conf->entity].'/image/'.$object->ref.$dirforimages.(preg_match('/^\//', $regs[2][$key])?'':'/').$regs[2][$key]; |
|
527 | + $filetosave = $conf->medias->multidir_output[$conf->entity].'/image/'.$object->ref.$dirforimages.(preg_match('/^\//', $regs[2][$key]) ? '' : '/').$regs[2][$key]; |
|
528 | 528 | |
529 | 529 | if (preg_match('/^http/', $regs[2][$key])) |
530 | 530 | { |
531 | 531 | $urltograbbis = $regs[2][$key]; |
532 | 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; |
|
533 | + $filetosave = $conf->medias->multidir_output[$conf->entity].'/image/'.$object->ref.$dirforimages.(preg_match('/^\//', $linkwithoutdomain) ? '' : '/').$linkwithoutdomain; |
|
534 | 534 | } |
535 | 535 | |
536 | - $filename = 'image/'.$object->ref.$dirforimages.(preg_match('/^\//', $linkwithoutdomain)?'':'/').$linkwithoutdomain; |
|
536 | + $filename = 'image/'.$object->ref.$dirforimages.(preg_match('/^\//', $linkwithoutdomain) ? '' : '/').$linkwithoutdomain; |
|
537 | 537 | |
538 | 538 | // Clean the aa/bb/../cc into aa/cc |
539 | 539 | $filetosave = preg_replace('/\/[^\/]+\/\.\./', '', $filetosave); |
@@ -552,24 +552,24 @@ discard block |
||
552 | 552 | { |
553 | 553 | $error++; |
554 | 554 | setEventMessages('Error getting '.$urltograbbis.': '.$tmpgeturl['curl_error_msg'], null, 'errors'); |
555 | - $action='create'; |
|
555 | + $action = 'create'; |
|
556 | 556 | } |
557 | 557 | elseif ($tmpgeturl['http_code'] != '200') |
558 | 558 | { |
559 | 559 | $error++; |
560 | 560 | setEventMessages('Error getting '.$urltograbbis.': '.$tmpgeturl['http_code'], null, 'errors'); |
561 | - $action='create'; |
|
561 | + $action = 'create'; |
|
562 | 562 | } |
563 | 563 | else |
564 | 564 | { |
565 | - $alreadygrabbed[$urltograbbis]=1; // Track that file was alreay grabbed. |
|
565 | + $alreadygrabbed[$urltograbbis] = 1; // Track that file was alreay grabbed. |
|
566 | 566 | |
567 | 567 | dol_mkdir(dirname($filetosave)); |
568 | 568 | |
569 | 569 | $fp = fopen($filetosave, "w"); |
570 | 570 | fputs($fp, $tmpgeturl['content']); |
571 | 571 | fclose($fp); |
572 | - if (! empty($conf->global->MAIN_UMASK)) |
|
572 | + if (!empty($conf->global->MAIN_UMASK)) |
|
573 | 573 | @chmod($filetosave, octdec($conf->global->MAIN_UMASK)); |
574 | 574 | } |
575 | 575 | } |
@@ -577,7 +577,7 @@ discard block |
||
577 | 577 | |
578 | 578 | if ($modifylinks) |
579 | 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); |
|
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 | 581 | } |
582 | 582 | } |
583 | 583 | } |
@@ -599,11 +599,11 @@ discard block |
||
599 | 599 | dol_delete_file($filemaster); |
600 | 600 | |
601 | 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"; |
|
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 | 605 | $result = file_put_contents($filemaster, $mastercontent); |
606 | - if (! empty($conf->global->MAIN_UMASK)) |
|
606 | + if (!empty($conf->global->MAIN_UMASK)) |
|
607 | 607 | @chmod($filemaster, octdec($conf->global->MAIN_UMASK)); |
608 | 608 | |
609 | 609 | return $result; |
@@ -625,17 +625,17 @@ discard block |
||
625 | 625 | dol_syslog("We regenerate the alias page filealias=".$filealias); |
626 | 626 | |
627 | 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"; |
|
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 | 633 | $result = file_put_contents($filealias, $aliascontent); |
634 | - if (! empty($conf->global->MAIN_UMASK)) { |
|
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 | |
@@ -657,49 +657,49 @@ discard block |
||
657 | 657 | dol_delete_file($filetpl); |
658 | 658 | |
659 | 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"; |
|
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 | 699 | |
700 | 700 | //var_dump($filetpl);exit; |
701 | 701 | $result = file_put_contents($filetpl, $tplcontent); |
702 | - if (! empty($conf->global->MAIN_UMASK)) |
|
702 | + if (!empty($conf->global->MAIN_UMASK)) |
|
703 | 703 | @chmod($filetpl, octdec($conf->global->MAIN_UMASK)); |
704 | 704 | |
705 | 705 | return $result; |
@@ -719,33 +719,33 @@ discard block |
||
719 | 719 | { |
720 | 720 | global $conf; |
721 | 721 | |
722 | - $result1=false; |
|
723 | - $result2=false; |
|
722 | + $result1 = false; |
|
723 | + $result2 = false; |
|
724 | 724 | |
725 | 725 | dol_mkdir($pathofwebsite); |
726 | 726 | |
727 | 727 | dol_delete_file($fileindex); |
728 | 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"; |
|
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 | 739 | $result1 = file_put_contents($fileindex, $indexcontent); |
740 | - if (! empty($conf->global->MAIN_UMASK)) |
|
740 | + if (!empty($conf->global->MAIN_UMASK)) |
|
741 | 741 | @chmod($fileindex, octdec($conf->global->MAIN_UMASK)); |
742 | 742 | |
743 | 743 | dol_delete_file($filewrapper); |
744 | 744 | |
745 | - $wrappercontent=file_get_contents(DOL_DOCUMENT_ROOT.'/website/samples/wrapper.html'); |
|
745 | + $wrappercontent = file_get_contents(DOL_DOCUMENT_ROOT.'/website/samples/wrapper.html'); |
|
746 | 746 | |
747 | 747 | $result2 = file_put_contents($filewrapper, $wrappercontent); |
748 | - if (! empty($conf->global->MAIN_UMASK)) |
|
748 | + if (!empty($conf->global->MAIN_UMASK)) |
|
749 | 749 | @chmod($filewrapper, octdec($conf->global->MAIN_UMASK)); |
750 | 750 | |
751 | 751 | return ($result1 && $result2); |
@@ -767,10 +767,10 @@ discard block |
||
767 | 767 | |
768 | 768 | dol_mkdir($pathofwebsite); |
769 | 769 | $result = file_put_contents($filehtmlheader, $htmlheadercontent); |
770 | - if (! empty($conf->global->MAIN_UMASK)) |
|
770 | + if (!empty($conf->global->MAIN_UMASK)) |
|
771 | 771 | @chmod($filehtmlheader, octdec($conf->global->MAIN_UMASK)); |
772 | 772 | |
773 | - if (! $result) |
|
773 | + if (!$result) |
|
774 | 774 | { |
775 | 775 | setEventMessages('Failed to write file '.$filehtmlheader, null, 'errors'); |
776 | 776 | return false; |
@@ -794,10 +794,10 @@ discard block |
||
794 | 794 | |
795 | 795 | dol_mkdir($pathofwebsite); |
796 | 796 | $result = file_put_contents($filecss, $csscontent); |
797 | - if (! empty($conf->global->MAIN_UMASK)) |
|
797 | + if (!empty($conf->global->MAIN_UMASK)) |
|
798 | 798 | @chmod($filecss, octdec($conf->global->MAIN_UMASK)); |
799 | 799 | |
800 | - if (! $result) |
|
800 | + if (!$result) |
|
801 | 801 | { |
802 | 802 | setEventMessages('Failed to write file '.$filecss, null, 'errors'); |
803 | 803 | return false; |
@@ -821,10 +821,10 @@ discard block |
||
821 | 821 | |
822 | 822 | dol_mkdir($pathofwebsite); |
823 | 823 | $result = file_put_contents($filejs, $jscontent); |
824 | - if (! empty($conf->global->MAIN_UMASK)) |
|
824 | + if (!empty($conf->global->MAIN_UMASK)) |
|
825 | 825 | @chmod($filejs, octdec($conf->global->MAIN_UMASK)); |
826 | 826 | |
827 | - if (! $result) |
|
827 | + if (!$result) |
|
828 | 828 | { |
829 | 829 | setEventMessages('Failed to write file '.$filejs, null, 'errors'); |
830 | 830 | return false; |
@@ -848,10 +848,10 @@ discard block |
||
848 | 848 | |
849 | 849 | dol_mkdir($pathofwebsite); |
850 | 850 | $result = file_put_contents($filerobot, $robotcontent); |
851 | - if (! empty($conf->global->MAIN_UMASK)) |
|
851 | + if (!empty($conf->global->MAIN_UMASK)) |
|
852 | 852 | @chmod($filerobot, octdec($conf->global->MAIN_UMASK)); |
853 | 853 | |
854 | - if (! $result) |
|
854 | + if (!$result) |
|
855 | 855 | { |
856 | 856 | setEventMessages('Failed to write file '.$filerobot, null, 'errors'); |
857 | 857 | return false; |
@@ -875,10 +875,10 @@ discard block |
||
875 | 875 | |
876 | 876 | dol_mkdir($pathofwebsite); |
877 | 877 | $result = file_put_contents($filehtaccess, $htaccess); |
878 | - if (! empty($conf->global->MAIN_UMASK)) |
|
878 | + if (!empty($conf->global->MAIN_UMASK)) |
|
879 | 879 | @chmod($filehtaccess, octdec($conf->global->MAIN_UMASK)); |
880 | 880 | |
881 | - if (! $result) |
|
881 | + if (!$result) |
|
882 | 882 | { |
883 | 883 | setEventMessages('Failed to write file '.$filehtaccess, null, 'errors'); |
884 | 884 | return false; |
@@ -39,28 +39,40 @@ discard block |
||
39 | 39 | |
40 | 40 | // Replace php code. Note $content may come from database and does not contains body tags. |
41 | 41 | $replacewith='...php...'; |
42 | - if ($removephppart) $replacewith=''; |
|
42 | + if ($removephppart) { |
|
43 | + $replacewith=''; |
|
44 | + } |
|
43 | 45 | $content = preg_replace('/value="<\?php((?!\?>).)*\?>\n*/ims', 'value="'.$replacewith.'"', $content); |
44 | 46 | |
45 | 47 | $replacewith='"callto=#'; |
46 | - if ($removephppart) $replacewith=''; |
|
48 | + if ($removephppart) { |
|
49 | + $replacewith=''; |
|
50 | + } |
|
47 | 51 | $content = preg_replace('/"callto:<\?php((?!\?>).)*\?>\n*/ims', $replacewith, $content); |
48 | 52 | |
49 | 53 | $replacewith='"mailto=#'; |
50 | - if ($removephppart) $replacewith=''; |
|
54 | + if ($removephppart) { |
|
55 | + $replacewith=''; |
|
56 | + } |
|
51 | 57 | $content = preg_replace('/"mailto:<\?php((?!\?>).)*\?>\n*/ims', $replacewith, $content); |
52 | 58 | |
53 | 59 | $replacewith='src="php'; |
54 | - if ($removephppart) $replacewith=''; |
|
60 | + if ($removephppart) { |
|
61 | + $replacewith=''; |
|
62 | + } |
|
55 | 63 | $content = preg_replace('/src="<\?php((?!\?>).)*\?>\n*/ims', $replacewith, $content); |
56 | 64 | |
57 | 65 | $replacewith='href="php'; |
58 | - if ($removephppart) $replacewith=''; |
|
66 | + if ($removephppart) { |
|
67 | + $replacewith=''; |
|
68 | + } |
|
59 | 69 | $content = preg_replace('/href="<\?php((?!\?>).)*\?>\n*/ims', $replacewith, $content); |
60 | 70 | |
61 | 71 | //$replacewith='<span class="phptag">...php...</span>'; |
62 | 72 | $replacewith='<span class="phptag">...php...</span>'; |
63 | - if ($removephppart) $replacewith=''; |
|
73 | + if ($removephppart) { |
|
74 | + $replacewith=''; |
|
75 | + } |
|
64 | 76 | //$content = preg_replace('/<\?php((?!\?toremove>).)*\?toremove>\n*/ims', $replacewith, $content); |
65 | 77 | /*if ($content === null) { |
66 | 78 | if (preg_last_error() == PREG_JIT_STACKLIMIT_ERROR) $content = 'preg_replace error (when removing php tags) PREG_JIT_STACKLIMIT_ERROR'; |
@@ -113,9 +125,11 @@ discard block |
||
113 | 125 | $i=0; |
114 | 126 | foreach($parts as $part) |
115 | 127 | { |
116 | - if ($i == 0) // The first part is never php code |
|
128 | + if ($i == 0) { |
|
129 | + // The first part is never php code |
|
117 | 130 | { |
118 | 131 | $i++; |
132 | + } |
|
119 | 133 | $newstr .= $part; |
120 | 134 | continue; |
121 | 135 | } |
@@ -124,7 +138,9 @@ discard block |
||
124 | 138 | if (!empty($partlings)) |
125 | 139 | { |
126 | 140 | //remove content before closing tag |
127 | - if (count($partlings) > 1) $partlings[0] = ''; |
|
141 | + if (count($partlings) > 1) { |
|
142 | + $partlings[0] = ''; |
|
143 | + } |
|
128 | 144 | //append to out string |
129 | 145 | $newstr .= $replacewith.implode('',$partlings); |
130 | 146 | } |
@@ -154,16 +170,19 @@ discard block |
||
154 | 170 | $urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file |
155 | 171 | //$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current |
156 | 172 | |
157 | - if (defined('USEDOLIBARREDITOR')) // REPLACEMENT OF LINKS When page called from Dolibarr editor |
|
173 | + if (defined('USEDOLIBARREDITOR')) { |
|
174 | + // REPLACEMENT OF LINKS When page called from Dolibarr editor |
|
158 | 175 | { |
159 | 176 | // We remove the <head> part of content |
160 | 177 | $content = preg_replace('/<head>.*<\/head>/ims', '', $content); |
178 | + } |
|
161 | 179 | $content = preg_replace('/^.*<body(\s[^>]*)*>/ims', '', $content); |
162 | 180 | $content = preg_replace('/<\/body(\s[^>]*)*>.*$/ims', '', $content); |
163 | - } |
|
164 | - elseif (defined('USEDOLIBARRSERVER')) // REPLACEMENT OF LINKS When page called from Dolibarr server |
|
181 | + } elseif (defined('USEDOLIBARRSERVER')) { |
|
182 | + // REPLACEMENT OF LINKS When page called from Dolibarr server |
|
165 | 183 | { |
166 | 184 | global $website; |
185 | + } |
|
167 | 186 | |
168 | 187 | // Replace relative link / with dolibarr URL: ...href="/"... |
169 | 188 | $content=preg_replace('/(href=")\/\"/', '\1'.DOL_URL_ROOT.'/public/website/index.php?website='.$website->ref.'"', $content, -1, $nbrep); |
@@ -194,8 +213,7 @@ discard block |
||
194 | 213 | |
195 | 214 | // action="newpage.php" => action="dolibarr/website/index.php?website=...&pageref=newpage |
196 | 215 | $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 |
|
216 | + } else // REPLACEMENT OF LINKS When page called from virtual host |
|
199 | 217 | { |
200 | 218 | $symlinktomediaexists=1; |
201 | 219 | |
@@ -217,8 +235,7 @@ discard block |
||
217 | 235 | $content=preg_replace('/(url\(["\']?)[^\)]*viewimage\.php([^\)]*)hashp=([^\)]*)(["\']?\))/', '\1/wrapper.php\2hashp\3\4', $content, -1, $nbrep); |
218 | 236 | |
219 | 237 | $content=preg_replace('/(<img[^>]*src=")[^\"]*viewimage\.php([^\"]*)modulepart=mycompany([^\"]*)file=([^\"]*)("[^>]*>)/', '\1/wrapper.php\2modulepart=mycompany\3file=\4\5', $content, -1, $nbrep); |
220 | - } |
|
221 | - else |
|
238 | + } else |
|
222 | 239 | { |
223 | 240 | $content=preg_replace('/(<script[^>]*src=")[^\"]*document\.php([^\"]*)modulepart=medias([^\"]*)file=([^\"]*)("[^>]*>)/', '\1medias/\4\5', $content, -1, $nbrep); |
224 | 241 | |
@@ -293,20 +310,21 @@ discard block |
||
293 | 310 | if ($result > 0) |
294 | 311 | { |
295 | 312 | $containerref = $tmpwebsitepage->pageurl; |
296 | - } |
|
297 | - else |
|
313 | + } else |
|
298 | 314 | { |
299 | 315 | print "Error, page contains a redirect to the alternative alias '".$containeraliasalt."' that does not exists in web site (".$website->id." / ".$website->ref.")"; |
300 | 316 | exit; |
301 | 317 | } |
302 | 318 | } |
303 | 319 | |
304 | - if (defined('USEDOLIBARRSERVER')) // When page called from Dolibarr server |
|
320 | + if (defined('USEDOLIBARRSERVER')) { |
|
321 | + // When page called from Dolibarr server |
|
305 | 322 | { |
306 | 323 | // Check new container exists |
307 | 324 | if (! $containeraliasalt) // If containeraliasalt set, we already did the test |
308 | 325 | { |
309 | 326 | include_once DOL_DOCUMENT_ROOT.'/website/class/websitepage.class.php'; |
327 | + } |
|
310 | 328 | $tmpwebsitepage=new WebsitePage($db); |
311 | 329 | $result = $tmpwebsitepage->fetch(0, $website->id, $containerref); |
312 | 330 | unset($tmpwebsitepage); |
@@ -320,19 +338,16 @@ discard block |
||
320 | 338 | { |
321 | 339 | print "Error, page with uri '.$currenturi.' try a redirect to the same alias page '".$containerref."' in web site '".$website->ref."'"; |
322 | 340 | exit; |
323 | - } |
|
324 | - else |
|
341 | + } else |
|
325 | 342 | { |
326 | 343 | $newurl = preg_replace('/&pageref=([^&]+)/', '&pageref='.$containerref, $currenturi); |
327 | 344 | } |
328 | - } |
|
329 | - else |
|
345 | + } else |
|
330 | 346 | { |
331 | 347 | $newurl = $currenturi.'&pageref='.urlencode($containerref); |
332 | 348 | } |
333 | 349 | } |
334 | - } |
|
335 | - else // When page called from virtual host server |
|
350 | + } else // When page called from virtual host server |
|
336 | 351 | { |
337 | 352 | $newurl = '/'.$containerref.'.php'; |
338 | 353 | } |
@@ -341,8 +356,7 @@ discard block |
||
341 | 356 | { |
342 | 357 | header("Location: ".$newurl); |
343 | 358 | exit; |
344 | - } |
|
345 | - else |
|
359 | + } else |
|
346 | 360 | { |
347 | 361 | print "Error, page contains a redirect to the alias page '".$containerref."' that does not exists in web site (".$website->id." / ".$website->ref.")"; |
348 | 362 | exit; |
@@ -365,11 +379,15 @@ discard block |
||
365 | 379 | |
366 | 380 | $MAXLEVEL=20; |
367 | 381 | |
368 | - if (! preg_match('/\.php$/i', $containerref)) $containerref.='.php'; |
|
382 | + if (! preg_match('/\.php$/i', $containerref)) { |
|
383 | + $containerref.='.php'; |
|
384 | + } |
|
369 | 385 | |
370 | 386 | $fullpathfile=DOL_DATA_ROOT.'/website/'.$websitekey.'/'.$containerref; |
371 | 387 | |
372 | - if (empty($includehtmlcontentopened)) $includehtmlcontentopened=0; |
|
388 | + if (empty($includehtmlcontentopened)) { |
|
389 | + $includehtmlcontentopened=0; |
|
390 | + } |
|
373 | 391 | $includehtmlcontentopened++; |
374 | 392 | if ($includehtmlcontentopened > $MAXLEVEL) |
375 | 393 | { |
@@ -422,7 +440,9 @@ discard block |
||
422 | 440 | |
423 | 441 | $alreadygrabbed=array(); |
424 | 442 | |
425 | - if (preg_match('/\/$/', $urltograb)) $urltograb.='.'; |
|
443 | + if (preg_match('/\/$/', $urltograb)) { |
|
444 | + $urltograb.='.'; |
|
445 | + } |
|
426 | 446 | $urltograb = dirname($urltograb); // So urltograb is now http://www.nltechno.com or http://www.nltechno.com/dir1 |
427 | 447 | |
428 | 448 | // Search X in "img...src=X" |
@@ -430,21 +450,25 @@ discard block |
||
430 | 450 | |
431 | 451 | foreach ($regs[0] as $key => $val) |
432 | 452 | { |
433 | - if (preg_match('/^data:image/i', $regs[2][$key])) continue; // We do nothing for such images |
|
453 | + if (preg_match('/^data:image/i', $regs[2][$key])) { |
|
454 | + continue; |
|
455 | + } |
|
456 | + // We do nothing for such images |
|
434 | 457 | |
435 | 458 | if (preg_match('/^\//', $regs[2][$key])) |
436 | 459 | { |
437 | 460 | $urltograbdirrootwithoutslash = getRootURLFromURL($urltograb); |
438 | 461 | $urltograbbis = $urltograbdirrootwithoutslash.$regs[2][$key]; // We use dirroot |
439 | - } |
|
440 | - else |
|
462 | + } else |
|
441 | 463 | { |
442 | 464 | $urltograbbis = $urltograb.'/'.$regs[2][$key]; // We use dir of grabbed file |
443 | 465 | } |
444 | 466 | |
445 | 467 | $linkwithoutdomain = $regs[2][$key]; |
446 | 468 | $dirforimages = '/'.$objectpage->pageurl; |
447 | - if ($grabimagesinto == 'root') $dirforimages=''; |
|
469 | + if ($grabimagesinto == 'root') { |
|
470 | + $dirforimages=''; |
|
471 | + } |
|
448 | 472 | |
449 | 473 | // Define $filetosave and $filename |
450 | 474 | $filetosave = $conf->medias->multidir_output[$conf->entity].'/image/'.$object->ref.$dirforimages.(preg_match('/^\//', $regs[2][$key])?'':'/').$regs[2][$key]; |
@@ -474,14 +498,12 @@ discard block |
||
474 | 498 | $error++; |
475 | 499 | setEventMessages('Error getting '.$urltograbbis.': '.$tmpgeturl['curl_error_msg'], null, 'errors'); |
476 | 500 | $action='create'; |
477 | - } |
|
478 | - elseif ($tmpgeturl['http_code'] != '200') |
|
501 | + } elseif ($tmpgeturl['http_code'] != '200') |
|
479 | 502 | { |
480 | 503 | $error++; |
481 | 504 | setEventMessages('Error getting '.$urltograbbis.': '.$tmpgeturl['http_code'], null, 'errors'); |
482 | 505 | $action='create'; |
483 | - } |
|
484 | - else |
|
506 | + } else |
|
485 | 507 | { |
486 | 508 | $alreadygrabbed[$urltograbbis]=1; // Track that file was alreay grabbed. |
487 | 509 | |
@@ -490,8 +512,9 @@ discard block |
||
490 | 512 | $fp = fopen($filetosave, "w"); |
491 | 513 | fputs($fp, $tmpgeturl['content']); |
492 | 514 | fclose($fp); |
493 | - if (! empty($conf->global->MAIN_UMASK)) |
|
494 | - @chmod($filetosave, octdec($conf->global->MAIN_UMASK)); |
|
515 | + if (! empty($conf->global->MAIN_UMASK)) { |
|
516 | + @chmod($filetosave, octdec($conf->global->MAIN_UMASK)); |
|
517 | + } |
|
495 | 518 | } |
496 | 519 | } |
497 | 520 | } |
@@ -507,14 +530,16 @@ discard block |
||
507 | 530 | |
508 | 531 | foreach ($regs[0] as $key => $val) |
509 | 532 | { |
510 | - if (preg_match('/^data:image/i', $regs[2][$key])) continue; // We do nothing for such images |
|
533 | + if (preg_match('/^data:image/i', $regs[2][$key])) { |
|
534 | + continue; |
|
535 | + } |
|
536 | + // We do nothing for such images |
|
511 | 537 | |
512 | 538 | if (preg_match('/^\//', $regs[2][$key])) |
513 | 539 | { |
514 | 540 | $urltograbdirrootwithoutslash = getRootURLFromURL($urltograb); |
515 | 541 | $urltograbbis = $urltograbdirrootwithoutslash.$regs[2][$key]; // We use dirroot |
516 | - } |
|
517 | - else |
|
542 | + } else |
|
518 | 543 | { |
519 | 544 | $urltograbbis = $urltograb.'/'.$regs[2][$key]; // We use dir of grabbed file |
520 | 545 | } |
@@ -522,7 +547,9 @@ discard block |
||
522 | 547 | $linkwithoutdomain = $regs[2][$key]; |
523 | 548 | |
524 | 549 | $dirforimages = '/'.$objectpage->pageurl; |
525 | - if ($grabimagesinto == 'root') $dirforimages=''; |
|
550 | + if ($grabimagesinto == 'root') { |
|
551 | + $dirforimages=''; |
|
552 | + } |
|
526 | 553 | |
527 | 554 | $filetosave = $conf->medias->multidir_output[$conf->entity].'/image/'.$object->ref.$dirforimages.(preg_match('/^\//', $regs[2][$key])?'':'/').$regs[2][$key]; |
528 | 555 | |
@@ -553,14 +580,12 @@ discard block |
||
553 | 580 | $error++; |
554 | 581 | setEventMessages('Error getting '.$urltograbbis.': '.$tmpgeturl['curl_error_msg'], null, 'errors'); |
555 | 582 | $action='create'; |
556 | - } |
|
557 | - elseif ($tmpgeturl['http_code'] != '200') |
|
583 | + } elseif ($tmpgeturl['http_code'] != '200') |
|
558 | 584 | { |
559 | 585 | $error++; |
560 | 586 | setEventMessages('Error getting '.$urltograbbis.': '.$tmpgeturl['http_code'], null, 'errors'); |
561 | 587 | $action='create'; |
562 | - } |
|
563 | - else |
|
588 | + } else |
|
564 | 589 | { |
565 | 590 | $alreadygrabbed[$urltograbbis]=1; // Track that file was alreay grabbed. |
566 | 591 | |
@@ -569,8 +594,9 @@ discard block |
||
569 | 594 | $fp = fopen($filetosave, "w"); |
570 | 595 | fputs($fp, $tmpgeturl['content']); |
571 | 596 | fclose($fp); |
572 | - if (! empty($conf->global->MAIN_UMASK)) |
|
573 | - @chmod($filetosave, octdec($conf->global->MAIN_UMASK)); |
|
597 | + if (! empty($conf->global->MAIN_UMASK)) { |
|
598 | + @chmod($filetosave, octdec($conf->global->MAIN_UMASK)); |
|
599 | + } |
|
574 | 600 | } |
575 | 601 | } |
576 | 602 | } |
@@ -603,8 +629,9 @@ discard block |
||
603 | 629 | $mastercontent.= "if (! defined('USEDOLIBARRSERVER') && ! defined('USEDOLIBARREDITOR')) require_once '".DOL_DOCUMENT_ROOT."/master.inc.php';\n"; |
604 | 630 | $mastercontent.= '?>'."\n"; |
605 | 631 | $result = file_put_contents($filemaster, $mastercontent); |
606 | - if (! empty($conf->global->MAIN_UMASK)) |
|
607 | - @chmod($filemaster, octdec($conf->global->MAIN_UMASK)); |
|
632 | + if (! empty($conf->global->MAIN_UMASK)) { |
|
633 | + @chmod($filemaster, octdec($conf->global->MAIN_UMASK)); |
|
634 | + } |
|
608 | 635 | |
609 | 636 | return $result; |
610 | 637 | } |
@@ -657,7 +684,10 @@ discard block |
||
657 | 684 | dol_delete_file($filetpl); |
658 | 685 | |
659 | 686 | $shortlangcode = ''; |
660 | - if ($objectpage->lang) $shortlangcode=preg_replace('/[_-].*$/', '', $objectpage->lang); // en_US or en-US -> en |
|
687 | + if ($objectpage->lang) { |
|
688 | + $shortlangcode=preg_replace('/[_-].*$/', '', $objectpage->lang); |
|
689 | + } |
|
690 | + // en_US or en-US -> en |
|
661 | 691 | |
662 | 692 | $tplcontent =''; |
663 | 693 | $tplcontent.= "<?php // BEGIN PHP\n"; |
@@ -699,8 +729,9 @@ discard block |
||
699 | 729 | |
700 | 730 | //var_dump($filetpl);exit; |
701 | 731 | $result = file_put_contents($filetpl, $tplcontent); |
702 | - if (! empty($conf->global->MAIN_UMASK)) |
|
703 | - @chmod($filetpl, octdec($conf->global->MAIN_UMASK)); |
|
732 | + if (! empty($conf->global->MAIN_UMASK)) { |
|
733 | + @chmod($filetpl, octdec($conf->global->MAIN_UMASK)); |
|
734 | + } |
|
704 | 735 | |
705 | 736 | return $result; |
706 | 737 | } |
@@ -737,16 +768,18 @@ discard block |
||
737 | 768 | $indexcontent.= "include_once './".basename($filetpl)."'\n"; |
738 | 769 | $indexcontent.= '// END PHP ?>'."\n"; |
739 | 770 | $result1 = file_put_contents($fileindex, $indexcontent); |
740 | - if (! empty($conf->global->MAIN_UMASK)) |
|
741 | - @chmod($fileindex, octdec($conf->global->MAIN_UMASK)); |
|
771 | + if (! empty($conf->global->MAIN_UMASK)) { |
|
772 | + @chmod($fileindex, octdec($conf->global->MAIN_UMASK)); |
|
773 | + } |
|
742 | 774 | |
743 | 775 | dol_delete_file($filewrapper); |
744 | 776 | |
745 | 777 | $wrappercontent=file_get_contents(DOL_DOCUMENT_ROOT.'/website/samples/wrapper.html'); |
746 | 778 | |
747 | 779 | $result2 = file_put_contents($filewrapper, $wrappercontent); |
748 | - if (! empty($conf->global->MAIN_UMASK)) |
|
749 | - @chmod($filewrapper, octdec($conf->global->MAIN_UMASK)); |
|
780 | + if (! empty($conf->global->MAIN_UMASK)) { |
|
781 | + @chmod($filewrapper, octdec($conf->global->MAIN_UMASK)); |
|
782 | + } |
|
750 | 783 | |
751 | 784 | return ($result1 && $result2); |
752 | 785 | } |
@@ -767,8 +800,9 @@ discard block |
||
767 | 800 | |
768 | 801 | dol_mkdir($pathofwebsite); |
769 | 802 | $result = file_put_contents($filehtmlheader, $htmlheadercontent); |
770 | - if (! empty($conf->global->MAIN_UMASK)) |
|
771 | - @chmod($filehtmlheader, octdec($conf->global->MAIN_UMASK)); |
|
803 | + if (! empty($conf->global->MAIN_UMASK)) { |
|
804 | + @chmod($filehtmlheader, octdec($conf->global->MAIN_UMASK)); |
|
805 | + } |
|
772 | 806 | |
773 | 807 | if (! $result) |
774 | 808 | { |
@@ -794,8 +828,9 @@ discard block |
||
794 | 828 | |
795 | 829 | dol_mkdir($pathofwebsite); |
796 | 830 | $result = file_put_contents($filecss, $csscontent); |
797 | - if (! empty($conf->global->MAIN_UMASK)) |
|
798 | - @chmod($filecss, octdec($conf->global->MAIN_UMASK)); |
|
831 | + if (! empty($conf->global->MAIN_UMASK)) { |
|
832 | + @chmod($filecss, octdec($conf->global->MAIN_UMASK)); |
|
833 | + } |
|
799 | 834 | |
800 | 835 | if (! $result) |
801 | 836 | { |
@@ -821,8 +856,9 @@ discard block |
||
821 | 856 | |
822 | 857 | dol_mkdir($pathofwebsite); |
823 | 858 | $result = file_put_contents($filejs, $jscontent); |
824 | - if (! empty($conf->global->MAIN_UMASK)) |
|
825 | - @chmod($filejs, octdec($conf->global->MAIN_UMASK)); |
|
859 | + if (! empty($conf->global->MAIN_UMASK)) { |
|
860 | + @chmod($filejs, octdec($conf->global->MAIN_UMASK)); |
|
861 | + } |
|
826 | 862 | |
827 | 863 | if (! $result) |
828 | 864 | { |
@@ -848,8 +884,9 @@ discard block |
||
848 | 884 | |
849 | 885 | dol_mkdir($pathofwebsite); |
850 | 886 | $result = file_put_contents($filerobot, $robotcontent); |
851 | - if (! empty($conf->global->MAIN_UMASK)) |
|
852 | - @chmod($filerobot, octdec($conf->global->MAIN_UMASK)); |
|
887 | + if (! empty($conf->global->MAIN_UMASK)) { |
|
888 | + @chmod($filerobot, octdec($conf->global->MAIN_UMASK)); |
|
889 | + } |
|
853 | 890 | |
854 | 891 | if (! $result) |
855 | 892 | { |
@@ -875,8 +912,9 @@ discard block |
||
875 | 912 | |
876 | 913 | dol_mkdir($pathofwebsite); |
877 | 914 | $result = file_put_contents($filehtaccess, $htaccess); |
878 | - if (! empty($conf->global->MAIN_UMASK)) |
|
879 | - @chmod($filehtaccess, octdec($conf->global->MAIN_UMASK)); |
|
915 | + if (! empty($conf->global->MAIN_UMASK)) { |
|
916 | + @chmod($filehtaccess, octdec($conf->global->MAIN_UMASK)); |
|
917 | + } |
|
880 | 918 | |
881 | 919 | if (! $result) |
882 | 920 | { |
@@ -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 |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | global $db, $langs, $conf, $user; |
35 | 35 | |
36 | 36 | // Load translation files required by the page |
37 | - $langs->loadLangs(array("supplier_proposal","compta")); |
|
37 | + $langs->loadLangs(array("supplier_proposal", "compta")); |
|
38 | 38 | |
39 | 39 | $h = 0; |
40 | 40 | $head = array(); |
@@ -46,10 +46,10 @@ discard block |
||
46 | 46 | |
47 | 47 | if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) |
48 | 48 | { |
49 | - $nbContact = count($object->liste_contact(-1,'internal')) + count($object->liste_contact(-1,'external')); |
|
49 | + $nbContact = count($object->liste_contact(-1, 'internal')) + count($object->liste_contact(-1, 'external')); |
|
50 | 50 | $head[$h][0] = DOL_URL_ROOT.'/supplier_proposal/contact.php?id='.$object->id; |
51 | 51 | $head[$h][1] = $langs->trans('ContactsAddresses'); |
52 | - if ($nbContact > 0) $head[$h][1].= ' <span class="badge">'.$nbContact.'</span>'; |
|
52 | + if ($nbContact > 0) $head[$h][1] .= ' <span class="badge">'.$nbContact.'</span>'; |
|
53 | 53 | $head[$h][2] = 'contact'; |
54 | 54 | $h++; |
55 | 55 | } |
@@ -58,28 +58,28 @@ discard block |
||
58 | 58 | // Entries must be declared in modules descriptor with line |
59 | 59 | // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab |
60 | 60 | // $this->tabs = array('entity:-tabname); to remove a tab |
61 | - complete_head_from_modules($conf,$langs,$object,$head,$h,'supplier_proposal'); |
|
61 | + complete_head_from_modules($conf, $langs, $object, $head, $h, 'supplier_proposal'); |
|
62 | 62 | |
63 | 63 | if (empty($conf->global->MAIN_DISABLE_NOTES_TAB)) |
64 | 64 | { |
65 | 65 | $nbNote = 0; |
66 | - if(!empty($object->note_private)) $nbNote++; |
|
67 | - if(!empty($object->note_public)) $nbNote++; |
|
66 | + if (!empty($object->note_private)) $nbNote++; |
|
67 | + if (!empty($object->note_public)) $nbNote++; |
|
68 | 68 | $head[$h][0] = DOL_URL_ROOT.'/supplier_proposal/note.php?id='.$object->id; |
69 | 69 | $head[$h][1] = $langs->trans('Notes'); |
70 | - if ($nbNote > 0) $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>'; |
|
70 | + if ($nbNote > 0) $head[$h][1] .= ' <span class="badge">'.$nbNote.'</span>'; |
|
71 | 71 | $head[$h][2] = 'note'; |
72 | 72 | $h++; |
73 | 73 | } |
74 | 74 | |
75 | 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)$')); |
|
79 | - $nbLinks=Link::count($db, $object->element, $object->id); |
|
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 | + $nbLinks = Link::count($db, $object->element, $object->id); |
|
80 | 80 | $head[$h][0] = DOL_URL_ROOT.'/supplier_proposal/document.php?id='.$object->id; |
81 | 81 | $head[$h][1] = $langs->trans('Documents'); |
82 | - if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>'; |
|
82 | + if (($nbFiles + $nbLinks) > 0) $head[$h][1] .= ' <span class="badge">'.($nbFiles + $nbLinks).'</span>'; |
|
83 | 83 | $head[$h][2] = 'document'; |
84 | 84 | $h++; |
85 | 85 | |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | $head[$h][2] = 'info'; |
89 | 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 | 93 | return $head; |
94 | 94 | } |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | // Entries must be declared in modules descriptor with line |
115 | 115 | // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab |
116 | 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'); |
|
117 | + complete_head_from_modules($conf, $langs, null, $head, $h, 'supplier_proposal_admin'); |
|
118 | 118 | |
119 | 119 | $head[$h][0] = DOL_URL_ROOT.'/supplier_proposal/admin/supplier_proposal_extrafields.php'; |
120 | 120 | $head[$h][1] = $langs->trans("ExtraFields"); |
@@ -126,7 +126,7 @@ 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 | 131 | return $head; |
132 | 132 | } |
@@ -49,7 +49,9 @@ discard block |
||
49 | 49 | $nbContact = count($object->liste_contact(-1,'internal')) + count($object->liste_contact(-1,'external')); |
50 | 50 | $head[$h][0] = DOL_URL_ROOT.'/supplier_proposal/contact.php?id='.$object->id; |
51 | 51 | $head[$h][1] = $langs->trans('ContactsAddresses'); |
52 | - if ($nbContact > 0) $head[$h][1].= ' <span class="badge">'.$nbContact.'</span>'; |
|
52 | + if ($nbContact > 0) { |
|
53 | + $head[$h][1].= ' <span class="badge">'.$nbContact.'</span>'; |
|
54 | + } |
|
53 | 55 | $head[$h][2] = 'contact'; |
54 | 56 | $h++; |
55 | 57 | } |
@@ -63,11 +65,17 @@ discard block |
||
63 | 65 | if (empty($conf->global->MAIN_DISABLE_NOTES_TAB)) |
64 | 66 | { |
65 | 67 | $nbNote = 0; |
66 | - if(!empty($object->note_private)) $nbNote++; |
|
67 | - if(!empty($object->note_public)) $nbNote++; |
|
68 | + if(!empty($object->note_private)) { |
|
69 | + $nbNote++; |
|
70 | + } |
|
71 | + if(!empty($object->note_public)) { |
|
72 | + $nbNote++; |
|
73 | + } |
|
68 | 74 | $head[$h][0] = DOL_URL_ROOT.'/supplier_proposal/note.php?id='.$object->id; |
69 | 75 | $head[$h][1] = $langs->trans('Notes'); |
70 | - if ($nbNote > 0) $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>'; |
|
76 | + if ($nbNote > 0) { |
|
77 | + $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>'; |
|
78 | + } |
|
71 | 79 | $head[$h][2] = 'note'; |
72 | 80 | $h++; |
73 | 81 | } |
@@ -79,7 +87,9 @@ discard block |
||
79 | 87 | $nbLinks=Link::count($db, $object->element, $object->id); |
80 | 88 | $head[$h][0] = DOL_URL_ROOT.'/supplier_proposal/document.php?id='.$object->id; |
81 | 89 | $head[$h][1] = $langs->trans('Documents'); |
82 | - if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>'; |
|
90 | + if (($nbFiles+$nbLinks) > 0) { |
|
91 | + $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>'; |
|
92 | + } |
|
83 | 93 | $head[$h][2] = 'document'; |
84 | 94 | $h++; |
85 | 95 |
@@ -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 | } |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | */ |
34 | 34 | function get_tz_array() |
35 | 35 | { |
36 | - $tzarray=array( |
|
36 | + $tzarray = array( |
|
37 | 37 | -11=>"Pacific/Midway", |
38 | 38 | -10=>"Pacific/Fakaofo", |
39 | 39 | -9=>"America/Anchorage", |
@@ -80,28 +80,28 @@ discard block |
||
80 | 80 | * @param string $refgmtdate Reference period for timezone (timezone differs on winter and summer. May be 'now', 'winter' or 'summer') |
81 | 81 | * @return int An offset in hour (+1 for Europe/Paris on winter and +2 for Europe/Paris on summer) |
82 | 82 | */ |
83 | -function getServerTimeZoneInt($refgmtdate='now') |
|
83 | +function getServerTimeZoneInt($refgmtdate = 'now') |
|
84 | 84 | { |
85 | 85 | global $conf; |
86 | - if (method_exists('DateTimeZone','getOffset')) |
|
86 | + if (method_exists('DateTimeZone', 'getOffset')) |
|
87 | 87 | { |
88 | 88 | // Method 1 (include daylight) |
89 | - $gmtnow=dol_now('gmt'); $yearref=dol_print_date($gmtnow,'%Y'); $monthref=dol_print_date($gmtnow,'%m'); $dayref=dol_print_date($gmtnow,'%d'); |
|
90 | - if ($refgmtdate == 'now') $newrefgmtdate=$yearref.'-'.$monthref.'-'.$dayref; |
|
91 | - elseif ($refgmtdate == 'summer') $newrefgmtdate=$yearref.'-08-01'; |
|
92 | - else $newrefgmtdate=$yearref.'-01-01'; |
|
93 | - $newrefgmtdate.='T00:00:00+00:00'; |
|
89 | + $gmtnow = dol_now('gmt'); $yearref = dol_print_date($gmtnow, '%Y'); $monthref = dol_print_date($gmtnow, '%m'); $dayref = dol_print_date($gmtnow, '%d'); |
|
90 | + if ($refgmtdate == 'now') $newrefgmtdate = $yearref.'-'.$monthref.'-'.$dayref; |
|
91 | + elseif ($refgmtdate == 'summer') $newrefgmtdate = $yearref.'-08-01'; |
|
92 | + else $newrefgmtdate = $yearref.'-01-01'; |
|
93 | + $newrefgmtdate .= 'T00:00:00+00:00'; |
|
94 | 94 | $localtz = new DateTimeZone(getServerTimeZoneString()); |
95 | 95 | $localdt = new DateTime($newrefgmtdate, $localtz); |
96 | - $tmp=-1*$localtz->getOffset($localdt); |
|
96 | + $tmp = -1 * $localtz->getOffset($localdt); |
|
97 | 97 | //print $refgmtdate.'='.$tmp; |
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 | - $tz=round(($tmp<0?1:-1)*abs($tmp/3600)); |
|
104 | + $tz = round(($tmp < 0 ? 1 : -1) * abs($tmp / 3600)); |
|
105 | 105 | return $tz; |
106 | 106 | } |
107 | 107 | |
@@ -119,24 +119,24 @@ discard block |
||
119 | 119 | global $conf; |
120 | 120 | |
121 | 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); |
|
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 | 133 | $date = new DateTime(); |
134 | - if (! empty($conf->global->MAIN_DATE_IN_MEMORY_ARE_GMT)) $date->setTimezone(new DateTimeZone('UTC')); |
|
134 | + if (!empty($conf->global->MAIN_DATE_IN_MEMORY_ARE_GMT)) $date->setTimezone(new DateTimeZone('UTC')); |
|
135 | 135 | $date->setTimestamp($time); |
136 | 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 | 141 | return $date->getTimestamp(); |
142 | 142 | } |
@@ -151,9 +151,9 @@ discard block |
||
151 | 151 | * @return int Time into seconds |
152 | 152 | * @see convertSecondToTime |
153 | 153 | */ |
154 | -function convertTime2Seconds($iHours=0, $iMinutes=0, $iSeconds=0) |
|
154 | +function convertTime2Seconds($iHours = 0, $iMinutes = 0, $iSeconds = 0) |
|
155 | 155 | { |
156 | - $iResult=($iHours*3600)+($iMinutes*60)+$iSeconds; |
|
156 | + $iResult = ($iHours * 3600) + ($iMinutes * 60) + $iSeconds; |
|
157 | 157 | return $iResult; |
158 | 158 | } |
159 | 159 | |
@@ -178,30 +178,30 @@ discard block |
||
178 | 178 | * Example: 0 return 00:00, 3600 return 1:00, 86400 return 1d, 90000 return 1 Day 01:00 |
179 | 179 | * @see convertTime2Seconds |
180 | 180 | */ |
181 | -function convertSecondToTime($iSecond, $format='all', $lengthOfDay=86400, $lengthOfWeek=7) |
|
181 | +function convertSecondToTime($iSecond, $format = 'all', $lengthOfDay = 86400, $lengthOfWeek = 7) |
|
182 | 182 | { |
183 | 183 | global $langs; |
184 | 184 | |
185 | - if (empty($lengthOfDay)) $lengthOfDay = 86400; // 1 day = 24 hours |
|
186 | - if (empty($lengthOfWeek)) $lengthOfWeek = 7; // 1 week = 7 days |
|
185 | + if (empty($lengthOfDay)) $lengthOfDay = 86400; // 1 day = 24 hours |
|
186 | + if (empty($lengthOfWeek)) $lengthOfWeek = 7; // 1 week = 7 days |
|
187 | 187 | |
188 | 188 | if ($format == 'all' || $format == 'allwithouthour' || $format == 'allhour' || $format == 'allhourmin') |
189 | 189 | { |
190 | - if ((int) $iSecond === 0) return '0'; // This is to avoid having 0 return a 12:00 AM for en_US |
|
190 | + if ((int) $iSecond === 0) return '0'; // This is to avoid having 0 return a 12:00 AM for en_US |
|
191 | 191 | |
192 | - $sTime=''; |
|
193 | - $sDay=0; |
|
194 | - $sWeek=0; |
|
192 | + $sTime = ''; |
|
193 | + $sDay = 0; |
|
194 | + $sWeek = 0; |
|
195 | 195 | |
196 | 196 | if ($iSecond >= $lengthOfDay) |
197 | 197 | { |
198 | - for($i = $iSecond; $i >= $lengthOfDay; $i -= $lengthOfDay ) |
|
198 | + for ($i = $iSecond; $i >= $lengthOfDay; $i -= $lengthOfDay) |
|
199 | 199 | { |
200 | 200 | $sDay++; |
201 | - $iSecond-=$lengthOfDay; |
|
201 | + $iSecond -= $lengthOfDay; |
|
202 | 202 | } |
203 | 203 | $dayTranslate = $langs->trans("Day"); |
204 | - if ($iSecond >= ($lengthOfDay*2)) $dayTranslate = $langs->trans("Days"); |
|
204 | + if ($iSecond >= ($lengthOfDay * 2)) $dayTranslate = $langs->trans("Days"); |
|
205 | 205 | } |
206 | 206 | |
207 | 207 | if ($lengthOfWeek < 7) |
@@ -210,66 +210,66 @@ discard block |
||
210 | 210 | { |
211 | 211 | if ($sDay >= $lengthOfWeek) |
212 | 212 | { |
213 | - $sWeek = (int) (($sDay - $sDay % $lengthOfWeek ) / $lengthOfWeek); |
|
213 | + $sWeek = (int) (($sDay - $sDay % $lengthOfWeek) / $lengthOfWeek); |
|
214 | 214 | $sDay = $sDay % $lengthOfWeek; |
215 | 215 | $weekTranslate = $langs->trans("DurationWeek"); |
216 | 216 | if ($sWeek >= 2) $weekTranslate = $langs->trans("DurationWeeks"); |
217 | - $sTime.=$sWeek.' '.$weekTranslate.' '; |
|
217 | + $sTime .= $sWeek.' '.$weekTranslate.' '; |
|
218 | 218 | } |
219 | 219 | } |
220 | 220 | } |
221 | - if ($sDay>0) |
|
221 | + if ($sDay > 0) |
|
222 | 222 | { |
223 | 223 | $dayTranslate = $langs->trans("Day"); |
224 | 224 | if ($sDay > 1) $dayTranslate = $langs->trans("Days"); |
225 | - $sTime.=$sDay.' '.$dayTranslate.' '; |
|
225 | + $sTime .= $sDay.' '.$dayTranslate.' '; |
|
226 | 226 | } |
227 | 227 | |
228 | 228 | if ($format == 'all') |
229 | 229 | { |
230 | 230 | if ($iSecond || empty($sDay)) |
231 | 231 | { |
232 | - $sTime.= dol_print_date($iSecond,'hourduration',true); |
|
232 | + $sTime .= dol_print_date($iSecond, 'hourduration', true); |
|
233 | 233 | } |
234 | 234 | } |
235 | 235 | if ($format == 'allhourmin') |
236 | 236 | { |
237 | - return sprintf("%02d",($sWeek*$lengthOfWeek*24 + $sDay*24 + (int) floor($iSecond/3600))).':'.sprintf("%02d",((int) floor(($iSecond % 3600)/60))); |
|
237 | + return sprintf("%02d", ($sWeek * $lengthOfWeek * 24 + $sDay * 24 + (int) floor($iSecond / 3600))).':'.sprintf("%02d", ((int) floor(($iSecond % 3600) / 60))); |
|
238 | 238 | } |
239 | 239 | if ($format == 'allhour') |
240 | 240 | { |
241 | - return sprintf("%02d",($sWeek*$lengthOfWeek*24 + $sDay*24 + (int) floor($iSecond/3600))); |
|
241 | + return sprintf("%02d", ($sWeek * $lengthOfWeek * 24 + $sDay * 24 + (int) floor($iSecond / 3600))); |
|
242 | 242 | } |
243 | 243 | } |
244 | 244 | else if ($format == 'hour') // only hour part |
245 | 245 | { |
246 | - $sTime=dol_print_date($iSecond,'%H',true); |
|
246 | + $sTime = dol_print_date($iSecond, '%H', true); |
|
247 | 247 | } |
248 | 248 | else if ($format == 'fullhour') |
249 | 249 | { |
250 | 250 | if (!empty($iSecond)) { |
251 | - $iSecond=$iSecond/3600; |
|
251 | + $iSecond = $iSecond / 3600; |
|
252 | 252 | } |
253 | 253 | else { |
254 | - $iSecond=0; |
|
254 | + $iSecond = 0; |
|
255 | 255 | } |
256 | - $sTime=$iSecond; |
|
256 | + $sTime = $iSecond; |
|
257 | 257 | } |
258 | 258 | else if ($format == 'min') // only min part |
259 | 259 | { |
260 | - $sTime=dol_print_date($iSecond,'%M',true); |
|
260 | + $sTime = dol_print_date($iSecond, '%M', true); |
|
261 | 261 | } |
262 | 262 | else if ($format == 'sec') // only sec part |
263 | 263 | { |
264 | - $sTime=dol_print_date($iSecond,'%S',true); |
|
264 | + $sTime = dol_print_date($iSecond, '%S', true); |
|
265 | 265 | } |
266 | 266 | else if ($format == 'month') // only month part |
267 | 267 | { |
268 | - $sTime=dol_print_date($iSecond,'%m',true); |
|
268 | + $sTime = dol_print_date($iSecond, '%m', true); |
|
269 | 269 | } |
270 | 270 | else if ($format == 'year') // only year part |
271 | 271 | { |
272 | - $sTime=dol_print_date($iSecond,'%Y',true); |
|
272 | + $sTime = dol_print_date($iSecond, '%Y', true); |
|
273 | 273 | } |
274 | 274 | return trim($sTime); |
275 | 275 | } |
@@ -287,19 +287,19 @@ discard block |
||
287 | 287 | function dolSqlDateFilter($datefield, $day_date, $month_date, $year_date) |
288 | 288 | { |
289 | 289 | global $db; |
290 | - $sqldate=""; |
|
290 | + $sqldate = ""; |
|
291 | 291 | if ($month_date > 0) { |
292 | 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))."'"; |
|
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 | 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))."'"; |
|
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 | 303 | } |
304 | 304 | return $sqldate; |
305 | 305 | } |
@@ -322,10 +322,10 @@ discard block |
||
322 | 322 | * |
323 | 323 | * @see dol_print_date, dol_mktime, dol_getdate |
324 | 324 | */ |
325 | -function dol_stringtotime($string, $gm=1) |
|
325 | +function dol_stringtotime($string, $gm = 1) |
|
326 | 326 | { |
327 | 327 | // Convert date with format DD/MM/YYY HH:MM:SS. This part of code should not be used. |
328 | - if (preg_match('/^([0-9]+)\/([0-9]+)\/([0-9]+)\s?([0-9]+)?:?([0-9]+)?:?([0-9]+)?/i',$string,$reg)) |
|
328 | + if (preg_match('/^([0-9]+)\/([0-9]+)\/([0-9]+)\s?([0-9]+)?:?([0-9]+)?:?([0-9]+)?/i', $string, $reg)) |
|
329 | 329 | { |
330 | 330 | dol_syslog("dol_stringtotime call to function with deprecated parameter format", LOG_WARNING); |
331 | 331 | // Date est au format 'DD/MM/YY' ou 'DD/MM/YY HH:MM:SS' |
@@ -336,14 +336,14 @@ discard block |
||
336 | 336 | $shour = $reg[4]; |
337 | 337 | $smin = $reg[5]; |
338 | 338 | $ssec = $reg[6]; |
339 | - if ($syear < 50) $syear+=1900; |
|
340 | - if ($syear >= 50 && $syear < 100) $syear+=2000; |
|
341 | - $string=sprintf("%04d%02d%02d%02d%02d%02d",$syear,$smonth,$sday,$shour,$smin,$ssec); |
|
339 | + if ($syear < 50) $syear += 1900; |
|
340 | + if ($syear >= 50 && $syear < 100) $syear += 2000; |
|
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]; |
@@ -352,12 +352,12 @@ discard block |
||
352 | 352 | $shour = $reg[4]; |
353 | 353 | $smin = $reg[5]; |
354 | 354 | $ssec = $reg[6]; |
355 | - $string=sprintf("%04d%02d%02d%02d%02d%02d",$syear,$smonth,$sday,$shour,$smin,$ssec); |
|
355 | + $string = sprintf("%04d%02d%02d%02d%02d%02d", $syear, $smonth, $sday, $shour, $smin, $ssec); |
|
356 | 356 | } |
357 | 357 | |
358 | - $string=preg_replace('/([^0-9])/i','',$string); |
|
359 | - $tmp=$string.'000000'; |
|
360 | - $date=dol_mktime(substr($tmp,8,2),substr($tmp,10,2),substr($tmp,12,2),substr($tmp,4,2),substr($tmp,6,2),substr($tmp,0,4),($gm?1:0)); |
|
358 | + $string = preg_replace('/([^0-9])/i', '', $string); |
|
359 | + $tmp = $string.'000000'; |
|
360 | + $date = dol_mktime(substr($tmp, 8, 2), substr($tmp, 10, 2), substr($tmp, 12, 2), substr($tmp, 4, 2), substr($tmp, 6, 2), substr($tmp, 0, 4), ($gm ? 1 : 0)); |
|
361 | 361 | return $date; |
362 | 362 | } |
363 | 363 | |
@@ -371,9 +371,9 @@ 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); |
|
374 | + $time = dol_mktime(12, 0, 0, $month, $day, $year, 1, 0); |
|
375 | + $time -= 24 * 60 * 60; |
|
376 | + $tmparray = dol_getdate($time, true); |
|
377 | 377 | return array('year' => $tmparray['year'], 'month' => $tmparray['mon'], 'day' => $tmparray['mday']); |
378 | 378 | } |
379 | 379 | |
@@ -386,9 +386,9 @@ 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); |
|
389 | + $time = dol_mktime(12, 0, 0, $month, $day, $year, 1, 0); |
|
390 | + $time += 24 * 60 * 60; |
|
391 | + $tmparray = dol_getdate($time, true); |
|
392 | 392 | return array('year' => $tmparray['year'], 'month' => $tmparray['mon'], 'day' => $tmparray['mday']); |
393 | 393 | } |
394 | 394 | |
@@ -407,7 +407,7 @@ discard block |
||
407 | 407 | } |
408 | 408 | else |
409 | 409 | { |
410 | - $prev_month = $month-1; |
|
410 | + $prev_month = $month - 1; |
|
411 | 411 | $prev_year = $year; |
412 | 412 | } |
413 | 413 | return array('year' => $prev_year, 'month' => $prev_month); |
@@ -446,9 +446,9 @@ discard block |
||
446 | 446 | { |
447 | 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); |
|
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 | 452 | return array('year' => $tmparray['year'], 'month' => $tmparray['mon'], 'day' => $tmparray['mday']); |
453 | 453 | } |
454 | 454 | |
@@ -464,9 +464,9 @@ discard block |
||
464 | 464 | { |
465 | 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 | 471 | return array('year' => $tmparray['year'], 'month' => $tmparray['mon'], 'day' => $tmparray['mday']); |
472 | 472 | } |
@@ -480,10 +480,10 @@ discard block |
||
480 | 480 | * Exemple: dol_get_first_day(1970,1,true) will return 0 whatever is TZ, after a dol_print_date will return 1970-01-01 00:00:00 |
481 | 481 | * @return int Date for first day, '' if error |
482 | 482 | */ |
483 | -function dol_get_first_day($year,$month=1,$gm=false) |
|
483 | +function dol_get_first_day($year, $month = 1, $gm = false) |
|
484 | 484 | { |
485 | 485 | if ($year > 9999) return ''; |
486 | - return dol_mktime(0,0,0,$month,1,$year,$gm); |
|
486 | + return dol_mktime(0, 0, 0, $month, 1, $year, $gm); |
|
487 | 487 | } |
488 | 488 | |
489 | 489 | |
@@ -494,7 +494,7 @@ discard block |
||
494 | 494 | * @param boolean $gm False or 0 or 'server' = Return date to compare with server TZ, True or 1 to compare with GM date. |
495 | 495 | * @return int Date for first day, '' if error |
496 | 496 | */ |
497 | -function dol_get_last_day($year,$month=12,$gm=false) |
|
497 | +function dol_get_last_day($year, $month = 12, $gm = false) |
|
498 | 498 | { |
499 | 499 | if ($year > 9999) return ''; |
500 | 500 | if ($month == 12) |
@@ -508,7 +508,7 @@ discard block |
||
508 | 508 | } |
509 | 509 | |
510 | 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); |
|
511 | + $datelim = dol_mktime(23, 59, 59, $month, 1, $year, $gm); |
|
512 | 512 | $datelim -= (3600 * 24); |
513 | 513 | |
514 | 514 | return $datelim; |
@@ -522,69 +522,69 @@ discard block |
||
522 | 522 | * @param int $gm False or 0 or 'server' = Return date to compare with server TZ, True or 1 to compare with GM date. |
523 | 523 | * @return array year,month,week,first_day,first_month,first_year,prev_day,prev_month,prev_year |
524 | 524 | */ |
525 | -function dol_get_first_day_week($day,$month,$year,$gm=false) |
|
525 | +function dol_get_first_day_week($day, $month, $year, $gm = false) |
|
526 | 526 | { |
527 | 527 | global $conf; |
528 | 528 | |
529 | 529 | //$day=2; $month=2; $year=2015; |
530 | - $date = dol_mktime(0,0,0,$month,$day,$year,$gm); |
|
530 | + $date = dol_mktime(0, 0, 0, $month, $day, $year, $gm); |
|
531 | 531 | |
532 | 532 | //Checking conf of start week |
533 | - $start_week = (isset($conf->global->MAIN_START_WEEK)?$conf->global->MAIN_START_WEEK:1); |
|
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 | 537 | //Calculate days = offset from current day |
538 | 538 | $days = $start_week - $tmparray['wday']; |
539 | - if ($days>=1) $days=7-$days; |
|
539 | + if ($days >= 1) $days = 7 - $days; |
|
540 | 540 | $days = abs($days); |
541 | - $seconds = $days*24*60*60; |
|
541 | + $seconds = $days * 24 * 60 * 60; |
|
542 | 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 | - $tmpdaytms = date($tmparray[0])-$seconds; // $tmparray[0] is day of parameters |
|
546 | - $tmpday = date("d",$tmpdaytms); |
|
545 | + $tmpdaytms = date($tmparray[0]) - $seconds; // $tmparray[0] is day of parameters |
|
546 | + $tmpday = date("d", $tmpdaytms); |
|
547 | 547 | |
548 | 548 | //Check first day of week is in same month than current day or not |
549 | - if ($tmpday>$day) |
|
549 | + if ($tmpday > $day) |
|
550 | 550 | { |
551 | - $prev_month = $month-1; |
|
552 | - $prev_year = $year; |
|
551 | + $prev_month = $month - 1; |
|
552 | + $prev_year = $year; |
|
553 | 553 | |
554 | - if ($prev_month==0) |
|
554 | + if ($prev_month == 0) |
|
555 | 555 | { |
556 | 556 | $prev_month = 12; |
557 | - $prev_year = $year-1; |
|
557 | + $prev_year = $year - 1; |
|
558 | 558 | } |
559 | 559 | } |
560 | 560 | else |
561 | 561 | { |
562 | 562 | $prev_month = $month; |
563 | - $prev_year = $year; |
|
563 | + $prev_year = $year; |
|
564 | 564 | } |
565 | 565 | $tmpmonth = $prev_month; |
566 | 566 | $tmpyear = $prev_year; |
567 | 567 | |
568 | 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 | - $prev_day = $tmparray['mday']; |
|
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 | + $prev_day = $tmparray['mday']; |
|
573 | 573 | |
574 | 574 | //Check prev day of week is in same month than first day or not |
575 | 575 | if ($prev_day > $tmpday) |
576 | 576 | { |
577 | - $prev_month = $month-1; |
|
578 | - $prev_year = $year; |
|
577 | + $prev_month = $month - 1; |
|
578 | + $prev_year = $year; |
|
579 | 579 | |
580 | - if ($prev_month==0) |
|
580 | + if ($prev_month == 0) |
|
581 | 581 | { |
582 | 582 | $prev_month = 12; |
583 | - $prev_year = $year-1; |
|
583 | + $prev_year = $year - 1; |
|
584 | 584 | } |
585 | 585 | } |
586 | 586 | |
587 | - $week = date("W",dol_mktime(0,0,0,$tmpmonth,$tmpday,$tmpyear,$gm)); |
|
587 | + $week = date("W", dol_mktime(0, 0, 0, $tmpmonth, $tmpday, $tmpyear, $gm)); |
|
588 | 588 | |
589 | 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 | } |
@@ -600,7 +600,7 @@ discard block |
||
600 | 600 | * @return int Nombre de jours feries |
601 | 601 | * @see num_between_day, num_open_day |
602 | 602 | */ |
603 | -function num_public_holiday($timestampStart, $timestampEnd, $countrycode='FR', $lastday=0) |
|
603 | +function num_public_holiday($timestampStart, $timestampEnd, $countrycode = 'FR', $lastday = 0) |
|
604 | 604 | { |
605 | 605 | global $conf; |
606 | 606 | |
@@ -609,13 +609,13 @@ discard block |
||
609 | 609 | // Check to ensure we use correct parameters |
610 | 610 | if ((($timestampEnd - $timestampStart) % 86400) != 0) return 'ErrorDates must use same hours and must be GMT dates'; |
611 | 611 | |
612 | - $i=0; |
|
613 | - while (( ($lastday == 0 && $timestampStart < $timestampEnd) || ($lastday && $timestampStart <= $timestampEnd) ) |
|
612 | + $i = 0; |
|
613 | + while ((($lastday == 0 && $timestampStart < $timestampEnd) || ($lastday && $timestampStart <= $timestampEnd)) |
|
614 | 614 | && ($i < 50000)) // Loop end when equals (Test on i is a security loop to avoid infinite loop) |
615 | 615 | { |
616 | - $ferie=false; |
|
617 | - $countryfound=0; |
|
618 | - $includesaturdayandsunday=1; |
|
616 | + $ferie = false; |
|
617 | + $countryfound = 0; |
|
618 | + $includesaturdayandsunday = 1; |
|
619 | 619 | |
620 | 620 | $jour = date("d", $timestampStart); |
621 | 621 | $mois = date("m", $timestampStart); |
@@ -623,42 +623,42 @@ discard block |
||
623 | 623 | |
624 | 624 | |
625 | 625 | // Check into var $conf->global->HOLIDAY_MORE_DAYS MM-DD,YYYY-MM-DD, ... |
626 | - if (! empty($conf->global->HOLIDAY_MORE_PUBLIC_HOLIDAYS)) |
|
626 | + if (!empty($conf->global->HOLIDAY_MORE_PUBLIC_HOLIDAYS)) |
|
627 | 627 | { |
628 | - $arrayofdaystring=explode(',',$conf->global->HOLIDAY_MORE_PUBLIC_HOLIDAYS); |
|
629 | - foreach($arrayofdaystring as $daystring) |
|
628 | + $arrayofdaystring = explode(',', $conf->global->HOLIDAY_MORE_PUBLIC_HOLIDAYS); |
|
629 | + foreach ($arrayofdaystring as $daystring) |
|
630 | 630 | { |
631 | - $tmp=explode('-',$daystring); |
|
631 | + $tmp = explode('-', $daystring); |
|
632 | 632 | if ($tmp[2]) |
633 | 633 | { |
634 | - if ($tmp[0] == $annee && $tmp[1] == $mois && $tmp[2] == $jour) $ferie=true; |
|
634 | + if ($tmp[0] == $annee && $tmp[1] == $mois && $tmp[2] == $jour) $ferie = true; |
|
635 | 635 | } |
636 | 636 | else |
637 | 637 | { |
638 | - if ($tmp[0] == $mois && $tmp[1] == $jour) $ferie=true; |
|
638 | + if ($tmp[0] == $mois && $tmp[1] == $jour) $ferie = true; |
|
639 | 639 | } |
640 | 640 | } |
641 | 641 | } |
642 | 642 | |
643 | 643 | if ($countrycode == 'FR') |
644 | 644 | { |
645 | - $countryfound=1; |
|
645 | + $countryfound = 1; |
|
646 | 646 | |
647 | 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 |
|
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 | 656 | |
657 | 657 | // Calculation for easter date |
658 | 658 | $date_paques = easter_date($annee); |
659 | 659 | $jour_paques = date("d", $date_paques); |
660 | 660 | $mois_paques = date("m", $date_paques); |
661 | - if($jour_paques == $jour && $mois_paques == $mois) $ferie=true; |
|
661 | + if ($jour_paques == $jour && $mois_paques == $mois) $ferie = true; |
|
662 | 662 | // Pâques |
663 | 663 | |
664 | 664 | // Calculation for the monday of easter date |
@@ -672,7 +672,7 @@ discard block |
||
672 | 672 | ); |
673 | 673 | $jour_lundi_ascension = date("d", $date_lundi_paques); |
674 | 674 | $mois_lundi_ascension = date("m", $date_lundi_paques); |
675 | - if($jour_lundi_ascension == $jour && $mois_lundi_ascension == $mois) $ferie=true; |
|
675 | + if ($jour_lundi_ascension == $jour && $mois_lundi_ascension == $mois) $ferie = true; |
|
676 | 676 | // Lundi de Pâques |
677 | 677 | |
678 | 678 | // Calcul du jour de l'ascension (38 days after easter day) |
@@ -686,7 +686,7 @@ discard block |
||
686 | 686 | ); |
687 | 687 | $jour_ascension = date("d", $date_ascension); |
688 | 688 | $mois_ascension = date("m", $date_ascension); |
689 | - if($jour_ascension == $jour && $mois_ascension == $mois) $ferie=true; |
|
689 | + if ($jour_ascension == $jour && $mois_ascension == $mois) $ferie = true; |
|
690 | 690 | // Ascension |
691 | 691 | |
692 | 692 | // Calculation of "Pentecote" (11 days after easter day) |
@@ -700,7 +700,7 @@ discard block |
||
700 | 700 | ); |
701 | 701 | $jour_pentecote = date("d", $date_pentecote); |
702 | 702 | $mois_pentecote = date("m", $date_pentecote); |
703 | - if($jour_pentecote == $jour && $mois_pentecote == $mois) $ferie=true; |
|
703 | + if ($jour_pentecote == $jour && $mois_pentecote == $mois) $ferie = true; |
|
704 | 704 | // "Pentecote" |
705 | 705 | } |
706 | 706 | |
@@ -708,60 +708,60 @@ discard block |
||
708 | 708 | // Pentecoste is 50 days after Easter, Ascensione 40 |
709 | 709 | if ($countrycode == 'IT') |
710 | 710 | { |
711 | - $countryfound=1; |
|
711 | + $countryfound = 1; |
|
712 | 712 | |
713 | 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 |
|
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 | 724 | |
725 | 725 | // Calcul du jour de paques |
726 | 726 | $date_paques = easter_date($annee); |
727 | 727 | $jour_paques = date("d", $date_paques); |
728 | 728 | $mois_paques = date("m", $date_paques); |
729 | - if($jour_paques == $jour && $mois_paques == $mois) $ferie=true; |
|
729 | + if ($jour_paques == $jour && $mois_paques == $mois) $ferie = true; |
|
730 | 730 | // Paques |
731 | 731 | } |
732 | 732 | |
733 | 733 | if ($countrycode == 'IN') |
734 | 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 |
|
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 | 743 | } |
744 | 744 | |
745 | 745 | if ($countrycode == 'ES') |
746 | 746 | { |
747 | - $countryfound=1; |
|
747 | + $countryfound = 1; |
|
748 | 748 | |
749 | 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 |
|
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 | 759 | |
760 | 760 | // Calcul día de Pascua |
761 | 761 | $date_paques = easter_date($annee); |
762 | 762 | $jour_paques = date("d", $date_paques); |
763 | 763 | $mois_paques = date("m", $date_paques); |
764 | - if($jour_paques == $jour && $mois_paques == $mois) $ferie=true; |
|
764 | + if ($jour_paques == $jour && $mois_paques == $mois) $ferie = true; |
|
765 | 765 | // Paques |
766 | 766 | |
767 | 767 | // Viernes Santo |
@@ -770,37 +770,37 @@ discard block |
||
770 | 770 | date("i", $date_paques), |
771 | 771 | date("s", $date_paques), |
772 | 772 | date("m", $date_paques), |
773 | - date("d", $date_paques) -2, |
|
773 | + date("d", $date_paques) - 2, |
|
774 | 774 | date("Y", $date_paques) |
775 | 775 | ); |
776 | 776 | $jour_viernes = date("d", $date_viernes); |
777 | 777 | $mois_viernes = date("m", $date_viernes); |
778 | - if($jour_viernes == $jour && $mois_viernes == $mois) $ferie=true; |
|
778 | + if ($jour_viernes == $jour && $mois_viernes == $mois) $ferie = true; |
|
779 | 779 | //Viernes Santo |
780 | 780 | } |
781 | 781 | |
782 | 782 | if ($countrycode == 'AT') |
783 | 783 | { |
784 | - $countryfound=1; |
|
784 | + $countryfound = 1; |
|
785 | 785 | |
786 | 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 |
|
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 | 798 | |
799 | 799 | // Easter calculation |
800 | 800 | $date_paques = easter_date($annee); |
801 | 801 | $jour_paques = date("d", $date_paques); |
802 | 802 | $mois_paques = date("m", $date_paques); |
803 | - if($jour_paques == $jour && $mois_paques == $mois) $ferie=true; |
|
803 | + if ($jour_paques == $jour && $mois_paques == $mois) $ferie = true; |
|
804 | 804 | // Easter sunday |
805 | 805 | |
806 | 806 | // Monday after easter |
@@ -814,7 +814,7 @@ discard block |
||
814 | 814 | ); |
815 | 815 | $jour_eastermonday = date("d", $date_eastermonday); |
816 | 816 | $mois_eastermonday = date("m", $date_eastermonday); |
817 | - if($jour_eastermonday == $jour && $mois_eastermonday == $mois) $ferie=true; |
|
817 | + if ($jour_eastermonday == $jour && $mois_eastermonday == $mois) $ferie = true; |
|
818 | 818 | // Easter monday |
819 | 819 | |
820 | 820 | // Christi Himmelfahrt (39 days after easter sunday) |
@@ -828,7 +828,7 @@ discard block |
||
828 | 828 | ); |
829 | 829 | $jour_ch = date("d", $date_ch); |
830 | 830 | $mois_ch = date("m", $date_ch); |
831 | - if($jour_ch == $jour && $mois_ch == $mois) $ferie=true; |
|
831 | + if ($jour_ch == $jour && $mois_ch == $mois) $ferie = true; |
|
832 | 832 | // Christi Himmelfahrt |
833 | 833 | |
834 | 834 | // Pfingsten (50 days after easter sunday) |
@@ -842,7 +842,7 @@ discard block |
||
842 | 842 | ); |
843 | 843 | $jour_pentecote = date("d", $date_pentecote); |
844 | 844 | $mois_pentecote = date("m", $date_pentecote); |
845 | - if($jour_pentecote == $jour && $mois_pentecote == $mois) $ferie=true; |
|
845 | + if ($jour_pentecote == $jour && $mois_pentecote == $mois) $ferie = true; |
|
846 | 846 | // Pfingsten |
847 | 847 | |
848 | 848 | // Fronleichnam (60 days after easter sunday) |
@@ -856,7 +856,7 @@ discard block |
||
856 | 856 | ); |
857 | 857 | $jour_fronleichnam = date("d", $date_fronleichnam); |
858 | 858 | $mois_fronleichnam = date("m", $date_fronleichnam); |
859 | - if($jour_fronleichnam == $jour && $mois_fronleichnam == $mois) $ferie=true; |
|
859 | + if ($jour_fronleichnam == $jour && $mois_fronleichnam == $mois) $ferie = true; |
|
860 | 860 | // Fronleichnam |
861 | 861 | } |
862 | 862 | |
@@ -865,7 +865,7 @@ discard block |
||
865 | 865 | { |
866 | 866 | $jour_julien = unixtojd($timestampStart); |
867 | 867 | $jour_semaine = jddayofweek($jour_julien, 0); |
868 | - if($jour_semaine == 0 || $jour_semaine == 6) $ferie=true; |
|
868 | + if ($jour_semaine == 0 || $jour_semaine == 6) $ferie = true; |
|
869 | 869 | //Saturday (6) and Sunday (0) |
870 | 870 | } |
871 | 871 | |
@@ -873,7 +873,7 @@ discard block |
||
873 | 873 | if ($ferie) $nbFerie++; |
874 | 874 | |
875 | 875 | // Increase number of days (on go up into loop) |
876 | - $timestampStart=dol_time_plus_duree($timestampStart, 1, 'd'); |
|
876 | + $timestampStart = dol_time_plus_duree($timestampStart, 1, 'd'); |
|
877 | 877 | //var_dump($jour.' '.$mois.' '.$annee.' '.$timestampStart); |
878 | 878 | |
879 | 879 | $i++; |
@@ -892,7 +892,7 @@ discard block |
||
892 | 892 | * @return int Number of days |
893 | 893 | * @see also num_public_holiday, num_open_day |
894 | 894 | */ |
895 | -function num_between_day($timestampStart, $timestampEnd, $lastday=0) |
|
895 | +function num_between_day($timestampStart, $timestampEnd, $lastday = 0) |
|
896 | 896 | { |
897 | 897 | if ($timestampStart < $timestampEnd) |
898 | 898 | { |
@@ -904,7 +904,7 @@ discard block |
||
904 | 904 | { |
905 | 905 | $bit = 1; |
906 | 906 | } |
907 | - $nbjours = (int) floor(($timestampEnd - $timestampStart)/(60*60*24)) + 1 - $bit; |
|
907 | + $nbjours = (int) floor(($timestampEnd - $timestampStart) / (60 * 60 * 24)) + 1 - $bit; |
|
908 | 908 | } |
909 | 909 | //print ($timestampEnd - $timestampStart) - $lastday; |
910 | 910 | return $nbjours; |
@@ -922,17 +922,17 @@ discard block |
||
922 | 922 | * @return int Number of days or hours |
923 | 923 | * @see also num_between_day, num_public_holiday |
924 | 924 | */ |
925 | -function num_open_day($timestampStart, $timestampEnd, $inhour=0, $lastday=0, $halfday=0, $country_code='') |
|
925 | +function num_open_day($timestampStart, $timestampEnd, $inhour = 0, $lastday = 0, $halfday = 0, $country_code = '') |
|
926 | 926 | { |
927 | - global $langs,$mysoc; |
|
927 | + global $langs, $mysoc; |
|
928 | 928 | |
929 | - if (empty($country_code)) $country_code=$mysoc->country_code; |
|
929 | + if (empty($country_code)) $country_code = $mysoc->country_code; |
|
930 | 930 | |
931 | 931 | dol_syslog('num_open_day timestampStart='.$timestampStart.' timestampEnd='.$timestampEnd.' bit='.$lastday.' country_code='.$country_code); |
932 | 932 | |
933 | 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'; |
|
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 | 936 | |
937 | 937 | //print 'num_open_day timestampStart='.$timestampStart.' timestampEnd='.$timestampEnd.' bit='.$lastday; |
938 | 938 | if ($timestampStart < $timestampEnd) |
@@ -940,14 +940,14 @@ discard block |
||
940 | 940 | $numdays = num_between_day($timestampStart, $timestampEnd, $lastday); |
941 | 941 | $numholidays = num_public_holiday($timestampStart, $timestampEnd, $country_code, $lastday); |
942 | 942 | $nbOpenDay = $numdays - $numholidays; |
943 | - $nbOpenDay.= " " . $langs->trans("Days"); |
|
944 | - if ($inhour == 1 && $nbOpenDay <= 3) $nbOpenDay = $nbOpenDay*24 . $langs->trans("HourShort"); |
|
943 | + $nbOpenDay .= " ".$langs->trans("Days"); |
|
944 | + if ($inhour == 1 && $nbOpenDay <= 3) $nbOpenDay = $nbOpenDay * 24.$langs->trans("HourShort"); |
|
945 | 945 | return $nbOpenDay - (($inhour == 1 ? 12 : 0.5) * abs($halfday)); |
946 | 946 | } |
947 | 947 | elseif ($timestampStart == $timestampEnd) |
948 | 948 | { |
949 | - $nbOpenDay=$lastday; |
|
950 | - if ($inhour == 1) $nbOpenDay = $nbOpenDay*24 . $langs->trans("HourShort"); |
|
949 | + $nbOpenDay = $lastday; |
|
950 | + if ($inhour == 1) $nbOpenDay = $nbOpenDay * 24.$langs->trans("HourShort"); |
|
951 | 951 | return $nbOpenDay - (($inhour == 1 ? 12 : 0.5) * abs($halfday)); |
952 | 952 | } |
953 | 953 | else |
@@ -966,9 +966,9 @@ discard block |
||
966 | 966 | * @param int $short 0=Return long label, 1=Return short label |
967 | 967 | * @return array Month string or array if selected < 0 |
968 | 968 | */ |
969 | -function monthArray($outputlangs,$short=0) |
|
969 | +function monthArray($outputlangs, $short = 0) |
|
970 | 970 | { |
971 | - $montharray = array ( |
|
971 | + $montharray = array( |
|
972 | 972 | 1 => $outputlangs->trans("Month01"), |
973 | 973 | 2 => $outputlangs->trans("Month02"), |
974 | 974 | 3 => $outputlangs->trans("Month03"), |
@@ -983,9 +983,9 @@ discard block |
||
983 | 983 | 12 => $outputlangs->trans("Month12") |
984 | 984 | ); |
985 | 985 | |
986 | - if (! empty($short)) |
|
986 | + if (!empty($short)) |
|
987 | 987 | { |
988 | - $montharray = array ( |
|
988 | + $montharray = array( |
|
989 | 989 | 1 => $outputlangs->trans("MonthShort01"), |
990 | 990 | 2 => $outputlangs->trans("MonthShort02"), |
991 | 991 | 3 => $outputlangs->trans("MonthShort03"), |
@@ -87,16 +87,19 @@ discard block |
||
87 | 87 | { |
88 | 88 | // Method 1 (include daylight) |
89 | 89 | $gmtnow=dol_now('gmt'); $yearref=dol_print_date($gmtnow,'%Y'); $monthref=dol_print_date($gmtnow,'%m'); $dayref=dol_print_date($gmtnow,'%d'); |
90 | - if ($refgmtdate == 'now') $newrefgmtdate=$yearref.'-'.$monthref.'-'.$dayref; |
|
91 | - elseif ($refgmtdate == 'summer') $newrefgmtdate=$yearref.'-08-01'; |
|
92 | - else $newrefgmtdate=$yearref.'-01-01'; |
|
90 | + if ($refgmtdate == 'now') { |
|
91 | + $newrefgmtdate=$yearref.'-'.$monthref.'-'.$dayref; |
|
92 | + } elseif ($refgmtdate == 'summer') { |
|
93 | + $newrefgmtdate=$yearref.'-08-01'; |
|
94 | + } else { |
|
95 | + $newrefgmtdate=$yearref.'-01-01'; |
|
96 | + } |
|
93 | 97 | $newrefgmtdate.='T00:00:00+00:00'; |
94 | 98 | $localtz = new DateTimeZone(getServerTimeZoneString()); |
95 | 99 | $localdt = new DateTime($newrefgmtdate, $localtz); |
96 | 100 | $tmp=-1*$localtz->getOffset($localdt); |
97 | 101 | //print $refgmtdate.'='.$tmp; |
98 | - } |
|
99 | - else |
|
102 | + } else |
|
100 | 103 | { |
101 | 104 | $tmp=0; |
102 | 105 | dol_print_error('','PHP version must be 5.3+'); |
@@ -118,9 +121,15 @@ discard block |
||
118 | 121 | { |
119 | 122 | global $conf; |
120 | 123 | |
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 | + if ($duration_value == 0) { |
|
125 | + return $time; |
|
126 | + } |
|
127 | + if ($duration_unit == 'h') { |
|
128 | + return $time + (3600*$duration_value); |
|
129 | + } |
|
130 | + if ($duration_unit == 'w') { |
|
131 | + return $time + (3600*24*7*$duration_value); |
|
132 | + } |
|
124 | 133 | |
125 | 134 | $deltastring='P'; |
126 | 135 | |
@@ -131,12 +140,17 @@ discard block |
||
131 | 140 | if ($duration_unit == 'y') { $deltastring.="Y"; } |
132 | 141 | |
133 | 142 | $date = new DateTime(); |
134 | - if (! empty($conf->global->MAIN_DATE_IN_MEMORY_ARE_GMT)) $date->setTimezone(new DateTimeZone('UTC')); |
|
143 | + if (! empty($conf->global->MAIN_DATE_IN_MEMORY_ARE_GMT)) { |
|
144 | + $date->setTimezone(new DateTimeZone('UTC')); |
|
145 | + } |
|
135 | 146 | $date->setTimestamp($time); |
136 | 147 | $interval = new DateInterval($deltastring); |
137 | 148 | |
138 | - if($sub) $date->sub($interval); |
|
139 | - else $date->add( $interval ); |
|
149 | + if($sub) { |
|
150 | + $date->sub($interval); |
|
151 | + } else { |
|
152 | + $date->add( $interval ); |
|
153 | + } |
|
140 | 154 | |
141 | 155 | return $date->getTimestamp(); |
142 | 156 | } |
@@ -182,12 +196,21 @@ discard block |
||
182 | 196 | { |
183 | 197 | global $langs; |
184 | 198 | |
185 | - if (empty($lengthOfDay)) $lengthOfDay = 86400; // 1 day = 24 hours |
|
186 | - if (empty($lengthOfWeek)) $lengthOfWeek = 7; // 1 week = 7 days |
|
199 | + if (empty($lengthOfDay)) { |
|
200 | + $lengthOfDay = 86400; |
|
201 | + } |
|
202 | + // 1 day = 24 hours |
|
203 | + if (empty($lengthOfWeek)) { |
|
204 | + $lengthOfWeek = 7; |
|
205 | + } |
|
206 | + // 1 week = 7 days |
|
187 | 207 | |
188 | 208 | if ($format == 'all' || $format == 'allwithouthour' || $format == 'allhour' || $format == 'allhourmin') |
189 | 209 | { |
190 | - if ((int) $iSecond === 0) return '0'; // This is to avoid having 0 return a 12:00 AM for en_US |
|
210 | + if ((int) $iSecond === 0) { |
|
211 | + return '0'; |
|
212 | + } |
|
213 | + // This is to avoid having 0 return a 12:00 AM for en_US |
|
191 | 214 | |
192 | 215 | $sTime=''; |
193 | 216 | $sDay=0; |
@@ -201,7 +224,9 @@ discard block |
||
201 | 224 | $iSecond-=$lengthOfDay; |
202 | 225 | } |
203 | 226 | $dayTranslate = $langs->trans("Day"); |
204 | - if ($iSecond >= ($lengthOfDay*2)) $dayTranslate = $langs->trans("Days"); |
|
227 | + if ($iSecond >= ($lengthOfDay*2)) { |
|
228 | + $dayTranslate = $langs->trans("Days"); |
|
229 | + } |
|
205 | 230 | } |
206 | 231 | |
207 | 232 | if ($lengthOfWeek < 7) |
@@ -213,7 +238,9 @@ discard block |
||
213 | 238 | $sWeek = (int) (($sDay - $sDay % $lengthOfWeek ) / $lengthOfWeek); |
214 | 239 | $sDay = $sDay % $lengthOfWeek; |
215 | 240 | $weekTranslate = $langs->trans("DurationWeek"); |
216 | - if ($sWeek >= 2) $weekTranslate = $langs->trans("DurationWeeks"); |
|
241 | + if ($sWeek >= 2) { |
|
242 | + $weekTranslate = $langs->trans("DurationWeeks"); |
|
243 | + } |
|
217 | 244 | $sTime.=$sWeek.' '.$weekTranslate.' '; |
218 | 245 | } |
219 | 246 | } |
@@ -221,7 +248,9 @@ discard block |
||
221 | 248 | if ($sDay>0) |
222 | 249 | { |
223 | 250 | $dayTranslate = $langs->trans("Day"); |
224 | - if ($sDay > 1) $dayTranslate = $langs->trans("Days"); |
|
251 | + if ($sDay > 1) { |
|
252 | + $dayTranslate = $langs->trans("Days"); |
|
253 | + } |
|
225 | 254 | $sTime.=$sDay.' '.$dayTranslate.' '; |
226 | 255 | } |
227 | 256 | |
@@ -240,37 +269,40 @@ discard block |
||
240 | 269 | { |
241 | 270 | return sprintf("%02d",($sWeek*$lengthOfWeek*24 + $sDay*24 + (int) floor($iSecond/3600))); |
242 | 271 | } |
243 | - } |
|
244 | - else if ($format == 'hour') // only hour part |
|
272 | + } else if ($format == 'hour') { |
|
273 | + // only hour part |
|
245 | 274 | { |
246 | 275 | $sTime=dol_print_date($iSecond,'%H',true); |
247 | 276 | } |
248 | - else if ($format == 'fullhour') |
|
277 | + } else if ($format == 'fullhour') |
|
249 | 278 | { |
250 | 279 | if (!empty($iSecond)) { |
251 | 280 | $iSecond=$iSecond/3600; |
252 | - } |
|
253 | - else { |
|
281 | + } else { |
|
254 | 282 | $iSecond=0; |
255 | 283 | } |
256 | 284 | $sTime=$iSecond; |
257 | - } |
|
258 | - else if ($format == 'min') // only min part |
|
285 | + } else if ($format == 'min') { |
|
286 | + // only min part |
|
259 | 287 | { |
260 | 288 | $sTime=dol_print_date($iSecond,'%M',true); |
261 | 289 | } |
262 | - else if ($format == 'sec') // only sec part |
|
290 | + } else if ($format == 'sec') { |
|
291 | + // only sec part |
|
263 | 292 | { |
264 | 293 | $sTime=dol_print_date($iSecond,'%S',true); |
265 | 294 | } |
266 | - else if ($format == 'month') // only month part |
|
295 | + } else if ($format == 'month') { |
|
296 | + // only month part |
|
267 | 297 | { |
268 | 298 | $sTime=dol_print_date($iSecond,'%m',true); |
269 | 299 | } |
270 | - else if ($format == 'year') // only year part |
|
300 | + } else if ($format == 'year') { |
|
301 | + // only year part |
|
271 | 302 | { |
272 | 303 | $sTime=dol_print_date($iSecond,'%Y',true); |
273 | 304 | } |
305 | + } |
|
274 | 306 | return trim($sTime); |
275 | 307 | } |
276 | 308 | |
@@ -295,8 +327,9 @@ discard block |
||
295 | 327 | } else if ($year_date > 0 && ! empty($day_date)) { |
296 | 328 | $sqldate.= " AND ".$datefield." BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month_date, $day_date, $year_date)); |
297 | 329 | $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)."'"; |
|
330 | + } else { |
|
331 | + $sqldate.= " AND date_format( ".$datefield.", '%m') = '".$db->escape($month_date)."'"; |
|
332 | + } |
|
300 | 333 | } else if ($year_date > 0){ |
301 | 334 | $sqldate.= " AND ".$datefield." BETWEEN '".$db->idate(dol_get_first_day($year_date, 1, false)); |
302 | 335 | $sqldate.= "' AND '".$db->idate(dol_get_last_day($year_date, 12, false))."'"; |
@@ -336,11 +369,14 @@ discard block |
||
336 | 369 | $shour = $reg[4]; |
337 | 370 | $smin = $reg[5]; |
338 | 371 | $ssec = $reg[6]; |
339 | - if ($syear < 50) $syear+=1900; |
|
340 | - if ($syear >= 50 && $syear < 100) $syear+=2000; |
|
372 | + if ($syear < 50) { |
|
373 | + $syear+=1900; |
|
374 | + } |
|
375 | + if ($syear >= 50 && $syear < 100) { |
|
376 | + $syear+=2000; |
|
377 | + } |
|
341 | 378 | $string=sprintf("%04d%02d%02d%02d%02d%02d",$syear,$smonth,$sday,$shour,$smin,$ssec); |
342 | - } |
|
343 | - else if ( |
|
379 | + } else if ( |
|
344 | 380 | 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 | 381 | || 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 | 382 | || 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 |
@@ -404,8 +440,7 @@ discard block |
||
404 | 440 | { |
405 | 441 | $prev_month = 12; |
406 | 442 | $prev_year = $year - 1; |
407 | - } |
|
408 | - else |
|
443 | + } else |
|
409 | 444 | { |
410 | 445 | $prev_month = $month-1; |
411 | 446 | $prev_year = $year; |
@@ -425,8 +460,7 @@ discard block |
||
425 | 460 | { |
426 | 461 | $next_month = 1; |
427 | 462 | $next_year = $year + 1; |
428 | - } |
|
429 | - else |
|
463 | + } else |
|
430 | 464 | { |
431 | 465 | $next_month = $month + 1; |
432 | 466 | $next_year = $year; |
@@ -482,7 +516,9 @@ discard block |
||
482 | 516 | */ |
483 | 517 | function dol_get_first_day($year,$month=1,$gm=false) |
484 | 518 | { |
485 | - if ($year > 9999) return ''; |
|
519 | + if ($year > 9999) { |
|
520 | + return ''; |
|
521 | + } |
|
486 | 522 | return dol_mktime(0,0,0,$month,1,$year,$gm); |
487 | 523 | } |
488 | 524 | |
@@ -496,13 +532,14 @@ discard block |
||
496 | 532 | */ |
497 | 533 | function dol_get_last_day($year,$month=12,$gm=false) |
498 | 534 | { |
499 | - if ($year > 9999) return ''; |
|
535 | + if ($year > 9999) { |
|
536 | + return ''; |
|
537 | + } |
|
500 | 538 | if ($month == 12) |
501 | 539 | { |
502 | 540 | $month = 1; |
503 | 541 | $year += 1; |
504 | - } |
|
505 | - else |
|
542 | + } else |
|
506 | 543 | { |
507 | 544 | $month += 1; |
508 | 545 | } |
@@ -536,7 +573,9 @@ discard block |
||
536 | 573 | |
537 | 574 | //Calculate days = offset from current day |
538 | 575 | $days = $start_week - $tmparray['wday']; |
539 | - if ($days>=1) $days=7-$days; |
|
576 | + if ($days>=1) { |
|
577 | + $days=7-$days; |
|
578 | + } |
|
540 | 579 | $days = abs($days); |
541 | 580 | $seconds = $days*24*60*60; |
542 | 581 | //print 'start_week='.$start_week.' tmparray[wday]='.$tmparray['wday'].' day offset='.$days.' seconds offset='.$seconds.'<br>'; |
@@ -556,8 +595,7 @@ discard block |
||
556 | 595 | $prev_month = 12; |
557 | 596 | $prev_year = $year-1; |
558 | 597 | } |
559 | - } |
|
560 | - else |
|
598 | + } else |
|
561 | 599 | { |
562 | 600 | $prev_month = $month; |
563 | 601 | $prev_year = $year; |
@@ -607,13 +645,17 @@ discard block |
||
607 | 645 | $nbFerie = 0; |
608 | 646 | |
609 | 647 | // Check to ensure we use correct parameters |
610 | - if ((($timestampEnd - $timestampStart) % 86400) != 0) return 'ErrorDates must use same hours and must be GMT dates'; |
|
648 | + if ((($timestampEnd - $timestampStart) % 86400) != 0) { |
|
649 | + return 'ErrorDates must use same hours and must be GMT dates'; |
|
650 | + } |
|
611 | 651 | |
612 | 652 | $i=0; |
613 | 653 | 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) |
|
654 | + && ($i < 50000)) { |
|
655 | + // Loop end when equals (Test on i is a security loop to avoid infinite loop) |
|
615 | 656 | { |
616 | 657 | $ferie=false; |
658 | + } |
|
617 | 659 | $countryfound=0; |
618 | 660 | $includesaturdayandsunday=1; |
619 | 661 | |
@@ -631,11 +673,14 @@ discard block |
||
631 | 673 | $tmp=explode('-',$daystring); |
632 | 674 | if ($tmp[2]) |
633 | 675 | { |
634 | - if ($tmp[0] == $annee && $tmp[1] == $mois && $tmp[2] == $jour) $ferie=true; |
|
635 | - } |
|
636 | - else |
|
676 | + if ($tmp[0] == $annee && $tmp[1] == $mois && $tmp[2] == $jour) { |
|
677 | + $ferie=true; |
|
678 | + } |
|
679 | + } else |
|
637 | 680 | { |
638 | - if ($tmp[0] == $mois && $tmp[1] == $jour) $ferie=true; |
|
681 | + if ($tmp[0] == $mois && $tmp[1] == $jour) { |
|
682 | + $ferie=true; |
|
683 | + } |
|
639 | 684 | } |
640 | 685 | } |
641 | 686 | } |
@@ -645,20 +690,46 @@ discard block |
||
645 | 690 | $countryfound=1; |
646 | 691 | |
647 | 692 | // 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 |
|
693 | + if($jour == 1 && $mois == 1) { |
|
694 | + $ferie=true; |
|
695 | + } |
|
696 | + // 1er january |
|
697 | + if($jour == 1 && $mois == 5) { |
|
698 | + $ferie=true; |
|
699 | + } |
|
700 | + // 1er may |
|
701 | + if($jour == 8 && $mois == 5) { |
|
702 | + $ferie=true; |
|
703 | + } |
|
704 | + // 5 may |
|
705 | + if($jour == 14 && $mois == 7) { |
|
706 | + $ferie=true; |
|
707 | + } |
|
708 | + // 14 july |
|
709 | + if($jour == 15 && $mois == 8) { |
|
710 | + $ferie=true; |
|
711 | + } |
|
712 | + // 15 august |
|
713 | + if($jour == 1 && $mois == 11) { |
|
714 | + $ferie=true; |
|
715 | + } |
|
716 | + // 1 november |
|
717 | + if($jour == 11 && $mois == 11) { |
|
718 | + $ferie=true; |
|
719 | + } |
|
720 | + // 11 november |
|
721 | + if($jour == 25 && $mois == 12) { |
|
722 | + $ferie=true; |
|
723 | + } |
|
724 | + // 25 december |
|
656 | 725 | |
657 | 726 | // Calculation for easter date |
658 | 727 | $date_paques = easter_date($annee); |
659 | 728 | $jour_paques = date("d", $date_paques); |
660 | 729 | $mois_paques = date("m", $date_paques); |
661 | - if($jour_paques == $jour && $mois_paques == $mois) $ferie=true; |
|
730 | + if($jour_paques == $jour && $mois_paques == $mois) { |
|
731 | + $ferie=true; |
|
732 | + } |
|
662 | 733 | // Pâques |
663 | 734 | |
664 | 735 | // Calculation for the monday of easter date |
@@ -672,7 +743,9 @@ discard block |
||
672 | 743 | ); |
673 | 744 | $jour_lundi_ascension = date("d", $date_lundi_paques); |
674 | 745 | $mois_lundi_ascension = date("m", $date_lundi_paques); |
675 | - if($jour_lundi_ascension == $jour && $mois_lundi_ascension == $mois) $ferie=true; |
|
746 | + if($jour_lundi_ascension == $jour && $mois_lundi_ascension == $mois) { |
|
747 | + $ferie=true; |
|
748 | + } |
|
676 | 749 | // Lundi de Pâques |
677 | 750 | |
678 | 751 | // Calcul du jour de l'ascension (38 days after easter day) |
@@ -686,7 +759,9 @@ discard block |
||
686 | 759 | ); |
687 | 760 | $jour_ascension = date("d", $date_ascension); |
688 | 761 | $mois_ascension = date("m", $date_ascension); |
689 | - if($jour_ascension == $jour && $mois_ascension == $mois) $ferie=true; |
|
762 | + if($jour_ascension == $jour && $mois_ascension == $mois) { |
|
763 | + $ferie=true; |
|
764 | + } |
|
690 | 765 | // Ascension |
691 | 766 | |
692 | 767 | // Calculation of "Pentecote" (11 days after easter day) |
@@ -700,7 +775,9 @@ discard block |
||
700 | 775 | ); |
701 | 776 | $jour_pentecote = date("d", $date_pentecote); |
702 | 777 | $mois_pentecote = date("m", $date_pentecote); |
703 | - if($jour_pentecote == $jour && $mois_pentecote == $mois) $ferie=true; |
|
778 | + if($jour_pentecote == $jour && $mois_pentecote == $mois) { |
|
779 | + $ferie=true; |
|
780 | + } |
|
704 | 781 | // "Pentecote" |
705 | 782 | } |
706 | 783 | |
@@ -711,22 +788,54 @@ discard block |
||
711 | 788 | $countryfound=1; |
712 | 789 | |
713 | 790 | // 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 |
|
791 | + if($jour == 1 && $mois == 1) { |
|
792 | + $ferie=true; |
|
793 | + } |
|
794 | + // Capodanno |
|
795 | + if($jour == 6 && $mois == 1) { |
|
796 | + $ferie=true; |
|
797 | + } |
|
798 | + // Epifania |
|
799 | + if($jour == 25 && $mois == 4) { |
|
800 | + $ferie=true; |
|
801 | + } |
|
802 | + // Anniversario Liberazione |
|
803 | + if($jour == 1 && $mois == 5) { |
|
804 | + $ferie=true; |
|
805 | + } |
|
806 | + // Festa del Lavoro |
|
807 | + if($jour == 2 && $mois == 6) { |
|
808 | + $ferie=true; |
|
809 | + } |
|
810 | + // Festa della Repubblica |
|
811 | + if($jour == 15 && $mois == 8) { |
|
812 | + $ferie=true; |
|
813 | + } |
|
814 | + // Ferragosto |
|
815 | + if($jour == 1 && $mois == 11) { |
|
816 | + $ferie=true; |
|
817 | + } |
|
818 | + // Tutti i Santi |
|
819 | + if($jour == 8 && $mois == 12) { |
|
820 | + $ferie=true; |
|
821 | + } |
|
822 | + // Immacolata Concezione |
|
823 | + if($jour == 25 && $mois == 12) { |
|
824 | + $ferie=true; |
|
825 | + } |
|
826 | + // 25 decembre |
|
827 | + if($jour == 26 && $mois == 12) { |
|
828 | + $ferie=true; |
|
829 | + } |
|
830 | + // Santo Stefano |
|
724 | 831 | |
725 | 832 | // Calcul du jour de paques |
726 | 833 | $date_paques = easter_date($annee); |
727 | 834 | $jour_paques = date("d", $date_paques); |
728 | 835 | $mois_paques = date("m", $date_paques); |
729 | - if($jour_paques == $jour && $mois_paques == $mois) $ferie=true; |
|
836 | + if($jour_paques == $jour && $mois_paques == $mois) { |
|
837 | + $ferie=true; |
|
838 | + } |
|
730 | 839 | // Paques |
731 | 840 | } |
732 | 841 | |
@@ -734,12 +843,30 @@ discard block |
||
734 | 843 | { |
735 | 844 | $countryfound=1; |
736 | 845 | |
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 |
|
846 | + if($jour == 1 && $mois == 1) { |
|
847 | + $ferie=true; |
|
848 | + } |
|
849 | + // New Year's Day |
|
850 | + if($jour == 26 && $mois == 1) { |
|
851 | + $ferie=true; |
|
852 | + } |
|
853 | + // Republic Day |
|
854 | + if($jour == 1 && $mois == 5) { |
|
855 | + $ferie=true; |
|
856 | + } |
|
857 | + // May Day |
|
858 | + if($jour == 15 && $mois == 8) { |
|
859 | + $ferie=true; |
|
860 | + } |
|
861 | + // Independence Day |
|
862 | + if($jour == 2 && $mois == 10) { |
|
863 | + $ferie=true; |
|
864 | + } |
|
865 | + // Gandhi Jayanti |
|
866 | + if($jour == 25 && $mois == 12) { |
|
867 | + $ferie=true; |
|
868 | + } |
|
869 | + // Christmas |
|
743 | 870 | } |
744 | 871 | |
745 | 872 | if ($countrycode == 'ES') |
@@ -747,21 +874,50 @@ discard block |
||
747 | 874 | $countryfound=1; |
748 | 875 | |
749 | 876 | // 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 |
|
877 | + if($jour == 1 && $mois == 1) { |
|
878 | + $ferie=true; |
|
879 | + } |
|
880 | + // Año nuevo |
|
881 | + if($jour == 6 && $mois == 1) { |
|
882 | + $ferie=true; |
|
883 | + } |
|
884 | + // Día Reyes |
|
885 | + if($jour == 1 && $mois == 5) { |
|
886 | + $ferie=true; |
|
887 | + } |
|
888 | + // 1 Mayo |
|
889 | + if($jour == 15 && $mois == 8) { |
|
890 | + $ferie=true; |
|
891 | + } |
|
892 | + // 15 Agosto |
|
893 | + if($jour == 12 && $mois == 10) { |
|
894 | + $ferie=true; |
|
895 | + } |
|
896 | + // Día Hispanidad |
|
897 | + if($jour == 1 && $mois == 11) { |
|
898 | + $ferie=true; |
|
899 | + } |
|
900 | + // 1 noviembre |
|
901 | + if($jour == 6 && $mois == 12) { |
|
902 | + $ferie=true; |
|
903 | + } |
|
904 | + // Constitución |
|
905 | + if($jour == 8 && $mois == 12) { |
|
906 | + $ferie=true; |
|
907 | + } |
|
908 | + // Inmaculada |
|
909 | + if($jour == 25 && $mois == 12) { |
|
910 | + $ferie=true; |
|
911 | + } |
|
912 | + // 25 diciembre |
|
759 | 913 | |
760 | 914 | // Calcul día de Pascua |
761 | 915 | $date_paques = easter_date($annee); |
762 | 916 | $jour_paques = date("d", $date_paques); |
763 | 917 | $mois_paques = date("m", $date_paques); |
764 | - if($jour_paques == $jour && $mois_paques == $mois) $ferie=true; |
|
918 | + if($jour_paques == $jour && $mois_paques == $mois) { |
|
919 | + $ferie=true; |
|
920 | + } |
|
765 | 921 | // Paques |
766 | 922 | |
767 | 923 | // Viernes Santo |
@@ -775,7 +931,9 @@ discard block |
||
775 | 931 | ); |
776 | 932 | $jour_viernes = date("d", $date_viernes); |
777 | 933 | $mois_viernes = date("m", $date_viernes); |
778 | - if($jour_viernes == $jour && $mois_viernes == $mois) $ferie=true; |
|
934 | + if($jour_viernes == $jour && $mois_viernes == $mois) { |
|
935 | + $ferie=true; |
|
936 | + } |
|
779 | 937 | //Viernes Santo |
780 | 938 | } |
781 | 939 | |
@@ -784,23 +942,58 @@ discard block |
||
784 | 942 | $countryfound=1; |
785 | 943 | |
786 | 944 | // 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 |
|
945 | + if($jour == 1 && $mois == 1) { |
|
946 | + $ferie=true; |
|
947 | + } |
|
948 | + // Neujahr |
|
949 | + if($jour == 6 && $mois == 1) { |
|
950 | + $ferie=true; |
|
951 | + } |
|
952 | + // Hl. 3 Koenige |
|
953 | + if($jour == 1 && $mois == 5) { |
|
954 | + $ferie=true; |
|
955 | + } |
|
956 | + // 1. Mai |
|
957 | + if($jour == 15 && $mois == 8) { |
|
958 | + $ferie=true; |
|
959 | + } |
|
960 | + // Mariae Himmelfahrt |
|
961 | + if($jour == 26 && $mois == 10) { |
|
962 | + $ferie=true; |
|
963 | + } |
|
964 | + // 26. Oktober |
|
965 | + if($jour == 1 && $mois == 11) { |
|
966 | + $ferie=true; |
|
967 | + } |
|
968 | + // Allerheiligen |
|
969 | + if($jour == 8 && $mois == 12) { |
|
970 | + $ferie=true; |
|
971 | + } |
|
972 | + // Mariae Empfaengnis |
|
973 | + if($jour == 24 && $mois == 12) { |
|
974 | + $ferie=true; |
|
975 | + } |
|
976 | + // Heilig abend |
|
977 | + if($jour == 25 && $mois == 12) { |
|
978 | + $ferie=true; |
|
979 | + } |
|
980 | + // Christtag |
|
981 | + if($jour == 26 && $mois == 12) { |
|
982 | + $ferie=true; |
|
983 | + } |
|
984 | + // Stefanietag |
|
985 | + if($jour == 31 && $mois == 12) { |
|
986 | + $ferie=true; |
|
987 | + } |
|
988 | + // Silvester |
|
798 | 989 | |
799 | 990 | // Easter calculation |
800 | 991 | $date_paques = easter_date($annee); |
801 | 992 | $jour_paques = date("d", $date_paques); |
802 | 993 | $mois_paques = date("m", $date_paques); |
803 | - if($jour_paques == $jour && $mois_paques == $mois) $ferie=true; |
|
994 | + if($jour_paques == $jour && $mois_paques == $mois) { |
|
995 | + $ferie=true; |
|
996 | + } |
|
804 | 997 | // Easter sunday |
805 | 998 | |
806 | 999 | // Monday after easter |
@@ -814,7 +1007,9 @@ discard block |
||
814 | 1007 | ); |
815 | 1008 | $jour_eastermonday = date("d", $date_eastermonday); |
816 | 1009 | $mois_eastermonday = date("m", $date_eastermonday); |
817 | - if($jour_eastermonday == $jour && $mois_eastermonday == $mois) $ferie=true; |
|
1010 | + if($jour_eastermonday == $jour && $mois_eastermonday == $mois) { |
|
1011 | + $ferie=true; |
|
1012 | + } |
|
818 | 1013 | // Easter monday |
819 | 1014 | |
820 | 1015 | // Christi Himmelfahrt (39 days after easter sunday) |
@@ -828,7 +1023,9 @@ discard block |
||
828 | 1023 | ); |
829 | 1024 | $jour_ch = date("d", $date_ch); |
830 | 1025 | $mois_ch = date("m", $date_ch); |
831 | - if($jour_ch == $jour && $mois_ch == $mois) $ferie=true; |
|
1026 | + if($jour_ch == $jour && $mois_ch == $mois) { |
|
1027 | + $ferie=true; |
|
1028 | + } |
|
832 | 1029 | // Christi Himmelfahrt |
833 | 1030 | |
834 | 1031 | // Pfingsten (50 days after easter sunday) |
@@ -842,7 +1039,9 @@ discard block |
||
842 | 1039 | ); |
843 | 1040 | $jour_pentecote = date("d", $date_pentecote); |
844 | 1041 | $mois_pentecote = date("m", $date_pentecote); |
845 | - if($jour_pentecote == $jour && $mois_pentecote == $mois) $ferie=true; |
|
1042 | + if($jour_pentecote == $jour && $mois_pentecote == $mois) { |
|
1043 | + $ferie=true; |
|
1044 | + } |
|
846 | 1045 | // Pfingsten |
847 | 1046 | |
848 | 1047 | // Fronleichnam (60 days after easter sunday) |
@@ -856,7 +1055,9 @@ discard block |
||
856 | 1055 | ); |
857 | 1056 | $jour_fronleichnam = date("d", $date_fronleichnam); |
858 | 1057 | $mois_fronleichnam = date("m", $date_fronleichnam); |
859 | - if($jour_fronleichnam == $jour && $mois_fronleichnam == $mois) $ferie=true; |
|
1058 | + if($jour_fronleichnam == $jour && $mois_fronleichnam == $mois) { |
|
1059 | + $ferie=true; |
|
1060 | + } |
|
860 | 1061 | // Fronleichnam |
861 | 1062 | } |
862 | 1063 | |
@@ -865,12 +1066,16 @@ discard block |
||
865 | 1066 | { |
866 | 1067 | $jour_julien = unixtojd($timestampStart); |
867 | 1068 | $jour_semaine = jddayofweek($jour_julien, 0); |
868 | - if($jour_semaine == 0 || $jour_semaine == 6) $ferie=true; |
|
1069 | + if($jour_semaine == 0 || $jour_semaine == 6) { |
|
1070 | + $ferie=true; |
|
1071 | + } |
|
869 | 1072 | //Saturday (6) and Sunday (0) |
870 | 1073 | } |
871 | 1074 | |
872 | 1075 | // On incremente compteur |
873 | - if ($ferie) $nbFerie++; |
|
1076 | + if ($ferie) { |
|
1077 | + $nbFerie++; |
|
1078 | + } |
|
874 | 1079 | |
875 | 1080 | // Increase number of days (on go up into loop) |
876 | 1081 | $timestampStart=dol_time_plus_duree($timestampStart, 1, 'd'); |
@@ -899,8 +1104,7 @@ discard block |
||
899 | 1104 | if ($lastday == 1) |
900 | 1105 | { |
901 | 1106 | $bit = 0; |
902 | - } |
|
903 | - else |
|
1107 | + } else |
|
904 | 1108 | { |
905 | 1109 | $bit = 1; |
906 | 1110 | } |
@@ -926,13 +1130,19 @@ discard block |
||
926 | 1130 | { |
927 | 1131 | global $langs,$mysoc; |
928 | 1132 | |
929 | - if (empty($country_code)) $country_code=$mysoc->country_code; |
|
1133 | + if (empty($country_code)) { |
|
1134 | + $country_code=$mysoc->country_code; |
|
1135 | + } |
|
930 | 1136 | |
931 | 1137 | dol_syslog('num_open_day timestampStart='.$timestampStart.' timestampEnd='.$timestampEnd.' bit='.$lastday.' country_code='.$country_code); |
932 | 1138 | |
933 | 1139 | // 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'; |
|
1140 | + if (! is_int($timestampStart) && ! is_float($timestampStart)) { |
|
1141 | + return 'ErrorBadParameter_num_open_day'; |
|
1142 | + } |
|
1143 | + if (! is_int($timestampEnd) && ! is_float($timestampEnd)) { |
|
1144 | + return 'ErrorBadParameter_num_open_day'; |
|
1145 | + } |
|
936 | 1146 | |
937 | 1147 | //print 'num_open_day timestampStart='.$timestampStart.' timestampEnd='.$timestampEnd.' bit='.$lastday; |
938 | 1148 | if ($timestampStart < $timestampEnd) |
@@ -941,16 +1151,18 @@ discard block |
||
941 | 1151 | $numholidays = num_public_holiday($timestampStart, $timestampEnd, $country_code, $lastday); |
942 | 1152 | $nbOpenDay = $numdays - $numholidays; |
943 | 1153 | $nbOpenDay.= " " . $langs->trans("Days"); |
944 | - if ($inhour == 1 && $nbOpenDay <= 3) $nbOpenDay = $nbOpenDay*24 . $langs->trans("HourShort"); |
|
1154 | + if ($inhour == 1 && $nbOpenDay <= 3) { |
|
1155 | + $nbOpenDay = $nbOpenDay*24 . $langs->trans("HourShort"); |
|
1156 | + } |
|
945 | 1157 | return $nbOpenDay - (($inhour == 1 ? 12 : 0.5) * abs($halfday)); |
946 | - } |
|
947 | - elseif ($timestampStart == $timestampEnd) |
|
1158 | + } elseif ($timestampStart == $timestampEnd) |
|
948 | 1159 | { |
949 | 1160 | $nbOpenDay=$lastday; |
950 | - if ($inhour == 1) $nbOpenDay = $nbOpenDay*24 . $langs->trans("HourShort"); |
|
1161 | + if ($inhour == 1) { |
|
1162 | + $nbOpenDay = $nbOpenDay*24 . $langs->trans("HourShort"); |
|
1163 | + } |
|
951 | 1164 | return $nbOpenDay - (($inhour == 1 ? 12 : 0.5) * abs($halfday)); |
952 | - } |
|
953 | - else |
|
1165 | + } else |
|
954 | 1166 | { |
955 | 1167 | return $langs->trans("Error"); |
956 | 1168 | } |
@@ -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 | } |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | $head[$h][2] = 'card'; |
46 | 46 | $h++; |
47 | 47 | |
48 | - if (! empty($object->status)) |
|
48 | + if (!empty($object->status)) |
|
49 | 49 | { |
50 | 50 | $head[$h][0] = DOL_URL_ROOT."/product/price.php?id=".$object->id; |
51 | 51 | $head[$h][1] = $langs->trans("SellingPrices"); |
@@ -53,10 +53,10 @@ discard block |
||
53 | 53 | $h++; |
54 | 54 | } |
55 | 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 |
|
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 | 57 | { |
58 | - if ((! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->lire) |
|
59 | - || (! empty($conf->margin->enabled) && $user->rights->margin->liretous) |
|
58 | + if ((!empty($conf->fournisseur->enabled) && $user->rights->fournisseur->lire) |
|
59 | + || (!empty($conf->margin->enabled) && $user->rights->margin->liretous) |
|
60 | 60 | ) |
61 | 61 | { |
62 | 62 | $head[$h][0] = DOL_URL_ROOT."/product/fournisseurs.php?id=".$object->id; |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | } |
68 | 68 | |
69 | 69 | // Multilangs |
70 | - if (! empty($conf->global->MAIN_MULTILANGS)) |
|
70 | + if (!empty($conf->global->MAIN_MULTILANGS)) |
|
71 | 71 | { |
72 | 72 | $head[$h][0] = DOL_URL_ROOT."/product/traduction.php?id=".$object->id; |
73 | 73 | $head[$h][1] = $langs->trans("Translation"); |
@@ -76,13 +76,13 @@ discard block |
||
76 | 76 | } |
77 | 77 | |
78 | 78 | // Sub products |
79 | - if (! empty($conf->global->PRODUIT_SOUSPRODUITS)) |
|
79 | + if (!empty($conf->global->PRODUIT_SOUSPRODUITS)) |
|
80 | 80 | { |
81 | 81 | $head[$h][0] = DOL_URL_ROOT."/product/composition/card.php?id=".$object->id; |
82 | 82 | $head[$h][1] = $langs->trans('AssociatedProducts'); |
83 | 83 | |
84 | 84 | $nbFatherAndChild = $object->hasFatherOrChild(); |
85 | - if ($nbFatherAndChild > 0) $head[$h][1].= ' <span class="badge">'.$nbFatherAndChild.'</span>'; |
|
85 | + if ($nbFatherAndChild > 0) $head[$h][1] .= ' <span class="badge">'.$nbFatherAndChild.'</span>'; |
|
86 | 86 | $head[$h][2] = 'subproduct'; |
87 | 87 | $h++; |
88 | 88 | } |
@@ -111,15 +111,15 @@ discard block |
||
111 | 111 | $head[$h][1] = $langs->trans('ProductCombinations'); |
112 | 112 | $head[$h][2] = 'combinations'; |
113 | 113 | $nbVariant = $prodcomb->countNbOfCombinationForFkProductParent($object->id); |
114 | - if ($nbVariant > 0) $head[$h][1].= ' <span class="badge">'.$nbVariant.'</span>'; |
|
114 | + if ($nbVariant > 0) $head[$h][1] .= ' <span class="badge">'.$nbVariant.'</span>'; |
|
115 | 115 | } |
116 | 116 | |
117 | 117 | $h++; |
118 | 118 | } |
119 | 119 | |
120 | - if ($object->isProduct() || ($object->isService() && ! empty($conf->global->STOCK_SUPPORTS_SERVICES))) // If physical product we can stock (or service with option) |
|
120 | + if ($object->isProduct() || ($object->isService() && !empty($conf->global->STOCK_SUPPORTS_SERVICES))) // If physical product we can stock (or service with option) |
|
121 | 121 | { |
122 | - if (! empty($conf->stock->enabled) && $user->rights->stock->lire) |
|
122 | + if (!empty($conf->stock->enabled) && $user->rights->stock->lire) |
|
123 | 123 | { |
124 | 124 | $head[$h][0] = DOL_URL_ROOT."/product/stock/product.php?id=".$object->id; |
125 | 125 | $head[$h][1] = $langs->trans("Stock"); |
@@ -132,17 +132,17 @@ discard block |
||
132 | 132 | // Entries must be declared in modules descriptor with line |
133 | 133 | // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab |
134 | 134 | // $this->tabs = array('entity:-tabname); to remove a tab |
135 | - complete_head_from_modules($conf,$langs,$object,$head,$h,'product'); |
|
135 | + complete_head_from_modules($conf, $langs, $object, $head, $h, 'product'); |
|
136 | 136 | |
137 | 137 | // Notes |
138 | 138 | if (empty($conf->global->MAIN_DISABLE_NOTES_TAB)) |
139 | 139 | { |
140 | 140 | $nbNote = 0; |
141 | - if(!empty($object->note_private)) $nbNote++; |
|
142 | - if(!empty($object->note_public)) $nbNote++; |
|
141 | + if (!empty($object->note_private)) $nbNote++; |
|
142 | + if (!empty($object->note_public)) $nbNote++; |
|
143 | 143 | $head[$h][0] = DOL_URL_ROOT.'/product/note.php?id='.$object->id; |
144 | 144 | $head[$h][1] = $langs->trans('Notes'); |
145 | - if ($nbNote > 0) $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>'; |
|
145 | + if ($nbNote > 0) $head[$h][1] .= ' <span class="badge">'.$nbNote.'</span>'; |
|
146 | 146 | $head[$h][2] = 'note'; |
147 | 147 | $h++; |
148 | 148 | } |
@@ -150,30 +150,30 @@ discard block |
||
150 | 150 | // Attachments |
151 | 151 | require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; |
152 | 152 | require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php'; |
153 | - if (! empty($conf->product->enabled) && ($object->type==Product::TYPE_PRODUCT)) $upload_dir = $conf->product->multidir_output[$object->entity].'/'.dol_sanitizeFileName($object->ref); |
|
154 | - if (! empty($conf->service->enabled) && ($object->type==Product::TYPE_SERVICE)) $upload_dir = $conf->service->multidir_output[$object->entity].'/'.dol_sanitizeFileName($object->ref); |
|
155 | - $nbFiles = count(dol_dir_list($upload_dir,'files',0,'','(\.meta|_preview.*\.png)$')); |
|
156 | - if (! empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) { |
|
157 | - if (! empty($conf->product->enabled) && ($object->type==Product::TYPE_PRODUCT)) $upload_dir = $conf->produit->multidir_output[$object->entity].'/'.get_exdir($object->id,2,0,0,$object,'product').$object->id.'/photos'; |
|
158 | - if (! empty($conf->service->enabled) && ($object->type==Product::TYPE_SERVICE)) $upload_dir = $conf->service->multidir_output[$object->entity].'/'.get_exdir($object->id,2,0,0,$object,'product').$object->id.'/photos'; |
|
159 | - $nbFiles += count(dol_dir_list($upload_dir,'files',0,'','(\.meta|_preview.*\.png)$')); |
|
153 | + if (!empty($conf->product->enabled) && ($object->type == Product::TYPE_PRODUCT)) $upload_dir = $conf->product->multidir_output[$object->entity].'/'.dol_sanitizeFileName($object->ref); |
|
154 | + if (!empty($conf->service->enabled) && ($object->type == Product::TYPE_SERVICE)) $upload_dir = $conf->service->multidir_output[$object->entity].'/'.dol_sanitizeFileName($object->ref); |
|
155 | + $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$')); |
|
156 | + if (!empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) { |
|
157 | + if (!empty($conf->product->enabled) && ($object->type == Product::TYPE_PRODUCT)) $upload_dir = $conf->produit->multidir_output[$object->entity].'/'.get_exdir($object->id, 2, 0, 0, $object, 'product').$object->id.'/photos'; |
|
158 | + if (!empty($conf->service->enabled) && ($object->type == Product::TYPE_SERVICE)) $upload_dir = $conf->service->multidir_output[$object->entity].'/'.get_exdir($object->id, 2, 0, 0, $object, 'product').$object->id.'/photos'; |
|
159 | + $nbFiles += count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$')); |
|
160 | 160 | } |
161 | - $nbLinks=Link::count($db, $object->element, $object->id); |
|
161 | + $nbLinks = Link::count($db, $object->element, $object->id); |
|
162 | 162 | $head[$h][0] = DOL_URL_ROOT.'/product/document.php?id='.$object->id; |
163 | 163 | $head[$h][1] = $langs->trans('Documents'); |
164 | - if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>'; |
|
164 | + if (($nbFiles + $nbLinks) > 0) $head[$h][1] .= ' <span class="badge">'.($nbFiles + $nbLinks).'</span>'; |
|
165 | 165 | $head[$h][2] = 'documents'; |
166 | 166 | $h++; |
167 | 167 | |
168 | - complete_head_from_modules($conf,$langs,$object,$head,$h,'product', 'remove'); |
|
168 | + complete_head_from_modules($conf, $langs, $object, $head, $h, 'product', 'remove'); |
|
169 | 169 | |
170 | 170 | // Log |
171 | 171 | $head[$h][0] = DOL_URL_ROOT.'/product/agenda.php?id='.$object->id; |
172 | 172 | $head[$h][1] = $langs->trans("Events"); |
173 | - if (! empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read) )) |
|
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++; |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | global $db, $langs, $conf, $user; |
193 | 193 | |
194 | 194 | // Load translation files required by the page |
195 | - $langs->loadLangs(array("products","productbatch")); |
|
195 | + $langs->loadLangs(array("products", "productbatch")); |
|
196 | 196 | |
197 | 197 | $h = 0; |
198 | 198 | $head = array(); |
@@ -206,11 +206,11 @@ discard block |
||
206 | 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 | - $nbFiles = count(dol_dir_list($upload_dir,'files',0,'','(\.meta|_preview.*\.png)$')); |
|
210 | - $nbLinks=Link::count($db, $object->element, $object->id); |
|
209 | + $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$')); |
|
210 | + $nbLinks = Link::count($db, $object->element, $object->id); |
|
211 | 211 | $head[$h][0] = DOL_URL_ROOT."/product/stock/productlot_document.php?id=".$object->id; |
212 | 212 | $head[$h][1] = $langs->trans("Documents"); |
213 | - if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>'; |
|
213 | + if (($nbFiles + $nbLinks) > 0) $head[$h][1] .= ' <span class="badge">'.($nbFiles + $nbLinks).'</span>'; |
|
214 | 214 | $head[$h][2] = 'documents'; |
215 | 215 | $h++; |
216 | 216 | |
@@ -218,9 +218,9 @@ discard block |
||
218 | 218 | // Entries must be declared in modules descriptor with line |
219 | 219 | // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab |
220 | 220 | // $this->tabs = array('entity:-tabname); to remove a tab |
221 | - complete_head_from_modules($conf,$langs,$object,$head,$h,'productlot'); |
|
221 | + complete_head_from_modules($conf, $langs, $object, $head, $h, 'productlot'); |
|
222 | 222 | |
223 | - complete_head_from_modules($conf,$langs,$object,$head,$h,'productlot', 'remove'); |
|
223 | + complete_head_from_modules($conf, $langs, $object, $head, $h, 'productlot', 'remove'); |
|
224 | 224 | |
225 | 225 | // Log |
226 | 226 | /* |
@@ -252,7 +252,7 @@ discard block |
||
252 | 252 | $head[$h][2] = 'general'; |
253 | 253 | $h++; |
254 | 254 | |
255 | - if (!empty($conf->global->PRODUIT_MULTIPRICES) && ! empty($conf->global->PRODUIT_MULTIPRICES_ALLOW_AUTOCALC_PRICELEVEL)) |
|
255 | + if (!empty($conf->global->PRODUIT_MULTIPRICES) && !empty($conf->global->PRODUIT_MULTIPRICES_ALLOW_AUTOCALC_PRICELEVEL)) |
|
256 | 256 | { |
257 | 257 | $head[$h] = array( |
258 | 258 | 0 => DOL_URL_ROOT."/product/admin/price_rules.php", |
@@ -266,14 +266,14 @@ discard block |
||
266 | 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 | 271 | $head[$h][0] = DOL_URL_ROOT.'/product/admin/product_extrafields.php'; |
272 | 272 | $head[$h][1] = $langs->trans("ExtraFields"); |
273 | 273 | $head[$h][2] = 'attributes'; |
274 | 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 | 278 | return $head; |
279 | 279 | } |
@@ -296,14 +296,14 @@ discard block |
||
296 | 296 | // Entries must be declared in modules descriptor with line |
297 | 297 | // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab |
298 | 298 | // $this->tabs = array('entity:-tabname); to remove a tab |
299 | - complete_head_from_modules($conf,$langs,null,$head,$h,'product_lot_admin'); |
|
299 | + complete_head_from_modules($conf, $langs, null, $head, $h, 'product_lot_admin'); |
|
300 | 300 | |
301 | 301 | $head[$h][0] = DOL_URL_ROOT.'/product/admin/product_lot_extrafields.php'; |
302 | 302 | $head[$h][1] = $langs->trans("ExtraFields"); |
303 | 303 | $head[$h][2] = 'attributes'; |
304 | 304 | $h++; |
305 | 305 | |
306 | - complete_head_from_modules($conf,$langs,null,$head,$h,'product_lot_admin','remove'); |
|
306 | + complete_head_from_modules($conf, $langs, null, $head, $h, 'product_lot_admin', 'remove'); |
|
307 | 307 | |
308 | 308 | return $head; |
309 | 309 | } |
@@ -317,9 +317,9 @@ discard block |
||
317 | 317 | * @param int $socid Thirdparty id |
318 | 318 | * @return integer NB of lines shown into array |
319 | 319 | */ |
320 | -function show_stats_for_company($product,$socid) |
|
320 | +function show_stats_for_company($product, $socid) |
|
321 | 321 | { |
322 | - global $conf,$langs,$user,$db; |
|
322 | + global $conf, $langs, $user, $db; |
|
323 | 323 | |
324 | 324 | $nblines = 0; |
325 | 325 | |
@@ -331,14 +331,14 @@ discard block |
||
331 | 331 | print '</tr>'; |
332 | 332 | |
333 | 333 | // Customer proposals |
334 | - if (! empty($conf->propal->enabled) && $user->rights->propale->lire) |
|
334 | + if (!empty($conf->propal->enabled) && $user->rights->propale->lire) |
|
335 | 335 | { |
336 | 336 | $nblines++; |
337 | - $ret=$product->load_stats_propale($socid); |
|
337 | + $ret = $product->load_stats_propale($socid); |
|
338 | 338 | if ($ret < 0) dol_print_error($db); |
339 | 339 | $langs->load("propal"); |
340 | 340 | print '<tr><td>'; |
341 | - print '<a href="propal.php?id='.$product->id.'">'.img_object('','propal').' '.$langs->trans("Proposals").'</a>'; |
|
341 | + print '<a href="propal.php?id='.$product->id.'">'.img_object('', 'propal').' '.$langs->trans("Proposals").'</a>'; |
|
342 | 342 | print '</td><td align="right">'; |
343 | 343 | print $product->stats_propale['customers']; |
344 | 344 | print '</td><td align="right">'; |
@@ -349,14 +349,14 @@ discard block |
||
349 | 349 | print '</tr>'; |
350 | 350 | } |
351 | 351 | // Supplier proposals |
352 | - if (! empty($conf->supplier_proposal->enabled) && $user->rights->supplier_proposal->lire) |
|
352 | + if (!empty($conf->supplier_proposal->enabled) && $user->rights->supplier_proposal->lire) |
|
353 | 353 | { |
354 | 354 | $nblines++; |
355 | - $ret=$product->load_stats_proposal_supplier($socid); |
|
355 | + $ret = $product->load_stats_proposal_supplier($socid); |
|
356 | 356 | if ($ret < 0) dol_print_error($db); |
357 | 357 | $langs->load("propal"); |
358 | 358 | print '<tr><td>'; |
359 | - print '<a href="supplier_proposal.php?id='.$product->id.'">'.img_object('','propal').' '.$langs->trans("SupplierProposals").'</a>'; |
|
359 | + print '<a href="supplier_proposal.php?id='.$product->id.'">'.img_object('', 'propal').' '.$langs->trans("SupplierProposals").'</a>'; |
|
360 | 360 | print '</td><td align="right">'; |
361 | 361 | print $product->stats_proposal_supplier['suppliers']; |
362 | 362 | print '</td><td align="right">'; |
@@ -367,14 +367,14 @@ discard block |
||
367 | 367 | print '</tr>'; |
368 | 368 | } |
369 | 369 | // Customer orders |
370 | - if (! empty($conf->commande->enabled) && $user->rights->commande->lire) |
|
370 | + if (!empty($conf->commande->enabled) && $user->rights->commande->lire) |
|
371 | 371 | { |
372 | 372 | $nblines++; |
373 | - $ret=$product->load_stats_commande($socid); |
|
373 | + $ret = $product->load_stats_commande($socid); |
|
374 | 374 | if ($ret < 0) dol_print_error($db); |
375 | 375 | $langs->load("orders"); |
376 | 376 | print '<tr><td>'; |
377 | - print '<a href="commande.php?id='.$product->id.'">'.img_object('','order').' '.$langs->trans("CustomersOrders").'</a>'; |
|
377 | + print '<a href="commande.php?id='.$product->id.'">'.img_object('', 'order').' '.$langs->trans("CustomersOrders").'</a>'; |
|
378 | 378 | print '</td><td align="right">'; |
379 | 379 | print $product->stats_commande['customers']; |
380 | 380 | print '</td><td align="right">'; |
@@ -385,14 +385,14 @@ discard block |
||
385 | 385 | print '</tr>'; |
386 | 386 | } |
387 | 387 | // Supplier orders |
388 | - if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->commande->lire) |
|
388 | + if (!empty($conf->fournisseur->enabled) && $user->rights->fournisseur->commande->lire) |
|
389 | 389 | { |
390 | 390 | $nblines++; |
391 | - $ret=$product->load_stats_commande_fournisseur($socid); |
|
391 | + $ret = $product->load_stats_commande_fournisseur($socid); |
|
392 | 392 | if ($ret < 0) dol_print_error($db); |
393 | 393 | $langs->load("orders"); |
394 | 394 | print '<tr><td>'; |
395 | - print '<a href="commande_fournisseur.php?id='.$product->id.'">'.img_object('','order').' '.$langs->trans("SuppliersOrders").'</a>'; |
|
395 | + print '<a href="commande_fournisseur.php?id='.$product->id.'">'.img_object('', 'order').' '.$langs->trans("SuppliersOrders").'</a>'; |
|
396 | 396 | print '</td><td align="right">'; |
397 | 397 | print $product->stats_commande_fournisseur['suppliers']; |
398 | 398 | print '</td><td align="right">'; |
@@ -403,14 +403,14 @@ discard block |
||
403 | 403 | print '</tr>'; |
404 | 404 | } |
405 | 405 | // Customer invoices |
406 | - if (! empty($conf->facture->enabled) && $user->rights->facture->lire) |
|
406 | + if (!empty($conf->facture->enabled) && $user->rights->facture->lire) |
|
407 | 407 | { |
408 | 408 | $nblines++; |
409 | - $ret=$product->load_stats_facture($socid); |
|
409 | + $ret = $product->load_stats_facture($socid); |
|
410 | 410 | if ($ret < 0) dol_print_error($db); |
411 | 411 | $langs->load("bills"); |
412 | 412 | print '<tr><td>'; |
413 | - print '<a href="facture.php?id='.$product->id.'">'.img_object('','bill').' '.$langs->trans("CustomersInvoices").'</a>'; |
|
413 | + print '<a href="facture.php?id='.$product->id.'">'.img_object('', 'bill').' '.$langs->trans("CustomersInvoices").'</a>'; |
|
414 | 414 | print '</td><td align="right">'; |
415 | 415 | print $product->stats_facture['customers']; |
416 | 416 | print '</td><td align="right">'; |
@@ -421,14 +421,14 @@ discard block |
||
421 | 421 | print '</tr>'; |
422 | 422 | } |
423 | 423 | // Supplier invoices |
424 | - if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->facture->lire) |
|
424 | + if (!empty($conf->fournisseur->enabled) && $user->rights->fournisseur->facture->lire) |
|
425 | 425 | { |
426 | 426 | $nblines++; |
427 | - $ret=$product->load_stats_facture_fournisseur($socid); |
|
427 | + $ret = $product->load_stats_facture_fournisseur($socid); |
|
428 | 428 | if ($ret < 0) dol_print_error($db); |
429 | 429 | $langs->load("bills"); |
430 | 430 | print '<tr><td>'; |
431 | - print '<a href="facture_fournisseur.php?id='.$product->id.'">'.img_object('','bill').' '.$langs->trans("SuppliersInvoices").'</a>'; |
|
431 | + print '<a href="facture_fournisseur.php?id='.$product->id.'">'.img_object('', 'bill').' '.$langs->trans("SuppliersInvoices").'</a>'; |
|
432 | 432 | print '</td><td align="right">'; |
433 | 433 | print $product->stats_facture_fournisseur['suppliers']; |
434 | 434 | print '</td><td align="right">'; |
@@ -440,14 +440,14 @@ discard block |
||
440 | 440 | } |
441 | 441 | |
442 | 442 | // Contracts |
443 | - if (! empty($conf->contrat->enabled) && $user->rights->contrat->lire) |
|
443 | + if (!empty($conf->contrat->enabled) && $user->rights->contrat->lire) |
|
444 | 444 | { |
445 | 445 | $nblines++; |
446 | - $ret=$product->load_stats_contrat($socid); |
|
446 | + $ret = $product->load_stats_contrat($socid); |
|
447 | 447 | if ($ret < 0) dol_print_error($db); |
448 | 448 | $langs->load("contracts"); |
449 | 449 | print '<tr><td>'; |
450 | - print '<a href="contrat.php?id='.$product->id.'">'.img_object('','contract').' '.$langs->trans("Contracts").'</a>'; |
|
450 | + print '<a href="contrat.php?id='.$product->id.'">'.img_object('', 'contract').' '.$langs->trans("Contracts").'</a>'; |
|
451 | 451 | print '</td><td align="right">'; |
452 | 452 | print $product->stats_contrat['customers']; |
453 | 453 | print '</td><td align="right">'; |
@@ -470,11 +470,11 @@ discard block |
||
470 | 470 | * @return string Unit string |
471 | 471 | * @see formproduct->load_measuring_units |
472 | 472 | */ |
473 | -function measuring_units_string($unit,$measuring_style='') |
|
473 | +function measuring_units_string($unit, $measuring_style = '') |
|
474 | 474 | { |
475 | 475 | global $langs; |
476 | 476 | |
477 | - $measuring_units=array(); |
|
477 | + $measuring_units = array(); |
|
478 | 478 | if ($measuring_style == 'weight') |
479 | 479 | { |
480 | 480 | $measuring_units[3] = $langs->transnoentitiesnoconv("WeightUnitton"); |
@@ -527,8 +527,8 @@ discard block |
||
527 | 527 | */ |
528 | 528 | function measuring_units_squared($unit) |
529 | 529 | { |
530 | - $measuring_units=array(); |
|
531 | - $measuring_units[0] = 0; // m -> m3 |
|
530 | + $measuring_units = array(); |
|
531 | + $measuring_units[0] = 0; // m -> m3 |
|
532 | 532 | $measuring_units[-1] = -2; // dm-> dm2 |
533 | 533 | $measuring_units[-2] = -4; // cm -> cm2 |
534 | 534 | $measuring_units[-3] = -6; // mm -> mm2 |
@@ -547,8 +547,8 @@ discard block |
||
547 | 547 | */ |
548 | 548 | function measuring_units_cubed($unit) |
549 | 549 | { |
550 | - $measuring_units=array(); |
|
551 | - $measuring_units[0] = 0; // m -> m2 |
|
550 | + $measuring_units = array(); |
|
551 | + $measuring_units[0] = 0; // m -> m2 |
|
552 | 552 | $measuring_units[-1] = -3; // dm-> dm3 |
553 | 553 | $measuring_units[-2] = -6; // cm -> cm3 |
554 | 554 | $measuring_units[-3] = -9; // mm -> mm3 |
@@ -53,13 +53,15 @@ discard block |
||
53 | 53 | $h++; |
54 | 54 | } |
55 | 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 |
|
56 | + if (! empty($object->status_buy) || (! empty($conf->margin->enabled) && ! empty($object->status))) { |
|
57 | + // If margin is on and product on sell, we may need the cost price even if product os not on purchase |
|
57 | 58 | { |
58 | 59 | if ((! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->lire) |
59 | 60 | || (! empty($conf->margin->enabled) && $user->rights->margin->liretous) |
60 | 61 | ) |
61 | 62 | { |
62 | 63 | $head[$h][0] = DOL_URL_ROOT."/product/fournisseurs.php?id=".$object->id; |
64 | + } |
|
63 | 65 | $head[$h][1] = $langs->trans("BuyingPrices"); |
64 | 66 | $head[$h][2] = 'suppliers'; |
65 | 67 | $h++; |
@@ -82,7 +84,9 @@ discard block |
||
82 | 84 | $head[$h][1] = $langs->trans('AssociatedProducts'); |
83 | 85 | |
84 | 86 | $nbFatherAndChild = $object->hasFatherOrChild(); |
85 | - if ($nbFatherAndChild > 0) $head[$h][1].= ' <span class="badge">'.$nbFatherAndChild.'</span>'; |
|
87 | + if ($nbFatherAndChild > 0) { |
|
88 | + $head[$h][1].= ' <span class="badge">'.$nbFatherAndChild.'</span>'; |
|
89 | + } |
|
86 | 90 | $head[$h][2] = 'subproduct'; |
87 | 91 | $h++; |
88 | 92 | } |
@@ -111,17 +115,21 @@ discard block |
||
111 | 115 | $head[$h][1] = $langs->trans('ProductCombinations'); |
112 | 116 | $head[$h][2] = 'combinations'; |
113 | 117 | $nbVariant = $prodcomb->countNbOfCombinationForFkProductParent($object->id); |
114 | - if ($nbVariant > 0) $head[$h][1].= ' <span class="badge">'.$nbVariant.'</span>'; |
|
118 | + if ($nbVariant > 0) { |
|
119 | + $head[$h][1].= ' <span class="badge">'.$nbVariant.'</span>'; |
|
120 | + } |
|
115 | 121 | } |
116 | 122 | |
117 | 123 | $h++; |
118 | 124 | } |
119 | 125 | |
120 | - if ($object->isProduct() || ($object->isService() && ! empty($conf->global->STOCK_SUPPORTS_SERVICES))) // If physical product we can stock (or service with option) |
|
126 | + if ($object->isProduct() || ($object->isService() && ! empty($conf->global->STOCK_SUPPORTS_SERVICES))) { |
|
127 | + // If physical product we can stock (or service with option) |
|
121 | 128 | { |
122 | 129 | if (! empty($conf->stock->enabled) && $user->rights->stock->lire) |
123 | 130 | { |
124 | 131 | $head[$h][0] = DOL_URL_ROOT."/product/stock/product.php?id=".$object->id; |
132 | + } |
|
125 | 133 | $head[$h][1] = $langs->trans("Stock"); |
126 | 134 | $head[$h][2] = 'stock'; |
127 | 135 | $h++; |
@@ -138,11 +146,17 @@ discard block |
||
138 | 146 | if (empty($conf->global->MAIN_DISABLE_NOTES_TAB)) |
139 | 147 | { |
140 | 148 | $nbNote = 0; |
141 | - if(!empty($object->note_private)) $nbNote++; |
|
142 | - if(!empty($object->note_public)) $nbNote++; |
|
149 | + if(!empty($object->note_private)) { |
|
150 | + $nbNote++; |
|
151 | + } |
|
152 | + if(!empty($object->note_public)) { |
|
153 | + $nbNote++; |
|
154 | + } |
|
143 | 155 | $head[$h][0] = DOL_URL_ROOT.'/product/note.php?id='.$object->id; |
144 | 156 | $head[$h][1] = $langs->trans('Notes'); |
145 | - if ($nbNote > 0) $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>'; |
|
157 | + if ($nbNote > 0) { |
|
158 | + $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>'; |
|
159 | + } |
|
146 | 160 | $head[$h][2] = 'note'; |
147 | 161 | $h++; |
148 | 162 | } |
@@ -150,18 +164,28 @@ discard block |
||
150 | 164 | // Attachments |
151 | 165 | require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; |
152 | 166 | require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php'; |
153 | - if (! empty($conf->product->enabled) && ($object->type==Product::TYPE_PRODUCT)) $upload_dir = $conf->product->multidir_output[$object->entity].'/'.dol_sanitizeFileName($object->ref); |
|
154 | - if (! empty($conf->service->enabled) && ($object->type==Product::TYPE_SERVICE)) $upload_dir = $conf->service->multidir_output[$object->entity].'/'.dol_sanitizeFileName($object->ref); |
|
167 | + if (! empty($conf->product->enabled) && ($object->type==Product::TYPE_PRODUCT)) { |
|
168 | + $upload_dir = $conf->product->multidir_output[$object->entity].'/'.dol_sanitizeFileName($object->ref); |
|
169 | + } |
|
170 | + if (! empty($conf->service->enabled) && ($object->type==Product::TYPE_SERVICE)) { |
|
171 | + $upload_dir = $conf->service->multidir_output[$object->entity].'/'.dol_sanitizeFileName($object->ref); |
|
172 | + } |
|
155 | 173 | $nbFiles = count(dol_dir_list($upload_dir,'files',0,'','(\.meta|_preview.*\.png)$')); |
156 | 174 | if (! empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) { |
157 | - if (! empty($conf->product->enabled) && ($object->type==Product::TYPE_PRODUCT)) $upload_dir = $conf->produit->multidir_output[$object->entity].'/'.get_exdir($object->id,2,0,0,$object,'product').$object->id.'/photos'; |
|
158 | - if (! empty($conf->service->enabled) && ($object->type==Product::TYPE_SERVICE)) $upload_dir = $conf->service->multidir_output[$object->entity].'/'.get_exdir($object->id,2,0,0,$object,'product').$object->id.'/photos'; |
|
175 | + if (! empty($conf->product->enabled) && ($object->type==Product::TYPE_PRODUCT)) { |
|
176 | + $upload_dir = $conf->produit->multidir_output[$object->entity].'/'.get_exdir($object->id,2,0,0,$object,'product').$object->id.'/photos'; |
|
177 | + } |
|
178 | + if (! empty($conf->service->enabled) && ($object->type==Product::TYPE_SERVICE)) { |
|
179 | + $upload_dir = $conf->service->multidir_output[$object->entity].'/'.get_exdir($object->id,2,0,0,$object,'product').$object->id.'/photos'; |
|
180 | + } |
|
159 | 181 | $nbFiles += count(dol_dir_list($upload_dir,'files',0,'','(\.meta|_preview.*\.png)$')); |
160 | 182 | } |
161 | 183 | $nbLinks=Link::count($db, $object->element, $object->id); |
162 | 184 | $head[$h][0] = DOL_URL_ROOT.'/product/document.php?id='.$object->id; |
163 | 185 | $head[$h][1] = $langs->trans('Documents'); |
164 | - if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>'; |
|
186 | + if (($nbFiles+$nbLinks) > 0) { |
|
187 | + $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>'; |
|
188 | + } |
|
165 | 189 | $head[$h][2] = 'documents'; |
166 | 190 | $h++; |
167 | 191 | |
@@ -210,7 +234,9 @@ discard block |
||
210 | 234 | $nbLinks=Link::count($db, $object->element, $object->id); |
211 | 235 | $head[$h][0] = DOL_URL_ROOT."/product/stock/productlot_document.php?id=".$object->id; |
212 | 236 | $head[$h][1] = $langs->trans("Documents"); |
213 | - if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>'; |
|
237 | + if (($nbFiles+$nbLinks) > 0) { |
|
238 | + $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>'; |
|
239 | + } |
|
214 | 240 | $head[$h][2] = 'documents'; |
215 | 241 | $h++; |
216 | 242 | |
@@ -335,7 +361,9 @@ discard block |
||
335 | 361 | { |
336 | 362 | $nblines++; |
337 | 363 | $ret=$product->load_stats_propale($socid); |
338 | - if ($ret < 0) dol_print_error($db); |
|
364 | + if ($ret < 0) { |
|
365 | + dol_print_error($db); |
|
366 | + } |
|
339 | 367 | $langs->load("propal"); |
340 | 368 | print '<tr><td>'; |
341 | 369 | print '<a href="propal.php?id='.$product->id.'">'.img_object('','propal').' '.$langs->trans("Proposals").'</a>'; |
@@ -353,7 +381,9 @@ discard block |
||
353 | 381 | { |
354 | 382 | $nblines++; |
355 | 383 | $ret=$product->load_stats_proposal_supplier($socid); |
356 | - if ($ret < 0) dol_print_error($db); |
|
384 | + if ($ret < 0) { |
|
385 | + dol_print_error($db); |
|
386 | + } |
|
357 | 387 | $langs->load("propal"); |
358 | 388 | print '<tr><td>'; |
359 | 389 | print '<a href="supplier_proposal.php?id='.$product->id.'">'.img_object('','propal').' '.$langs->trans("SupplierProposals").'</a>'; |
@@ -371,7 +401,9 @@ discard block |
||
371 | 401 | { |
372 | 402 | $nblines++; |
373 | 403 | $ret=$product->load_stats_commande($socid); |
374 | - if ($ret < 0) dol_print_error($db); |
|
404 | + if ($ret < 0) { |
|
405 | + dol_print_error($db); |
|
406 | + } |
|
375 | 407 | $langs->load("orders"); |
376 | 408 | print '<tr><td>'; |
377 | 409 | print '<a href="commande.php?id='.$product->id.'">'.img_object('','order').' '.$langs->trans("CustomersOrders").'</a>'; |
@@ -389,7 +421,9 @@ discard block |
||
389 | 421 | { |
390 | 422 | $nblines++; |
391 | 423 | $ret=$product->load_stats_commande_fournisseur($socid); |
392 | - if ($ret < 0) dol_print_error($db); |
|
424 | + if ($ret < 0) { |
|
425 | + dol_print_error($db); |
|
426 | + } |
|
393 | 427 | $langs->load("orders"); |
394 | 428 | print '<tr><td>'; |
395 | 429 | print '<a href="commande_fournisseur.php?id='.$product->id.'">'.img_object('','order').' '.$langs->trans("SuppliersOrders").'</a>'; |
@@ -407,7 +441,9 @@ discard block |
||
407 | 441 | { |
408 | 442 | $nblines++; |
409 | 443 | $ret=$product->load_stats_facture($socid); |
410 | - if ($ret < 0) dol_print_error($db); |
|
444 | + if ($ret < 0) { |
|
445 | + dol_print_error($db); |
|
446 | + } |
|
411 | 447 | $langs->load("bills"); |
412 | 448 | print '<tr><td>'; |
413 | 449 | print '<a href="facture.php?id='.$product->id.'">'.img_object('','bill').' '.$langs->trans("CustomersInvoices").'</a>'; |
@@ -425,7 +461,9 @@ discard block |
||
425 | 461 | { |
426 | 462 | $nblines++; |
427 | 463 | $ret=$product->load_stats_facture_fournisseur($socid); |
428 | - if ($ret < 0) dol_print_error($db); |
|
464 | + if ($ret < 0) { |
|
465 | + dol_print_error($db); |
|
466 | + } |
|
429 | 467 | $langs->load("bills"); |
430 | 468 | print '<tr><td>'; |
431 | 469 | print '<a href="facture_fournisseur.php?id='.$product->id.'">'.img_object('','bill').' '.$langs->trans("SuppliersInvoices").'</a>'; |
@@ -444,7 +482,9 @@ discard block |
||
444 | 482 | { |
445 | 483 | $nblines++; |
446 | 484 | $ret=$product->load_stats_contrat($socid); |
447 | - if ($ret < 0) dol_print_error($db); |
|
485 | + if ($ret < 0) { |
|
486 | + dol_print_error($db); |
|
487 | + } |
|
448 | 488 | $langs->load("contracts"); |
449 | 489 | print '<tr><td>'; |
450 | 490 | print '<a href="contrat.php?id='.$product->id.'">'.img_object('','contract').' '.$langs->trans("Contracts").'</a>'; |
@@ -483,8 +523,7 @@ discard block |
||
483 | 523 | $measuring_units[-6] = $langs->transnoentitiesnoconv("WeightUnitmg"); |
484 | 524 | $measuring_units[98] = $langs->transnoentitiesnoconv("WeightUnitounce"); |
485 | 525 | $measuring_units[99] = $langs->transnoentitiesnoconv("WeightUnitpound"); |
486 | - } |
|
487 | - else if ($measuring_style == 'size') |
|
526 | + } else if ($measuring_style == 'size') |
|
488 | 527 | { |
489 | 528 | $measuring_units[0] = $langs->transnoentitiesnoconv("SizeUnitm"); |
490 | 529 | $measuring_units[-1] = $langs->transnoentitiesnoconv("SizeUnitdm"); |
@@ -492,8 +531,7 @@ discard block |
||
492 | 531 | $measuring_units[-3] = $langs->transnoentitiesnoconv("SizeUnitmm"); |
493 | 532 | $measuring_units[98] = $langs->transnoentitiesnoconv("SizeUnitfoot"); |
494 | 533 | $measuring_units[99] = $langs->transnoentitiesnoconv("SizeUnitinch"); |
495 | - } |
|
496 | - else if ($measuring_style == 'surface') |
|
534 | + } else if ($measuring_style == 'surface') |
|
497 | 535 | { |
498 | 536 | $measuring_units[0] = $langs->transnoentitiesnoconv("SurfaceUnitm2"); |
499 | 537 | $measuring_units[-2] = $langs->transnoentitiesnoconv("SurfaceUnitdm2"); |
@@ -501,8 +539,7 @@ discard block |
||
501 | 539 | $measuring_units[-6] = $langs->transnoentitiesnoconv("SurfaceUnitmm2"); |
502 | 540 | $measuring_units[98] = $langs->transnoentitiesnoconv("SurfaceUnitfoot2"); |
503 | 541 | $measuring_units[99] = $langs->transnoentitiesnoconv("SurfaceUnitinch2"); |
504 | - } |
|
505 | - else if ($measuring_style == 'volume') |
|
542 | + } else if ($measuring_style == 'volume') |
|
506 | 543 | { |
507 | 544 | $measuring_units[0] = $langs->transnoentitiesnoconv("VolumeUnitm3"); |
508 | 545 | $measuring_units[-3] = $langs->transnoentitiesnoconv("VolumeUnitdm3"); |
@@ -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 |
@@ -36,15 +36,15 @@ discard block |
||
36 | 36 | |
37 | 37 | $h = 0; |
38 | 38 | $head = array(); |
39 | - $helptext =$langs->trans("ECMAreaDesc").'<br>'; |
|
40 | - $helptext.=$langs->trans("ECMAreaDesc2"); |
|
39 | + $helptext = $langs->trans("ECMAreaDesc").'<br>'; |
|
40 | + $helptext .= $langs->trans("ECMAreaDesc2"); |
|
41 | 41 | |
42 | 42 | $head[$h][0] = DOL_URL_ROOT.'/ecm/index.php'; |
43 | 43 | $head[$h][1] = $langs->trans("ECMSectionsManual").$form->textwithpicto('', $helptext, 1, 'info', '', 0, 3); |
44 | 44 | $head[$h][2] = 'index'; |
45 | 45 | $h++; |
46 | 46 | |
47 | - if (! empty($conf->global->ECM_AUTO_TREE_ENABLED)) |
|
47 | + if (!empty($conf->global->ECM_AUTO_TREE_ENABLED)) |
|
48 | 48 | { |
49 | 49 | $head[$h][0] = DOL_URL_ROOT.'/ecm/index_auto.php'; |
50 | 50 | $head[$h][1] = $langs->trans("ECMSectionsAuto").$form->textwithpicto('', $helptext, 1, 'info', '', 0, 3); |
@@ -56,9 +56,9 @@ discard block |
||
56 | 56 | // Entries must be declared in modules descriptor with line |
57 | 57 | // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab |
58 | 58 | // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab |
59 | - complete_head_from_modules($conf,$langs,$object,$head,$h,'ecm'); |
|
59 | + complete_head_from_modules($conf, $langs, $object, $head, $h, 'ecm'); |
|
60 | 60 | |
61 | - complete_head_from_modules($conf,$langs,$object,$head,$h,'ecm','remove'); |
|
61 | + complete_head_from_modules($conf, $langs, $object, $head, $h, 'ecm', 'remove'); |
|
62 | 62 | |
63 | 63 | return $head; |
64 | 64 | } |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | * @param string $section Section |
73 | 73 | * @return array Array of tabs to show |
74 | 74 | */ |
75 | -function ecm_prepare_head($object, $module='ecm', $section='') |
|
75 | +function ecm_prepare_head($object, $module = 'ecm', $section = '') |
|
76 | 76 | { |
77 | 77 | global $langs, $conf, $user; |
78 | 78 | $h = 0; |
@@ -84,8 +84,7 @@ |
||
84 | 84 | $head[$h][1] = $langs->trans("Card"); |
85 | 85 | $head[$h][2] = 'card'; |
86 | 86 | $h++; |
87 | - } |
|
88 | - else |
|
87 | + } else |
|
89 | 88 | { |
90 | 89 | $head[$h][0] = DOL_URL_ROOT.'/ecm/dir_card.php?section='.$section.'&module='.$module; |
91 | 90 | $head[$h][1] = $langs->trans("Card"); |