@@ -35,7 +35,9 @@ discard block |
||
35 | 35 | // Load translation files required by the page |
36 | 36 | $langs->loadLangs(array("admin", "members", "mailmanspip")); |
37 | 37 | |
38 | -if (!$user->admin) accessforbidden(); |
|
38 | +if (!$user->admin) { |
|
39 | + accessforbidden(); |
|
40 | +} |
|
39 | 41 | |
40 | 42 | |
41 | 43 | $type = array('yesno', 'texte', 'chaine'); |
@@ -59,7 +61,9 @@ discard block |
||
59 | 61 | $constnote = $_POST["constnote"][$key]; |
60 | 62 | $res = dolibarr_set_const($db, $constname, $constvalue, $type[$consttype], 0, $constnote, $conf->entity); |
61 | 63 | |
62 | - if (!$res > 0) $error++; |
|
64 | + if (!$res > 0) { |
|
65 | + $error++; |
|
66 | + } |
|
63 | 67 | } |
64 | 68 | |
65 | 69 | if (!$error) |
@@ -40,7 +40,9 @@ |
||
40 | 40 | |
41 | 41 | $rowid = GETPOST('rowid', 'alpha'); |
42 | 42 | |
43 | -if (!$user->admin) accessforbidden(); |
|
43 | +if (!$user->admin) { |
|
44 | + accessforbidden(); |
|
45 | +} |
|
44 | 46 | |
45 | 47 | $status = 1; |
46 | 48 |
@@ -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'); |