@@ -92,10 +92,16 @@ discard block |
||
92 | 92 | $sql .= " FROM ".MAIN_DB_PREFIX."socpeople as sp"; |
93 | 93 | $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as co ON sp.fk_pays = co.rowid"; |
94 | 94 | $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON sp.fk_soc = s.rowid"; |
95 | - if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; |
|
95 | + if (!$user->rights->societe->client->voir && !$user->socid) { |
|
96 | + $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; |
|
97 | + } |
|
96 | 98 | $sql .= " WHERE sp.entity IN (".getEntity('socpeople').")"; |
97 | - if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; |
|
98 | - if ($user->socid) $sql .= " AND sp.fk_soc = ".$user->socid; |
|
99 | + if (!$user->rights->societe->client->voir && !$user->socid) { |
|
100 | + $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; |
|
101 | + } |
|
102 | + if ($user->socid) { |
|
103 | + $sql .= " AND sp.fk_soc = ".$user->socid; |
|
104 | + } |
|
99 | 105 | $sql .= " ORDER BY sp.tms DESC"; |
100 | 106 | $sql .= $this->db->plimit($max, 0); |
101 | 107 | |
@@ -163,12 +169,13 @@ discard block |
||
163 | 169 | $line++; |
164 | 170 | } |
165 | 171 | |
166 | - if ($num == 0) |
|
167 | - $this->info_box_contents[$line][0] = array( |
|
172 | + if ($num == 0) { |
|
173 | + $this->info_box_contents[$line][0] = array( |
|
168 | 174 | 'td' => 'class="center"', |
169 | 175 | 'text'=> '<span class="opacitymedium">'.$langs->trans("NoRecordedContacts").'</span>', |
170 | 176 | 'asis'=> 1 |
171 | 177 | ); |
178 | + } |
|
172 | 179 | |
173 | 180 | $this->db->free($result); |
174 | 181 | } else { |
@@ -44,11 +44,17 @@ discard block |
||
44 | 44 | if (isset($object->fields['note_public']) || isset($object->fields['note_private'])) |
45 | 45 | { |
46 | 46 | $nbNote = 0; |
47 | - if (!empty($object->note_private)) $nbNote++; |
|
48 | - if (!empty($object->note_public)) $nbNote++; |
|
47 | + if (!empty($object->note_private)) { |
|
48 | + $nbNote++; |
|
49 | + } |
|
50 | + if (!empty($object->note_public)) { |
|
51 | + $nbNote++; |
|
52 | + } |
|
49 | 53 | $head[$h][0] = dol_buildpath('/recruitment/recruitmentcandidature_note.php', 1).'?id='.$object->id; |
50 | 54 | $head[$h][1] = $langs->trans('Notes'); |
51 | - if ($nbNote > 0) $head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbNote.'</span>'; |
|
55 | + if ($nbNote > 0) { |
|
56 | + $head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbNote.'</span>'; |
|
57 | + } |
|
52 | 58 | $head[$h][2] = 'note'; |
53 | 59 | $h++; |
54 | 60 | } |
@@ -60,7 +66,9 @@ discard block |
||
60 | 66 | $nbLinks = Link::count($db, $object->element, $object->id); |
61 | 67 | $head[$h][0] = dol_buildpath("/recruitment/recruitmentcandidature_document.php", 1).'?id='.$object->id; |
62 | 68 | $head[$h][1] = $langs->trans('Documents'); |
63 | - if (($nbFiles + $nbLinks) > 0) $head[$h][1] .= '<span class="badge marginleftonlyshort">'.($nbFiles + $nbLinks).'</span>'; |
|
69 | + if (($nbFiles + $nbLinks) > 0) { |
|
70 | + $head[$h][1] .= '<span class="badge marginleftonlyshort">'.($nbFiles + $nbLinks).'</span>'; |
|
71 | + } |
|
64 | 72 | $head[$h][2] = 'document'; |
65 | 73 | $h++; |
66 | 74 |
@@ -136,8 +136,11 @@ discard block |
||
136 | 136 | if ($resql) |
137 | 137 | { |
138 | 138 | $obj = $db->fetch_object($resql); |
139 | - if ($obj) $max = intval($obj->max); |
|
140 | - else $max = 0; |
|
139 | + if ($obj) { |
|
140 | + $max = intval($obj->max); |
|
141 | + } else { |
|
142 | + $max = 0; |
|
143 | + } |
|
141 | 144 | } else { |
142 | 145 | dol_syslog("mod_recruitmentcandidature_standard::getNextValue", LOG_DEBUG); |
143 | 146 | return -1; |
@@ -147,8 +150,13 @@ discard block |
||
147 | 150 | $date = $object->date_creation; |
148 | 151 | $yymm = strftime("%y%m", $date); |
149 | 152 | |
150 | - if ($max >= (pow(10, 4) - 1)) $num = $max + 1; // If counter > 9999, we do not format on 4 chars, we take number as it is |
|
151 | - else $num = sprintf("%04s", $max + 1); |
|
153 | + if ($max >= (pow(10, 4) - 1)) { |
|
154 | + $num = $max + 1; |
|
155 | + } |
|
156 | + // If counter > 9999, we do not format on 4 chars, we take number as it is |
|
157 | + else { |
|
158 | + $num = sprintf("%04s", $max + 1); |
|
159 | + } |
|
152 | 160 | |
153 | 161 | dol_syslog("mod_recruitmentcandidature_standard::getNextValue return ".$this->prefix.$yymm."-".$num); |
154 | 162 | return $this->prefix.$yymm."-".$num; |
@@ -92,10 +92,18 @@ |
||
92 | 92 | global $langs; |
93 | 93 | $langs->load("admin"); |
94 | 94 | |
95 | - if ($this->version == 'development') return $langs->trans("VersionDevelopment"); |
|
96 | - if ($this->version == 'experimental') return $langs->trans("VersionExperimental"); |
|
97 | - if ($this->version == 'dolibarr') return DOL_VERSION; |
|
98 | - if ($this->version) return $this->version; |
|
95 | + if ($this->version == 'development') { |
|
96 | + return $langs->trans("VersionDevelopment"); |
|
97 | + } |
|
98 | + if ($this->version == 'experimental') { |
|
99 | + return $langs->trans("VersionExperimental"); |
|
100 | + } |
|
101 | + if ($this->version == 'dolibarr') { |
|
102 | + return DOL_VERSION; |
|
103 | + } |
|
104 | + if ($this->version) { |
|
105 | + return $this->version; |
|
106 | + } |
|
99 | 107 | return $langs->trans("NotAvailable"); |
100 | 108 | } |
101 | 109 | } |
@@ -25,17 +25,31 @@ discard block |
||
25 | 25 | // Load Dolibarr environment |
26 | 26 | $res = 0; |
27 | 27 | // Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) |
28 | -if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; |
|
28 | +if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) { |
|
29 | + $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; |
|
30 | +} |
|
29 | 31 | // Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME |
30 | 32 | $tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1; |
31 | 33 | while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { $i--; $j--; } |
32 | -if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php"; |
|
33 | -if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php"; |
|
34 | +if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) { |
|
35 | + $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php"; |
|
36 | +} |
|
37 | +if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) { |
|
38 | + $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php"; |
|
39 | +} |
|
34 | 40 | // Try main.inc.php using relative path |
35 | -if (!$res && file_exists("../main.inc.php")) $res = @include "../main.inc.php"; |
|
36 | -if (!$res && file_exists("../../main.inc.php")) $res = @include "../../main.inc.php"; |
|
37 | -if (!$res && file_exists("../../../main.inc.php")) $res = @include "../../../main.inc.php"; |
|
38 | -if (!$res) die("Include of main fails"); |
|
41 | +if (!$res && file_exists("../main.inc.php")) { |
|
42 | + $res = @include "../main.inc.php"; |
|
43 | +} |
|
44 | +if (!$res && file_exists("../../main.inc.php")) { |
|
45 | + $res = @include "../../main.inc.php"; |
|
46 | +} |
|
47 | +if (!$res && file_exists("../../../main.inc.php")) { |
|
48 | + $res = @include "../../../main.inc.php"; |
|
49 | +} |
|
50 | +if (!$res) { |
|
51 | + die("Include of main fails"); |
|
52 | +} |
|
39 | 53 | |
40 | 54 | dol_include_once('/recruitment/class/recruitmentcandidature.class.php'); |
41 | 55 | dol_include_once('/recruitment/lib/recruitment_recruitmentcandidature.lib.php'); |
@@ -65,7 +79,9 @@ discard block |
||
65 | 79 | |
66 | 80 | // Load object |
67 | 81 | include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals |
68 | -if ($id > 0 || !empty($ref)) $upload_dir = $conf->recruitment->multidir_output[$object->entity]."/".$object->id; |
|
82 | +if ($id > 0 || !empty($ref)) { |
|
83 | + $upload_dir = $conf->recruitment->multidir_output[$object->entity]."/".$object->id; |
|
84 | +} |
|
69 | 85 | |
70 | 86 | $permissionnote = $user->rights->recruitment->recruitmentjobposition->write; // Used by the include of actions_setnotes.inc.php |
71 | 87 | $permissiontoadd = $user->rights->recruitment->recruitmentjobposition->write; // Used by the include of actions_addupdatedelete.inc.php |
@@ -25,17 +25,31 @@ discard block |
||
25 | 25 | // Load Dolibarr environment |
26 | 26 | $res = 0; |
27 | 27 | // Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) |
28 | -if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; |
|
28 | +if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) { |
|
29 | + $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; |
|
30 | +} |
|
29 | 31 | // Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME |
30 | 32 | $tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1; |
31 | 33 | while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { $i--; $j--; } |
32 | -if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php"; |
|
33 | -if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php"; |
|
34 | +if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) { |
|
35 | + $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php"; |
|
36 | +} |
|
37 | +if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) { |
|
38 | + $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php"; |
|
39 | +} |
|
34 | 40 | // Try main.inc.php using relative path |
35 | -if (!$res && file_exists("../main.inc.php")) $res = @include "../main.inc.php"; |
|
36 | -if (!$res && file_exists("../../main.inc.php")) $res = @include "../../main.inc.php"; |
|
37 | -if (!$res && file_exists("../../../main.inc.php")) $res = @include "../../../main.inc.php"; |
|
38 | -if (!$res) die("Include of main fails"); |
|
41 | +if (!$res && file_exists("../main.inc.php")) { |
|
42 | + $res = @include "../main.inc.php"; |
|
43 | +} |
|
44 | +if (!$res && file_exists("../../main.inc.php")) { |
|
45 | + $res = @include "../../main.inc.php"; |
|
46 | +} |
|
47 | +if (!$res && file_exists("../../../main.inc.php")) { |
|
48 | + $res = @include "../../../main.inc.php"; |
|
49 | +} |
|
50 | +if (!$res) { |
|
51 | + die("Include of main fails"); |
|
52 | +} |
|
39 | 53 | |
40 | 54 | require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; |
41 | 55 | require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; |
@@ -56,8 +70,10 @@ discard block |
||
56 | 70 | |
57 | 71 | if (GETPOST('actioncode', 'array')) { |
58 | 72 | $actioncode = GETPOST('actioncode', 'array', 3); |
59 | - if (!count($actioncode)) $actioncode = '0'; |
|
60 | -} else { |
|
73 | + if (!count($actioncode)) { |
|
74 | + $actioncode = '0'; |
|
75 | + } |
|
76 | + } else { |
|
61 | 77 | $actioncode = GETPOST("actioncode", "alpha", 3) ?GETPOST("actioncode", "alpha", 3) : (GETPOST("actioncode") == '0' ? '0' : (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT)); |
62 | 78 | } |
63 | 79 | $search_agenda_label = GETPOST('search_agenda_label'); |
@@ -70,8 +86,12 @@ discard block |
||
70 | 86 | $offset = $limit * $page; |
71 | 87 | $pageprev = $page - 1; |
72 | 88 | $pagenext = $page + 1; |
73 | -if (!$sortfield) $sortfield = 'a.datep,a.id'; |
|
74 | -if (!$sortorder) $sortorder = 'DESC,DESC'; |
|
89 | +if (!$sortfield) { |
|
90 | + $sortfield = 'a.datep,a.id'; |
|
91 | +} |
|
92 | +if (!$sortorder) { |
|
93 | + $sortorder = 'DESC,DESC'; |
|
94 | +} |
|
75 | 95 | |
76 | 96 | // Initialize technical objects |
77 | 97 | $object = new RecruitmentCandidature($db); |
@@ -83,7 +103,9 @@ discard block |
||
83 | 103 | |
84 | 104 | // Load object |
85 | 105 | include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals |
86 | -if ($id > 0 || !empty($ref)) $upload_dir = $conf->recruitment->multidir_output[$object->entity]."/".$object->id; |
|
106 | +if ($id > 0 || !empty($ref)) { |
|
107 | + $upload_dir = $conf->recruitment->multidir_output[$object->entity]."/".$object->id; |
|
108 | +} |
|
87 | 109 | |
88 | 110 | // Security check - Protection if external user |
89 | 111 | //if ($user->socid > 0) accessforbidden(); |
@@ -99,7 +121,9 @@ discard block |
||
99 | 121 | |
100 | 122 | $parameters = array('id'=>$id); |
101 | 123 | $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks |
102 | -if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); |
|
124 | +if ($reshook < 0) { |
|
125 | + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); |
|
126 | +} |
|
103 | 127 | |
104 | 128 | if (empty($reshook)) |
105 | 129 | { |
@@ -111,9 +135,11 @@ discard block |
||
111 | 135 | } |
112 | 136 | |
113 | 137 | // Purge search criteria |
114 | - if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers |
|
138 | + if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { |
|
139 | + // All tests are required to be compatible with all browsers |
|
115 | 140 | { |
116 | 141 | $actioncode = ''; |
142 | + } |
|
117 | 143 | $search_agenda_label = ''; |
118 | 144 | } |
119 | 145 | } |
@@ -133,7 +159,9 @@ discard block |
||
133 | 159 | $help_url = ''; |
134 | 160 | llxHeader('', $title, $help_url); |
135 | 161 | |
136 | - if (!empty($conf->notification->enabled)) $langs->load("mails"); |
|
162 | + if (!empty($conf->notification->enabled)) { |
|
163 | + $langs->load("mails"); |
|
164 | + } |
|
137 | 165 | $head = recruitmentCandidaturePrepareHead($object); |
138 | 166 | |
139 | 167 | |
@@ -209,7 +237,9 @@ discard block |
||
209 | 237 | if ((!empty($objthirdparty->id) || !empty($objcon->id)) && $permok) |
210 | 238 | { |
211 | 239 | //$out.='<a href="'.DOL_URL_ROOT.'/comm/action/card.php?action=create'; |
212 | - if (get_class($objthirdparty) == 'Societe') $out .= '&socid='.$objthirdparty->id; |
|
240 | + if (get_class($objthirdparty) == 'Societe') { |
|
241 | + $out .= '&socid='.$objthirdparty->id; |
|
242 | + } |
|
213 | 243 | $out .= (!empty($objcon->id) ? '&contactid='.$objcon->id : '').'&backtopage=1&percentage=-1'; |
214 | 244 | //$out.=$langs->trans("AddAnAction").' '; |
215 | 245 | //$out.=img_picto($langs->trans("AddAnAction"),'filenew'); |
@@ -234,8 +264,12 @@ discard block |
||
234 | 264 | if (!empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read))) |
235 | 265 | { |
236 | 266 | $param = '&id='.$object->id.'&socid='.$socid; |
237 | - if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); |
|
238 | - if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); |
|
267 | + if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { |
|
268 | + $param .= '&contextpage='.urlencode($contextpage); |
|
269 | + } |
|
270 | + if ($limit > 0 && $limit != $conf->liste_limit) { |
|
271 | + $param .= '&limit='.urlencode($limit); |
|
272 | + } |
|
239 | 273 | |
240 | 274 | |
241 | 275 | //print load_fiche_titre($langs->trans("ActionsOnRecruitmentJobPosition"), '', ''); |
@@ -172,8 +172,12 @@ discard block |
||
172 | 172 | |
173 | 173 | $this->db = $db; |
174 | 174 | |
175 | - if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID)) $this->fields['rowid']['visible'] = 0; |
|
176 | - if (empty($conf->multicompany->enabled)) $this->fields['entity']['enabled'] = 0; |
|
175 | + if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID)) { |
|
176 | + $this->fields['rowid']['visible'] = 0; |
|
177 | + } |
|
178 | + if (empty($conf->multicompany->enabled)) { |
|
179 | + $this->fields['entity']['enabled'] = 0; |
|
180 | + } |
|
177 | 181 | } |
178 | 182 | |
179 | 183 | /** |
@@ -249,7 +253,9 @@ discard block |
||
249 | 253 | public function fetch($id, $ref = null) |
250 | 254 | { |
251 | 255 | $result = $this->fetchCommon($id, $ref); |
252 | - if ($result > 0 && !empty($this->table_element_line)) $this->fetchLines(); |
|
256 | + if ($result > 0 && !empty($this->table_element_line)) { |
|
257 | + $this->fetchLines(); |
|
258 | + } |
|
253 | 259 | return $result; |
254 | 260 | } |
255 | 261 | |
@@ -316,7 +322,9 @@ discard block |
||
316 | 322 | |
317 | 323 | if ($withpicto) { |
318 | 324 | $result .= ($linkstart.img_object($label, 'label', 'class="classfortooltip"').$linkend); |
319 | - if ($withpicto != 2) $result .= ' '; |
|
325 | + if ($withpicto != 2) { |
|
326 | + $result .= ' '; |
|
327 | + } |
|
320 | 328 | } |
321 | 329 | $result .= $linkstart.$this->label.$linkend; |
322 | 330 | return $result; |
@@ -352,7 +360,9 @@ discard block |
||
352 | 360 | } |
353 | 361 | |
354 | 362 | $statusType = 'status'.$status; |
355 | - if ($status == self::STATUS_ENABLED) $statusType = 'status4'; |
|
363 | + if ($status == self::STATUS_ENABLED) { |
|
364 | + $statusType = 'status4'; |
|
365 | + } |
|
356 | 366 | |
357 | 367 | return dolGetStatus($label, $labelshort, '', $statusType, $mode); |
358 | 368 | } |
@@ -271,13 +271,19 @@ discard block |
||
271 | 271 | 'st.code'=>'ProspectStatus', 'payterm.libelle'=>'PaymentConditions', 'paymode.libelle'=>'PaymentMode', |
272 | 272 | 's.outstanding_limit'=>'OutstandingBill', 'pbacc.ref'=>'PaymentBankAccount', 'incoterm.code'=>'IncotermLabel' |
273 | 273 | ); |
274 | - if (!empty($conf->global->SOCIETE_USEPREFIX)) $this->export_fields_array[$r]['s.prefix'] = 'Prefix'; |
|
275 | - if (!empty($conf->global->PRODUIT_MULTIPRICES)) $this->export_fields_array[$r]['s.price_level'] = 'PriceLevel'; |
|
274 | + if (!empty($conf->global->SOCIETE_USEPREFIX)) { |
|
275 | + $this->export_fields_array[$r]['s.prefix'] = 'Prefix'; |
|
276 | + } |
|
277 | + if (!empty($conf->global->PRODUIT_MULTIPRICES)) { |
|
278 | + $this->export_fields_array[$r]['s.price_level'] = 'PriceLevel'; |
|
279 | + } |
|
276 | 280 | // Add multicompany field |
277 | 281 | if (!empty($conf->global->MULTICOMPANY_ENTITY_IN_EXPORT_IF_SHARED)) |
278 | 282 | { |
279 | 283 | $nbofallowedentities = count(explode(',', getEntity('societe'))); // If project are shared, nb will be > 1 |
280 | - if (!empty($conf->multicompany->enabled) && $nbofallowedentities > 1) $this->export_fields_array[$r] += array('s.entity'=>'Entity'); |
|
284 | + if (!empty($conf->multicompany->enabled) && $nbofallowedentities > 1) { |
|
285 | + $this->export_fields_array[$r] += array('s.entity'=>'Entity'); |
|
286 | + } |
|
281 | 287 | } |
282 | 288 | $keyforselect = 'societe'; $keyforelement = 'company'; $keyforaliasextra = 'extra'; |
283 | 289 | include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; |
@@ -382,7 +388,9 @@ discard block |
||
382 | 388 | $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'socpeople as c'; |
383 | 389 | $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe as s ON c.fk_soc = s.rowid'; |
384 | 390 | $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe_extrafields as extrasoc ON s.rowid = extrasoc.fk_object'; |
385 | - if (is_object($user) && empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid'; |
|
391 | + if (is_object($user) && empty($user->rights->societe->client->voir)) { |
|
392 | + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid'; |
|
393 | + } |
|
386 | 394 | $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_departements as d ON c.fk_departement = d.rowid'; |
387 | 395 | $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_regions as r ON r.code_region = d.fk_region AND r.fk_pays = c.fk_pays'; |
388 | 396 | $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as co ON c.fk_pays = co.rowid'; |
@@ -465,14 +473,18 @@ discard block |
||
465 | 473 | 's.fk_multicurrency' => 'MulticurrencyUsed', |
466 | 474 | 's.multicurrency_code' => 'MulticurrencyCurrency' |
467 | 475 | ); |
468 | - if (!empty($conf->global->PRODUIT_MULTIPRICES)) $this->import_fields_array[$r]['s.price_level'] = 'PriceLevel'; |
|
476 | + if (!empty($conf->global->PRODUIT_MULTIPRICES)) { |
|
477 | + $this->import_fields_array[$r]['s.price_level'] = 'PriceLevel'; |
|
478 | + } |
|
469 | 479 | // Add extra fields |
470 | 480 | $sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'societe' AND entity IN (0, ".$conf->entity.")"; |
471 | 481 | $resql = $this->db->query($sql); |
472 | - if ($resql) // This can fail when class is used on old database (during migration for example) |
|
482 | + if ($resql) { |
|
483 | + // This can fail when class is used on old database (during migration for example) |
|
473 | 484 | { |
474 | 485 | while ($obj = $this->db->fetch_object($resql)) { |
475 | 486 | $fieldname = 'extra.'.$obj->name; |
487 | + } |
|
476 | 488 | $fieldlabel = ucfirst($obj->label); |
477 | 489 | $this->import_fields_array[$r][$fieldname] = $fieldlabel.($obj->fieldrequired ? '*' : ''); |
478 | 490 | } |
@@ -646,10 +658,12 @@ discard block |
||
646 | 658 | // Add extra fields |
647 | 659 | $sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'socpeople' AND entity IN (0, ".$conf->entity.")"; |
648 | 660 | $resql = $this->db->query($sql); |
649 | - if ($resql) // This can fail when class is used on an old database (during a migration for example) |
|
661 | + if ($resql) { |
|
662 | + // This can fail when class is used on an old database (during a migration for example) |
|
650 | 663 | { |
651 | 664 | while ($obj = $this->db->fetch_object($resql)) { |
652 | 665 | $fieldname = 'extra.'.$obj->name; |
666 | + } |
|
653 | 667 | $fieldlabel = ucfirst($obj->label); |
654 | 668 | $this->import_fields_array[$r][$fieldname] = $fieldlabel.($obj->fieldrequired ? '*' : ''); |
655 | 669 | } |
@@ -37,7 +37,9 @@ discard block |
||
37 | 37 | |
38 | 38 | $now = dol_now(); |
39 | 39 | $current_date = dol_getdate($now); |
40 | -if (empty($conf->global->SOCIETE_FISCAL_MONTH_START)) $conf->global->SOCIETE_FISCAL_MONTH_START = 1; |
|
40 | +if (empty($conf->global->SOCIETE_FISCAL_MONTH_START)) { |
|
41 | + $conf->global->SOCIETE_FISCAL_MONTH_START = 1; |
|
42 | +} |
|
41 | 43 | |
42 | 44 | // Date range |
43 | 45 | $year = GETPOST("year", "int"); |
@@ -52,9 +54,11 @@ discard block |
||
52 | 54 | $date_start = dol_mktime(0, 0, 0, GETPOST("date_startmonth"), GETPOST("date_startday"), GETPOST("date_startyear")); |
53 | 55 | $date_end = dol_mktime(23, 59, 59, GETPOST("date_endmonth"), GETPOST("date_endday"), GETPOST("date_endyear")); |
54 | 56 | // Set default period if not defined |
55 | -if (empty($date_start) || empty($date_end)) // We define date_start and date_end |
|
57 | +if (empty($date_start) || empty($date_end)) { |
|
58 | + // We define date_start and date_end |
|
56 | 59 | { |
57 | 60 | $q = GETPOST("q", "int"); |
61 | +} |
|
58 | 62 | if (empty($q)) |
59 | 63 | { |
60 | 64 | if (GETPOST("month", "int")) { $date_start = dol_get_first_day($year_start, GETPOST("month", "int"), false); $date_end = dol_get_last_day($year_start, GETPOST("month", "int"), false); } else { |
@@ -89,12 +93,18 @@ discard block |
||
89 | 93 | // Define modetax (0 or 1) |
90 | 94 | // 0=normal, 1=option vat for services is on debit, 2=option on payments for products |
91 | 95 | $modetax = $conf->global->TAX_MODE; |
92 | -if (GETPOSTISSET("modetax")) $modetax = GETPOST("modetax", 'int'); |
|
93 | -if (empty($modetax)) $modetax = 0; |
|
96 | +if (GETPOSTISSET("modetax")) { |
|
97 | + $modetax = GETPOST("modetax", 'int'); |
|
98 | +} |
|
99 | +if (empty($modetax)) { |
|
100 | + $modetax = 0; |
|
101 | +} |
|
94 | 102 | |
95 | 103 | // Security check |
96 | 104 | $socid = GETPOST('socid', 'int'); |
97 | -if ($user->socid) $socid = $user->socid; |
|
105 | +if ($user->socid) { |
|
106 | + $socid = $user->socid; |
|
107 | +} |
|
98 | 108 | $result = restrictedArea($user, 'tax', '', '', 'charges'); |
99 | 109 | |
100 | 110 | |
@@ -222,20 +232,36 @@ discard block |
||
222 | 232 | // Show report header |
223 | 233 | $name = $langs->trans("VATReportByMonth"); |
224 | 234 | $calcmode = ''; |
225 | -if ($modetax == 0) $calcmode = $langs->trans('OptionVATDefault'); |
|
226 | -if ($modetax == 1) $calcmode = $langs->trans('OptionVATDebitOption'); |
|
227 | -if ($modetax == 2) $calcmode = $langs->trans('OptionPaymentForProductAndServices'); |
|
235 | +if ($modetax == 0) { |
|
236 | + $calcmode = $langs->trans('OptionVATDefault'); |
|
237 | +} |
|
238 | +if ($modetax == 1) { |
|
239 | + $calcmode = $langs->trans('OptionVATDebitOption'); |
|
240 | +} |
|
241 | +if ($modetax == 2) { |
|
242 | + $calcmode = $langs->trans('OptionPaymentForProductAndServices'); |
|
243 | +} |
|
228 | 244 | $calcmode .= ' <span class="opacitymedium">('.$langs->trans("TaxModuleSetupToModifyRules", DOL_URL_ROOT.'/admin/taxes.php').')</span>'; |
229 | 245 | |
230 | 246 | $description .= $langs->trans("VATSummary").'<br>'; |
231 | -if ($conf->global->TAX_MODE_SELL_PRODUCT == 'invoice') $description .= $langs->trans("RulesVATDueProducts"); |
|
232 | -if ($conf->global->TAX_MODE_SELL_PRODUCT == 'payment') $description .= $langs->trans("RulesVATInProducts"); |
|
233 | -if ($conf->global->TAX_MODE_SELL_SERVICE == 'invoice') $description .= '<br>'.$langs->trans("RulesVATDueServices"); |
|
234 | -if ($conf->global->TAX_MODE_SELL_SERVICE == 'payment') $description .= '<br>'.$langs->trans("RulesVATInServices"); |
|
247 | +if ($conf->global->TAX_MODE_SELL_PRODUCT == 'invoice') { |
|
248 | + $description .= $langs->trans("RulesVATDueProducts"); |
|
249 | +} |
|
250 | +if ($conf->global->TAX_MODE_SELL_PRODUCT == 'payment') { |
|
251 | + $description .= $langs->trans("RulesVATInProducts"); |
|
252 | +} |
|
253 | +if ($conf->global->TAX_MODE_SELL_SERVICE == 'invoice') { |
|
254 | + $description .= '<br>'.$langs->trans("RulesVATDueServices"); |
|
255 | +} |
|
256 | +if ($conf->global->TAX_MODE_SELL_SERVICE == 'payment') { |
|
257 | + $description .= '<br>'.$langs->trans("RulesVATInServices"); |
|
258 | +} |
|
235 | 259 | if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { |
236 | 260 | $description .= '<br>'.$langs->trans("DepositsAreNotIncluded"); |
237 | 261 | } |
238 | -if (!empty($conf->global->MAIN_MODULE_ACCOUNTING)) $description .= '<br>'.$langs->trans("ThisIsAnEstimatedValue"); |
|
262 | +if (!empty($conf->global->MAIN_MODULE_ACCOUNTING)) { |
|
263 | + $description .= '<br>'.$langs->trans("ThisIsAnEstimatedValue"); |
|
264 | +} |
|
239 | 265 | |
240 | 266 | $period = $form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0); |
241 | 267 | |
@@ -277,11 +303,15 @@ discard block |
||
277 | 303 | $total = 0; $subtotalcoll = 0; $subtotalpaye = 0; $subtotal = 0; |
278 | 304 | $i = 0; $mcursor = 0; |
279 | 305 | |
280 | -while ((($y < $yend) || ($y == $yend && $m <= $mend)) && $mcursor < 1000) // $mcursor is to avoid too large loop |
|
306 | +while ((($y < $yend) || ($y == $yend && $m <= $mend)) && $mcursor < 1000) { |
|
307 | + // $mcursor is to avoid too large loop |
|
281 | 308 | { |
282 | 309 | //$m = $conf->global->SOCIETE_FISCAL_MONTH_START + ($mcursor % 12); |
283 | 310 | if ($m == 13) $y++; |
284 | - if ($m > 12) $m -= 12; |
|
311 | +} |
|
312 | + if ($m > 12) { |
|
313 | + $m -= 12; |
|
314 | + } |
|
285 | 315 | $mcursor++; |
286 | 316 | |
287 | 317 | $x_coll = tax_by_rate('vat', $db, $y, 0, 0, 0, $modetax, 'sell', $m); |