@@ -90,9 +90,14 @@ discard block |
||
90 | 90 | { |
91 | 91 | if ($currency->create($user) > 0) |
92 | 92 | { |
93 | - if ($currency->addRate($rate)) setEventMessages($langs->trans('RecordSaved'), array()); |
|
94 | - else setEventMessages($langs->trans('ErrorAddRateFail'), array(), 'errors'); |
|
95 | - } else setEventMessages($langs->trans('ErrorAddCurrencyFail'), $currency->errors, 'errors'); |
|
93 | + if ($currency->addRate($rate)) { |
|
94 | + setEventMessages($langs->trans('RecordSaved'), array()); |
|
95 | + } else { |
|
96 | + setEventMessages($langs->trans('ErrorAddRateFail'), array(), 'errors'); |
|
97 | + } |
|
98 | + } else { |
|
99 | + setEventMessages($langs->trans('ErrorAddCurrencyFail'), $currency->errors, 'errors'); |
|
100 | + } |
|
96 | 101 | } |
97 | 102 | } elseif ($action == 'update_currency') |
98 | 103 | { |
@@ -126,8 +131,11 @@ discard block |
||
126 | 131 | |
127 | 132 | if ($currency->fetch($fk_multicurrency) > 0) |
128 | 133 | { |
129 | - if ($currency->delete() > 0) setEventMessages($langs->trans('RecordDeleted'), array()); |
|
130 | - else setEventMessages($langs->trans('ErrorDeleteCurrencyFail'), array(), 'errors'); |
|
134 | + if ($currency->delete() > 0) { |
|
135 | + setEventMessages($langs->trans('RecordDeleted'), array()); |
|
136 | + } else { |
|
137 | + setEventMessages($langs->trans('ErrorDeleteCurrencyFail'), array(), 'errors'); |
|
138 | + } |
|
131 | 139 | } |
132 | 140 | } |
133 | 141 | } elseif ($action == 'setapilayer') |
@@ -330,7 +338,9 @@ discard block |
||
330 | 338 | |
331 | 339 | foreach ($TCurrency as &$currency) |
332 | 340 | { |
333 | - if ($currency->code == $conf->currency) continue; |
|
341 | + if ($currency->code == $conf->currency) { |
|
342 | + continue; |
|
343 | + } |
|
334 | 344 | |
335 | 345 | print '<tr class="oddeven">'; |
336 | 346 | print '<td>'.$currency->code.' - '.$currency->name.'</td>'; |
@@ -35,8 +35,9 @@ discard block |
||
35 | 35 | // Load translation files required by the page |
36 | 36 | $langs->loadLangs(array("admin", "errors")); |
37 | 37 | |
38 | -if (!$user->admin) |
|
38 | +if (!$user->admin) { |
|
39 | 39 | accessforbidden(); |
40 | +} |
|
40 | 41 | |
41 | 42 | $action = GETPOST('action', 'aZ09'); |
42 | 43 | |
@@ -50,29 +51,65 @@ discard block |
||
50 | 51 | |
51 | 52 | $db->begin(); |
52 | 53 | |
53 | - if (!dolibarr_set_const($db, 'LDAP_CONTACT_DN', GETPOST("contactdn"), 'chaine', 0, '', $conf->entity)) $error++; |
|
54 | - if (!dolibarr_set_const($db, 'LDAP_CONTACT_OBJECT_CLASS', GETPOST("objectclass"), 'chaine', 0, '', $conf->entity)) $error++; |
|
55 | - |
|
56 | - if (!dolibarr_set_const($db, 'LDAP_CONTACT_FIELD_FULLNAME', GETPOST("fieldfullname"), 'chaine', 0, '', $conf->entity)) $error++; |
|
57 | - if (!dolibarr_set_const($db, 'LDAP_CONTACT_FIELD_NAME', GETPOST("fieldname"), 'chaine', 0, '', $conf->entity)) $error++; |
|
58 | - if (!dolibarr_set_const($db, 'LDAP_CONTACT_FIELD_FIRSTNAME', GETPOST("fieldfirstname"), 'chaine', 0, '', $conf->entity)) $error++; |
|
59 | - if (!dolibarr_set_const($db, 'LDAP_CONTACT_FIELD_COMPANY', GETPOST("fieldcompany"), 'chaine', 0, '', $conf->entity)) $error++; |
|
60 | - if (!dolibarr_set_const($db, 'LDAP_CONTACT_FIELD_MAIL', GETPOST("fieldmail"), 'chaine', 0, '', $conf->entity)) $error++; |
|
61 | - if (!dolibarr_set_const($db, 'LDAP_CONTACT_FIELD_PHONE', GETPOST("fieldphone"), 'chaine', 0, '', $conf->entity)) $error++; |
|
62 | - if (!dolibarr_set_const($db, 'LDAP_CONTACT_FIELD_HOMEPHONE', GETPOST("fieldhomephone"), 'chaine', 0, '', $conf->entity)) $error++; |
|
63 | - if (!dolibarr_set_const($db, 'LDAP_CONTACT_FIELD_MOBILE', GETPOST("fieldmobile"), 'chaine', 0, '', $conf->entity)) $error++; |
|
64 | - if (!dolibarr_set_const($db, 'LDAP_CONTACT_FIELD_SKYPE', GETPOST("fieldskype"), 'chaine', 0, '', $conf->entity)) $error++; |
|
65 | - if (!dolibarr_set_const($db, 'LDAP_CONTACT_FIELD_FAX', GETPOST("fieldfax"), 'chaine', 0, '', $conf->entity)) $error++; |
|
66 | - if (!dolibarr_set_const($db, 'LDAP_CONTACT_FIELD_ADDRESS', GETPOST("fieldaddress"), 'chaine', 0, '', $conf->entity)) $error++; |
|
67 | - if (!dolibarr_set_const($db, 'LDAP_CONTACT_FIELD_ZIP', GETPOST("fieldzip"), 'chaine', 0, '', $conf->entity)) $error++; |
|
68 | - if (!dolibarr_set_const($db, 'LDAP_CONTACT_FIELD_TOWN', GETPOST("fieldtown"), 'chaine', 0, '', $conf->entity)) $error++; |
|
69 | - if (!dolibarr_set_const($db, 'LDAP_CONTACT_FIELD_COUNTRY', GETPOST("fieldcountry"), 'chaine', 0, '', $conf->entity)) $error++; |
|
54 | + if (!dolibarr_set_const($db, 'LDAP_CONTACT_DN', GETPOST("contactdn"), 'chaine', 0, '', $conf->entity)) { |
|
55 | + $error++; |
|
56 | + } |
|
57 | + if (!dolibarr_set_const($db, 'LDAP_CONTACT_OBJECT_CLASS', GETPOST("objectclass"), 'chaine', 0, '', $conf->entity)) { |
|
58 | + $error++; |
|
59 | + } |
|
60 | + |
|
61 | + if (!dolibarr_set_const($db, 'LDAP_CONTACT_FIELD_FULLNAME', GETPOST("fieldfullname"), 'chaine', 0, '', $conf->entity)) { |
|
62 | + $error++; |
|
63 | + } |
|
64 | + if (!dolibarr_set_const($db, 'LDAP_CONTACT_FIELD_NAME', GETPOST("fieldname"), 'chaine', 0, '', $conf->entity)) { |
|
65 | + $error++; |
|
66 | + } |
|
67 | + if (!dolibarr_set_const($db, 'LDAP_CONTACT_FIELD_FIRSTNAME', GETPOST("fieldfirstname"), 'chaine', 0, '', $conf->entity)) { |
|
68 | + $error++; |
|
69 | + } |
|
70 | + if (!dolibarr_set_const($db, 'LDAP_CONTACT_FIELD_COMPANY', GETPOST("fieldcompany"), 'chaine', 0, '', $conf->entity)) { |
|
71 | + $error++; |
|
72 | + } |
|
73 | + if (!dolibarr_set_const($db, 'LDAP_CONTACT_FIELD_MAIL', GETPOST("fieldmail"), 'chaine', 0, '', $conf->entity)) { |
|
74 | + $error++; |
|
75 | + } |
|
76 | + if (!dolibarr_set_const($db, 'LDAP_CONTACT_FIELD_PHONE', GETPOST("fieldphone"), 'chaine', 0, '', $conf->entity)) { |
|
77 | + $error++; |
|
78 | + } |
|
79 | + if (!dolibarr_set_const($db, 'LDAP_CONTACT_FIELD_HOMEPHONE', GETPOST("fieldhomephone"), 'chaine', 0, '', $conf->entity)) { |
|
80 | + $error++; |
|
81 | + } |
|
82 | + if (!dolibarr_set_const($db, 'LDAP_CONTACT_FIELD_MOBILE', GETPOST("fieldmobile"), 'chaine', 0, '', $conf->entity)) { |
|
83 | + $error++; |
|
84 | + } |
|
85 | + if (!dolibarr_set_const($db, 'LDAP_CONTACT_FIELD_SKYPE', GETPOST("fieldskype"), 'chaine', 0, '', $conf->entity)) { |
|
86 | + $error++; |
|
87 | + } |
|
88 | + if (!dolibarr_set_const($db, 'LDAP_CONTACT_FIELD_FAX', GETPOST("fieldfax"), 'chaine', 0, '', $conf->entity)) { |
|
89 | + $error++; |
|
90 | + } |
|
91 | + if (!dolibarr_set_const($db, 'LDAP_CONTACT_FIELD_ADDRESS', GETPOST("fieldaddress"), 'chaine', 0, '', $conf->entity)) { |
|
92 | + $error++; |
|
93 | + } |
|
94 | + if (!dolibarr_set_const($db, 'LDAP_CONTACT_FIELD_ZIP', GETPOST("fieldzip"), 'chaine', 0, '', $conf->entity)) { |
|
95 | + $error++; |
|
96 | + } |
|
97 | + if (!dolibarr_set_const($db, 'LDAP_CONTACT_FIELD_TOWN', GETPOST("fieldtown"), 'chaine', 0, '', $conf->entity)) { |
|
98 | + $error++; |
|
99 | + } |
|
100 | + if (!dolibarr_set_const($db, 'LDAP_CONTACT_FIELD_COUNTRY', GETPOST("fieldcountry"), 'chaine', 0, '', $conf->entity)) { |
|
101 | + $error++; |
|
102 | + } |
|
70 | 103 | |
71 | 104 | // This one must be after the others |
72 | 105 | $valkey = ''; |
73 | 106 | $key = GETPOST("key"); |
74 | - if ($key) $valkey = $conf->global->$key; |
|
75 | - if (!dolibarr_set_const($db, 'LDAP_KEY_CONTACTS', $valkey, 'chaine', 0, '', $conf->entity)) $error++; |
|
107 | + if ($key) { |
|
108 | + $valkey = $conf->global->$key; |
|
109 | + } |
|
110 | + if (!dolibarr_set_const($db, 'LDAP_KEY_CONTACTS', $valkey, 'chaine', 0, '', $conf->entity)) { |
|
111 | + $error++; |
|
112 | + } |
|
76 | 113 | |
77 | 114 | if (!$error) |
78 | 115 | { |
@@ -194,7 +194,9 @@ discard block |
||
194 | 194 | $arrayyears[$val['year']] = $val['year']; |
195 | 195 | } |
196 | 196 | } |
197 | -if (!count($arrayyears)) $arrayyears[$nowyear] = $nowyear; |
|
197 | +if (!count($arrayyears)) { |
|
198 | + $arrayyears[$nowyear] = $nowyear; |
|
199 | +} |
|
198 | 200 | |
199 | 201 | $h = 0; |
200 | 202 | $head = array(); |
@@ -231,8 +233,12 @@ discard block |
||
231 | 233 | print '</td></tr>'; |
232 | 234 | // Year |
233 | 235 | print '<tr><td class="left">'.$langs->trans("Year").'</td><td class="left">'; |
234 | - if (!in_array($year, $arrayyears)) $arrayyears[$year] = $year; |
|
235 | - if (!in_array($nowyear, $arrayyears)) $arrayyears[$nowyear] = $nowyear; |
|
236 | + if (!in_array($year, $arrayyears)) { |
|
237 | + $arrayyears[$year] = $year; |
|
238 | + } |
|
239 | + if (!in_array($nowyear, $arrayyears)) { |
|
240 | + $arrayyears[$nowyear] = $nowyear; |
|
241 | + } |
|
236 | 242 | arsort($arrayyears); |
237 | 243 | print $form->selectarray('year', $arrayyears, $year, 0); |
238 | 244 | print '</td></tr>'; |
@@ -270,8 +276,11 @@ discard block |
||
270 | 276 | |
271 | 277 | print '<tr class="oddeven" height="24">'; |
272 | 278 | print '<td class="center">'; |
273 | - if ($year) print '<a href="'.$_SERVER["PHP_SELF"].'?year='.$year.'">'.$year.'</a>'; |
|
274 | - else print $langs->trans("ValidationDateNotDefinedEvenIfReceptionValidated"); |
|
279 | + if ($year) { |
|
280 | + print '<a href="'.$_SERVER["PHP_SELF"].'?year='.$year.'">'.$year.'</a>'; |
|
281 | + } else { |
|
282 | + print $langs->trans("ValidationDateNotDefinedEvenIfReceptionValidated"); |
|
283 | + } |
|
275 | 284 | print '</td>'; |
276 | 285 | print '<td class="right">'.$val['nb'].'</td>'; |
277 | 286 | /*print '<td class="right">'.price(price2num($val['total'],'MT'),1).'</td>'; |
@@ -50,7 +50,9 @@ discard block |
||
50 | 50 | // Security check |
51 | 51 | $socid = 0; |
52 | 52 | //if ($user->socid > 0) $socid = $user->socid; // For external user, no check is done on company because readability is managed by public status of project and assignement. |
53 | -if (!$user->rights->projet->lire) accessforbidden(); |
|
53 | +if (!$user->rights->projet->lire) { |
|
54 | + accessforbidden(); |
|
55 | +} |
|
54 | 56 | |
55 | 57 | // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context |
56 | 58 | $hookmanager->initHooks(array('projectcard', 'globalcard')); |
@@ -67,7 +69,9 @@ discard block |
||
67 | 69 | $ret = $object->fetch($id, $ref); // If we create project, ref may be defined into POST but record does not yet exists into database |
68 | 70 | if ($ret > 0) { |
69 | 71 | $object->fetch_thirdparty(); |
70 | - if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($object, 'fetchComments') && empty($object->comments)) $object->fetchComments(); |
|
72 | + if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($object, 'fetchComments') && empty($object->comments)) { |
|
73 | + $object->fetchComments(); |
|
74 | + } |
|
71 | 75 | $id = $object->id; |
72 | 76 | } |
73 | 77 | } |
@@ -122,20 +126,27 @@ discard block |
||
122 | 126 | |
123 | 127 | // Visibility |
124 | 128 | print '<tr><td class="titlefield">'.$langs->trans("Visibility").'</td><td>'; |
125 | -if ($object->public) print $langs->trans('SharedProject'); |
|
126 | -else print $langs->trans('PrivateProject'); |
|
129 | +if ($object->public) { |
|
130 | + print $langs->trans('SharedProject'); |
|
131 | +} else { |
|
132 | + print $langs->trans('PrivateProject'); |
|
133 | +} |
|
127 | 134 | print '</td></tr>'; |
128 | 135 | |
129 | 136 | // Date start - end |
130 | 137 | print '<tr><td>'.$langs->trans("DateStart").' - '.$langs->trans("DateEnd").'</td><td>'; |
131 | 138 | print dol_print_date($object->date_start, 'day'); |
132 | 139 | $end = dol_print_date($object->date_end, 'day'); |
133 | -if ($end) print ' - '.$end; |
|
140 | +if ($end) { |
|
141 | + print ' - '.$end; |
|
142 | +} |
|
134 | 143 | print '</td></tr>'; |
135 | 144 | |
136 | 145 | // Budget |
137 | 146 | print '<tr><td>'.$langs->trans("Budget").'</td><td>'; |
138 | -if (strcmp($object->budget_amount, '')) print price($object->budget_amount, '', $langs, 1, 0, 0, $conf->currency); |
|
147 | +if (strcmp($object->budget_amount, '')) { |
|
148 | + print price($object->budget_amount, '', $langs, 1, 0, 0, $conf->currency); |
|
149 | +} |
|
139 | 150 | print '</td></tr>'; |
140 | 151 | |
141 | 152 | // Other attributes |
@@ -28,8 +28,9 @@ discard block |
||
28 | 28 | require_once DOL_DOCUMENT_ROOT.'/projet/class/taskstats.class.php'; |
29 | 29 | |
30 | 30 | // Security check |
31 | -if (!$user->rights->projet->lire) |
|
31 | +if (!$user->rights->projet->lire) { |
|
32 | 32 | accessforbidden(); |
33 | +} |
|
33 | 34 | |
34 | 35 | |
35 | 36 | $WIDTH = DolGraph::getDefaultGraphSizeForStats('width'); |
@@ -73,9 +74,15 @@ discard block |
||
73 | 74 | |
74 | 75 | |
75 | 76 | $stats_tasks = new TaskStats($db); |
76 | -if (!empty($userid) && $userid != -1) $stats_tasks->userid = $userid; |
|
77 | -if (!empty($socid) && $socid != -1) $stats_tasks->socid = $socid; |
|
78 | -if (!empty($year)) $stats_tasks->year = $year; |
|
77 | +if (!empty($userid) && $userid != -1) { |
|
78 | + $stats_tasks->userid = $userid; |
|
79 | +} |
|
80 | +if (!empty($socid) && $socid != -1) { |
|
81 | + $stats_tasks->socid = $socid; |
|
82 | +} |
|
83 | +if (!empty($year)) { |
|
84 | + $stats_tasks->year = $year; |
|
85 | +} |
|
79 | 86 | |
80 | 87 | |
81 | 88 | |
@@ -116,12 +123,16 @@ discard block |
||
116 | 123 | $stats_tasks->year = 0; |
117 | 124 | $data_all_year = $stats_tasks->getAllByYear(); |
118 | 125 | |
119 | -if (!empty($year)) $stats_tasks->year = $year; |
|
126 | +if (!empty($year)) { |
|
127 | + $stats_tasks->year = $year; |
|
128 | +} |
|
120 | 129 | $arrayyears = array(); |
121 | 130 | foreach ($data_all_year as $val) { |
122 | 131 | $arrayyears[$val['year']] = $val['year']; |
123 | 132 | } |
124 | -if (!count($arrayyears)) $arrayyears[$nowyear] = $nowyear; |
|
133 | +if (!count($arrayyears)) { |
|
134 | + $arrayyears[$nowyear] = $nowyear; |
|
135 | +} |
|
125 | 136 | |
126 | 137 | |
127 | 138 | $h = 0; |
@@ -154,8 +165,12 @@ discard block |
||
154 | 165 | print '</td></tr>';*/ |
155 | 166 | // Year |
156 | 167 | print '<tr><td>'.$langs->trans("Year").'</td><td>'; |
157 | -if (!in_array($year, $arrayyears)) $arrayyears[$year] = $year; |
|
158 | -if (!in_array($nowyear, $arrayyears)) $arrayyears[$nowyear] = $nowyear; |
|
168 | +if (!in_array($year, $arrayyears)) { |
|
169 | + $arrayyears[$year] = $year; |
|
170 | +} |
|
171 | +if (!in_array($nowyear, $arrayyears)) { |
|
172 | + $arrayyears[$nowyear] = $nowyear; |
|
173 | +} |
|
159 | 174 | arsort($arrayyears); |
160 | 175 | print $form->selectarray('year', $arrayyears, $year, 0); |
161 | 176 | print '</td></tr>'; |
@@ -175,7 +175,9 @@ |
||
175 | 175 | |
176 | 176 | $start_date = $task["task_start_date"]; |
177 | 177 | $end_date = $task["task_end_date"]; |
178 | - if (!$end_date) $end_date = $start_date; |
|
178 | + if (!$end_date) { |
|
179 | + $end_date = $start_date; |
|
180 | + } |
|
179 | 181 | $start_date = dol_print_date($start_date, $dateformatinput2); |
180 | 182 | $end_date = dol_print_date($end_date, $dateformatinput2); |
181 | 183 | // Resources |
@@ -59,8 +59,9 @@ discard block |
||
59 | 59 | $sql = "SELECT"; |
60 | 60 | $sql .= " COUNT(t.rowid), t.priority"; |
61 | 61 | $sql .= " FROM ".MAIN_DB_PREFIX."projet_task as t INNER JOIN ".MAIN_DB_PREFIX."projet as p ON p.rowid = t.fk_projet"; |
62 | - if (!$user->rights->societe->client->voir && !$user->soc_id) |
|
63 | - $sql .= " INNER JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON sc.fk_soc=t.fk_soc AND sc.fk_user=".$user->id; |
|
62 | + if (!$user->rights->societe->client->voir && !$user->soc_id) { |
|
63 | + $sql .= " INNER JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON sc.fk_soc=t.fk_soc AND sc.fk_user=".$user->id; |
|
64 | + } |
|
64 | 65 | $sql .= $this->buildWhere(); |
65 | 66 | //$sql .= " AND t.fk_statut <> 0"; // We want historic also, so all task not draft |
66 | 67 | $sql .= " GROUP BY t.priority"; |
@@ -82,14 +83,17 @@ discard block |
||
82 | 83 | $row[1], |
83 | 84 | $row[0] |
84 | 85 | ); |
85 | - } else $other += $row[1]; |
|
86 | + } else { |
|
87 | + $other += $row[1]; |
|
88 | + } |
|
86 | 89 | $i++; |
87 | 90 | } |
88 | - if ($num > $limit) |
|
89 | - $result[$i] = array( |
|
91 | + if ($num > $limit) { |
|
92 | + $result[$i] = array( |
|
90 | 93 | $langs->transnoentitiesnoconv("Other"), |
91 | 94 | $other |
92 | 95 | ); |
96 | + } |
|
93 | 97 | $this->db->free($resql); |
94 | 98 | } else { |
95 | 99 | $this->error = "Error ".$this->db->lasterror(); |
@@ -115,8 +119,9 @@ discard block |
||
115 | 119 | |
116 | 120 | $sql = "SELECT date_format(t.datec,'%Y') as year, COUNT(t.rowid) as nb"; |
117 | 121 | $sql .= " FROM ".MAIN_DB_PREFIX."projet_task as t INNER JOIN ".MAIN_DB_PREFIX."projet as p ON p.rowid = t.fk_projet"; |
118 | - if (!$user->rights->societe->client->voir && !$user->soc_id) |
|
119 | - $sql .= " INNER JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON sc.fk_soc=t.fk_soc AND sc.fk_user=".$user->id; |
|
122 | + if (!$user->rights->societe->client->voir && !$user->soc_id) { |
|
123 | + $sql .= " INNER JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON sc.fk_soc=t.fk_soc AND sc.fk_user=".$user->id; |
|
124 | + } |
|
120 | 125 | $sql .= $this->buildWhere(); |
121 | 126 | $sql .= " GROUP BY year"; |
122 | 127 | $sql .= $this->db->order('year', 'DESC'); |
@@ -137,18 +142,24 @@ discard block |
||
137 | 142 | |
138 | 143 | $sqlwhere[] = ' t.entity IN ('.getEntity('project').')'; |
139 | 144 | |
140 | - if (!empty($this->userid)) |
|
141 | - $sqlwhere[] = ' t.fk_user_resp='.$this->userid; |
|
145 | + if (!empty($this->userid)) { |
|
146 | + $sqlwhere[] = ' t.fk_user_resp='.$this->userid; |
|
147 | + } |
|
142 | 148 | // Forced filter on socid is similar to forced filter on project. TODO Use project assignement to allow to not use filter on project |
143 | - if (!empty($this->socid)) |
|
144 | - $sqlwhere[] = ' p.fk_soc='.$this->socid; // Link on thirdparty is on project, not on task |
|
145 | - if (!empty($this->year) && empty($this->yearmonth)) |
|
146 | - $sqlwhere[] = " date_format(t.datec,'%Y')='".$this->db->escape($this->year)."'"; |
|
147 | - if (!empty($this->yearmonth)) |
|
148 | - $sqlwhere[] = " t.datec BETWEEN '".$this->db->idate(dol_get_first_day($this->yearmonth))."' AND '".$this->db->idate(dol_get_last_day($this->yearmonth))."'"; |
|
149 | + if (!empty($this->socid)) { |
|
150 | + $sqlwhere[] = ' p.fk_soc='.$this->socid; |
|
151 | + } |
|
152 | + // Link on thirdparty is on project, not on task |
|
153 | + if (!empty($this->year) && empty($this->yearmonth)) { |
|
154 | + $sqlwhere[] = " date_format(t.datec,'%Y')='".$this->db->escape($this->year)."'"; |
|
155 | + } |
|
156 | + if (!empty($this->yearmonth)) { |
|
157 | + $sqlwhere[] = " t.datec BETWEEN '".$this->db->idate(dol_get_first_day($this->yearmonth))."' AND '".$this->db->idate(dol_get_last_day($this->yearmonth))."'"; |
|
158 | + } |
|
149 | 159 | |
150 | - if (!empty($this->status)) |
|
151 | - $sqlwhere[] = " t.priority IN (".$this->priority.")"; |
|
160 | + if (!empty($this->status)) { |
|
161 | + $sqlwhere[] = " t.priority IN (".$this->priority.")"; |
|
162 | + } |
|
152 | 163 | |
153 | 164 | if (count($sqlwhere) > 0) { |
154 | 165 | $sqlwhere_str = ' WHERE '.implode(' AND ', $sqlwhere); |
@@ -172,8 +183,9 @@ discard block |
||
172 | 183 | |
173 | 184 | $sql = "SELECT date_format(t.datec,'%m') as dm, COUNT(t.rowid) as nb"; |
174 | 185 | $sql .= " FROM ".MAIN_DB_PREFIX."projet_task as t INNER JOIN ".MAIN_DB_PREFIX."projet as p ON p.rowid = t.fk_projet"; |
175 | - if (!$user->rights->societe->client->voir && !$user->soc_id) |
|
176 | - $sql .= " INNER JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON sc.fk_soc=t.fk_soc AND sc.fk_user=".$user->id; |
|
186 | + if (!$user->rights->societe->client->voir && !$user->soc_id) { |
|
187 | + $sql .= " INNER JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON sc.fk_soc=t.fk_soc AND sc.fk_user=".$user->id; |
|
188 | + } |
|
177 | 189 | $sql .= $this->buildWhere(); |
178 | 190 | $sql .= " GROUP BY dm"; |
179 | 191 | $sql .= $this->db->order('dm', 'DESC'); |
@@ -92,14 +92,17 @@ discard block |
||
92 | 92 | $label.' ('.price(price2num($row[0], 'MT'), 1, $langs, 1, -1, -1, $conf->currency).')', |
93 | 93 | $row[0] |
94 | 94 | ); |
95 | - } else $other += $row[1]; |
|
95 | + } else { |
|
96 | + $other += $row[1]; |
|
97 | + } |
|
96 | 98 | $i++; |
97 | 99 | } |
98 | - if ($num > $limit) |
|
99 | - $result[$i] = array( |
|
100 | + if ($num > $limit) { |
|
101 | + $result[$i] = array( |
|
100 | 102 | $langs->transnoentitiesnoconv("Other"), |
101 | 103 | $other |
102 | 104 | ); |
105 | + } |
|
103 | 106 | $this->db->free($resql); |
104 | 107 | } else { |
105 | 108 | $this->error = "Error ".$this->db->lasterror(); |
@@ -156,25 +159,35 @@ discard block |
||
156 | 159 | // Get list of project id allowed to user (in a string list separated by coma) |
157 | 160 | $object = new Project($this->db); |
158 | 161 | $projectsListId = ''; |
159 | - if (!$user->rights->projet->all->lire) $projectsListId = $object->getProjectsAuthorizedForUser($user, 0, 1, $user->socid); |
|
162 | + if (!$user->rights->projet->all->lire) { |
|
163 | + $projectsListId = $object->getProjectsAuthorizedForUser($user, 0, 1, $user->socid); |
|
164 | + } |
|
160 | 165 | |
161 | 166 | $sqlwhere[] = ' t.entity IN ('.getEntity('project').')'; |
162 | 167 | |
163 | - if (!empty($this->userid)) |
|
164 | - $sqlwhere[] = ' t.fk_user_resp='.$this->userid; |
|
168 | + if (!empty($this->userid)) { |
|
169 | + $sqlwhere[] = ' t.fk_user_resp='.$this->userid; |
|
170 | + } |
|
165 | 171 | |
166 | 172 | // Forced filter on socid is similar to forced filter on project. TODO Use project assignement to allow to not use filter on project |
167 | - if (!empty($this->socid)) |
|
168 | - $sqlwhere[] = ' t.fk_soc='.$this->socid; |
|
169 | - if (!empty($this->year) && empty($this->yearmonth)) |
|
170 | - $sqlwhere[] = " date_format(t.datec,'%Y')='".$this->db->escape($this->year)."'"; |
|
171 | - if (!empty($this->yearmonth)) |
|
172 | - $sqlwhere[] = " t.datec BETWEEN '".$this->db->idate(dol_get_first_day($this->yearmonth))."' AND '".$this->db->idate(dol_get_last_day($this->yearmonth))."'"; |
|
173 | + if (!empty($this->socid)) { |
|
174 | + $sqlwhere[] = ' t.fk_soc='.$this->socid; |
|
175 | + } |
|
176 | + if (!empty($this->year) && empty($this->yearmonth)) { |
|
177 | + $sqlwhere[] = " date_format(t.datec,'%Y')='".$this->db->escape($this->year)."'"; |
|
178 | + } |
|
179 | + if (!empty($this->yearmonth)) { |
|
180 | + $sqlwhere[] = " t.datec BETWEEN '".$this->db->idate(dol_get_first_day($this->yearmonth))."' AND '".$this->db->idate(dol_get_last_day($this->yearmonth))."'"; |
|
181 | + } |
|
173 | 182 | |
174 | - if (!empty($this->status)) |
|
175 | - $sqlwhere[] = " t.fk_opp_status IN (".$this->status.")"; |
|
183 | + if (!empty($this->status)) { |
|
184 | + $sqlwhere[] = " t.fk_opp_status IN (".$this->status.")"; |
|
185 | + } |
|
176 | 186 | |
177 | - if (!$user->rights->projet->all->lire) $sqlwhere[] = " t.rowid IN (".$projectsListId.")"; // public and assigned to, or restricted to company for external users |
|
187 | + if (!$user->rights->projet->all->lire) { |
|
188 | + $sqlwhere[] = " t.rowid IN (".$projectsListId.")"; |
|
189 | + } |
|
190 | + // public and assigned to, or restricted to company for external users |
|
178 | 191 | |
179 | 192 | if (count($sqlwhere) > 0) { |
180 | 193 | $sqlwhere_str = ' WHERE '.implode(' AND ', $sqlwhere); |
@@ -254,7 +267,9 @@ discard block |
||
254 | 267 | { |
255 | 268 | global $conf, $user, $langs; |
256 | 269 | |
257 | - if ($startyear > $endyear) return -1; |
|
270 | + if ($startyear > $endyear) { |
|
271 | + return -1; |
|
272 | + } |
|
258 | 273 | |
259 | 274 | $datay = array(); |
260 | 275 | |
@@ -285,9 +300,11 @@ discard block |
||
285 | 300 | } |
286 | 301 | |
287 | 302 | // Load file into $data |
288 | - if ($foundintocache) // Cache file found and is not too old |
|
303 | + if ($foundintocache) { |
|
304 | + // Cache file found and is not too old |
|
289 | 305 | { |
290 | 306 | dol_syslog(get_class($this).'::'.__FUNCTION__." read data from cache file ".$newpathofdestfile." ".$filedate."."); |
307 | + } |
|
291 | 308 | $data = json_decode(file_get_contents($newpathofdestfile), true); |
292 | 309 | } else { |
293 | 310 | $year = $startyear; |
@@ -315,15 +332,21 @@ discard block |
||
315 | 332 | if (empty($foundintocache) && ($cachedelay > 0 || $cachedelay == -1)) |
316 | 333 | { |
317 | 334 | dol_syslog(get_class($this).'::'.__FUNCTION__." save cache file ".$newpathofdestfile." onto disk."); |
318 | - if (!dol_is_dir($conf->user->dir_temp)) dol_mkdir($conf->user->dir_temp); |
|
335 | + if (!dol_is_dir($conf->user->dir_temp)) { |
|
336 | + dol_mkdir($conf->user->dir_temp); |
|
337 | + } |
|
319 | 338 | $fp = fopen($newpathofdestfile, 'w'); |
320 | 339 | if ($fp) |
321 | 340 | { |
322 | 341 | fwrite($fp, json_encode($data)); |
323 | 342 | fclose($fp); |
324 | - if (!empty($conf->global->MAIN_UMASK)) $newmask = $conf->global->MAIN_UMASK; |
|
343 | + if (!empty($conf->global->MAIN_UMASK)) { |
|
344 | + $newmask = $conf->global->MAIN_UMASK; |
|
345 | + } |
|
325 | 346 | @chmod($newpathofdestfile, octdec($newmask)); |
326 | - } else dol_syslog("Failed to write cache file", LOG_ERR); |
|
347 | + } else { |
|
348 | + dol_syslog("Failed to write cache file", LOG_ERR); |
|
349 | + } |
|
327 | 350 | $this->lastfetchdate[get_class($this).'_'.__FUNCTION__] = $nowgmt; |
328 | 351 | } |
329 | 352 | |
@@ -371,7 +394,9 @@ discard block |
||
371 | 394 | { |
372 | 395 | global $conf, $user, $langs; |
373 | 396 | |
374 | - if ($startyear > $endyear) return -1; |
|
397 | + if ($startyear > $endyear) { |
|
398 | + return -1; |
|
399 | + } |
|
375 | 400 | |
376 | 401 | $datay = array(); |
377 | 402 | |
@@ -400,9 +425,11 @@ discard block |
||
400 | 425 | } |
401 | 426 | |
402 | 427 | // Load file into $data |
403 | - if ($foundintocache) // Cache file found and is not too old |
|
428 | + if ($foundintocache) { |
|
429 | + // Cache file found and is not too old |
|
404 | 430 | { |
405 | 431 | dol_syslog(get_class($this).'::'.__FUNCTION__." read data from cache file ".$newpathofdestfile." ".$filedate."."); |
432 | + } |
|
406 | 433 | $data = json_decode(file_get_contents($newpathofdestfile), true); |
407 | 434 | } else { |
408 | 435 | $year = $startyear; |
@@ -426,13 +453,15 @@ discard block |
||
426 | 453 | // Save cache file |
427 | 454 | if (empty($foundintocache) && ($cachedelay > 0 || $cachedelay == - 1)) { |
428 | 455 | dol_syslog(get_class($this).'::'.__FUNCTION__." save cache file ".$newpathofdestfile." onto disk."); |
429 | - if (!dol_is_dir($conf->user->dir_temp)) |
|
430 | - dol_mkdir($conf->user->dir_temp); |
|
456 | + if (!dol_is_dir($conf->user->dir_temp)) { |
|
457 | + dol_mkdir($conf->user->dir_temp); |
|
458 | + } |
|
431 | 459 | $fp = fopen($newpathofdestfile, 'w'); |
432 | 460 | fwrite($fp, json_encode($data)); |
433 | 461 | fclose($fp); |
434 | - if (!empty($conf->global->MAIN_UMASK)) |
|
435 | - $newmask = $conf->global->MAIN_UMASK; |
|
462 | + if (!empty($conf->global->MAIN_UMASK)) { |
|
463 | + $newmask = $conf->global->MAIN_UMASK; |
|
464 | + } |
|
436 | 465 | @chmod($newpathofdestfile, octdec($newmask)); |
437 | 466 | |
438 | 467 | $this->lastfetchdate[get_class($this).'_'.__FUNCTION__] = $nowgmt; |
@@ -28,8 +28,9 @@ discard block |
||
28 | 28 | require_once DOL_DOCUMENT_ROOT.'/projet/class/projectstats.class.php'; |
29 | 29 | |
30 | 30 | // Security check |
31 | -if (!$user->rights->projet->lire) |
|
31 | +if (!$user->rights->projet->lire) { |
|
32 | 32 | accessforbidden(); |
33 | +} |
|
33 | 34 | |
34 | 35 | |
35 | 36 | $WIDTH = DolGraph::getDefaultGraphSizeForStats('width'); |
@@ -73,9 +74,15 @@ discard block |
||
73 | 74 | |
74 | 75 | |
75 | 76 | $stats_project = new ProjectStats($db); |
76 | -if (!empty($userid) && $userid != -1) $stats_project->userid = $userid; |
|
77 | -if (!empty($socid) && $socid != -1) $stats_project->socid = $socid; |
|
78 | -if (!empty($year)) $stats_project->year = $year; |
|
77 | +if (!empty($userid) && $userid != -1) { |
|
78 | + $stats_project->userid = $userid; |
|
79 | +} |
|
80 | +if (!empty($socid) && $socid != -1) { |
|
81 | + $stats_project->socid = $socid; |
|
82 | +} |
|
83 | +if (!empty($year)) { |
|
84 | + $stats_project->year = $year; |
|
85 | +} |
|
79 | 86 | |
80 | 87 | /* |
81 | 88 | if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) |
@@ -251,12 +258,16 @@ discard block |
||
251 | 258 | $stats_project->year = 0; |
252 | 259 | $data_all_year = $stats_project->getAllByYear(); |
253 | 260 | |
254 | -if (!empty($year)) $stats_project->year = $year; |
|
261 | +if (!empty($year)) { |
|
262 | + $stats_project->year = $year; |
|
263 | +} |
|
255 | 264 | $arrayyears = array(); |
256 | 265 | foreach ($data_all_year as $val) { |
257 | 266 | $arrayyears[$val['year']] = $val['year']; |
258 | 267 | } |
259 | -if (!count($arrayyears)) $arrayyears[$nowyear] = $nowyear; |
|
268 | +if (!count($arrayyears)) { |
|
269 | + $arrayyears[$nowyear] = $nowyear; |
|
270 | +} |
|
260 | 271 | |
261 | 272 | |
262 | 273 | $h = 0; |
@@ -288,8 +299,12 @@ discard block |
||
288 | 299 | print '</td></tr>';*/ |
289 | 300 | // Year |
290 | 301 | print '<tr><td>'.$langs->trans("Year").'</td><td>'; |
291 | -if (!in_array($year, $arrayyears)) $arrayyears[$year] = $year; |
|
292 | -if (!in_array($nowyear, $arrayyears)) $arrayyears[$nowyear] = $nowyear; |
|
302 | +if (!in_array($year, $arrayyears)) { |
|
303 | + $arrayyears[$year] = $year; |
|
304 | +} |
|
305 | +if (!in_array($nowyear, $arrayyears)) { |
|
306 | + $arrayyears[$nowyear] = $nowyear; |
|
307 | +} |
|
293 | 308 | arsort($arrayyears); |
294 | 309 | print $form->selectarray('year', $arrayyears, $year, 0); |
295 | 310 | print '</td></tr>'; |