@@ -44,16 +44,16 @@ discard block |
||
| 44 | 44 | $head[$h][2] = 'project'; |
| 45 | 45 | $h++; |
| 46 | 46 | |
| 47 | - $nbContact = count($object->liste_contact(-1,'internal')) + count($object->liste_contact(-1,'external')); |
|
| 47 | + $nbContact = count($object->liste_contact(-1, 'internal')) + count($object->liste_contact(-1, 'external')); |
|
| 48 | 48 | $head[$h][0] = DOL_URL_ROOT.'/projet/contact.php?id='.$object->id; |
| 49 | 49 | $head[$h][1] = $langs->trans("ProjectContact"); |
| 50 | - if ($nbContact > 0) $head[$h][1].= ' <span class="badge">'.$nbContact.'</span>'; |
|
| 50 | + if ($nbContact > 0) $head[$h][1] .= ' <span class="badge">'.$nbContact.'</span>'; |
|
| 51 | 51 | $head[$h][2] = 'contact'; |
| 52 | 52 | $h++; |
| 53 | 53 | |
| 54 | - if (! empty($conf->fournisseur->enabled) || ! empty($conf->propal->enabled) || ! empty($conf->commande->enabled) |
|
| 55 | - || ! empty($conf->facture->enabled) || ! empty($conf->contrat->enabled) |
|
| 56 | - || ! empty($conf->ficheinter->enabled) || ! empty($conf->agenda->enabled) || ! empty($conf->deplacement->enabled)) |
|
| 54 | + if (!empty($conf->fournisseur->enabled) || !empty($conf->propal->enabled) || !empty($conf->commande->enabled) |
|
| 55 | + || !empty($conf->facture->enabled) || !empty($conf->contrat->enabled) |
|
| 56 | + || !empty($conf->ficheinter->enabled) || !empty($conf->agenda->enabled) || !empty($conf->deplacement->enabled)) |
|
| 57 | 57 | { |
| 58 | 58 | $head[$h][0] = DOL_URL_ROOT.'/projet/element.php?id='.$object->id; |
| 59 | 59 | $head[$h][1] = $langs->trans("ProjectOverview"); |
@@ -65,29 +65,29 @@ discard block |
||
| 65 | 65 | // Entries must be declared in modules descriptor with line |
| 66 | 66 | // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab |
| 67 | 67 | // $this->tabs = array('entity:-tabname); to remove a tab |
| 68 | - complete_head_from_modules($conf,$langs,$object,$head,$h,'project'); |
|
| 68 | + complete_head_from_modules($conf, $langs, $object, $head, $h, 'project'); |
|
| 69 | 69 | |
| 70 | 70 | |
| 71 | 71 | if (empty($conf->global->MAIN_DISABLE_NOTES_TAB)) |
| 72 | 72 | { |
| 73 | 73 | $nbNote = 0; |
| 74 | - if(!empty($object->note_private)) $nbNote++; |
|
| 75 | - if(!empty($object->note_public)) $nbNote++; |
|
| 74 | + if (!empty($object->note_private)) $nbNote++; |
|
| 75 | + if (!empty($object->note_public)) $nbNote++; |
|
| 76 | 76 | $head[$h][0] = DOL_URL_ROOT.'/projet/note.php?id='.$object->id; |
| 77 | 77 | $head[$h][1] = $langs->trans('Notes'); |
| 78 | - if ($nbNote > 0) $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>'; |
|
| 78 | + if ($nbNote > 0) $head[$h][1] .= ' <span class="badge">'.$nbNote.'</span>'; |
|
| 79 | 79 | $head[$h][2] = 'notes'; |
| 80 | 80 | $h++; |
| 81 | 81 | } |
| 82 | 82 | |
| 83 | 83 | require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; |
| 84 | 84 | require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php'; |
| 85 | - $upload_dir = $conf->projet->dir_output . "/" . dol_sanitizeFileName($object->ref); |
|
| 86 | - $nbFiles = count(dol_dir_list($upload_dir,'files',0,'','(\.meta|_preview.*\.png)$')); |
|
| 87 | - $nbLinks=Link::count($db, $object->element, $object->id); |
|
| 85 | + $upload_dir = $conf->projet->dir_output."/".dol_sanitizeFileName($object->ref); |
|
| 86 | + $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$')); |
|
| 87 | + $nbLinks = Link::count($db, $object->element, $object->id); |
|
| 88 | 88 | $head[$h][0] = DOL_URL_ROOT.'/projet/document.php?id='.$object->id; |
| 89 | 89 | $head[$h][1] = $langs->trans('Documents'); |
| 90 | - if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>'; |
|
| 90 | + if (($nbFiles + $nbLinks) > 0) $head[$h][1] .= ' <span class="badge">'.($nbFiles + $nbLinks).'</span>'; |
|
| 91 | 91 | $head[$h][2] = 'document'; |
| 92 | 92 | $h++; |
| 93 | 93 | |
@@ -98,9 +98,9 @@ discard block |
||
| 98 | 98 | $head[$h][1] = $langs->trans("Tasks"); |
| 99 | 99 | |
| 100 | 100 | require_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php'; |
| 101 | - $taskstatic=new Task($db); |
|
| 102 | - $nbTasks=count($taskstatic->getTasksArray(0, 0, $object->id, 0, 0)); |
|
| 103 | - if ($nbTasks > 0) $head[$h][1].= ' <span class="badge">'.($nbTasks).'</span>'; |
|
| 101 | + $taskstatic = new Task($db); |
|
| 102 | + $nbTasks = count($taskstatic->getTasksArray(0, 0, $object->id, 0, 0)); |
|
| 103 | + if ($nbTasks > 0) $head[$h][1] .= ' <span class="badge">'.($nbTasks).'</span>'; |
|
| 104 | 104 | $head[$h][2] = 'tasks'; |
| 105 | 105 | $h++; |
| 106 | 106 | |
@@ -117,22 +117,22 @@ discard block |
||
| 117 | 117 | $nbComments = $object->getNbComments(); |
| 118 | 118 | $head[$h][0] = DOL_URL_ROOT.'/projet/comment.php?id='.$object->id; |
| 119 | 119 | $head[$h][1] = $langs->trans("CommentLink"); |
| 120 | - if ($nbComments > 0) $head[$h][1].= ' <span class="badge">'.$nbComments.'</span>'; |
|
| 120 | + if ($nbComments > 0) $head[$h][1] .= ' <span class="badge">'.$nbComments.'</span>'; |
|
| 121 | 121 | $head[$h][2] = 'project_comment'; |
| 122 | 122 | $h++; |
| 123 | 123 | } |
| 124 | 124 | |
| 125 | 125 | $head[$h][0] = DOL_URL_ROOT.'/projet/info.php?id='.$object->id; |
| 126 | - $head[$h][1].= $langs->trans("Events"); |
|
| 127 | - if (! empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read) )) |
|
| 126 | + $head[$h][1] .= $langs->trans("Events"); |
|
| 127 | + if (!empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read))) |
|
| 128 | 128 | { |
| 129 | - $head[$h][1].= '/'; |
|
| 130 | - $head[$h][1].= $langs->trans("Agenda"); |
|
| 129 | + $head[$h][1] .= '/'; |
|
| 130 | + $head[$h][1] .= $langs->trans("Agenda"); |
|
| 131 | 131 | } |
| 132 | 132 | $head[$h][2] = 'agenda'; |
| 133 | 133 | $h++; |
| 134 | 134 | |
| 135 | - complete_head_from_modules($conf,$langs,$object,$head,$h,'project','remove'); |
|
| 135 | + complete_head_from_modules($conf, $langs, $object, $head, $h, 'project', 'remove'); |
|
| 136 | 136 | |
| 137 | 137 | return $head; |
| 138 | 138 | } |
@@ -150,20 +150,20 @@ discard block |
||
| 150 | 150 | $h = 0; |
| 151 | 151 | $head = array(); |
| 152 | 152 | |
| 153 | - $head[$h][0] = DOL_URL_ROOT.'/projet/tasks/task.php?id='.$object->id.(GETPOST('withproject')?'&withproject=1':''); |
|
| 153 | + $head[$h][0] = DOL_URL_ROOT.'/projet/tasks/task.php?id='.$object->id.(GETPOST('withproject') ? '&withproject=1' : ''); |
|
| 154 | 154 | $head[$h][1] = $langs->trans("Card"); |
| 155 | 155 | $head[$h][2] = 'task_task'; |
| 156 | 156 | $h++; |
| 157 | 157 | |
| 158 | - $nbContact = count($object->liste_contact(-1,'internal')) + count($object->liste_contact(-1,'external')); |
|
| 159 | - $head[$h][0] = DOL_URL_ROOT.'/projet/tasks/contact.php?id='.$object->id.(GETPOST('withproject')?'&withproject=1':''); |
|
| 158 | + $nbContact = count($object->liste_contact(-1, 'internal')) + count($object->liste_contact(-1, 'external')); |
|
| 159 | + $head[$h][0] = DOL_URL_ROOT.'/projet/tasks/contact.php?id='.$object->id.(GETPOST('withproject') ? '&withproject=1' : ''); |
|
| 160 | 160 | $head[$h][1] = $langs->trans("TaskRessourceLinks"); |
| 161 | - if ($nbContact > 0) $head[$h][1].= ' <span class="badge">'.$nbContact.'</span>'; |
|
| 161 | + if ($nbContact > 0) $head[$h][1] .= ' <span class="badge">'.$nbContact.'</span>'; |
|
| 162 | 162 | $head[$h][2] = 'task_contact'; |
| 163 | 163 | $h++; |
| 164 | 164 | |
| 165 | 165 | // Is there timespent ? |
| 166 | - $nbTimeSpent=0; |
|
| 166 | + $nbTimeSpent = 0; |
|
| 167 | 167 | $sql = "SELECT t.rowid"; |
| 168 | 168 | $sql .= " FROM ".MAIN_DB_PREFIX."projet_task_time as t, ".MAIN_DB_PREFIX."projet_task as pt, ".MAIN_DB_PREFIX."user as u"; |
| 169 | 169 | $sql .= " WHERE t.fk_user = u.rowid AND t.fk_task = pt.rowid"; |
@@ -172,13 +172,13 @@ discard block |
||
| 172 | 172 | if ($resql) |
| 173 | 173 | { |
| 174 | 174 | $obj = $db->fetch_object($resql); |
| 175 | - if ($obj) $nbTimeSpent=1; |
|
| 175 | + if ($obj) $nbTimeSpent = 1; |
|
| 176 | 176 | } |
| 177 | 177 | else dol_print_error($db); |
| 178 | 178 | |
| 179 | - $head[$h][0] = DOL_URL_ROOT.'/projet/tasks/time.php?id='.$object->id.(GETPOST('withproject')?'&withproject=1':''); |
|
| 179 | + $head[$h][0] = DOL_URL_ROOT.'/projet/tasks/time.php?id='.$object->id.(GETPOST('withproject') ? '&withproject=1' : ''); |
|
| 180 | 180 | $head[$h][1] = $langs->trans("TimeSpent"); |
| 181 | - if ($nbTimeSpent > 0) $head[$h][1].= ' <span class="badge">...</span>'; |
|
| 181 | + if ($nbTimeSpent > 0) $head[$h][1] .= ' <span class="badge">...</span>'; |
|
| 182 | 182 | $head[$h][2] = 'task_time'; |
| 183 | 183 | $h++; |
| 184 | 184 | |
@@ -186,28 +186,28 @@ discard block |
||
| 186 | 186 | // Entries must be declared in modules descriptor with line |
| 187 | 187 | // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab |
| 188 | 188 | // $this->tabs = array('entity:-tabname); to remove a tab |
| 189 | - complete_head_from_modules($conf,$langs,$object,$head,$h,'task'); |
|
| 189 | + complete_head_from_modules($conf, $langs, $object, $head, $h, 'task'); |
|
| 190 | 190 | |
| 191 | 191 | if (empty($conf->global->MAIN_DISABLE_NOTES_TAB)) |
| 192 | 192 | { |
| 193 | 193 | $nbNote = 0; |
| 194 | - if(!empty($object->note_private)) $nbNote++; |
|
| 195 | - if(!empty($object->note_public)) $nbNote++; |
|
| 196 | - $head[$h][0] = DOL_URL_ROOT.'/projet/tasks/note.php?id='.$object->id.(GETPOST('withproject')?'&withproject=1':''); |
|
| 194 | + if (!empty($object->note_private)) $nbNote++; |
|
| 195 | + if (!empty($object->note_public)) $nbNote++; |
|
| 196 | + $head[$h][0] = DOL_URL_ROOT.'/projet/tasks/note.php?id='.$object->id.(GETPOST('withproject') ? '&withproject=1' : ''); |
|
| 197 | 197 | $head[$h][1] = $langs->trans('Notes'); |
| 198 | - if ($nbNote > 0) $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>'; |
|
| 198 | + if ($nbNote > 0) $head[$h][1] .= ' <span class="badge">'.$nbNote.'</span>'; |
|
| 199 | 199 | $head[$h][2] = 'task_notes'; |
| 200 | 200 | $h++; |
| 201 | 201 | } |
| 202 | 202 | |
| 203 | - $head[$h][0] = DOL_URL_ROOT.'/projet/tasks/document.php?id='.$object->id.(GETPOST('withproject')?'&withproject=1':''); |
|
| 204 | - $filesdir = $conf->projet->dir_output . "/" . dol_sanitizeFileName($object->project->ref) . '/' .dol_sanitizeFileName($object->ref); |
|
| 203 | + $head[$h][0] = DOL_URL_ROOT.'/projet/tasks/document.php?id='.$object->id.(GETPOST('withproject') ? '&withproject=1' : ''); |
|
| 204 | + $filesdir = $conf->projet->dir_output."/".dol_sanitizeFileName($object->project->ref).'/'.dol_sanitizeFileName($object->ref); |
|
| 205 | 205 | include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; |
| 206 | 206 | include_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php'; |
| 207 | - $nbFiles = count(dol_dir_list($filesdir,'files',0,'','(\.meta|_preview.*\.png)$')); |
|
| 208 | - $nbLinks=Link::count($db, $object->element, $object->id); |
|
| 207 | + $nbFiles = count(dol_dir_list($filesdir, 'files', 0, '', '(\.meta|_preview.*\.png)$')); |
|
| 208 | + $nbLinks = Link::count($db, $object->element, $object->id); |
|
| 209 | 209 | $head[$h][1] = $langs->trans('Documents'); |
| 210 | - if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>'; |
|
| 210 | + if (($nbFiles + $nbLinks) > 0) $head[$h][1] .= ' <span class="badge">'.($nbFiles + $nbLinks).'</span>'; |
|
| 211 | 211 | $head[$h][2] = 'task_document'; |
| 212 | 212 | $h++; |
| 213 | 213 | |
@@ -215,14 +215,14 @@ discard block |
||
| 215 | 215 | if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_TASK)) |
| 216 | 216 | { |
| 217 | 217 | $nbComments = $object->getNbComments(); |
| 218 | - $head[$h][0] = DOL_URL_ROOT.'/projet/tasks/comment.php?id='.$object->id.(GETPOST('withproject')?'&withproject=1':''); |
|
| 218 | + $head[$h][0] = DOL_URL_ROOT.'/projet/tasks/comment.php?id='.$object->id.(GETPOST('withproject') ? '&withproject=1' : ''); |
|
| 219 | 219 | $head[$h][1] = $langs->trans("CommentLink"); |
| 220 | - if ($nbComments > 0) $head[$h][1].= ' <span class="badge">'.$nbComments.'</span>'; |
|
| 220 | + if ($nbComments > 0) $head[$h][1] .= ' <span class="badge">'.$nbComments.'</span>'; |
|
| 221 | 221 | $head[$h][2] = 'task_comment'; |
| 222 | 222 | $h++; |
| 223 | 223 | } |
| 224 | 224 | |
| 225 | - complete_head_from_modules($conf,$langs,$object,$head,$h,'task','remove'); |
|
| 225 | + complete_head_from_modules($conf, $langs, $object, $head, $h, 'task', 'remove'); |
|
| 226 | 226 | |
| 227 | 227 | return $head; |
| 228 | 228 | } |
@@ -234,7 +234,7 @@ discard block |
||
| 234 | 234 | * @param string $fuser Filter on user |
| 235 | 235 | * @return array Array of tabs to show |
| 236 | 236 | */ |
| 237 | -function project_timesheet_prepare_head($mode, $fuser=null) |
|
| 237 | +function project_timesheet_prepare_head($mode, $fuser = null) |
|
| 238 | 238 | { |
| 239 | 239 | global $langs, $conf, $user; |
| 240 | 240 | $h = 0; |
@@ -242,13 +242,13 @@ discard block |
||
| 242 | 242 | |
| 243 | 243 | $h = 0; |
| 244 | 244 | |
| 245 | - $param=''; |
|
| 246 | - $param.=($mode?'&mode='.$mode:''); |
|
| 247 | - if (is_object($fuser) && $fuser->id > 0 && $fuser->id != $user->id) $param.='&search_usertoprocessid='.$fuser->id; |
|
| 245 | + $param = ''; |
|
| 246 | + $param .= ($mode ? '&mode='.$mode : ''); |
|
| 247 | + if (is_object($fuser) && $fuser->id > 0 && $fuser->id != $user->id) $param .= '&search_usertoprocessid='.$fuser->id; |
|
| 248 | 248 | |
| 249 | 249 | if (empty($conf->global->PROJECT_DISABLE_TIMESHEET_PERWEEK)) |
| 250 | 250 | { |
| 251 | - $head[$h][0] = DOL_URL_ROOT."/projet/activity/perweek.php".($param?'?'.$param:''); |
|
| 251 | + $head[$h][0] = DOL_URL_ROOT."/projet/activity/perweek.php".($param ? '?'.$param : ''); |
|
| 252 | 252 | $head[$h][1] = $langs->trans("InputPerWeek"); |
| 253 | 253 | $head[$h][2] = 'inputperweek'; |
| 254 | 254 | $h++; |
@@ -256,7 +256,7 @@ discard block |
||
| 256 | 256 | |
| 257 | 257 | if (empty($conf->global->PROJECT_DISABLE_TIMESHEET_PERTIME)) |
| 258 | 258 | { |
| 259 | - $head[$h][0] = DOL_URL_ROOT."/projet/activity/perday.php".($param?'?'.$param:''); |
|
| 259 | + $head[$h][0] = DOL_URL_ROOT."/projet/activity/perday.php".($param ? '?'.$param : ''); |
|
| 260 | 260 | $head[$h][1] = $langs->trans("InputPerDay"); |
| 261 | 261 | $head[$h][2] = 'inputperday'; |
| 262 | 262 | $h++; |
@@ -270,9 +270,9 @@ discard block |
||
| 270 | 270 | $h++; |
| 271 | 271 | }*/ |
| 272 | 272 | |
| 273 | - complete_head_from_modules($conf,$langs,null,$head,$h,'project_timesheet'); |
|
| 273 | + complete_head_from_modules($conf, $langs, null, $head, $h, 'project_timesheet'); |
|
| 274 | 274 | |
| 275 | - complete_head_from_modules($conf,$langs,null,$head,$h,'project_timesheet','remove'); |
|
| 275 | + complete_head_from_modules($conf, $langs, null, $head, $h, 'project_timesheet', 'remove'); |
|
| 276 | 276 | |
| 277 | 277 | return $head; |
| 278 | 278 | } |
@@ -296,7 +296,7 @@ discard block |
||
| 296 | 296 | $head[$h][2] = 'project'; |
| 297 | 297 | $h++; |
| 298 | 298 | |
| 299 | - complete_head_from_modules($conf,$langs,null,$head,$h,'project_admin'); |
|
| 299 | + complete_head_from_modules($conf, $langs, null, $head, $h, 'project_admin'); |
|
| 300 | 300 | |
| 301 | 301 | $head[$h][0] = DOL_URL_ROOT."/projet/admin/project_extrafields.php"; |
| 302 | 302 | $head[$h][1] = $langs->trans("ExtraFieldsProject"); |
@@ -308,7 +308,7 @@ discard block |
||
| 308 | 308 | $head[$h][2] = 'attributes_task'; |
| 309 | 309 | $h++; |
| 310 | 310 | |
| 311 | - complete_head_from_modules($conf,$langs,null,$head,$h,'project_admin','remove'); |
|
| 311 | + complete_head_from_modules($conf, $langs, null, $head, $h, 'project_admin', 'remove'); |
|
| 312 | 312 | |
| 313 | 313 | return $head; |
| 314 | 314 | } |
@@ -329,29 +329,29 @@ discard block |
||
| 329 | 329 | * @param int $projectidfortotallink 0 or Id of project to use on total line (link to see all time consumed for project) |
| 330 | 330 | * @return void |
| 331 | 331 | */ |
| 332 | -function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$taskrole, $projectsListId='', $addordertick=0, $projectidfortotallink=0) |
|
| 332 | +function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$taskrole, $projectsListId = '', $addordertick = 0, $projectidfortotallink = 0) |
|
| 333 | 333 | { |
| 334 | 334 | global $user, $bc, $langs, $conf; |
| 335 | 335 | global $projectstatic, $taskstatic; |
| 336 | 336 | |
| 337 | - $lastprojectid=0; |
|
| 337 | + $lastprojectid = 0; |
|
| 338 | 338 | |
| 339 | - $projectsArrayId=explode(',',$projectsListId); |
|
| 339 | + $projectsArrayId = explode(',', $projectsListId); |
|
| 340 | 340 | |
| 341 | - $numlines=count($lines); |
|
| 341 | + $numlines = count($lines); |
|
| 342 | 342 | |
| 343 | 343 | // We declare counter as global because we want to edit them into recursive call |
| 344 | - global $total_projectlinesa_spent,$total_projectlinesa_planned,$total_projectlinesa_spent_if_planned; |
|
| 344 | + global $total_projectlinesa_spent, $total_projectlinesa_planned, $total_projectlinesa_spent_if_planned; |
|
| 345 | 345 | if ($level == 0) |
| 346 | 346 | { |
| 347 | - $total_projectlinesa_spent=0; |
|
| 348 | - $total_projectlinesa_planned=0; |
|
| 349 | - $total_projectlinesa_spent_if_planned=0; |
|
| 347 | + $total_projectlinesa_spent = 0; |
|
| 348 | + $total_projectlinesa_planned = 0; |
|
| 349 | + $total_projectlinesa_spent_if_planned = 0; |
|
| 350 | 350 | } |
| 351 | 351 | |
| 352 | - for ($i = 0 ; $i < $numlines ; $i++) |
|
| 352 | + for ($i = 0; $i < $numlines; $i++) |
|
| 353 | 353 | { |
| 354 | - if ($parent == 0 && $level >= 0) $level = 0; // if $level = -1, we dont' use sublevel recursion, we show all lines |
|
| 354 | + if ($parent == 0 && $level >= 0) $level = 0; // if $level = -1, we dont' use sublevel recursion, we show all lines |
|
| 355 | 355 | |
| 356 | 356 | // Process line |
| 357 | 357 | // print "i:".$i."-".$lines[$i]->fk_project.'<br>'; |
@@ -359,26 +359,26 @@ discard block |
||
| 359 | 359 | if ($lines[$i]->fk_parent == $parent || $level < 0) // if $level = -1, we dont' use sublevel recursion, we show all lines |
| 360 | 360 | { |
| 361 | 361 | // Show task line. |
| 362 | - $showline=1; |
|
| 363 | - $showlineingray=0; |
|
| 362 | + $showline = 1; |
|
| 363 | + $showlineingray = 0; |
|
| 364 | 364 | |
| 365 | 365 | // If there is filters to use |
| 366 | 366 | if (is_array($taskrole)) |
| 367 | 367 | { |
| 368 | 368 | // If task not legitimate to show, search if a legitimate task exists later in tree |
| 369 | - if (! isset($taskrole[$lines[$i]->id]) && $lines[$i]->id != $lines[$i]->fk_parent) |
|
| 369 | + if (!isset($taskrole[$lines[$i]->id]) && $lines[$i]->id != $lines[$i]->fk_parent) |
|
| 370 | 370 | { |
| 371 | 371 | // So search if task has a subtask legitimate to show |
| 372 | - $foundtaskforuserdeeper=0; |
|
| 373 | - searchTaskInChild($foundtaskforuserdeeper,$lines[$i]->id,$lines,$taskrole); |
|
| 372 | + $foundtaskforuserdeeper = 0; |
|
| 373 | + searchTaskInChild($foundtaskforuserdeeper, $lines[$i]->id, $lines, $taskrole); |
|
| 374 | 374 | //print '$foundtaskforuserpeeper='.$foundtaskforuserdeeper.'<br>'; |
| 375 | 375 | if ($foundtaskforuserdeeper > 0) |
| 376 | 376 | { |
| 377 | - $showlineingray=1; // We will show line but in gray |
|
| 377 | + $showlineingray = 1; // We will show line but in gray |
|
| 378 | 378 | } |
| 379 | 379 | else |
| 380 | 380 | { |
| 381 | - $showline=0; // No reason to show line |
|
| 381 | + $showline = 0; // No reason to show line |
|
| 382 | 382 | } |
| 383 | 383 | } |
| 384 | 384 | } |
@@ -389,12 +389,12 @@ discard block |
||
| 389 | 389 | if (empty($user->rights->projet->all->lire)) |
| 390 | 390 | { |
| 391 | 391 | // User is not allowed on this project and project is not public, so we hide line |
| 392 | - if (! in_array($lines[$i]->fk_project, $projectsArrayId)) |
|
| 392 | + if (!in_array($lines[$i]->fk_project, $projectsArrayId)) |
|
| 393 | 393 | { |
| 394 | 394 | // Note that having a user assigned to a task into a project user has no permission on, should not be possible |
| 395 | 395 | // because assignement on task can be done only on contact of project. |
| 396 | 396 | // If assignement was done and after, was removed from contact of project, then we can hide the line. |
| 397 | - $showline=0; |
|
| 397 | + $showline = 0; |
|
| 398 | 398 | } |
| 399 | 399 | } |
| 400 | 400 | } |
@@ -405,7 +405,7 @@ discard block |
||
| 405 | 405 | if ($parent == 0 && $lines[$i]->fk_project != $lastprojectid) |
| 406 | 406 | { |
| 407 | 407 | $var = !$var; |
| 408 | - $lastprojectid=$lines[$i]->fk_project; |
|
| 408 | + $lastprojectid = $lines[$i]->fk_project; |
|
| 409 | 409 | } |
| 410 | 410 | |
| 411 | 411 | print '<tr '.$bc[$var].' id="row-'.$lines[$i]->id.'">'."\n"; |
@@ -415,18 +415,18 @@ discard block |
||
| 415 | 415 | // Project ref |
| 416 | 416 | print "<td>"; |
| 417 | 417 | //if ($showlineingray) print '<i>'; |
| 418 | - $projectstatic->id=$lines[$i]->fk_project; |
|
| 419 | - $projectstatic->ref=$lines[$i]->projectref; |
|
| 420 | - $projectstatic->public=$lines[$i]->public; |
|
| 421 | - $projectstatic->title=$lines[$i]->projectlabel; |
|
| 422 | - if ($lines[$i]->public || in_array($lines[$i]->fk_project,$projectsArrayId) || ! empty($user->rights->projet->all->lire)) print $projectstatic->getNomUrl(1); |
|
| 423 | - else print $projectstatic->getNomUrl(1,'nolink'); |
|
| 418 | + $projectstatic->id = $lines[$i]->fk_project; |
|
| 419 | + $projectstatic->ref = $lines[$i]->projectref; |
|
| 420 | + $projectstatic->public = $lines[$i]->public; |
|
| 421 | + $projectstatic->title = $lines[$i]->projectlabel; |
|
| 422 | + if ($lines[$i]->public || in_array($lines[$i]->fk_project, $projectsArrayId) || !empty($user->rights->projet->all->lire)) print $projectstatic->getNomUrl(1); |
|
| 423 | + else print $projectstatic->getNomUrl(1, 'nolink'); |
|
| 424 | 424 | //if ($showlineingray) print '</i>'; |
| 425 | 425 | print "</td>"; |
| 426 | 426 | |
| 427 | 427 | // Project status |
| 428 | 428 | print '<td>'; |
| 429 | - $projectstatic->statut=$lines[$i]->projectstatus; |
|
| 429 | + $projectstatic->statut = $lines[$i]->projectstatus; |
|
| 430 | 430 | print $projectstatic->getLibStatut(2); |
| 431 | 431 | print "</td>"; |
| 432 | 432 | } |
@@ -435,14 +435,14 @@ discard block |
||
| 435 | 435 | print '<td>'; |
| 436 | 436 | if ($showlineingray) |
| 437 | 437 | { |
| 438 | - print '<i>'.img_object('','projecttask').' '.$lines[$i]->ref.'</i>'; |
|
| 438 | + print '<i>'.img_object('', 'projecttask').' '.$lines[$i]->ref.'</i>'; |
|
| 439 | 439 | } |
| 440 | 440 | else |
| 441 | 441 | { |
| 442 | - $taskstatic->id=$lines[$i]->id; |
|
| 443 | - $taskstatic->ref=$lines[$i]->ref; |
|
| 444 | - $taskstatic->label=($taskrole[$lines[$i]->id]?$langs->trans("YourRole").': '.$taskrole[$lines[$i]->id]:''); |
|
| 445 | - print $taskstatic->getNomUrl(1,'withproject'); |
|
| 442 | + $taskstatic->id = $lines[$i]->id; |
|
| 443 | + $taskstatic->ref = $lines[$i]->ref; |
|
| 444 | + $taskstatic->label = ($taskrole[$lines[$i]->id] ? $langs->trans("YourRole").': '.$taskrole[$lines[$i]->id] : ''); |
|
| 445 | + print $taskstatic->getNomUrl(1, 'withproject'); |
|
| 446 | 446 | } |
| 447 | 447 | print '</td>'; |
| 448 | 448 | |
@@ -450,7 +450,7 @@ discard block |
||
| 450 | 450 | print "<td>"; |
| 451 | 451 | if ($showlineingray) print '<i>'; |
| 452 | 452 | //else print '<a href="'.DOL_URL_ROOT.'/projet/tasks/task.php?id='.$lines[$i]->id.'&withproject=1">'; |
| 453 | - for ($k = 0 ; $k < $level ; $k++) |
|
| 453 | + for ($k = 0; $k < $level; $k++) |
|
| 454 | 454 | { |
| 455 | 455 | print " "; |
| 456 | 456 | } |
@@ -461,7 +461,7 @@ discard block |
||
| 461 | 461 | |
| 462 | 462 | // Date start |
| 463 | 463 | print '<td align="center">'; |
| 464 | - print dol_print_date($lines[$i]->date_start,'dayhour'); |
|
| 464 | + print dol_print_date($lines[$i]->date_start, 'dayhour'); |
|
| 465 | 465 | print '</td>'; |
| 466 | 466 | |
| 467 | 467 | // Date end |
@@ -470,19 +470,19 @@ discard block |
||
| 470 | 470 | $taskstatic->progress = $lines[$i]->progress; |
| 471 | 471 | $taskstatic->fk_statut = $lines[$i]->status; |
| 472 | 472 | $taskstatic->datee = $lines[$i]->date_end; |
| 473 | - print dol_print_date($lines[$i]->date_end,'dayhour'); |
|
| 473 | + print dol_print_date($lines[$i]->date_end, 'dayhour'); |
|
| 474 | 474 | if ($taskstatic->hasDelay()) print img_warning($langs->trans("Late")); |
| 475 | 475 | print '</td>'; |
| 476 | 476 | |
| 477 | - $plannedworkloadoutputformat='allhourmin'; |
|
| 478 | - $timespentoutputformat='allhourmin'; |
|
| 479 | - if (! empty($conf->global->PROJECT_PLANNED_WORKLOAD_FORMAT)) $plannedworkloadoutputformat=$conf->global->PROJECT_PLANNED_WORKLOAD_FORMAT; |
|
| 480 | - if (! empty($conf->global->PROJECT_TIMES_SPENT_FORMAT)) $timespentoutputformat=$conf->global->PROJECT_TIME_SPENT_FORMAT; |
|
| 477 | + $plannedworkloadoutputformat = 'allhourmin'; |
|
| 478 | + $timespentoutputformat = 'allhourmin'; |
|
| 479 | + if (!empty($conf->global->PROJECT_PLANNED_WORKLOAD_FORMAT)) $plannedworkloadoutputformat = $conf->global->PROJECT_PLANNED_WORKLOAD_FORMAT; |
|
| 480 | + if (!empty($conf->global->PROJECT_TIMES_SPENT_FORMAT)) $timespentoutputformat = $conf->global->PROJECT_TIME_SPENT_FORMAT; |
|
| 481 | 481 | |
| 482 | 482 | // Planned Workload (in working hours) |
| 483 | 483 | print '<td align="right">'; |
| 484 | - $fullhour=convertSecondToTime($lines[$i]->planned_workload,$plannedworkloadoutputformat); |
|
| 485 | - $workingdelay=convertSecondToTime($lines[$i]->planned_workload,'all',86400,7); // TODO Replace 86400 and 7 to take account working hours per day and working day per weeks |
|
| 484 | + $fullhour = convertSecondToTime($lines[$i]->planned_workload, $plannedworkloadoutputformat); |
|
| 485 | + $workingdelay = convertSecondToTime($lines[$i]->planned_workload, 'all', 86400, 7); // TODO Replace 86400 and 7 to take account working hours per day and working day per weeks |
|
| 486 | 486 | if ($lines[$i]->planned_workload != '') |
| 487 | 487 | { |
| 488 | 488 | print $fullhour; |
@@ -495,8 +495,8 @@ discard block |
||
| 495 | 495 | // Time spent |
| 496 | 496 | print '<td align="right">'; |
| 497 | 497 | if ($showlineingray) print '<i>'; |
| 498 | - else print '<a href="'.DOL_URL_ROOT.'/projet/tasks/time.php?id='.$lines[$i]->id.($showproject?'':'&withproject=1').'">'; |
|
| 499 | - if ($lines[$i]->duration) print convertSecondToTime($lines[$i]->duration,$timespentoutputformat); |
|
| 498 | + else print '<a href="'.DOL_URL_ROOT.'/projet/tasks/time.php?id='.$lines[$i]->id.($showproject ? '' : '&withproject=1').'">'; |
|
| 499 | + if ($lines[$i]->duration) print convertSecondToTime($lines[$i]->duration, $timespentoutputformat); |
|
| 500 | 500 | else print '--:--'; |
| 501 | 501 | if ($showlineingray) print '</i>'; |
| 502 | 502 | else print '</a>'; |
@@ -506,7 +506,7 @@ discard block |
||
| 506 | 506 | print '<td align="right">'; |
| 507 | 507 | if ($lines[$i]->planned_workload || $lines[$i]->duration) |
| 508 | 508 | { |
| 509 | - if ($lines[$i]->planned_workload) print round(100 * $lines[$i]->duration / $lines[$i]->planned_workload,2).' %'; |
|
| 509 | + if ($lines[$i]->planned_workload) print round(100 * $lines[$i]->duration / $lines[$i]->planned_workload, 2).' %'; |
|
| 510 | 510 | else print '<span class="opacitymedium">'.$langs->trans('WorkloadNotDefined').'</span>'; |
| 511 | 511 | } |
| 512 | 512 | print '</td>'; |
@@ -527,7 +527,7 @@ discard block |
||
| 527 | 527 | |
| 528 | 528 | print "</tr>\n"; |
| 529 | 529 | |
| 530 | - if (! $showlineingray) $inc++; |
|
| 530 | + if (!$showlineingray) $inc++; |
|
| 531 | 531 | |
| 532 | 532 | if ($level >= 0) // Call sublevels |
| 533 | 533 | { |
@@ -559,12 +559,12 @@ discard block |
||
| 559 | 559 | print convertSecondToTime($total_projectlinesa_planned, 'allhourmin'); |
| 560 | 560 | print '</td>'; |
| 561 | 561 | print '<td align="right" class="nowrap liste_total">'; |
| 562 | - if ($projectidfortotallink > 0) print '<a href="'.DOL_URL_ROOT.'/projet/tasks/time.php?projectid='.$projectidfortotallink.($showproject?'':'&withproject=1').'">'; |
|
| 562 | + if ($projectidfortotallink > 0) print '<a href="'.DOL_URL_ROOT.'/projet/tasks/time.php?projectid='.$projectidfortotallink.($showproject ? '' : '&withproject=1').'">'; |
|
| 563 | 563 | print convertSecondToTime($total_projectlinesa_spent, 'allhourmin'); |
| 564 | 564 | if ($projectidfortotallink > 0) print '</a>'; |
| 565 | 565 | print '</td>'; |
| 566 | 566 | print '<td align="right" class="nowrap liste_total">'; |
| 567 | - if ($total_projectlinesa_planned) print round(100 * $total_projectlinesa_spent / $total_projectlinesa_planned,2).' %'; |
|
| 567 | + if ($total_projectlinesa_planned) print round(100 * $total_projectlinesa_spent / $total_projectlinesa_planned, 2).' %'; |
|
| 568 | 568 | print '</td>'; |
| 569 | 569 | print '<td></td>'; |
| 570 | 570 | if ($addordertick) print '<td class="hideonsmartphone"></td>'; |
@@ -592,48 +592,48 @@ discard block |
||
| 592 | 592 | * @param int $oldprojectforbreak Old project id of last project break |
| 593 | 593 | * @return array Array with time spent for $fuser for each day of week on tasks in $lines and substasks |
| 594 | 594 | */ |
| 595 | -function projectLinesPerAction(&$inc, $parent, $fuser, $lines, &$level, &$projectsrole, &$tasksrole, $mine, $restricteditformytask, $preselectedday, &$isavailable, $oldprojectforbreak=0) |
|
| 595 | +function projectLinesPerAction(&$inc, $parent, $fuser, $lines, &$level, &$projectsrole, &$tasksrole, $mine, $restricteditformytask, $preselectedday, &$isavailable, $oldprojectforbreak = 0) |
|
| 596 | 596 | { |
| 597 | 597 | global $conf, $db, $user, $bc, $langs; |
| 598 | 598 | global $form, $formother, $projectstatic, $taskstatic, $thirdpartystatic; |
| 599 | 599 | |
| 600 | - $lastprojectid=0; |
|
| 601 | - $totalforeachline=array(); |
|
| 602 | - $workloadforid=array(); |
|
| 603 | - $lineswithoutlevel0=array(); |
|
| 600 | + $lastprojectid = 0; |
|
| 601 | + $totalforeachline = array(); |
|
| 602 | + $workloadforid = array(); |
|
| 603 | + $lineswithoutlevel0 = array(); |
|
| 604 | 604 | |
| 605 | - $numlines=count($lines); |
|
| 605 | + $numlines = count($lines); |
|
| 606 | 606 | |
| 607 | 607 | // Create a smaller array with sublevels only to be used later. This increase dramatically performances. |
| 608 | 608 | if ($parent == 0) // Always and only if at first level |
| 609 | 609 | { |
| 610 | - for ($i = 0 ; $i < $numlines ; $i++) |
|
| 610 | + for ($i = 0; $i < $numlines; $i++) |
|
| 611 | 611 | { |
| 612 | - if ($lines[$i]->fk_task_parent) $lineswithoutlevel0[]=$lines[$i]; |
|
| 612 | + if ($lines[$i]->fk_task_parent) $lineswithoutlevel0[] = $lines[$i]; |
|
| 613 | 613 | } |
| 614 | 614 | } |
| 615 | 615 | |
| 616 | 616 | if (empty($oldprojectforbreak)) |
| 617 | 617 | { |
| 618 | - $oldprojectforbreak = (empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)?0:-1); // 0 to start break , -1 no break |
|
| 618 | + $oldprojectforbreak = (empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT) ? 0 : -1); // 0 to start break , -1 no break |
|
| 619 | 619 | } |
| 620 | 620 | |
| 621 | 621 | //dol_syslog('projectLinesPerDay inc='.$inc.' preselectedday='.$preselectedday.' task parent id='.$parent.' level='.$level." count(lines)=".$numlines." count(lineswithoutlevel0)=".count($lineswithoutlevel0)); |
| 622 | - for ($i = 0 ; $i < $numlines ; $i++) |
|
| 622 | + for ($i = 0; $i < $numlines; $i++) |
|
| 623 | 623 | { |
| 624 | 624 | if ($parent == 0) $level = 0; |
| 625 | 625 | |
| 626 | 626 | //if ($lines[$i]->fk_task_parent == $parent) |
| 627 | 627 | //{ |
| 628 | 628 | // If we want all or we have a role on task, we show it |
| 629 | - if (empty($mine) || ! empty($tasksrole[$lines[$i]->id])) |
|
| 629 | + if (empty($mine) || !empty($tasksrole[$lines[$i]->id])) |
|
| 630 | 630 | { |
| 631 | 631 | //dol_syslog("projectLinesPerWeek Found line ".$i.", a qualified task (i have role or want to show all tasks) with id=".$lines[$i]->id." project id=".$lines[$i]->fk_project); |
| 632 | 632 | |
| 633 | 633 | // Break on a new project |
| 634 | 634 | if ($parent == 0 && $lines[$i]->fk_project != $lastprojectid) |
| 635 | 635 | { |
| 636 | - $lastprojectid=$lines[$i]->fk_project; |
|
| 636 | + $lastprojectid = $lines[$i]->fk_project; |
|
| 637 | 637 | if ($preselectedday) |
| 638 | 638 | { |
| 639 | 639 | $projectstatic->id = $lines[$i]->fk_project; |
@@ -644,31 +644,31 @@ discard block |
||
| 644 | 644 | { |
| 645 | 645 | if ($preselectedday) |
| 646 | 646 | { |
| 647 | - $projectstatic->loadTimeSpent($preselectedday, 0, $fuser->id); // Load time spent from table projet_task_time for the project into this->weekWorkLoad and this->weekWorkLoadPerTask for all days of a week |
|
| 648 | - $workloadforid[$projectstatic->id]=1; |
|
| 647 | + $projectstatic->loadTimeSpent($preselectedday, 0, $fuser->id); // Load time spent from table projet_task_time for the project into this->weekWorkLoad and this->weekWorkLoadPerTask for all days of a week |
|
| 648 | + $workloadforid[$projectstatic->id] = 1; |
|
| 649 | 649 | } |
| 650 | 650 | } |
| 651 | 651 | |
| 652 | - $projectstatic->id=$lines[$i]->fk_project; |
|
| 653 | - $projectstatic->ref=$lines[$i]->project_ref; |
|
| 654 | - $projectstatic->title=$lines[$i]->project_label; |
|
| 655 | - $projectstatic->public=$lines[$i]->public; |
|
| 652 | + $projectstatic->id = $lines[$i]->fk_project; |
|
| 653 | + $projectstatic->ref = $lines[$i]->project_ref; |
|
| 654 | + $projectstatic->title = $lines[$i]->project_label; |
|
| 655 | + $projectstatic->public = $lines[$i]->public; |
|
| 656 | 656 | |
| 657 | - $taskstatic->id=$lines[$i]->task_id; |
|
| 658 | - $taskstatic->ref=($lines[$i]->task_ref?$lines[$i]->task_ref:$lines[$i]->task_id); |
|
| 659 | - $taskstatic->label=$lines[$i]->task_label; |
|
| 660 | - $taskstatic->date_start=$lines[$i]->date_start; |
|
| 661 | - $taskstatic->date_end=$lines[$i]->date_end; |
|
| 657 | + $taskstatic->id = $lines[$i]->task_id; |
|
| 658 | + $taskstatic->ref = ($lines[$i]->task_ref ? $lines[$i]->task_ref : $lines[$i]->task_id); |
|
| 659 | + $taskstatic->label = $lines[$i]->task_label; |
|
| 660 | + $taskstatic->date_start = $lines[$i]->date_start; |
|
| 661 | + $taskstatic->date_end = $lines[$i]->date_end; |
|
| 662 | 662 | |
| 663 | - $thirdpartystatic->id=$lines[$i]->socid; |
|
| 664 | - $thirdpartystatic->name=$lines[$i]->thirdparty_name; |
|
| 665 | - $thirdpartystatic->email=$lines[$i]->thirdparty_email; |
|
| 663 | + $thirdpartystatic->id = $lines[$i]->socid; |
|
| 664 | + $thirdpartystatic->name = $lines[$i]->thirdparty_name; |
|
| 665 | + $thirdpartystatic->email = $lines[$i]->thirdparty_email; |
|
| 666 | 666 | |
| 667 | 667 | if (empty($oldprojectforbreak) || ($oldprojectforbreak != -1 && $oldprojectforbreak != $projectstatic->id)) |
| 668 | 668 | { |
| 669 | 669 | print '<tr class="oddeven trforbreak">'."\n"; |
| 670 | 670 | print '<td colspan="11">'; |
| 671 | - print $projectstatic->getNomUrl(1,'',0,$langs->transnoentitiesnoconv("YourRole").': '.$projectsrole[$lines[$i]->fk_project]); |
|
| 671 | + print $projectstatic->getNomUrl(1, '', 0, $langs->transnoentitiesnoconv("YourRole").': '.$projectsrole[$lines[$i]->fk_project]); |
|
| 672 | 672 | if ($projectstatic->title) |
| 673 | 673 | { |
| 674 | 674 | print ' - '; |
@@ -693,7 +693,7 @@ discard block |
||
| 693 | 693 | print "<td>"; |
| 694 | 694 | if ($oldprojectforbreak == -1) |
| 695 | 695 | { |
| 696 | - print $projectstatic->getNomUrl(1,'',0,$langs->transnoentitiesnoconv("YourRole").': '.$projectsrole[$lines[$i]->fk_project]); |
|
| 696 | + print $projectstatic->getNomUrl(1, '', 0, $langs->transnoentitiesnoconv("YourRole").': '.$projectsrole[$lines[$i]->fk_project]); |
|
| 697 | 697 | print '<br>'.$projectstatic->title; |
| 698 | 698 | } |
| 699 | 699 | print "</td>"; |
@@ -706,11 +706,11 @@ discard block |
||
| 706 | 706 | // Ref |
| 707 | 707 | print '<td>'; |
| 708 | 708 | print '<!-- Task id = '.$lines[$i]->id.' -->'; |
| 709 | - for ($k = 0 ; $k < $level ; $k++) print " "; |
|
| 709 | + for ($k = 0; $k < $level; $k++) print " "; |
|
| 710 | 710 | print $taskstatic->getNomUrl(1, 'withproject', 'time'); |
| 711 | 711 | // Label task |
| 712 | 712 | print '<br>'; |
| 713 | - for ($k = 0 ; $k < $level ; $k++) print " "; |
|
| 713 | + for ($k = 0; $k < $level; $k++) print " "; |
|
| 714 | 714 | print $taskstatic->label; |
| 715 | 715 | //print "<br>"; |
| 716 | 716 | //for ($k = 0 ; $k < $level ; $k++) print " "; |
@@ -719,47 +719,47 @@ discard block |
||
| 719 | 719 | |
| 720 | 720 | // Date |
| 721 | 721 | print '<td align="center">'; |
| 722 | - print dol_print_date($lines[$i]->timespent_datehour,'day'); |
|
| 722 | + print dol_print_date($lines[$i]->timespent_datehour, 'day'); |
|
| 723 | 723 | print '</td>'; |
| 724 | 724 | |
| 725 | - $disabledproject=1;$disabledtask=1; |
|
| 725 | + $disabledproject = 1; $disabledtask = 1; |
|
| 726 | 726 | //print "x".$lines[$i]->fk_project; |
| 727 | 727 | //var_dump($lines[$i]); |
| 728 | 728 | //var_dump($projectsrole[$lines[$i]->fk_project]); |
| 729 | 729 | // If at least one role for project |
| 730 | - if ($lines[$i]->public || ! empty($projectsrole[$lines[$i]->fk_project]) || $user->rights->projet->all->creer) |
|
| 730 | + if ($lines[$i]->public || !empty($projectsrole[$lines[$i]->fk_project]) || $user->rights->projet->all->creer) |
|
| 731 | 731 | { |
| 732 | - $disabledproject=0; |
|
| 733 | - $disabledtask=0; |
|
| 732 | + $disabledproject = 0; |
|
| 733 | + $disabledtask = 0; |
|
| 734 | 734 | } |
| 735 | 735 | // If $restricteditformytask is on and I have no role on task, i disable edit |
| 736 | 736 | if ($restricteditformytask && empty($tasksrole[$lines[$i]->id])) |
| 737 | 737 | { |
| 738 | - $disabledtask=1; |
|
| 738 | + $disabledtask = 1; |
|
| 739 | 739 | } |
| 740 | 740 | |
| 741 | 741 | // Hour |
| 742 | 742 | print '<td class="nowrap" align="center">'; |
| 743 | - print dol_print_date($lines[$i]->timespent_datehour,'hour'); |
|
| 743 | + print dol_print_date($lines[$i]->timespent_datehour, 'hour'); |
|
| 744 | 744 | print '</td>'; |
| 745 | 745 | |
| 746 | - $cssonholiday=''; |
|
| 747 | - if (! $isavailable[$preselectedday]['morning'] && ! $isavailable[$preselectedday]['afternoon']) $cssonholiday.='onholidayallday '; |
|
| 748 | - elseif (! $isavailable[$preselectedday]['morning']) $cssonholiday.='onholidaymorning '; |
|
| 749 | - elseif (! $isavailable[$preselectedday]['afternoon']) $cssonholiday.='onholidayafternoon '; |
|
| 746 | + $cssonholiday = ''; |
|
| 747 | + if (!$isavailable[$preselectedday]['morning'] && !$isavailable[$preselectedday]['afternoon']) $cssonholiday .= 'onholidayallday '; |
|
| 748 | + elseif (!$isavailable[$preselectedday]['morning']) $cssonholiday .= 'onholidaymorning '; |
|
| 749 | + elseif (!$isavailable[$preselectedday]['afternoon']) $cssonholiday .= 'onholidayafternoon '; |
|
| 750 | 750 | |
| 751 | 751 | // Duration |
| 752 | - print '<td align="center" class="duration'.($cssonholiday?' '.$cssonholiday:'').'">'; |
|
| 752 | + print '<td align="center" class="duration'.($cssonholiday ? ' '.$cssonholiday : '').'">'; |
|
| 753 | 753 | |
| 754 | 754 | $dayWorkLoad = $lines[$i]->timespent_duration; |
| 755 | - $totalforeachline[$preselectedday]+=$lines[$i]->timespent_duration; |
|
| 755 | + $totalforeachline[$preselectedday] += $lines[$i]->timespent_duration; |
|
| 756 | 756 | |
| 757 | - $alreadyspent=''; |
|
| 758 | - if ($dayWorkLoad > 0) $alreadyspent=convertSecondToTime($lines[$i]->timespent_duration,'allhourmin'); |
|
| 757 | + $alreadyspent = ''; |
|
| 758 | + if ($dayWorkLoad > 0) $alreadyspent = convertSecondToTime($lines[$i]->timespent_duration, 'allhourmin'); |
|
| 759 | 759 | |
| 760 | - print convertSecondToTime($lines[$i]->timespent_duration,'allhourmin'); |
|
| 760 | + print convertSecondToTime($lines[$i]->timespent_duration, 'allhourmin'); |
|
| 761 | 761 | |
| 762 | - $modeinput='hours'; |
|
| 762 | + $modeinput = 'hours'; |
|
| 763 | 763 | |
| 764 | 764 | print '<script type="text/javascript">'; |
| 765 | 765 | print "jQuery(document).ready(function () {\n"; |
@@ -771,7 +771,7 @@ discard block |
||
| 771 | 771 | |
| 772 | 772 | // Note |
| 773 | 773 | print '<td align="center">'; |
| 774 | - print '<textarea name="'.$lines[$i]->id.'note" rows="'.ROWS_2.'" id="'.$lines[$i]->id.'note"'.($disabledtask?' disabled="disabled"':'').'>'; |
|
| 774 | + print '<textarea name="'.$lines[$i]->id.'note" rows="'.ROWS_2.'" id="'.$lines[$i]->id.'note"'.($disabledtask ? ' disabled="disabled"' : '').'>'; |
|
| 775 | 775 | print $lines[$i]->timespent_note; |
| 776 | 776 | print '</textarea>'; |
| 777 | 777 | print '</td>'; |
@@ -818,48 +818,48 @@ discard block |
||
| 818 | 818 | * @param int $oldprojectforbreak Old project id of last project break |
| 819 | 819 | * @return array Array with time spent for $fuser for each day of week on tasks in $lines and substasks |
| 820 | 820 | */ |
| 821 | -function projectLinesPerDay(&$inc, $parent, $fuser, $lines, &$level, &$projectsrole, &$tasksrole, $mine, $restricteditformytask, $preselectedday, &$isavailable, $oldprojectforbreak=0) |
|
| 821 | +function projectLinesPerDay(&$inc, $parent, $fuser, $lines, &$level, &$projectsrole, &$tasksrole, $mine, $restricteditformytask, $preselectedday, &$isavailable, $oldprojectforbreak = 0) |
|
| 822 | 822 | { |
| 823 | 823 | global $conf, $db, $user, $bc, $langs; |
| 824 | 824 | global $form, $formother, $projectstatic, $taskstatic, $thirdpartystatic; |
| 825 | 825 | |
| 826 | - $lastprojectid=0; |
|
| 827 | - $totalforeachday=array(); |
|
| 828 | - $workloadforid=array(); |
|
| 829 | - $lineswithoutlevel0=array(); |
|
| 826 | + $lastprojectid = 0; |
|
| 827 | + $totalforeachday = array(); |
|
| 828 | + $workloadforid = array(); |
|
| 829 | + $lineswithoutlevel0 = array(); |
|
| 830 | 830 | |
| 831 | - $numlines=count($lines); |
|
| 831 | + $numlines = count($lines); |
|
| 832 | 832 | |
| 833 | 833 | // Create a smaller array with sublevels only to be used later. This increase dramatically performances. |
| 834 | 834 | if ($parent == 0) // Always and only if at first level |
| 835 | 835 | { |
| 836 | - for ($i = 0 ; $i < $numlines ; $i++) |
|
| 836 | + for ($i = 0; $i < $numlines; $i++) |
|
| 837 | 837 | { |
| 838 | - if ($lines[$i]->fk_task_parent) $lineswithoutlevel0[]=$lines[$i]; |
|
| 838 | + if ($lines[$i]->fk_task_parent) $lineswithoutlevel0[] = $lines[$i]; |
|
| 839 | 839 | } |
| 840 | 840 | } |
| 841 | 841 | |
| 842 | 842 | if (empty($oldprojectforbreak)) |
| 843 | 843 | { |
| 844 | - $oldprojectforbreak = (empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)?0:-1); // 0 to start break , -1 no break |
|
| 844 | + $oldprojectforbreak = (empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT) ? 0 : -1); // 0 to start break , -1 no break |
|
| 845 | 845 | } |
| 846 | 846 | |
| 847 | 847 | //dol_syslog('projectLinesPerDay inc='.$inc.' preselectedday='.$preselectedday.' task parent id='.$parent.' level='.$level." count(lines)=".$numlines." count(lineswithoutlevel0)=".count($lineswithoutlevel0)); |
| 848 | - for ($i = 0 ; $i < $numlines ; $i++) |
|
| 848 | + for ($i = 0; $i < $numlines; $i++) |
|
| 849 | 849 | { |
| 850 | 850 | if ($parent == 0) $level = 0; |
| 851 | 851 | |
| 852 | 852 | if ($lines[$i]->fk_task_parent == $parent) |
| 853 | 853 | { |
| 854 | 854 | // If we want all or we have a role on task, we show it |
| 855 | - if (empty($mine) || ! empty($tasksrole[$lines[$i]->id])) |
|
| 855 | + if (empty($mine) || !empty($tasksrole[$lines[$i]->id])) |
|
| 856 | 856 | { |
| 857 | 857 | //dol_syslog("projectLinesPerWeek Found line ".$i.", a qualified task (i have role or want to show all tasks) with id=".$lines[$i]->id." project id=".$lines[$i]->fk_project); |
| 858 | 858 | |
| 859 | 859 | // Break on a new project |
| 860 | 860 | if ($parent == 0 && $lines[$i]->fk_project != $lastprojectid) |
| 861 | 861 | { |
| 862 | - $lastprojectid=$lines[$i]->fk_project; |
|
| 862 | + $lastprojectid = $lines[$i]->fk_project; |
|
| 863 | 863 | if ($preselectedday) |
| 864 | 864 | { |
| 865 | 865 | $projectstatic->id = $lines[$i]->fk_project; |
@@ -870,31 +870,31 @@ discard block |
||
| 870 | 870 | { |
| 871 | 871 | if ($preselectedday) |
| 872 | 872 | { |
| 873 | - $projectstatic->loadTimeSpent($preselectedday, 0, $fuser->id); // Load time spent from table projet_task_time for the project into this->weekWorkLoad and this->weekWorkLoadPerTask for all days of a week |
|
| 874 | - $workloadforid[$projectstatic->id]=1; |
|
| 873 | + $projectstatic->loadTimeSpent($preselectedday, 0, $fuser->id); // Load time spent from table projet_task_time for the project into this->weekWorkLoad and this->weekWorkLoadPerTask for all days of a week |
|
| 874 | + $workloadforid[$projectstatic->id] = 1; |
|
| 875 | 875 | } |
| 876 | 876 | } |
| 877 | 877 | |
| 878 | - $projectstatic->id=$lines[$i]->fk_project; |
|
| 879 | - $projectstatic->ref=$lines[$i]->projectref; |
|
| 880 | - $projectstatic->title=$lines[$i]->projectlabel; |
|
| 881 | - $projectstatic->public=$lines[$i]->public; |
|
| 878 | + $projectstatic->id = $lines[$i]->fk_project; |
|
| 879 | + $projectstatic->ref = $lines[$i]->projectref; |
|
| 880 | + $projectstatic->title = $lines[$i]->projectlabel; |
|
| 881 | + $projectstatic->public = $lines[$i]->public; |
|
| 882 | 882 | |
| 883 | - $taskstatic->id=$lines[$i]->id; |
|
| 884 | - $taskstatic->ref=($lines[$i]->ref?$lines[$i]->ref:$lines[$i]->id); |
|
| 885 | - $taskstatic->label=$lines[$i]->label; |
|
| 886 | - $taskstatic->date_start=$lines[$i]->date_start; |
|
| 887 | - $taskstatic->date_end=$lines[$i]->date_end; |
|
| 883 | + $taskstatic->id = $lines[$i]->id; |
|
| 884 | + $taskstatic->ref = ($lines[$i]->ref ? $lines[$i]->ref : $lines[$i]->id); |
|
| 885 | + $taskstatic->label = $lines[$i]->label; |
|
| 886 | + $taskstatic->date_start = $lines[$i]->date_start; |
|
| 887 | + $taskstatic->date_end = $lines[$i]->date_end; |
|
| 888 | 888 | |
| 889 | - $thirdpartystatic->id=$lines[$i]->socid; |
|
| 890 | - $thirdpartystatic->name=$lines[$i]->thirdparty_name; |
|
| 891 | - $thirdpartystatic->email=$lines[$i]->thirdparty_email; |
|
| 889 | + $thirdpartystatic->id = $lines[$i]->socid; |
|
| 890 | + $thirdpartystatic->name = $lines[$i]->thirdparty_name; |
|
| 891 | + $thirdpartystatic->email = $lines[$i]->thirdparty_email; |
|
| 892 | 892 | |
| 893 | 893 | if (empty($oldprojectforbreak) || ($oldprojectforbreak != -1 && $oldprojectforbreak != $projectstatic->id)) |
| 894 | 894 | { |
| 895 | 895 | print '<tr class="oddeven trforbreak">'."\n"; |
| 896 | 896 | print '<td colspan="9">'; |
| 897 | - print $projectstatic->getNomUrl(1,'',0,'<strong>'.$langs->transnoentitiesnoconv("YourRole").':</strong> '.$projectsrole[$lines[$i]->fk_project]); |
|
| 897 | + print $projectstatic->getNomUrl(1, '', 0, '<strong>'.$langs->transnoentitiesnoconv("YourRole").':</strong> '.$projectsrole[$lines[$i]->fk_project]); |
|
| 898 | 898 | if ($thirdpartystatic->id > 0) print ' - '.$thirdpartystatic->getNomUrl(1); |
| 899 | 899 | if ($projectstatic->title) |
| 900 | 900 | { |
@@ -929,11 +929,11 @@ discard block |
||
| 929 | 929 | // Ref |
| 930 | 930 | print '<td>'; |
| 931 | 931 | print '<!-- Task id = '.$lines[$i]->id.' -->'; |
| 932 | - for ($k = 0 ; $k < $level ; $k++) print " "; |
|
| 932 | + for ($k = 0; $k < $level; $k++) print " "; |
|
| 933 | 933 | print $taskstatic->getNomUrl(1, 'withproject', 'time'); |
| 934 | 934 | // Label task |
| 935 | 935 | print '<br>'; |
| 936 | - for ($k = 0 ; $k < $level ; $k++) print " "; |
|
| 936 | + for ($k = 0; $k < $level; $k++) print " "; |
|
| 937 | 937 | print $taskstatic->label; |
| 938 | 938 | //print "<br>"; |
| 939 | 939 | //for ($k = 0 ; $k < $level ; $k++) print " "; |
@@ -942,13 +942,13 @@ discard block |
||
| 942 | 942 | |
| 943 | 943 | // Planned Workload |
| 944 | 944 | print '<td align="right" class="leftborder plannedworkload">'; |
| 945 | - if ($lines[$i]->planned_workload) print convertSecondToTime($lines[$i]->planned_workload,'allhourmin'); |
|
| 945 | + if ($lines[$i]->planned_workload) print convertSecondToTime($lines[$i]->planned_workload, 'allhourmin'); |
|
| 946 | 946 | else print '--:--'; |
| 947 | 947 | print '</td>'; |
| 948 | 948 | |
| 949 | 949 | // Progress declared % |
| 950 | 950 | print '<td align="right">'; |
| 951 | - print $formother->select_percent($lines[$i]->progress, $lines[$i]->id . 'progress'); |
|
| 951 | + print $formother->select_percent($lines[$i]->progress, $lines[$i]->id.'progress'); |
|
| 952 | 952 | print '</td>'; |
| 953 | 953 | |
| 954 | 954 | // Time spent by everybody |
@@ -957,7 +957,7 @@ discard block |
||
| 957 | 957 | if ($lines[$i]->duration) |
| 958 | 958 | { |
| 959 | 959 | print '<a href="'.DOL_URL_ROOT.'/projet/tasks/time.php?id='.$lines[$i]->id.'">'; |
| 960 | - print convertSecondToTime($lines[$i]->duration,'allhourmin'); |
|
| 960 | + print convertSecondToTime($lines[$i]->duration, 'allhourmin'); |
|
| 961 | 961 | print '</a>'; |
| 962 | 962 | } |
| 963 | 963 | else print '--:--'; |
@@ -965,68 +965,68 @@ discard block |
||
| 965 | 965 | |
| 966 | 966 | // Time spent by user |
| 967 | 967 | print '<td align="right">'; |
| 968 | - $tmptimespent=$taskstatic->getSummaryOfTimeSpent($fuser->id); |
|
| 969 | - if ($tmptimespent['total_duration']) print convertSecondToTime($tmptimespent['total_duration'],'allhourmin'); |
|
| 968 | + $tmptimespent = $taskstatic->getSummaryOfTimeSpent($fuser->id); |
|
| 969 | + if ($tmptimespent['total_duration']) print convertSecondToTime($tmptimespent['total_duration'], 'allhourmin'); |
|
| 970 | 970 | else print '--:--'; |
| 971 | 971 | print "</td>\n"; |
| 972 | 972 | |
| 973 | - $disabledproject=1;$disabledtask=1; |
|
| 973 | + $disabledproject = 1; $disabledtask = 1; |
|
| 974 | 974 | //print "x".$lines[$i]->fk_project; |
| 975 | 975 | //var_dump($lines[$i]); |
| 976 | 976 | //var_dump($projectsrole[$lines[$i]->fk_project]); |
| 977 | 977 | // If at least one role for project |
| 978 | - if ($lines[$i]->public || ! empty($projectsrole[$lines[$i]->fk_project]) || $user->rights->projet->all->creer) |
|
| 978 | + if ($lines[$i]->public || !empty($projectsrole[$lines[$i]->fk_project]) || $user->rights->projet->all->creer) |
|
| 979 | 979 | { |
| 980 | - $disabledproject=0; |
|
| 981 | - $disabledtask=0; |
|
| 980 | + $disabledproject = 0; |
|
| 981 | + $disabledtask = 0; |
|
| 982 | 982 | } |
| 983 | 983 | // If $restricteditformytask is on and I have no role on task, i disable edit |
| 984 | 984 | if ($restricteditformytask && empty($tasksrole[$lines[$i]->id])) |
| 985 | 985 | { |
| 986 | - $disabledtask=1; |
|
| 986 | + $disabledtask = 1; |
|
| 987 | 987 | } |
| 988 | 988 | |
| 989 | 989 | // Form to add new time |
| 990 | 990 | print '<td class="nowrap leftborder" align="center">'; |
| 991 | - $tableCell=$form->select_date($preselectedday,$lines[$i]->id,1,1,2,"addtime",0,0,1,$disabledtask); |
|
| 991 | + $tableCell = $form->select_date($preselectedday, $lines[$i]->id, 1, 1, 2, "addtime", 0, 0, 1, $disabledtask); |
|
| 992 | 992 | print $tableCell; |
| 993 | 993 | print '</td>'; |
| 994 | 994 | |
| 995 | - $cssonholiday=''; |
|
| 996 | - if (! $isavailable[$preselectedday]['morning'] && ! $isavailable[$preselectedday]['afternoon']) $cssonholiday.='onholidayallday '; |
|
| 997 | - elseif (! $isavailable[$preselectedday]['morning']) $cssonholiday.='onholidaymorning '; |
|
| 998 | - elseif (! $isavailable[$preselectedday]['afternoon']) $cssonholiday.='onholidayafternoon '; |
|
| 995 | + $cssonholiday = ''; |
|
| 996 | + if (!$isavailable[$preselectedday]['morning'] && !$isavailable[$preselectedday]['afternoon']) $cssonholiday .= 'onholidayallday '; |
|
| 997 | + elseif (!$isavailable[$preselectedday]['morning']) $cssonholiday .= 'onholidaymorning '; |
|
| 998 | + elseif (!$isavailable[$preselectedday]['afternoon']) $cssonholiday .= 'onholidayafternoon '; |
|
| 999 | 999 | |
| 1000 | 1000 | global $daytoparse; |
| 1001 | - $tmparray = dol_getdate($daytoparse,true); // detail of current day |
|
| 1001 | + $tmparray = dol_getdate($daytoparse, true); // detail of current day |
|
| 1002 | 1002 | $idw = $tmparray['wday']; |
| 1003 | 1003 | |
| 1004 | 1004 | global $numstartworkingday, $numendworkingday; |
| 1005 | - $cssweekend=''; |
|
| 1005 | + $cssweekend = ''; |
|
| 1006 | 1006 | if (($idw + 1) < $numstartworkingday || ($idw + 1) > $numendworkingday) // This is a day is not inside the setup of working days, so we use a week-end css. |
| 1007 | 1007 | { |
| 1008 | - $cssweekend='weekend'; |
|
| 1008 | + $cssweekend = 'weekend'; |
|
| 1009 | 1009 | } |
| 1010 | 1010 | |
| 1011 | 1011 | // Duration |
| 1012 | - print '<td class="center duration'.($cssonholiday?' '.$cssonholiday:'').($cssweekend?' '.$cssweekend:'').'">'; |
|
| 1012 | + print '<td class="center duration'.($cssonholiday ? ' '.$cssonholiday : '').($cssweekend ? ' '.$cssweekend : '').'">'; |
|
| 1013 | 1013 | $dayWorkLoad = $projectstatic->weekWorkLoadPerTask[$preselectedday][$lines[$i]->id]; |
| 1014 | - $totalforeachday[$preselectedday]+=$dayWorkLoad; |
|
| 1014 | + $totalforeachday[$preselectedday] += $dayWorkLoad; |
|
| 1015 | 1015 | |
| 1016 | - $alreadyspent=''; |
|
| 1017 | - if ($dayWorkLoad > 0) $alreadyspent=convertSecondToTime($dayWorkLoad,'allhourmin'); |
|
| 1016 | + $alreadyspent = ''; |
|
| 1017 | + if ($dayWorkLoad > 0) $alreadyspent = convertSecondToTime($dayWorkLoad, 'allhourmin'); |
|
| 1018 | 1018 | |
| 1019 | 1019 | $idw = 0; |
| 1020 | 1020 | |
| 1021 | - $tableCell=''; |
|
| 1022 | - $tableCell.='<span class="timesheetalreadyrecorded" title="texttoreplace"><input type="text" class="center" size="2" disabled id="timespent['.$inc.']['.$idw.']" name="task['.$lines[$i]->id.']['.$idw.']" value="'.$alreadyspent.'"></span>'; |
|
| 1023 | - $tableCell.='<span class="hideonsmartphone"> + </span>'; |
|
| 1021 | + $tableCell = ''; |
|
| 1022 | + $tableCell .= '<span class="timesheetalreadyrecorded" title="texttoreplace"><input type="text" class="center" size="2" disabled id="timespent['.$inc.']['.$idw.']" name="task['.$lines[$i]->id.']['.$idw.']" value="'.$alreadyspent.'"></span>'; |
|
| 1023 | + $tableCell .= '<span class="hideonsmartphone"> + </span>'; |
|
| 1024 | 1024 | //$tableCell.=' '; |
| 1025 | - $tableCell.=$form->select_duration($lines[$i]->id.'duration','',$disabledtask,'text',0,1); |
|
| 1025 | + $tableCell .= $form->select_duration($lines[$i]->id.'duration', '', $disabledtask, 'text', 0, 1); |
|
| 1026 | 1026 | //$tableCell.=' <input type="submit" class="button"'.($disabledtask?' disabled':'').' value="'.$langs->trans("Add").'">'; |
| 1027 | 1027 | print $tableCell; |
| 1028 | 1028 | |
| 1029 | - $modeinput='hours'; |
|
| 1029 | + $modeinput = 'hours'; |
|
| 1030 | 1030 | |
| 1031 | 1031 | print '<script type="text/javascript">'; |
| 1032 | 1032 | print "jQuery(document).ready(function () {\n"; |
@@ -1038,19 +1038,19 @@ discard block |
||
| 1038 | 1038 | |
| 1039 | 1039 | // Note |
| 1040 | 1040 | print '<td align="center">'; |
| 1041 | - print '<textarea name="'.$lines[$i]->id.'note" rows="'.ROWS_2.'" id="'.$lines[$i]->id.'note"'.($disabledtask?' disabled="disabled"':'').'>'; |
|
| 1041 | + print '<textarea name="'.$lines[$i]->id.'note" rows="'.ROWS_2.'" id="'.$lines[$i]->id.'note"'.($disabledtask ? ' disabled="disabled"' : '').'>'; |
|
| 1042 | 1042 | print '</textarea>'; |
| 1043 | 1043 | print '</td>'; |
| 1044 | 1044 | |
| 1045 | 1045 | // Warning |
| 1046 | 1046 | print '<td align="right">'; |
| 1047 | - if ((! $lines[$i]->public) && $disabledproject) print $form->textwithpicto('',$langs->trans("UserIsNotContactOfProject")); |
|
| 1047 | + if ((!$lines[$i]->public) && $disabledproject) print $form->textwithpicto('', $langs->trans("UserIsNotContactOfProject")); |
|
| 1048 | 1048 | else if ($disabledtask) |
| 1049 | 1049 | { |
| 1050 | 1050 | $titleassigntask = $langs->trans("AssignTaskToMe"); |
| 1051 | 1051 | if ($fuser->id != $user->id) $titleassigntask = $langs->trans("AssignTaskToUser", '...'); |
| 1052 | 1052 | |
| 1053 | - print $form->textwithpicto('',$langs->trans("TaskIsNotAssignedToUser", $titleassigntask)); |
|
| 1053 | + print $form->textwithpicto('', $langs->trans("TaskIsNotAssignedToUser", $titleassigntask)); |
|
| 1054 | 1054 | } |
| 1055 | 1055 | print '</td>'; |
| 1056 | 1056 | |
@@ -1066,9 +1066,9 @@ discard block |
||
| 1066 | 1066 | $ret = projectLinesPerDay($inc, $lines[$i]->id, $fuser, ($parent == 0 ? $lineswithoutlevel0 : $lines), $level, $projectsrole, $tasksrole, $mine, $restricteditformytask, $preselectedday, $isavailable, $oldprojectforbreak); |
| 1067 | 1067 | //var_dump('ret with parent='.$lines[$i]->id.' level='.$level); |
| 1068 | 1068 | //var_dump($ret); |
| 1069 | - foreach($ret as $key => $val) |
|
| 1069 | + foreach ($ret as $key => $val) |
|
| 1070 | 1070 | { |
| 1071 | - $totalforeachday[$key]+=$val; |
|
| 1071 | + $totalforeachday[$key] += $val; |
|
| 1072 | 1072 | } |
| 1073 | 1073 | //var_dump('totalforeachday after taskid='.$lines[$i]->id.' and previous one on level '.$level.' + subtasks'); |
| 1074 | 1074 | //var_dump($totalforeachday); |
@@ -1102,24 +1102,24 @@ discard block |
||
| 1102 | 1102 | * @param int $oldprojectforbreak Old project id of last project break |
| 1103 | 1103 | * @return array Array with time spent for $fuser for each day of week on tasks in $lines and substasks |
| 1104 | 1104 | */ |
| 1105 | -function projectLinesPerWeek(&$inc, $firstdaytoshow, $fuser, $parent, $lines, &$level, &$projectsrole, &$tasksrole, $mine, $restricteditformytask, &$isavailable, $oldprojectforbreak=0) |
|
| 1105 | +function projectLinesPerWeek(&$inc, $firstdaytoshow, $fuser, $parent, $lines, &$level, &$projectsrole, &$tasksrole, $mine, $restricteditformytask, &$isavailable, $oldprojectforbreak = 0) |
|
| 1106 | 1106 | { |
| 1107 | 1107 | global $conf, $db, $user, $bc, $langs; |
| 1108 | 1108 | global $form, $formother, $projectstatic, $taskstatic, $thirdpartystatic; |
| 1109 | 1109 | |
| 1110 | - $numlines=count($lines); |
|
| 1110 | + $numlines = count($lines); |
|
| 1111 | 1111 | |
| 1112 | - $lastprojectid=0; |
|
| 1113 | - $workloadforid=array(); |
|
| 1114 | - $totalforeachday=array(); |
|
| 1115 | - $lineswithoutlevel0=array(); |
|
| 1112 | + $lastprojectid = 0; |
|
| 1113 | + $workloadforid = array(); |
|
| 1114 | + $totalforeachday = array(); |
|
| 1115 | + $lineswithoutlevel0 = array(); |
|
| 1116 | 1116 | |
| 1117 | 1117 | // Create a smaller array with sublevels only to be used later. This increase dramatically performances. |
| 1118 | 1118 | if ($parent == 0) // Always and only if at first level |
| 1119 | 1119 | { |
| 1120 | - for ($i = 0 ; $i < $numlines ; $i++) |
|
| 1120 | + for ($i = 0; $i < $numlines; $i++) |
|
| 1121 | 1121 | { |
| 1122 | - if ($lines[$i]->fk_task_parent) $lineswithoutlevel0[]=$lines[$i]; |
|
| 1122 | + if ($lines[$i]->fk_task_parent) $lineswithoutlevel0[] = $lines[$i]; |
|
| 1123 | 1123 | } |
| 1124 | 1124 | } |
| 1125 | 1125 | |
@@ -1127,24 +1127,24 @@ discard block |
||
| 1127 | 1127 | |
| 1128 | 1128 | if (empty($oldprojectforbreak)) |
| 1129 | 1129 | { |
| 1130 | - $oldprojectforbreak = (empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)?0:-1); // 0 = start break, -1 = never break |
|
| 1130 | + $oldprojectforbreak = (empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT) ? 0 : -1); // 0 = start break, -1 = never break |
|
| 1131 | 1131 | } |
| 1132 | 1132 | |
| 1133 | - for ($i = 0 ; $i < $numlines ; $i++) |
|
| 1133 | + for ($i = 0; $i < $numlines; $i++) |
|
| 1134 | 1134 | { |
| 1135 | 1135 | if ($parent == 0) $level = 0; |
| 1136 | 1136 | |
| 1137 | 1137 | if ($lines[$i]->fk_task_parent == $parent) |
| 1138 | 1138 | { |
| 1139 | 1139 | // If we want all or we have a role on task, we show it |
| 1140 | - if (empty($mine) || ! empty($tasksrole[$lines[$i]->id])) |
|
| 1140 | + if (empty($mine) || !empty($tasksrole[$lines[$i]->id])) |
|
| 1141 | 1141 | { |
| 1142 | 1142 | //dol_syslog("projectLinesPerWeek Found line ".$i.", a qualified task (i have role or want to show all tasks) with id=".$lines[$i]->id." project id=".$lines[$i]->fk_project); |
| 1143 | 1143 | |
| 1144 | 1144 | // Break on a new project |
| 1145 | 1145 | if ($parent == 0 && $lines[$i]->fk_project != $lastprojectid) |
| 1146 | 1146 | { |
| 1147 | - $lastprojectid=$lines[$i]->fk_project; |
|
| 1147 | + $lastprojectid = $lines[$i]->fk_project; |
|
| 1148 | 1148 | $projectstatic->id = $lines[$i]->fk_project; |
| 1149 | 1149 | } |
| 1150 | 1150 | |
@@ -1152,33 +1152,33 @@ discard block |
||
| 1152 | 1152 | //var_dump($projectstatic->weekWorkLoadPerTask); |
| 1153 | 1153 | if (empty($workloadforid[$projectstatic->id])) |
| 1154 | 1154 | { |
| 1155 | - $projectstatic->loadTimeSpent($firstdaytoshow, 0, $fuser->id); // Load time spent from table projet_task_time for the project into this->weekWorkLoad and this->weekWorkLoadPerTask for all days of a week |
|
| 1156 | - $workloadforid[$projectstatic->id]=1; |
|
| 1155 | + $projectstatic->loadTimeSpent($firstdaytoshow, 0, $fuser->id); // Load time spent from table projet_task_time for the project into this->weekWorkLoad and this->weekWorkLoadPerTask for all days of a week |
|
| 1156 | + $workloadforid[$projectstatic->id] = 1; |
|
| 1157 | 1157 | } |
| 1158 | 1158 | //var_dump($projectstatic->weekWorkLoadPerTask); |
| 1159 | 1159 | //var_dump('--- '.$projectstatic->id.' '.$workloadforid[$projectstatic->id]); |
| 1160 | 1160 | |
| 1161 | - $projectstatic->id=$lines[$i]->fk_project; |
|
| 1162 | - $projectstatic->ref=$lines[$i]->projectref; |
|
| 1163 | - $projectstatic->title=$lines[$i]->projectlabel; |
|
| 1164 | - $projectstatic->public=$lines[$i]->public; |
|
| 1165 | - $projectstatic->thirdparty_name=$lines[$i]->thirdparty_name; |
|
| 1161 | + $projectstatic->id = $lines[$i]->fk_project; |
|
| 1162 | + $projectstatic->ref = $lines[$i]->projectref; |
|
| 1163 | + $projectstatic->title = $lines[$i]->projectlabel; |
|
| 1164 | + $projectstatic->public = $lines[$i]->public; |
|
| 1165 | + $projectstatic->thirdparty_name = $lines[$i]->thirdparty_name; |
|
| 1166 | 1166 | |
| 1167 | - $taskstatic->id=$lines[$i]->id; |
|
| 1168 | - $taskstatic->ref=($lines[$i]->ref?$lines[$i]->ref:$lines[$i]->id); |
|
| 1169 | - $taskstatic->label=$lines[$i]->label; |
|
| 1170 | - $taskstatic->date_start=$lines[$i]->date_start; |
|
| 1171 | - $taskstatic->date_end=$lines[$i]->date_end; |
|
| 1167 | + $taskstatic->id = $lines[$i]->id; |
|
| 1168 | + $taskstatic->ref = ($lines[$i]->ref ? $lines[$i]->ref : $lines[$i]->id); |
|
| 1169 | + $taskstatic->label = $lines[$i]->label; |
|
| 1170 | + $taskstatic->date_start = $lines[$i]->date_start; |
|
| 1171 | + $taskstatic->date_end = $lines[$i]->date_end; |
|
| 1172 | 1172 | |
| 1173 | - $thirdpartystatic->id=$lines[$i]->thirdparty_id; |
|
| 1174 | - $thirdpartystatic->name=$lines[$i]->thirdparty_name; |
|
| 1175 | - $thirdpartystatic->email=$lines[$i]->thirdparty_email; |
|
| 1173 | + $thirdpartystatic->id = $lines[$i]->thirdparty_id; |
|
| 1174 | + $thirdpartystatic->name = $lines[$i]->thirdparty_name; |
|
| 1175 | + $thirdpartystatic->email = $lines[$i]->thirdparty_email; |
|
| 1176 | 1176 | |
| 1177 | 1177 | if (empty($oldprojectforbreak) || ($oldprojectforbreak != -1 && $oldprojectforbreak != $projectstatic->id)) |
| 1178 | 1178 | { |
| 1179 | 1179 | print '<tr class="oddeven trforbreak">'."\n"; |
| 1180 | 1180 | print '<td colspan="13">'; |
| 1181 | - print $projectstatic->getNomUrl(1,'',0,'<strong>'.$langs->transnoentitiesnoconv("YourRole").':</strong> '.$projectsrole[$lines[$i]->fk_project]); |
|
| 1181 | + print $projectstatic->getNomUrl(1, '', 0, '<strong>'.$langs->transnoentitiesnoconv("YourRole").':</strong> '.$projectsrole[$lines[$i]->fk_project]); |
|
| 1182 | 1182 | if ($thirdpartystatic->id > 0) print ' - '.$thirdpartystatic->getNomUrl(1); |
| 1183 | 1183 | if ($projectstatic->title) |
| 1184 | 1184 | { |
@@ -1213,11 +1213,11 @@ discard block |
||
| 1213 | 1213 | // Ref |
| 1214 | 1214 | print '<td class="nowrap">'; |
| 1215 | 1215 | print '<!-- Task id = '.$lines[$i]->id.' -->'; |
| 1216 | - for ($k = 0 ; $k < $level ; $k++) print " "; |
|
| 1216 | + for ($k = 0; $k < $level; $k++) print " "; |
|
| 1217 | 1217 | print $taskstatic->getNomUrl(1, 'withproject', 'time'); |
| 1218 | 1218 | // Label task |
| 1219 | 1219 | print '<br>'; |
| 1220 | - for ($k = 0 ; $k < $level ; $k++) print " "; |
|
| 1220 | + for ($k = 0; $k < $level; $k++) print " "; |
|
| 1221 | 1221 | //print $taskstatic->getNomUrl(0, 'withproject', 'time'); |
| 1222 | 1222 | print $taskstatic->label; |
| 1223 | 1223 | //print "<br>"; |
@@ -1227,13 +1227,13 @@ discard block |
||
| 1227 | 1227 | |
| 1228 | 1228 | // Planned Workload |
| 1229 | 1229 | print '<td align="right" class="leftborder plannedworkload">'; |
| 1230 | - if ($lines[$i]->planned_workload) print convertSecondToTime($lines[$i]->planned_workload,'allhourmin'); |
|
| 1230 | + if ($lines[$i]->planned_workload) print convertSecondToTime($lines[$i]->planned_workload, 'allhourmin'); |
|
| 1231 | 1231 | else print '--:--'; |
| 1232 | 1232 | print '</td>'; |
| 1233 | 1233 | |
| 1234 | 1234 | // Progress declared % |
| 1235 | 1235 | print '<td align="right">'; |
| 1236 | - print $formother->select_percent($lines[$i]->progress, $lines[$i]->id . 'progress'); |
|
| 1236 | + print $formother->select_percent($lines[$i]->progress, $lines[$i]->id.'progress'); |
|
| 1237 | 1237 | print '</td>'; |
| 1238 | 1238 | |
| 1239 | 1239 | // Time spent by everybody |
@@ -1242,7 +1242,7 @@ discard block |
||
| 1242 | 1242 | if ($lines[$i]->duration) |
| 1243 | 1243 | { |
| 1244 | 1244 | print '<a href="'.DOL_URL_ROOT.'/projet/tasks/time.php?id='.$lines[$i]->id.'">'; |
| 1245 | - print convertSecondToTime($lines[$i]->duration,'allhourmin'); |
|
| 1245 | + print convertSecondToTime($lines[$i]->duration, 'allhourmin'); |
|
| 1246 | 1246 | print '</a>'; |
| 1247 | 1247 | } |
| 1248 | 1248 | else print '--:--'; |
@@ -1250,80 +1250,80 @@ discard block |
||
| 1250 | 1250 | |
| 1251 | 1251 | // Time spent by user |
| 1252 | 1252 | print '<td align="right">'; |
| 1253 | - $tmptimespent=$taskstatic->getSummaryOfTimeSpent($fuser->id); |
|
| 1254 | - if ($tmptimespent['total_duration']) print convertSecondToTime($tmptimespent['total_duration'],'allhourmin'); |
|
| 1253 | + $tmptimespent = $taskstatic->getSummaryOfTimeSpent($fuser->id); |
|
| 1254 | + if ($tmptimespent['total_duration']) print convertSecondToTime($tmptimespent['total_duration'], 'allhourmin'); |
|
| 1255 | 1255 | else print '--:--'; |
| 1256 | 1256 | print "</td>\n"; |
| 1257 | 1257 | |
| 1258 | - $disabledproject=1;$disabledtask=1; |
|
| 1258 | + $disabledproject = 1; $disabledtask = 1; |
|
| 1259 | 1259 | //print "x".$lines[$i]->fk_project; |
| 1260 | 1260 | //var_dump($lines[$i]); |
| 1261 | 1261 | //var_dump($projectsrole[$lines[$i]->fk_project]); |
| 1262 | 1262 | // If at least one role for project |
| 1263 | - if ($lines[$i]->public || ! empty($projectsrole[$lines[$i]->fk_project]) || $user->rights->projet->all->creer) |
|
| 1263 | + if ($lines[$i]->public || !empty($projectsrole[$lines[$i]->fk_project]) || $user->rights->projet->all->creer) |
|
| 1264 | 1264 | { |
| 1265 | - $disabledproject=0; |
|
| 1266 | - $disabledtask=0; |
|
| 1265 | + $disabledproject = 0; |
|
| 1266 | + $disabledtask = 0; |
|
| 1267 | 1267 | } |
| 1268 | 1268 | // If $restricteditformytask is on and I have no role on task, i disable edit |
| 1269 | 1269 | if ($restricteditformytask && empty($tasksrole[$lines[$i]->id])) |
| 1270 | 1270 | { |
| 1271 | - $disabledtask=1; |
|
| 1271 | + $disabledtask = 1; |
|
| 1272 | 1272 | } |
| 1273 | 1273 | |
| 1274 | 1274 | //var_dump($projectstatic->weekWorkLoadPerTask); |
| 1275 | 1275 | |
| 1276 | 1276 | // Fields to show current time |
| 1277 | - $tableCell=''; $modeinput='hours'; |
|
| 1277 | + $tableCell = ''; $modeinput = 'hours'; |
|
| 1278 | 1278 | for ($idw = 0; $idw < 7; $idw++) |
| 1279 | 1279 | { |
| 1280 | - $tmpday=dol_time_plus_duree($firstdaytoshow, $idw, 'd'); |
|
| 1280 | + $tmpday = dol_time_plus_duree($firstdaytoshow, $idw, 'd'); |
|
| 1281 | 1281 | |
| 1282 | - $cssonholiday=''; |
|
| 1283 | - if (! $isavailable[$tmpday]['morning'] && ! $isavailable[$tmpday]['afternoon']) $cssonholiday.='onholidayallday '; |
|
| 1284 | - elseif (! $isavailable[$tmpday]['morning']) $cssonholiday.='onholidaymorning '; |
|
| 1285 | - elseif (! $isavailable[$tmpday]['afternoon']) $cssonholiday.='onholidayafternoon '; |
|
| 1282 | + $cssonholiday = ''; |
|
| 1283 | + if (!$isavailable[$tmpday]['morning'] && !$isavailable[$tmpday]['afternoon']) $cssonholiday .= 'onholidayallday '; |
|
| 1284 | + elseif (!$isavailable[$tmpday]['morning']) $cssonholiday .= 'onholidaymorning '; |
|
| 1285 | + elseif (!$isavailable[$tmpday]['afternoon']) $cssonholiday .= 'onholidayafternoon '; |
|
| 1286 | 1286 | |
| 1287 | - $tmparray=dol_getdate($tmpday); |
|
| 1287 | + $tmparray = dol_getdate($tmpday); |
|
| 1288 | 1288 | $dayWorkLoad = $projectstatic->weekWorkLoadPerTask[$tmpday][$lines[$i]->id]; |
| 1289 | - $totalforeachday[$tmpday]+=$dayWorkLoad; |
|
| 1289 | + $totalforeachday[$tmpday] += $dayWorkLoad; |
|
| 1290 | 1290 | |
| 1291 | - $alreadyspent=''; |
|
| 1292 | - if ($dayWorkLoad > 0) $alreadyspent=convertSecondToTime($dayWorkLoad,'allhourmin'); |
|
| 1293 | - $alttitle=$langs->trans("AddHereTimeSpentForDay",$tmparray['day'],$tmparray['mon']); |
|
| 1291 | + $alreadyspent = ''; |
|
| 1292 | + if ($dayWorkLoad > 0) $alreadyspent = convertSecondToTime($dayWorkLoad, 'allhourmin'); |
|
| 1293 | + $alttitle = $langs->trans("AddHereTimeSpentForDay", $tmparray['day'], $tmparray['mon']); |
|
| 1294 | 1294 | |
| 1295 | 1295 | global $numstartworkingday, $numendworkingday; |
| 1296 | - $cssweekend=''; |
|
| 1296 | + $cssweekend = ''; |
|
| 1297 | 1297 | if (($idw + 1) < $numstartworkingday || ($idw + 1) > $numendworkingday) // This is a day is not inside the setup of working days, so we use a week-end css. |
| 1298 | 1298 | { |
| 1299 | - $cssweekend='weekend'; |
|
| 1299 | + $cssweekend = 'weekend'; |
|
| 1300 | 1300 | } |
| 1301 | 1301 | |
| 1302 | - $tableCell ='<td align="center" class="hide'.$idw.($cssonholiday?' '.$cssonholiday:'').($cssweekend?' '.$cssweekend:'').'">'; |
|
| 1303 | - $placeholder=''; |
|
| 1302 | + $tableCell = '<td align="center" class="hide'.$idw.($cssonholiday ? ' '.$cssonholiday : '').($cssweekend ? ' '.$cssweekend : '').'">'; |
|
| 1303 | + $placeholder = ''; |
|
| 1304 | 1304 | if ($alreadyspent) |
| 1305 | 1305 | { |
| 1306 | - $tableCell.='<span class="timesheetalreadyrecorded" title="texttoreplace"><input type="text" class="center smallpadd" size="2" disabled id="timespent['.$inc.']['.$idw.']" name="task['.$lines[$i]->id.']['.$idw.']" value="'.$alreadyspent.'"></span>'; |
|
| 1306 | + $tableCell .= '<span class="timesheetalreadyrecorded" title="texttoreplace"><input type="text" class="center smallpadd" size="2" disabled id="timespent['.$inc.']['.$idw.']" name="task['.$lines[$i]->id.']['.$idw.']" value="'.$alreadyspent.'"></span>'; |
|
| 1307 | 1307 | //$placeholder=' placeholder="00:00"'; |
| 1308 | 1308 | //$tableCell.='+'; |
| 1309 | 1309 | } |
| 1310 | - $tableCell.='<input type="text" alt="'.($disabledtask?'':$alttitle).'" title="'.($disabledtask?'':$alttitle).'" '.($disabledtask?'disabled':$placeholder).' class="center smallpadd" size="2" id="timeadded['.$inc.']['.$idw.']" name="task['.$lines[$i]->id.']['.$idw.']" value="" cols="2" maxlength="5"'; |
|
| 1311 | - $tableCell.=' onkeypress="return regexEvent(this,event,\'timeChar\')"'; |
|
| 1312 | - $tableCell.=' onkeyup="updateTotal('.$idw.',\''.$modeinput.'\')"'; |
|
| 1313 | - $tableCell.=' onblur="regexEvent(this,event,\''.$modeinput.'\'); updateTotal('.$idw.',\''.$modeinput.'\')" />'; |
|
| 1314 | - $tableCell.='</td>'; |
|
| 1310 | + $tableCell .= '<input type="text" alt="'.($disabledtask ? '' : $alttitle).'" title="'.($disabledtask ? '' : $alttitle).'" '.($disabledtask ? 'disabled' : $placeholder).' class="center smallpadd" size="2" id="timeadded['.$inc.']['.$idw.']" name="task['.$lines[$i]->id.']['.$idw.']" value="" cols="2" maxlength="5"'; |
|
| 1311 | + $tableCell .= ' onkeypress="return regexEvent(this,event,\'timeChar\')"'; |
|
| 1312 | + $tableCell .= ' onkeyup="updateTotal('.$idw.',\''.$modeinput.'\')"'; |
|
| 1313 | + $tableCell .= ' onblur="regexEvent(this,event,\''.$modeinput.'\'); updateTotal('.$idw.',\''.$modeinput.'\')" />'; |
|
| 1314 | + $tableCell .= '</td>'; |
|
| 1315 | 1315 | print $tableCell; |
| 1316 | 1316 | } |
| 1317 | 1317 | |
| 1318 | 1318 | // Warning |
| 1319 | 1319 | print '<td align="right">'; |
| 1320 | - if ((! $lines[$i]->public) && $disabledproject) print $form->textwithpicto('',$langs->trans("UserIsNotContactOfProject")); |
|
| 1320 | + if ((!$lines[$i]->public) && $disabledproject) print $form->textwithpicto('', $langs->trans("UserIsNotContactOfProject")); |
|
| 1321 | 1321 | else if ($disabledtask) |
| 1322 | 1322 | { |
| 1323 | 1323 | $titleassigntask = $langs->trans("AssignTaskToMe"); |
| 1324 | 1324 | if ($fuser->id != $user->id) $titleassigntask = $langs->trans("AssignTaskToUser", '...'); |
| 1325 | 1325 | |
| 1326 | - print $form->textwithpicto('',$langs->trans("TaskIsNotAssignedToUser", $titleassigntask)); |
|
| 1326 | + print $form->textwithpicto('', $langs->trans("TaskIsNotAssignedToUser", $titleassigntask)); |
|
| 1327 | 1327 | } |
| 1328 | 1328 | print '</td>'; |
| 1329 | 1329 | |
@@ -1340,9 +1340,9 @@ discard block |
||
| 1340 | 1340 | $ret = projectLinesPerWeek($inc, $firstdaytoshow, $fuser, $lines[$i]->id, ($parent == 0 ? $lineswithoutlevel0 : $lines), $level, $projectsrole, $tasksrole, $mine, $restricteditformytask, $isavailable, $oldprojectforbreak); |
| 1341 | 1341 | //var_dump('ret with parent='.$lines[$i]->id.' level='.$level); |
| 1342 | 1342 | //var_dump($ret); |
| 1343 | - foreach($ret as $key => $val) |
|
| 1343 | + foreach ($ret as $key => $val) |
|
| 1344 | 1344 | { |
| 1345 | - $totalforeachday[$key]+=$val; |
|
| 1345 | + $totalforeachday[$key] += $val; |
|
| 1346 | 1346 | } |
| 1347 | 1347 | //var_dump('totalforeachday after taskid='.$lines[$i]->id.' and previous one on level '.$level.' + subtasks'); |
| 1348 | 1348 | //var_dump($totalforeachday); |
@@ -1371,8 +1371,8 @@ discard block |
||
| 1371 | 1371 | function searchTaskInChild(&$inc, $parent, &$lines, &$taskrole) |
| 1372 | 1372 | { |
| 1373 | 1373 | //print 'Search in line with parent id = '.$parent.'<br>'; |
| 1374 | - $numlines=count($lines); |
|
| 1375 | - for ($i = 0 ; $i < $numlines ; $i++) |
|
| 1374 | + $numlines = count($lines); |
|
| 1375 | + for ($i = 0; $i < $numlines; $i++) |
|
| 1376 | 1376 | { |
| 1377 | 1377 | // Process line $lines[$i] |
| 1378 | 1378 | if ($lines[$i]->fk_parent == $parent && $lines[$i]->id != $lines[$i]->fk_parent) |
@@ -1408,52 +1408,52 @@ discard block |
||
| 1408 | 1408 | * @param array $hiddenfields List of info to not show ('projectlabel', 'declaredprogress', '...', ) |
| 1409 | 1409 | * @return void |
| 1410 | 1410 | */ |
| 1411 | -function print_projecttasks_array($db, $form, $socid, $projectsListId, $mytasks=0, $statut=-1, $listofoppstatus=array(),$hiddenfields=array()) |
|
| 1411 | +function print_projecttasks_array($db, $form, $socid, $projectsListId, $mytasks = 0, $statut = -1, $listofoppstatus = array(), $hiddenfields = array()) |
|
| 1412 | 1412 | { |
| 1413 | - global $langs,$conf,$user,$bc; |
|
| 1413 | + global $langs, $conf, $user, $bc; |
|
| 1414 | 1414 | |
| 1415 | 1415 | require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; |
| 1416 | 1416 | |
| 1417 | - $projectstatic=new Project($db); |
|
| 1418 | - $thirdpartystatic=new Societe($db); |
|
| 1417 | + $projectstatic = new Project($db); |
|
| 1418 | + $thirdpartystatic = new Societe($db); |
|
| 1419 | 1419 | |
| 1420 | - $sortfield=''; |
|
| 1421 | - $sortorder=''; |
|
| 1422 | - $project_year_filter=0; |
|
| 1420 | + $sortfield = ''; |
|
| 1421 | + $sortorder = ''; |
|
| 1422 | + $project_year_filter = 0; |
|
| 1423 | 1423 | |
| 1424 | - $title=$langs->trans("Projects"); |
|
| 1425 | - if (strcmp($statut, '') && $statut >= 0) $title=$langs->trans("Projects").' '.$langs->trans($projectstatic->statuts_long[$statut]); |
|
| 1424 | + $title = $langs->trans("Projects"); |
|
| 1425 | + if (strcmp($statut, '') && $statut >= 0) $title = $langs->trans("Projects").' '.$langs->trans($projectstatic->statuts_long[$statut]); |
|
| 1426 | 1426 | |
| 1427 | - $arrayidtypeofcontact=array(); |
|
| 1427 | + $arrayidtypeofcontact = array(); |
|
| 1428 | 1428 | |
| 1429 | 1429 | print '<div class="div-table-responsive-no-min">'; |
| 1430 | 1430 | print '<table class="noborder" width="100%">'; |
| 1431 | 1431 | |
| 1432 | - $sql= " FROM ".MAIN_DB_PREFIX."projet as p"; |
|
| 1432 | + $sql = " FROM ".MAIN_DB_PREFIX."projet as p"; |
|
| 1433 | 1433 | if ($mytasks) |
| 1434 | 1434 | { |
| 1435 | - $sql.= ", ".MAIN_DB_PREFIX."projet_task as t"; |
|
| 1436 | - $sql.= ", ".MAIN_DB_PREFIX."element_contact as ec"; |
|
| 1437 | - $sql.= ", ".MAIN_DB_PREFIX."c_type_contact as ctc"; |
|
| 1435 | + $sql .= ", ".MAIN_DB_PREFIX."projet_task as t"; |
|
| 1436 | + $sql .= ", ".MAIN_DB_PREFIX."element_contact as ec"; |
|
| 1437 | + $sql .= ", ".MAIN_DB_PREFIX."c_type_contact as ctc"; |
|
| 1438 | 1438 | } |
| 1439 | 1439 | else |
| 1440 | 1440 | { |
| 1441 | - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."projet_task as t ON p.rowid = t.fk_projet"; |
|
| 1441 | + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."projet_task as t ON p.rowid = t.fk_projet"; |
|
| 1442 | 1442 | } |
| 1443 | - $sql.= " WHERE p.entity IN (".getEntity('project').")"; |
|
| 1444 | - $sql.= " AND p.rowid IN (".$projectsListId.")"; |
|
| 1445 | - if ($socid) $sql.= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")"; |
|
| 1443 | + $sql .= " WHERE p.entity IN (".getEntity('project').")"; |
|
| 1444 | + $sql .= " AND p.rowid IN (".$projectsListId.")"; |
|
| 1445 | + if ($socid) $sql .= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")"; |
|
| 1446 | 1446 | if ($mytasks) |
| 1447 | 1447 | { |
| 1448 | - $sql.= " AND p.rowid = t.fk_projet"; |
|
| 1449 | - $sql.= " AND ec.element_id = t.rowid"; |
|
| 1450 | - $sql.= " AND ec.fk_socpeople = ".$user->id; |
|
| 1451 | - $sql.= " AND ec.fk_c_type_contact = ctc.rowid"; // Replace the 2 lines with ec.fk_c_type_contact in $arrayidtypeofcontact |
|
| 1452 | - $sql.= " AND ctc.element = 'project_task'"; |
|
| 1448 | + $sql .= " AND p.rowid = t.fk_projet"; |
|
| 1449 | + $sql .= " AND ec.element_id = t.rowid"; |
|
| 1450 | + $sql .= " AND ec.fk_socpeople = ".$user->id; |
|
| 1451 | + $sql .= " AND ec.fk_c_type_contact = ctc.rowid"; // Replace the 2 lines with ec.fk_c_type_contact in $arrayidtypeofcontact |
|
| 1452 | + $sql .= " AND ctc.element = 'project_task'"; |
|
| 1453 | 1453 | } |
| 1454 | 1454 | if ($statut >= 0) |
| 1455 | 1455 | { |
| 1456 | - $sql.= " AND p.fk_statut = ".$statut; |
|
| 1456 | + $sql .= " AND p.fk_statut = ".$statut; |
|
| 1457 | 1457 | } |
| 1458 | 1458 | if (!empty($conf->global->PROJECT_LIMIT_YEAR_RANGE)) |
| 1459 | 1459 | { |
@@ -1465,40 +1465,40 @@ discard block |
||
| 1465 | 1465 | { |
| 1466 | 1466 | $project_year_filter = date("Y"); |
| 1467 | 1467 | } |
| 1468 | - $sql.= " AND (p.dateo IS NULL OR p.dateo <= ".$db->idate(dol_get_last_day($project_year_filter,12,false)).")"; |
|
| 1469 | - $sql.= " AND (p.datee IS NULL OR p.datee >= ".$db->idate(dol_get_first_day($project_year_filter,1,false)).")"; |
|
| 1468 | + $sql .= " AND (p.dateo IS NULL OR p.dateo <= ".$db->idate(dol_get_last_day($project_year_filter, 12, false)).")"; |
|
| 1469 | + $sql .= " AND (p.datee IS NULL OR p.datee >= ".$db->idate(dol_get_first_day($project_year_filter, 1, false)).")"; |
|
| 1470 | 1470 | } |
| 1471 | 1471 | } |
| 1472 | 1472 | |
| 1473 | 1473 | // Get id of project we must show tasks |
| 1474 | - $arrayidofprojects=array(); |
|
| 1474 | + $arrayidofprojects = array(); |
|
| 1475 | 1475 | $sql1 = "SELECT p.rowid as projectid"; |
| 1476 | - $sql1.= $sql; |
|
| 1476 | + $sql1 .= $sql; |
|
| 1477 | 1477 | $resql = $db->query($sql1); |
| 1478 | 1478 | if ($resql) |
| 1479 | 1479 | { |
| 1480 | - $i=0; |
|
| 1480 | + $i = 0; |
|
| 1481 | 1481 | $num = $db->num_rows($resql); |
| 1482 | 1482 | while ($i < $num) |
| 1483 | 1483 | { |
| 1484 | 1484 | $objp = $db->fetch_object($resql); |
| 1485 | - $arrayidofprojects[$objp->projectid]=$objp->projectid; |
|
| 1485 | + $arrayidofprojects[$objp->projectid] = $objp->projectid; |
|
| 1486 | 1486 | $i++; |
| 1487 | 1487 | } |
| 1488 | 1488 | } |
| 1489 | 1489 | else dol_print_error($db); |
| 1490 | - if (empty($arrayidofprojects)) $arrayidofprojects[0]=-1; |
|
| 1490 | + if (empty($arrayidofprojects)) $arrayidofprojects[0] = -1; |
|
| 1491 | 1491 | |
| 1492 | 1492 | // Get list of project with calculation on tasks |
| 1493 | 1493 | $sql2 = "SELECT p.rowid as projectid, p.ref, p.title, p.fk_soc, s.nom as socname, p.fk_user_creat, p.public, p.fk_statut as status, p.fk_opp_status as opp_status, p.opp_amount,"; |
| 1494 | - $sql2.= " p.dateo, p.datee,"; |
|
| 1495 | - $sql2.= " COUNT(t.rowid) as nb, SUM(t.planned_workload) as planned_workload, SUM(t.planned_workload * t.progress / 100) as declared_progess_workload"; |
|
| 1496 | - $sql2.= " FROM ".MAIN_DB_PREFIX."projet as p"; |
|
| 1497 | - $sql2.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = p.fk_soc"; |
|
| 1498 | - $sql2.= " LEFT JOIN ".MAIN_DB_PREFIX."projet_task as t ON p.rowid = t.fk_projet"; |
|
| 1499 | - $sql2.= " WHERE p.rowid IN (".join(',',$arrayidofprojects).")"; |
|
| 1500 | - $sql2.= " GROUP BY p.rowid, p.ref, p.title, p.fk_soc, s.nom, p.fk_user_creat, p.public, p.fk_statut, p.fk_opp_status, p.opp_amount, p.dateo, p.datee"; |
|
| 1501 | - $sql2.= " ORDER BY p.title, p.ref"; |
|
| 1494 | + $sql2 .= " p.dateo, p.datee,"; |
|
| 1495 | + $sql2 .= " COUNT(t.rowid) as nb, SUM(t.planned_workload) as planned_workload, SUM(t.planned_workload * t.progress / 100) as declared_progess_workload"; |
|
| 1496 | + $sql2 .= " FROM ".MAIN_DB_PREFIX."projet as p"; |
|
| 1497 | + $sql2 .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = p.fk_soc"; |
|
| 1498 | + $sql2 .= " LEFT JOIN ".MAIN_DB_PREFIX."projet_task as t ON p.rowid = t.fk_projet"; |
|
| 1499 | + $sql2 .= " WHERE p.rowid IN (".join(',', $arrayidofprojects).")"; |
|
| 1500 | + $sql2 .= " GROUP BY p.rowid, p.ref, p.title, p.fk_soc, s.nom, p.fk_user_creat, p.public, p.fk_statut, p.fk_opp_status, p.opp_amount, p.dateo, p.datee"; |
|
| 1501 | + $sql2 .= " ORDER BY p.title, p.ref"; |
|
| 1502 | 1502 | |
| 1503 | 1503 | $resql = $db->query($sql2); |
| 1504 | 1504 | if ($resql) |
@@ -1511,24 +1511,24 @@ discard block |
||
| 1511 | 1511 | $i = 0; |
| 1512 | 1512 | |
| 1513 | 1513 | print '<tr class="liste_titre">'; |
| 1514 | - print_liste_field_titre($title.' <span class="badge">'.$num.'</span>',$_SERVER["PHP_SELF"],"","","","",$sortfield,$sortorder); |
|
| 1515 | - print_liste_field_titre("ThirdParty",$_SERVER["PHP_SELF"],"","","","",$sortfield,$sortorder); |
|
| 1516 | - if (! empty($conf->global->PROJECT_USE_OPPORTUNITIES)) |
|
| 1514 | + print_liste_field_titre($title.' <span class="badge">'.$num.'</span>', $_SERVER["PHP_SELF"], "", "", "", "", $sortfield, $sortorder); |
|
| 1515 | + print_liste_field_titre("ThirdParty", $_SERVER["PHP_SELF"], "", "", "", "", $sortfield, $sortorder); |
|
| 1516 | + if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) |
|
| 1517 | 1517 | { |
| 1518 | - print_liste_field_titre("OpportunityAmount","","","","",'align="right"',$sortfield,$sortorder); |
|
| 1519 | - print_liste_field_titre("OpportunityStatus","","","","",'align="right"',$sortfield,$sortorder); |
|
| 1518 | + print_liste_field_titre("OpportunityAmount", "", "", "", "", 'align="right"', $sortfield, $sortorder); |
|
| 1519 | + print_liste_field_titre("OpportunityStatus", "", "", "", "", 'align="right"', $sortfield, $sortorder); |
|
| 1520 | 1520 | } |
| 1521 | 1521 | if (empty($conf->global->PROJECT_HIDE_TASKS)) |
| 1522 | 1522 | { |
| 1523 | - print_liste_field_titre("Tasks","","","","",'align="right"',$sortfield,$sortorder); |
|
| 1524 | - if (! in_array('plannedworkload', $hiddenfields)) print_liste_field_titre("PlannedWorkload","","","","",'align="right"',$sortfield,$sortorder); |
|
| 1525 | - if (! in_array('declaredprogress', $hiddenfields)) print_liste_field_titre("ProgressDeclared","","","","",'align="right"',$sortfield,$sortorder); |
|
| 1523 | + print_liste_field_titre("Tasks", "", "", "", "", 'align="right"', $sortfield, $sortorder); |
|
| 1524 | + if (!in_array('plannedworkload', $hiddenfields)) print_liste_field_titre("PlannedWorkload", "", "", "", "", 'align="right"', $sortfield, $sortorder); |
|
| 1525 | + if (!in_array('declaredprogress', $hiddenfields)) print_liste_field_titre("ProgressDeclared", "", "", "", "", 'align="right"', $sortfield, $sortorder); |
|
| 1526 | 1526 | } |
| 1527 | - print_liste_field_titre("Status","","","","",'align="right"',$sortfield,$sortorder); |
|
| 1527 | + print_liste_field_titre("Status", "", "", "", "", 'align="right"', $sortfield, $sortorder); |
|
| 1528 | 1528 | print "</tr>\n"; |
| 1529 | 1529 | |
| 1530 | - $total_plannedworkload=0; |
|
| 1531 | - $total_declaredprogressworkload=0; |
|
| 1530 | + $total_plannedworkload = 0; |
|
| 1531 | + $total_declaredprogressworkload = 0; |
|
| 1532 | 1532 | while ($i < $num) |
| 1533 | 1533 | { |
| 1534 | 1534 | $objp = $db->fetch_object($resql); |
@@ -1541,7 +1541,7 @@ discard block |
||
| 1541 | 1541 | $userAccess = $projectstatic->restrictedProjectArea($user); |
| 1542 | 1542 | if ($userAccess >= 0) |
| 1543 | 1543 | { |
| 1544 | - $projectstatic->ref=$objp->ref; |
|
| 1544 | + $projectstatic->ref = $objp->ref; |
|
| 1545 | 1545 | $projectstatic->statut = $objp->status; |
| 1546 | 1546 | $projectstatic->title = $objp->title; |
| 1547 | 1547 | $projectstatic->datee = $db->jdate($objp->datee); |
@@ -1551,18 +1551,18 @@ discard block |
||
| 1551 | 1551 | print '<tr class="oddeven">'; |
| 1552 | 1552 | print '<td>'; |
| 1553 | 1553 | print $projectstatic->getNomUrl(1); |
| 1554 | - if (! in_array('projectlabel', $hiddenfields)) print '<br>'.dol_trunc($objp->title,24); |
|
| 1554 | + if (!in_array('projectlabel', $hiddenfields)) print '<br>'.dol_trunc($objp->title, 24); |
|
| 1555 | 1555 | print '</td>'; |
| 1556 | 1556 | print '<td>'; |
| 1557 | 1557 | if ($objp->fk_soc > 0) |
| 1558 | 1558 | { |
| 1559 | - $thirdpartystatic->id=$objp->fk_soc; |
|
| 1560 | - $thirdpartystatic->ref=$objp->socname; |
|
| 1561 | - $thirdpartystatic->name=$objp->socname; |
|
| 1559 | + $thirdpartystatic->id = $objp->fk_soc; |
|
| 1560 | + $thirdpartystatic->ref = $objp->socname; |
|
| 1561 | + $thirdpartystatic->name = $objp->socname; |
|
| 1562 | 1562 | print $thirdpartystatic->getNomUrl(1); |
| 1563 | 1563 | } |
| 1564 | 1564 | print '</td>'; |
| 1565 | - if (! empty($conf->global->PROJECT_USE_OPPORTUNITIES)) |
|
| 1565 | + if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) |
|
| 1566 | 1566 | { |
| 1567 | 1567 | print '<td align="right">'; |
| 1568 | 1568 | if ($objp->opp_amount) print price($objp->opp_amount, 0, '', 1, -1, -1, $conf->currency); |
@@ -1576,19 +1576,19 @@ discard block |
||
| 1576 | 1576 | { |
| 1577 | 1577 | print '<td align="right">'.$objp->nb.'</td>'; |
| 1578 | 1578 | |
| 1579 | - $plannedworkload=$objp->planned_workload; |
|
| 1580 | - $total_plannedworkload+=$plannedworkload; |
|
| 1581 | - if (! in_array('plannedworkload', $hiddenfields)) |
|
| 1579 | + $plannedworkload = $objp->planned_workload; |
|
| 1580 | + $total_plannedworkload += $plannedworkload; |
|
| 1581 | + if (!in_array('plannedworkload', $hiddenfields)) |
|
| 1582 | 1582 | { |
| 1583 | - print '<td align="right">'.($plannedworkload?convertSecondToTime($plannedworkload):'').'</td>'; |
|
| 1583 | + print '<td align="right">'.($plannedworkload ?convertSecondToTime($plannedworkload) : '').'</td>'; |
|
| 1584 | 1584 | } |
| 1585 | - if (! in_array('declaredprogress', $hiddenfields)) |
|
| 1585 | + if (!in_array('declaredprogress', $hiddenfields)) |
|
| 1586 | 1586 | { |
| 1587 | - $declaredprogressworkload=$objp->declared_progess_workload; |
|
| 1588 | - $total_declaredprogressworkload+=$declaredprogressworkload; |
|
| 1587 | + $declaredprogressworkload = $objp->declared_progess_workload; |
|
| 1588 | + $total_declaredprogressworkload += $declaredprogressworkload; |
|
| 1589 | 1589 | print '<td align="right">'; |
| 1590 | 1590 | //print $objp->planned_workload.'-'.$objp->declared_progess_workload."<br>"; |
| 1591 | - print ($plannedworkload?round(100*$declaredprogressworkload/$plannedworkload,0).'%':''); |
|
| 1591 | + print ($plannedworkload ?round(100 * $declaredprogressworkload / $plannedworkload, 0).'%' : ''); |
|
| 1592 | 1592 | print '</td>'; |
| 1593 | 1593 | } |
| 1594 | 1594 | } |
@@ -1606,7 +1606,7 @@ discard block |
||
| 1606 | 1606 | |
| 1607 | 1607 | print '<tr class="liste_total">'; |
| 1608 | 1608 | print '<td colspan="2">'.$langs->trans("Total")."</td>"; |
| 1609 | - if (! empty($conf->global->PROJECT_USE_OPPORTUNITIES)) |
|
| 1609 | + if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) |
|
| 1610 | 1610 | { |
| 1611 | 1611 | print '<td class="liste_total" align="right">'.price($total_opp_amount, 0, '', 1, -1, -1, $conf->currency).'</td>'; |
| 1612 | 1612 | print '<td class="liste_total" align="right">'.$form->textwithpicto(price($ponderated_opp_amount, 0, '', 1, -1, -1, $conf->currency), $langs->trans("OpportunityPonderatedAmountDesc"), 1).'</td>'; |
@@ -1614,8 +1614,8 @@ discard block |
||
| 1614 | 1614 | if (empty($conf->global->PROJECT_HIDE_TASKS)) |
| 1615 | 1615 | { |
| 1616 | 1616 | print '<td class="liste_total" align="right">'.$total_task.'</td>'; |
| 1617 | - if (! in_array('plannedworkload', $hiddenfields)) print '<td class="liste_total" align="right">'.($total_plannedworkload?convertSecondToTime($total_plannedworkload):'').'</td>'; |
|
| 1618 | - if (! in_array('declaredprogress', $hiddenfields)) print '<td class="liste_total" align="right">'.($total_plannedworkload?round(100*$total_declaredprogressworkload/$total_plannedworkload,0).'%':'').'</td>'; |
|
| 1617 | + if (!in_array('plannedworkload', $hiddenfields)) print '<td class="liste_total" align="right">'.($total_plannedworkload ?convertSecondToTime($total_plannedworkload) : '').'</td>'; |
|
| 1618 | + if (!in_array('declaredprogress', $hiddenfields)) print '<td class="liste_total" align="right">'.($total_plannedworkload ?round(100 * $total_declaredprogressworkload / $total_plannedworkload, 0).'%' : '').'</td>'; |
|
| 1619 | 1619 | } |
| 1620 | 1620 | print '<td class="liste_total"></td>'; |
| 1621 | 1621 | print '</tr>'; |
@@ -47,7 +47,9 @@ discard block |
||
| 47 | 47 | $nbContact = count($object->liste_contact(-1,'internal')) + count($object->liste_contact(-1,'external')); |
| 48 | 48 | $head[$h][0] = DOL_URL_ROOT.'/projet/contact.php?id='.$object->id; |
| 49 | 49 | $head[$h][1] = $langs->trans("ProjectContact"); |
| 50 | - if ($nbContact > 0) $head[$h][1].= ' <span class="badge">'.$nbContact.'</span>'; |
|
| 50 | + if ($nbContact > 0) { |
|
| 51 | + $head[$h][1].= ' <span class="badge">'.$nbContact.'</span>'; |
|
| 52 | + } |
|
| 51 | 53 | $head[$h][2] = 'contact'; |
| 52 | 54 | $h++; |
| 53 | 55 | |
@@ -71,11 +73,17 @@ discard block |
||
| 71 | 73 | if (empty($conf->global->MAIN_DISABLE_NOTES_TAB)) |
| 72 | 74 | { |
| 73 | 75 | $nbNote = 0; |
| 74 | - if(!empty($object->note_private)) $nbNote++; |
|
| 75 | - if(!empty($object->note_public)) $nbNote++; |
|
| 76 | + if(!empty($object->note_private)) { |
|
| 77 | + $nbNote++; |
|
| 78 | + } |
|
| 79 | + if(!empty($object->note_public)) { |
|
| 80 | + $nbNote++; |
|
| 81 | + } |
|
| 76 | 82 | $head[$h][0] = DOL_URL_ROOT.'/projet/note.php?id='.$object->id; |
| 77 | 83 | $head[$h][1] = $langs->trans('Notes'); |
| 78 | - if ($nbNote > 0) $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>'; |
|
| 84 | + if ($nbNote > 0) { |
|
| 85 | + $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>'; |
|
| 86 | + } |
|
| 79 | 87 | $head[$h][2] = 'notes'; |
| 80 | 88 | $h++; |
| 81 | 89 | } |
@@ -87,7 +95,9 @@ discard block |
||
| 87 | 95 | $nbLinks=Link::count($db, $object->element, $object->id); |
| 88 | 96 | $head[$h][0] = DOL_URL_ROOT.'/projet/document.php?id='.$object->id; |
| 89 | 97 | $head[$h][1] = $langs->trans('Documents'); |
| 90 | - if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>'; |
|
| 98 | + if (($nbFiles+$nbLinks) > 0) { |
|
| 99 | + $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>'; |
|
| 100 | + } |
|
| 91 | 101 | $head[$h][2] = 'document'; |
| 92 | 102 | $h++; |
| 93 | 103 | |
@@ -100,7 +110,9 @@ discard block |
||
| 100 | 110 | require_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php'; |
| 101 | 111 | $taskstatic=new Task($db); |
| 102 | 112 | $nbTasks=count($taskstatic->getTasksArray(0, 0, $object->id, 0, 0)); |
| 103 | - if ($nbTasks > 0) $head[$h][1].= ' <span class="badge">'.($nbTasks).'</span>'; |
|
| 113 | + if ($nbTasks > 0) { |
|
| 114 | + $head[$h][1].= ' <span class="badge">'.($nbTasks).'</span>'; |
|
| 115 | + } |
|
| 104 | 116 | $head[$h][2] = 'tasks'; |
| 105 | 117 | $h++; |
| 106 | 118 | |
@@ -117,7 +129,9 @@ discard block |
||
| 117 | 129 | $nbComments = $object->getNbComments(); |
| 118 | 130 | $head[$h][0] = DOL_URL_ROOT.'/projet/comment.php?id='.$object->id; |
| 119 | 131 | $head[$h][1] = $langs->trans("CommentLink"); |
| 120 | - if ($nbComments > 0) $head[$h][1].= ' <span class="badge">'.$nbComments.'</span>'; |
|
| 132 | + if ($nbComments > 0) { |
|
| 133 | + $head[$h][1].= ' <span class="badge">'.$nbComments.'</span>'; |
|
| 134 | + } |
|
| 121 | 135 | $head[$h][2] = 'project_comment'; |
| 122 | 136 | $h++; |
| 123 | 137 | } |
@@ -158,7 +172,9 @@ discard block |
||
| 158 | 172 | $nbContact = count($object->liste_contact(-1,'internal')) + count($object->liste_contact(-1,'external')); |
| 159 | 173 | $head[$h][0] = DOL_URL_ROOT.'/projet/tasks/contact.php?id='.$object->id.(GETPOST('withproject')?'&withproject=1':''); |
| 160 | 174 | $head[$h][1] = $langs->trans("TaskRessourceLinks"); |
| 161 | - if ($nbContact > 0) $head[$h][1].= ' <span class="badge">'.$nbContact.'</span>'; |
|
| 175 | + if ($nbContact > 0) { |
|
| 176 | + $head[$h][1].= ' <span class="badge">'.$nbContact.'</span>'; |
|
| 177 | + } |
|
| 162 | 178 | $head[$h][2] = 'task_contact'; |
| 163 | 179 | $h++; |
| 164 | 180 | |
@@ -172,13 +188,18 @@ discard block |
||
| 172 | 188 | if ($resql) |
| 173 | 189 | { |
| 174 | 190 | $obj = $db->fetch_object($resql); |
| 175 | - if ($obj) $nbTimeSpent=1; |
|
| 191 | + if ($obj) { |
|
| 192 | + $nbTimeSpent=1; |
|
| 193 | + } |
|
| 194 | + } else { |
|
| 195 | + dol_print_error($db); |
|
| 176 | 196 | } |
| 177 | - else dol_print_error($db); |
|
| 178 | 197 | |
| 179 | 198 | $head[$h][0] = DOL_URL_ROOT.'/projet/tasks/time.php?id='.$object->id.(GETPOST('withproject')?'&withproject=1':''); |
| 180 | 199 | $head[$h][1] = $langs->trans("TimeSpent"); |
| 181 | - if ($nbTimeSpent > 0) $head[$h][1].= ' <span class="badge">...</span>'; |
|
| 200 | + if ($nbTimeSpent > 0) { |
|
| 201 | + $head[$h][1].= ' <span class="badge">...</span>'; |
|
| 202 | + } |
|
| 182 | 203 | $head[$h][2] = 'task_time'; |
| 183 | 204 | $h++; |
| 184 | 205 | |
@@ -191,11 +212,17 @@ discard block |
||
| 191 | 212 | if (empty($conf->global->MAIN_DISABLE_NOTES_TAB)) |
| 192 | 213 | { |
| 193 | 214 | $nbNote = 0; |
| 194 | - if(!empty($object->note_private)) $nbNote++; |
|
| 195 | - if(!empty($object->note_public)) $nbNote++; |
|
| 215 | + if(!empty($object->note_private)) { |
|
| 216 | + $nbNote++; |
|
| 217 | + } |
|
| 218 | + if(!empty($object->note_public)) { |
|
| 219 | + $nbNote++; |
|
| 220 | + } |
|
| 196 | 221 | $head[$h][0] = DOL_URL_ROOT.'/projet/tasks/note.php?id='.$object->id.(GETPOST('withproject')?'&withproject=1':''); |
| 197 | 222 | $head[$h][1] = $langs->trans('Notes'); |
| 198 | - if ($nbNote > 0) $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>'; |
|
| 223 | + if ($nbNote > 0) { |
|
| 224 | + $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>'; |
|
| 225 | + } |
|
| 199 | 226 | $head[$h][2] = 'task_notes'; |
| 200 | 227 | $h++; |
| 201 | 228 | } |
@@ -207,7 +234,9 @@ discard block |
||
| 207 | 234 | $nbFiles = count(dol_dir_list($filesdir,'files',0,'','(\.meta|_preview.*\.png)$')); |
| 208 | 235 | $nbLinks=Link::count($db, $object->element, $object->id); |
| 209 | 236 | $head[$h][1] = $langs->trans('Documents'); |
| 210 | - 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 | + } |
|
| 211 | 240 | $head[$h][2] = 'task_document'; |
| 212 | 241 | $h++; |
| 213 | 242 | |
@@ -217,7 +246,9 @@ discard block |
||
| 217 | 246 | $nbComments = $object->getNbComments(); |
| 218 | 247 | $head[$h][0] = DOL_URL_ROOT.'/projet/tasks/comment.php?id='.$object->id.(GETPOST('withproject')?'&withproject=1':''); |
| 219 | 248 | $head[$h][1] = $langs->trans("CommentLink"); |
| 220 | - if ($nbComments > 0) $head[$h][1].= ' <span class="badge">'.$nbComments.'</span>'; |
|
| 249 | + if ($nbComments > 0) { |
|
| 250 | + $head[$h][1].= ' <span class="badge">'.$nbComments.'</span>'; |
|
| 251 | + } |
|
| 221 | 252 | $head[$h][2] = 'task_comment'; |
| 222 | 253 | $h++; |
| 223 | 254 | } |
@@ -244,7 +275,9 @@ discard block |
||
| 244 | 275 | |
| 245 | 276 | $param=''; |
| 246 | 277 | $param.=($mode?'&mode='.$mode:''); |
| 247 | - if (is_object($fuser) && $fuser->id > 0 && $fuser->id != $user->id) $param.='&search_usertoprocessid='.$fuser->id; |
|
| 278 | + if (is_object($fuser) && $fuser->id > 0 && $fuser->id != $user->id) { |
|
| 279 | + $param.='&search_usertoprocessid='.$fuser->id; |
|
| 280 | + } |
|
| 248 | 281 | |
| 249 | 282 | if (empty($conf->global->PROJECT_DISABLE_TIMESHEET_PERWEEK)) |
| 250 | 283 | { |
@@ -351,15 +384,20 @@ discard block |
||
| 351 | 384 | |
| 352 | 385 | for ($i = 0 ; $i < $numlines ; $i++) |
| 353 | 386 | { |
| 354 | - if ($parent == 0 && $level >= 0) $level = 0; // if $level = -1, we dont' use sublevel recursion, we show all lines |
|
| 387 | + if ($parent == 0 && $level >= 0) { |
|
| 388 | + $level = 0; |
|
| 389 | + } |
|
| 390 | + // if $level = -1, we dont' use sublevel recursion, we show all lines |
|
| 355 | 391 | |
| 356 | 392 | // Process line |
| 357 | 393 | // print "i:".$i."-".$lines[$i]->fk_project.'<br>'; |
| 358 | 394 | |
| 359 | - if ($lines[$i]->fk_parent == $parent || $level < 0) // if $level = -1, we dont' use sublevel recursion, we show all lines |
|
| 395 | + if ($lines[$i]->fk_parent == $parent || $level < 0) { |
|
| 396 | + // if $level = -1, we dont' use sublevel recursion, we show all lines |
|
| 360 | 397 | { |
| 361 | 398 | // Show task line. |
| 362 | 399 | $showline=1; |
| 400 | + } |
|
| 363 | 401 | $showlineingray=0; |
| 364 | 402 | |
| 365 | 403 | // If there is filters to use |
@@ -375,14 +413,12 @@ discard block |
||
| 375 | 413 | if ($foundtaskforuserdeeper > 0) |
| 376 | 414 | { |
| 377 | 415 | $showlineingray=1; // We will show line but in gray |
| 378 | - } |
|
| 379 | - else |
|
| 416 | + } else |
|
| 380 | 417 | { |
| 381 | 418 | $showline=0; // No reason to show line |
| 382 | 419 | } |
| 383 | 420 | } |
| 384 | - } |
|
| 385 | - else |
|
| 421 | + } else |
|
| 386 | 422 | { |
| 387 | 423 | // Caller did not ask to filter on tasks of a specific user (this probably means he want also tasks of all users, into public project |
| 388 | 424 | // or into all other projects if user has permission to). |
@@ -419,8 +455,11 @@ discard block |
||
| 419 | 455 | $projectstatic->ref=$lines[$i]->projectref; |
| 420 | 456 | $projectstatic->public=$lines[$i]->public; |
| 421 | 457 | $projectstatic->title=$lines[$i]->projectlabel; |
| 422 | - if ($lines[$i]->public || in_array($lines[$i]->fk_project,$projectsArrayId) || ! empty($user->rights->projet->all->lire)) print $projectstatic->getNomUrl(1); |
|
| 423 | - else print $projectstatic->getNomUrl(1,'nolink'); |
|
| 458 | + if ($lines[$i]->public || in_array($lines[$i]->fk_project,$projectsArrayId) || ! empty($user->rights->projet->all->lire)) { |
|
| 459 | + print $projectstatic->getNomUrl(1); |
|
| 460 | + } else { |
|
| 461 | + print $projectstatic->getNomUrl(1,'nolink'); |
|
| 462 | + } |
|
| 424 | 463 | //if ($showlineingray) print '</i>'; |
| 425 | 464 | print "</td>"; |
| 426 | 465 | |
@@ -436,8 +475,7 @@ discard block |
||
| 436 | 475 | if ($showlineingray) |
| 437 | 476 | { |
| 438 | 477 | print '<i>'.img_object('','projecttask').' '.$lines[$i]->ref.'</i>'; |
| 439 | - } |
|
| 440 | - else |
|
| 478 | + } else |
|
| 441 | 479 | { |
| 442 | 480 | $taskstatic->id=$lines[$i]->id; |
| 443 | 481 | $taskstatic->ref=$lines[$i]->ref; |
@@ -448,14 +486,18 @@ discard block |
||
| 448 | 486 | |
| 449 | 487 | // Title of task |
| 450 | 488 | print "<td>"; |
| 451 | - if ($showlineingray) print '<i>'; |
|
| 489 | + if ($showlineingray) { |
|
| 490 | + print '<i>'; |
|
| 491 | + } |
|
| 452 | 492 | //else print '<a href="'.DOL_URL_ROOT.'/projet/tasks/task.php?id='.$lines[$i]->id.'&withproject=1">'; |
| 453 | 493 | for ($k = 0 ; $k < $level ; $k++) |
| 454 | 494 | { |
| 455 | 495 | print " "; |
| 456 | 496 | } |
| 457 | 497 | print $lines[$i]->label; |
| 458 | - if ($showlineingray) print '</i>'; |
|
| 498 | + if ($showlineingray) { |
|
| 499 | + print '</i>'; |
|
| 500 | + } |
|
| 459 | 501 | //else print '</a>'; |
| 460 | 502 | print "</td>\n"; |
| 461 | 503 | |
@@ -471,13 +513,19 @@ discard block |
||
| 471 | 513 | $taskstatic->fk_statut = $lines[$i]->status; |
| 472 | 514 | $taskstatic->datee = $lines[$i]->date_end; |
| 473 | 515 | print dol_print_date($lines[$i]->date_end,'dayhour'); |
| 474 | - if ($taskstatic->hasDelay()) print img_warning($langs->trans("Late")); |
|
| 516 | + if ($taskstatic->hasDelay()) { |
|
| 517 | + print img_warning($langs->trans("Late")); |
|
| 518 | + } |
|
| 475 | 519 | print '</td>'; |
| 476 | 520 | |
| 477 | 521 | $plannedworkloadoutputformat='allhourmin'; |
| 478 | 522 | $timespentoutputformat='allhourmin'; |
| 479 | - if (! empty($conf->global->PROJECT_PLANNED_WORKLOAD_FORMAT)) $plannedworkloadoutputformat=$conf->global->PROJECT_PLANNED_WORKLOAD_FORMAT; |
|
| 480 | - if (! empty($conf->global->PROJECT_TIMES_SPENT_FORMAT)) $timespentoutputformat=$conf->global->PROJECT_TIME_SPENT_FORMAT; |
|
| 523 | + if (! empty($conf->global->PROJECT_PLANNED_WORKLOAD_FORMAT)) { |
|
| 524 | + $plannedworkloadoutputformat=$conf->global->PROJECT_PLANNED_WORKLOAD_FORMAT; |
|
| 525 | + } |
|
| 526 | + if (! empty($conf->global->PROJECT_TIMES_SPENT_FORMAT)) { |
|
| 527 | + $timespentoutputformat=$conf->global->PROJECT_TIME_SPENT_FORMAT; |
|
| 528 | + } |
|
| 481 | 529 | |
| 482 | 530 | // Planned Workload (in working hours) |
| 483 | 531 | print '<td align="right">'; |
@@ -494,20 +542,32 @@ discard block |
||
| 494 | 542 | |
| 495 | 543 | // Time spent |
| 496 | 544 | print '<td align="right">'; |
| 497 | - if ($showlineingray) print '<i>'; |
|
| 498 | - else print '<a href="'.DOL_URL_ROOT.'/projet/tasks/time.php?id='.$lines[$i]->id.($showproject?'':'&withproject=1').'">'; |
|
| 499 | - if ($lines[$i]->duration) print convertSecondToTime($lines[$i]->duration,$timespentoutputformat); |
|
| 500 | - else print '--:--'; |
|
| 501 | - if ($showlineingray) print '</i>'; |
|
| 502 | - else print '</a>'; |
|
| 545 | + if ($showlineingray) { |
|
| 546 | + print '<i>'; |
|
| 547 | + } else { |
|
| 548 | + print '<a href="'.DOL_URL_ROOT.'/projet/tasks/time.php?id='.$lines[$i]->id.($showproject?'':'&withproject=1').'">'; |
|
| 549 | + } |
|
| 550 | + if ($lines[$i]->duration) { |
|
| 551 | + print convertSecondToTime($lines[$i]->duration,$timespentoutputformat); |
|
| 552 | + } else { |
|
| 553 | + print '--:--'; |
|
| 554 | + } |
|
| 555 | + if ($showlineingray) { |
|
| 556 | + print '</i>'; |
|
| 557 | + } else { |
|
| 558 | + print '</a>'; |
|
| 559 | + } |
|
| 503 | 560 | print '</td>'; |
| 504 | 561 | |
| 505 | 562 | // Progress calculated (Note: ->duration is time spent) |
| 506 | 563 | print '<td align="right">'; |
| 507 | 564 | if ($lines[$i]->planned_workload || $lines[$i]->duration) |
| 508 | 565 | { |
| 509 | - if ($lines[$i]->planned_workload) print round(100 * $lines[$i]->duration / $lines[$i]->planned_workload,2).' %'; |
|
| 510 | - else print '<span class="opacitymedium">'.$langs->trans('WorkloadNotDefined').'</span>'; |
|
| 566 | + if ($lines[$i]->planned_workload) { |
|
| 567 | + print round(100 * $lines[$i]->duration / $lines[$i]->planned_workload,2).' %'; |
|
| 568 | + } else { |
|
| 569 | + print '<span class="opacitymedium">'.$langs->trans('WorkloadNotDefined').'</span>'; |
|
| 570 | + } |
|
| 511 | 571 | } |
| 512 | 572 | print '</td>'; |
| 513 | 573 | |
@@ -527,21 +587,28 @@ discard block |
||
| 527 | 587 | |
| 528 | 588 | print "</tr>\n"; |
| 529 | 589 | |
| 530 | - if (! $showlineingray) $inc++; |
|
| 590 | + if (! $showlineingray) { |
|
| 591 | + $inc++; |
|
| 592 | + } |
|
| 531 | 593 | |
| 532 | - if ($level >= 0) // Call sublevels |
|
| 594 | + if ($level >= 0) { |
|
| 595 | + // Call sublevels |
|
| 533 | 596 | { |
| 534 | 597 | $level++; |
| 535 | - if ($lines[$i]->id) projectLinesa($inc, $lines[$i]->id, $lines, $level, $var, $showproject, $taskrole, $projectsListId, $addordertick); |
|
| 598 | + } |
|
| 599 | + if ($lines[$i]->id) { |
|
| 600 | + projectLinesa($inc, $lines[$i]->id, $lines, $level, $var, $showproject, $taskrole, $projectsListId, $addordertick); |
|
| 601 | + } |
|
| 536 | 602 | $level--; |
| 537 | 603 | } |
| 538 | 604 | |
| 539 | 605 | $total_projectlinesa_spent += $lines[$i]->duration; |
| 540 | 606 | $total_projectlinesa_planned += $lines[$i]->planned_workload; |
| 541 | - if ($lines[$i]->planned_workload) $total_projectlinesa_spent_if_planned += $lines[$i]->duration; |
|
| 607 | + if ($lines[$i]->planned_workload) { |
|
| 608 | + $total_projectlinesa_spent_if_planned += $lines[$i]->duration; |
|
| 609 | + } |
|
| 542 | 610 | } |
| 543 | - } |
|
| 544 | - else |
|
| 611 | + } else |
|
| 545 | 612 | { |
| 546 | 613 | //$level--; |
| 547 | 614 | } |
@@ -551,7 +618,9 @@ discard block |
||
| 551 | 618 | { |
| 552 | 619 | print '<tr class="liste_total nodrag nodrop">'; |
| 553 | 620 | print '<td class="liste_total">'.$langs->trans("Total").'</td>'; |
| 554 | - if ($showproject) print '<td></td><td></td>'; |
|
| 621 | + if ($showproject) { |
|
| 622 | + print '<td></td><td></td>'; |
|
| 623 | + } |
|
| 555 | 624 | print '<td></td>'; |
| 556 | 625 | print '<td></td>'; |
| 557 | 626 | print '<td></td>'; |
@@ -559,15 +628,23 @@ discard block |
||
| 559 | 628 | print convertSecondToTime($total_projectlinesa_planned, 'allhourmin'); |
| 560 | 629 | print '</td>'; |
| 561 | 630 | print '<td align="right" class="nowrap liste_total">'; |
| 562 | - if ($projectidfortotallink > 0) print '<a href="'.DOL_URL_ROOT.'/projet/tasks/time.php?projectid='.$projectidfortotallink.($showproject?'':'&withproject=1').'">'; |
|
| 631 | + if ($projectidfortotallink > 0) { |
|
| 632 | + print '<a href="'.DOL_URL_ROOT.'/projet/tasks/time.php?projectid='.$projectidfortotallink.($showproject?'':'&withproject=1').'">'; |
|
| 633 | + } |
|
| 563 | 634 | print convertSecondToTime($total_projectlinesa_spent, 'allhourmin'); |
| 564 | - if ($projectidfortotallink > 0) print '</a>'; |
|
| 635 | + if ($projectidfortotallink > 0) { |
|
| 636 | + print '</a>'; |
|
| 637 | + } |
|
| 565 | 638 | print '</td>'; |
| 566 | 639 | print '<td align="right" class="nowrap liste_total">'; |
| 567 | - if ($total_projectlinesa_planned) print round(100 * $total_projectlinesa_spent / $total_projectlinesa_planned,2).' %'; |
|
| 640 | + if ($total_projectlinesa_planned) { |
|
| 641 | + print round(100 * $total_projectlinesa_spent / $total_projectlinesa_planned,2).' %'; |
|
| 642 | + } |
|
| 568 | 643 | print '</td>'; |
| 569 | 644 | print '<td></td>'; |
| 570 | - if ($addordertick) print '<td class="hideonsmartphone"></td>'; |
|
| 645 | + if ($addordertick) { |
|
| 646 | + print '<td class="hideonsmartphone"></td>'; |
|
| 647 | + } |
|
| 571 | 648 | print '</tr>'; |
| 572 | 649 | } |
| 573 | 650 | |
@@ -605,11 +682,16 @@ discard block |
||
| 605 | 682 | $numlines=count($lines); |
| 606 | 683 | |
| 607 | 684 | // Create a smaller array with sublevels only to be used later. This increase dramatically performances. |
| 608 | - if ($parent == 0) // Always and only if at first level |
|
| 685 | + if ($parent == 0) { |
|
| 686 | + // Always and only if at first level |
|
| 609 | 687 | { |
| 610 | - for ($i = 0 ; $i < $numlines ; $i++) |
|
| 688 | + for ($i = 0 ; |
|
| 689 | + } |
|
| 690 | + $i < $numlines ; $i++) |
|
| 611 | 691 | { |
| 612 | - if ($lines[$i]->fk_task_parent) $lineswithoutlevel0[]=$lines[$i]; |
|
| 692 | + if ($lines[$i]->fk_task_parent) { |
|
| 693 | + $lineswithoutlevel0[]=$lines[$i]; |
|
| 694 | + } |
|
| 613 | 695 | } |
| 614 | 696 | } |
| 615 | 697 | |
@@ -621,7 +703,9 @@ discard block |
||
| 621 | 703 | //dol_syslog('projectLinesPerDay inc='.$inc.' preselectedday='.$preselectedday.' task parent id='.$parent.' level='.$level." count(lines)=".$numlines." count(lineswithoutlevel0)=".count($lineswithoutlevel0)); |
| 622 | 704 | for ($i = 0 ; $i < $numlines ; $i++) |
| 623 | 705 | { |
| 624 | - if ($parent == 0) $level = 0; |
|
| 706 | + if ($parent == 0) { |
|
| 707 | + $level = 0; |
|
| 708 | + } |
|
| 625 | 709 | |
| 626 | 710 | //if ($lines[$i]->fk_task_parent == $parent) |
| 627 | 711 | //{ |
@@ -678,7 +762,9 @@ discard block |
||
| 678 | 762 | print '</tr>'; |
| 679 | 763 | } |
| 680 | 764 | |
| 681 | - if ($oldprojectforbreak != -1) $oldprojectforbreak = $projectstatic->id; |
|
| 765 | + if ($oldprojectforbreak != -1) { |
|
| 766 | + $oldprojectforbreak = $projectstatic->id; |
|
| 767 | + } |
|
| 682 | 768 | |
| 683 | 769 | print '<tr class="oddeven">'."\n"; |
| 684 | 770 | |
@@ -700,17 +786,23 @@ discard block |
||
| 700 | 786 | |
| 701 | 787 | // Thirdparty |
| 702 | 788 | print '<td class="tdoverflowmax100">'; |
| 703 | - if ($thirdpartystatic->id > 0) print $thirdpartystatic->getNomUrl(1, 'project', 10); |
|
| 789 | + if ($thirdpartystatic->id > 0) { |
|
| 790 | + print $thirdpartystatic->getNomUrl(1, 'project', 10); |
|
| 791 | + } |
|
| 704 | 792 | print '</td>'; |
| 705 | 793 | |
| 706 | 794 | // Ref |
| 707 | 795 | print '<td>'; |
| 708 | 796 | print '<!-- Task id = '.$lines[$i]->id.' -->'; |
| 709 | - for ($k = 0 ; $k < $level ; $k++) print " "; |
|
| 797 | + for ($k = 0 ; $k < $level ; $k++) { |
|
| 798 | + print " "; |
|
| 799 | + } |
|
| 710 | 800 | print $taskstatic->getNomUrl(1, 'withproject', 'time'); |
| 711 | 801 | // Label task |
| 712 | 802 | print '<br>'; |
| 713 | - for ($k = 0 ; $k < $level ; $k++) print " "; |
|
| 803 | + for ($k = 0 ; $k < $level ; $k++) { |
|
| 804 | + print " "; |
|
| 805 | + } |
|
| 714 | 806 | print $taskstatic->label; |
| 715 | 807 | //print "<br>"; |
| 716 | 808 | //for ($k = 0 ; $k < $level ; $k++) print " "; |
@@ -744,9 +836,13 @@ discard block |
||
| 744 | 836 | print '</td>'; |
| 745 | 837 | |
| 746 | 838 | $cssonholiday=''; |
| 747 | - if (! $isavailable[$preselectedday]['morning'] && ! $isavailable[$preselectedday]['afternoon']) $cssonholiday.='onholidayallday '; |
|
| 748 | - elseif (! $isavailable[$preselectedday]['morning']) $cssonholiday.='onholidaymorning '; |
|
| 749 | - elseif (! $isavailable[$preselectedday]['afternoon']) $cssonholiday.='onholidayafternoon '; |
|
| 839 | + if (! $isavailable[$preselectedday]['morning'] && ! $isavailable[$preselectedday]['afternoon']) { |
|
| 840 | + $cssonholiday.='onholidayallday '; |
|
| 841 | + } elseif (! $isavailable[$preselectedday]['morning']) { |
|
| 842 | + $cssonholiday.='onholidaymorning '; |
|
| 843 | + } elseif (! $isavailable[$preselectedday]['afternoon']) { |
|
| 844 | + $cssonholiday.='onholidayafternoon '; |
|
| 845 | + } |
|
| 750 | 846 | |
| 751 | 847 | // Duration |
| 752 | 848 | print '<td align="center" class="duration'.($cssonholiday?' '.$cssonholiday:'').'">'; |
@@ -755,7 +851,9 @@ discard block |
||
| 755 | 851 | $totalforeachline[$preselectedday]+=$lines[$i]->timespent_duration; |
| 756 | 852 | |
| 757 | 853 | $alreadyspent=''; |
| 758 | - if ($dayWorkLoad > 0) $alreadyspent=convertSecondToTime($lines[$i]->timespent_duration,'allhourmin'); |
|
| 854 | + if ($dayWorkLoad > 0) { |
|
| 855 | + $alreadyspent=convertSecondToTime($lines[$i]->timespent_duration,'allhourmin'); |
|
| 856 | + } |
|
| 759 | 857 | |
| 760 | 858 | print convertSecondToTime($lines[$i]->timespent_duration,'allhourmin'); |
| 761 | 859 | |
@@ -831,11 +929,16 @@ discard block |
||
| 831 | 929 | $numlines=count($lines); |
| 832 | 930 | |
| 833 | 931 | // Create a smaller array with sublevels only to be used later. This increase dramatically performances. |
| 834 | - if ($parent == 0) // Always and only if at first level |
|
| 932 | + if ($parent == 0) { |
|
| 933 | + // Always and only if at first level |
|
| 835 | 934 | { |
| 836 | - for ($i = 0 ; $i < $numlines ; $i++) |
|
| 935 | + for ($i = 0 ; |
|
| 936 | + } |
|
| 937 | + $i < $numlines ; $i++) |
|
| 837 | 938 | { |
| 838 | - if ($lines[$i]->fk_task_parent) $lineswithoutlevel0[]=$lines[$i]; |
|
| 939 | + if ($lines[$i]->fk_task_parent) { |
|
| 940 | + $lineswithoutlevel0[]=$lines[$i]; |
|
| 941 | + } |
|
| 839 | 942 | } |
| 840 | 943 | } |
| 841 | 944 | |
@@ -847,7 +950,9 @@ discard block |
||
| 847 | 950 | //dol_syslog('projectLinesPerDay inc='.$inc.' preselectedday='.$preselectedday.' task parent id='.$parent.' level='.$level." count(lines)=".$numlines." count(lineswithoutlevel0)=".count($lineswithoutlevel0)); |
| 848 | 951 | for ($i = 0 ; $i < $numlines ; $i++) |
| 849 | 952 | { |
| 850 | - if ($parent == 0) $level = 0; |
|
| 953 | + if ($parent == 0) { |
|
| 954 | + $level = 0; |
|
| 955 | + } |
|
| 851 | 956 | |
| 852 | 957 | if ($lines[$i]->fk_task_parent == $parent) |
| 853 | 958 | { |
@@ -895,7 +1000,9 @@ discard block |
||
| 895 | 1000 | print '<tr class="oddeven trforbreak">'."\n"; |
| 896 | 1001 | print '<td colspan="9">'; |
| 897 | 1002 | print $projectstatic->getNomUrl(1,'',0,'<strong>'.$langs->transnoentitiesnoconv("YourRole").':</strong> '.$projectsrole[$lines[$i]->fk_project]); |
| 898 | - if ($thirdpartystatic->id > 0) print ' - '.$thirdpartystatic->getNomUrl(1); |
|
| 1003 | + if ($thirdpartystatic->id > 0) { |
|
| 1004 | + print ' - '.$thirdpartystatic->getNomUrl(1); |
|
| 1005 | + } |
|
| 899 | 1006 | if ($projectstatic->title) |
| 900 | 1007 | { |
| 901 | 1008 | print ' - '; |
@@ -905,7 +1012,9 @@ discard block |
||
| 905 | 1012 | print '</tr>'; |
| 906 | 1013 | } |
| 907 | 1014 | |
| 908 | - if ($oldprojectforbreak != -1) $oldprojectforbreak = $projectstatic->id; |
|
| 1015 | + if ($oldprojectforbreak != -1) { |
|
| 1016 | + $oldprojectforbreak = $projectstatic->id; |
|
| 1017 | + } |
|
| 909 | 1018 | |
| 910 | 1019 | print '<tr class="oddeven">'."\n"; |
| 911 | 1020 | |
@@ -929,11 +1038,15 @@ discard block |
||
| 929 | 1038 | // Ref |
| 930 | 1039 | print '<td>'; |
| 931 | 1040 | print '<!-- Task id = '.$lines[$i]->id.' -->'; |
| 932 | - for ($k = 0 ; $k < $level ; $k++) print " "; |
|
| 1041 | + for ($k = 0 ; $k < $level ; $k++) { |
|
| 1042 | + print " "; |
|
| 1043 | + } |
|
| 933 | 1044 | print $taskstatic->getNomUrl(1, 'withproject', 'time'); |
| 934 | 1045 | // Label task |
| 935 | 1046 | print '<br>'; |
| 936 | - for ($k = 0 ; $k < $level ; $k++) print " "; |
|
| 1047 | + for ($k = 0 ; $k < $level ; $k++) { |
|
| 1048 | + print " "; |
|
| 1049 | + } |
|
| 937 | 1050 | print $taskstatic->label; |
| 938 | 1051 | //print "<br>"; |
| 939 | 1052 | //for ($k = 0 ; $k < $level ; $k++) print " "; |
@@ -942,8 +1055,11 @@ discard block |
||
| 942 | 1055 | |
| 943 | 1056 | // Planned Workload |
| 944 | 1057 | print '<td align="right" class="leftborder plannedworkload">'; |
| 945 | - if ($lines[$i]->planned_workload) print convertSecondToTime($lines[$i]->planned_workload,'allhourmin'); |
|
| 946 | - else print '--:--'; |
|
| 1058 | + if ($lines[$i]->planned_workload) { |
|
| 1059 | + print convertSecondToTime($lines[$i]->planned_workload,'allhourmin'); |
|
| 1060 | + } else { |
|
| 1061 | + print '--:--'; |
|
| 1062 | + } |
|
| 947 | 1063 | print '</td>'; |
| 948 | 1064 | |
| 949 | 1065 | // Progress declared % |
@@ -959,15 +1075,19 @@ discard block |
||
| 959 | 1075 | print '<a href="'.DOL_URL_ROOT.'/projet/tasks/time.php?id='.$lines[$i]->id.'">'; |
| 960 | 1076 | print convertSecondToTime($lines[$i]->duration,'allhourmin'); |
| 961 | 1077 | print '</a>'; |
| 1078 | + } else { |
|
| 1079 | + print '--:--'; |
|
| 962 | 1080 | } |
| 963 | - else print '--:--'; |
|
| 964 | 1081 | print "</td>\n"; |
| 965 | 1082 | |
| 966 | 1083 | // Time spent by user |
| 967 | 1084 | print '<td align="right">'; |
| 968 | 1085 | $tmptimespent=$taskstatic->getSummaryOfTimeSpent($fuser->id); |
| 969 | - if ($tmptimespent['total_duration']) print convertSecondToTime($tmptimespent['total_duration'],'allhourmin'); |
|
| 970 | - else print '--:--'; |
|
| 1086 | + if ($tmptimespent['total_duration']) { |
|
| 1087 | + print convertSecondToTime($tmptimespent['total_duration'],'allhourmin'); |
|
| 1088 | + } else { |
|
| 1089 | + print '--:--'; |
|
| 1090 | + } |
|
| 971 | 1091 | print "</td>\n"; |
| 972 | 1092 | |
| 973 | 1093 | $disabledproject=1;$disabledtask=1; |
@@ -993,9 +1113,13 @@ discard block |
||
| 993 | 1113 | print '</td>'; |
| 994 | 1114 | |
| 995 | 1115 | $cssonholiday=''; |
| 996 | - if (! $isavailable[$preselectedday]['morning'] && ! $isavailable[$preselectedday]['afternoon']) $cssonholiday.='onholidayallday '; |
|
| 997 | - elseif (! $isavailable[$preselectedday]['morning']) $cssonholiday.='onholidaymorning '; |
|
| 998 | - elseif (! $isavailable[$preselectedday]['afternoon']) $cssonholiday.='onholidayafternoon '; |
|
| 1116 | + if (! $isavailable[$preselectedday]['morning'] && ! $isavailable[$preselectedday]['afternoon']) { |
|
| 1117 | + $cssonholiday.='onholidayallday '; |
|
| 1118 | + } elseif (! $isavailable[$preselectedday]['morning']) { |
|
| 1119 | + $cssonholiday.='onholidaymorning '; |
|
| 1120 | + } elseif (! $isavailable[$preselectedday]['afternoon']) { |
|
| 1121 | + $cssonholiday.='onholidayafternoon '; |
|
| 1122 | + } |
|
| 999 | 1123 | |
| 1000 | 1124 | global $daytoparse; |
| 1001 | 1125 | $tmparray = dol_getdate($daytoparse,true); // detail of current day |
@@ -1003,10 +1127,12 @@ discard block |
||
| 1003 | 1127 | |
| 1004 | 1128 | global $numstartworkingday, $numendworkingday; |
| 1005 | 1129 | $cssweekend=''; |
| 1006 | - if (($idw + 1) < $numstartworkingday || ($idw + 1) > $numendworkingday) // This is a day is not inside the setup of working days, so we use a week-end css. |
|
| 1130 | + if (($idw + 1) < $numstartworkingday || ($idw + 1) > $numendworkingday) { |
|
| 1131 | + // This is a day is not inside the setup of working days, so we use a week-end css. |
|
| 1007 | 1132 | { |
| 1008 | 1133 | $cssweekend='weekend'; |
| 1009 | 1134 | } |
| 1135 | + } |
|
| 1010 | 1136 | |
| 1011 | 1137 | // Duration |
| 1012 | 1138 | print '<td class="center duration'.($cssonholiday?' '.$cssonholiday:'').($cssweekend?' '.$cssweekend:'').'">'; |
@@ -1014,7 +1140,9 @@ discard block |
||
| 1014 | 1140 | $totalforeachday[$preselectedday]+=$dayWorkLoad; |
| 1015 | 1141 | |
| 1016 | 1142 | $alreadyspent=''; |
| 1017 | - if ($dayWorkLoad > 0) $alreadyspent=convertSecondToTime($dayWorkLoad,'allhourmin'); |
|
| 1143 | + if ($dayWorkLoad > 0) { |
|
| 1144 | + $alreadyspent=convertSecondToTime($dayWorkLoad,'allhourmin'); |
|
| 1145 | + } |
|
| 1018 | 1146 | |
| 1019 | 1147 | $idw = 0; |
| 1020 | 1148 | |
@@ -1044,11 +1172,14 @@ discard block |
||
| 1044 | 1172 | |
| 1045 | 1173 | // Warning |
| 1046 | 1174 | print '<td align="right">'; |
| 1047 | - if ((! $lines[$i]->public) && $disabledproject) print $form->textwithpicto('',$langs->trans("UserIsNotContactOfProject")); |
|
| 1048 | - else if ($disabledtask) |
|
| 1175 | + if ((! $lines[$i]->public) && $disabledproject) { |
|
| 1176 | + print $form->textwithpicto('',$langs->trans("UserIsNotContactOfProject")); |
|
| 1177 | + } else if ($disabledtask) |
|
| 1049 | 1178 | { |
| 1050 | 1179 | $titleassigntask = $langs->trans("AssignTaskToMe"); |
| 1051 | - if ($fuser->id != $user->id) $titleassigntask = $langs->trans("AssignTaskToUser", '...'); |
|
| 1180 | + if ($fuser->id != $user->id) { |
|
| 1181 | + $titleassigntask = $langs->trans("AssignTaskToUser", '...'); |
|
| 1182 | + } |
|
| 1052 | 1183 | |
| 1053 | 1184 | print $form->textwithpicto('',$langs->trans("TaskIsNotAssignedToUser", $titleassigntask)); |
| 1054 | 1185 | } |
@@ -1074,8 +1205,7 @@ discard block |
||
| 1074 | 1205 | //var_dump($totalforeachday); |
| 1075 | 1206 | } |
| 1076 | 1207 | $level--; |
| 1077 | - } |
|
| 1078 | - else |
|
| 1208 | + } else |
|
| 1079 | 1209 | { |
| 1080 | 1210 | //$level--; |
| 1081 | 1211 | } |
@@ -1115,11 +1245,16 @@ discard block |
||
| 1115 | 1245 | $lineswithoutlevel0=array(); |
| 1116 | 1246 | |
| 1117 | 1247 | // Create a smaller array with sublevels only to be used later. This increase dramatically performances. |
| 1118 | - if ($parent == 0) // Always and only if at first level |
|
| 1248 | + if ($parent == 0) { |
|
| 1249 | + // Always and only if at first level |
|
| 1119 | 1250 | { |
| 1120 | - for ($i = 0 ; $i < $numlines ; $i++) |
|
| 1251 | + for ($i = 0 ; |
|
| 1252 | + } |
|
| 1253 | + $i < $numlines ; $i++) |
|
| 1121 | 1254 | { |
| 1122 | - if ($lines[$i]->fk_task_parent) $lineswithoutlevel0[]=$lines[$i]; |
|
| 1255 | + if ($lines[$i]->fk_task_parent) { |
|
| 1256 | + $lineswithoutlevel0[]=$lines[$i]; |
|
| 1257 | + } |
|
| 1123 | 1258 | } |
| 1124 | 1259 | } |
| 1125 | 1260 | |
@@ -1132,7 +1267,9 @@ discard block |
||
| 1132 | 1267 | |
| 1133 | 1268 | for ($i = 0 ; $i < $numlines ; $i++) |
| 1134 | 1269 | { |
| 1135 | - if ($parent == 0) $level = 0; |
|
| 1270 | + if ($parent == 0) { |
|
| 1271 | + $level = 0; |
|
| 1272 | + } |
|
| 1136 | 1273 | |
| 1137 | 1274 | if ($lines[$i]->fk_task_parent == $parent) |
| 1138 | 1275 | { |
@@ -1179,7 +1316,9 @@ discard block |
||
| 1179 | 1316 | print '<tr class="oddeven trforbreak">'."\n"; |
| 1180 | 1317 | print '<td colspan="13">'; |
| 1181 | 1318 | print $projectstatic->getNomUrl(1,'',0,'<strong>'.$langs->transnoentitiesnoconv("YourRole").':</strong> '.$projectsrole[$lines[$i]->fk_project]); |
| 1182 | - if ($thirdpartystatic->id > 0) print ' - '.$thirdpartystatic->getNomUrl(1); |
|
| 1319 | + if ($thirdpartystatic->id > 0) { |
|
| 1320 | + print ' - '.$thirdpartystatic->getNomUrl(1); |
|
| 1321 | + } |
|
| 1183 | 1322 | if ($projectstatic->title) |
| 1184 | 1323 | { |
| 1185 | 1324 | print ' - '; |
@@ -1189,7 +1328,9 @@ discard block |
||
| 1189 | 1328 | print '</tr>'; |
| 1190 | 1329 | } |
| 1191 | 1330 | |
| 1192 | - if ($oldprojectforbreak != -1) $oldprojectforbreak = $projectstatic->id; |
|
| 1331 | + if ($oldprojectforbreak != -1) { |
|
| 1332 | + $oldprojectforbreak = $projectstatic->id; |
|
| 1333 | + } |
|
| 1193 | 1334 | |
| 1194 | 1335 | print '<tr class="oddeven">'."\n"; |
| 1195 | 1336 | |
@@ -1213,11 +1354,15 @@ discard block |
||
| 1213 | 1354 | // Ref |
| 1214 | 1355 | print '<td class="nowrap">'; |
| 1215 | 1356 | print '<!-- Task id = '.$lines[$i]->id.' -->'; |
| 1216 | - for ($k = 0 ; $k < $level ; $k++) print " "; |
|
| 1357 | + for ($k = 0 ; $k < $level ; $k++) { |
|
| 1358 | + print " "; |
|
| 1359 | + } |
|
| 1217 | 1360 | print $taskstatic->getNomUrl(1, 'withproject', 'time'); |
| 1218 | 1361 | // Label task |
| 1219 | 1362 | print '<br>'; |
| 1220 | - for ($k = 0 ; $k < $level ; $k++) print " "; |
|
| 1363 | + for ($k = 0 ; $k < $level ; $k++) { |
|
| 1364 | + print " "; |
|
| 1365 | + } |
|
| 1221 | 1366 | //print $taskstatic->getNomUrl(0, 'withproject', 'time'); |
| 1222 | 1367 | print $taskstatic->label; |
| 1223 | 1368 | //print "<br>"; |
@@ -1227,8 +1372,11 @@ discard block |
||
| 1227 | 1372 | |
| 1228 | 1373 | // Planned Workload |
| 1229 | 1374 | print '<td align="right" class="leftborder plannedworkload">'; |
| 1230 | - if ($lines[$i]->planned_workload) print convertSecondToTime($lines[$i]->planned_workload,'allhourmin'); |
|
| 1231 | - else print '--:--'; |
|
| 1375 | + if ($lines[$i]->planned_workload) { |
|
| 1376 | + print convertSecondToTime($lines[$i]->planned_workload,'allhourmin'); |
|
| 1377 | + } else { |
|
| 1378 | + print '--:--'; |
|
| 1379 | + } |
|
| 1232 | 1380 | print '</td>'; |
| 1233 | 1381 | |
| 1234 | 1382 | // Progress declared % |
@@ -1244,15 +1392,19 @@ discard block |
||
| 1244 | 1392 | print '<a href="'.DOL_URL_ROOT.'/projet/tasks/time.php?id='.$lines[$i]->id.'">'; |
| 1245 | 1393 | print convertSecondToTime($lines[$i]->duration,'allhourmin'); |
| 1246 | 1394 | print '</a>'; |
| 1395 | + } else { |
|
| 1396 | + print '--:--'; |
|
| 1247 | 1397 | } |
| 1248 | - else print '--:--'; |
|
| 1249 | 1398 | print "</td>\n"; |
| 1250 | 1399 | |
| 1251 | 1400 | // Time spent by user |
| 1252 | 1401 | print '<td align="right">'; |
| 1253 | 1402 | $tmptimespent=$taskstatic->getSummaryOfTimeSpent($fuser->id); |
| 1254 | - if ($tmptimespent['total_duration']) print convertSecondToTime($tmptimespent['total_duration'],'allhourmin'); |
|
| 1255 | - else print '--:--'; |
|
| 1403 | + if ($tmptimespent['total_duration']) { |
|
| 1404 | + print convertSecondToTime($tmptimespent['total_duration'],'allhourmin'); |
|
| 1405 | + } else { |
|
| 1406 | + print '--:--'; |
|
| 1407 | + } |
|
| 1256 | 1408 | print "</td>\n"; |
| 1257 | 1409 | |
| 1258 | 1410 | $disabledproject=1;$disabledtask=1; |
@@ -1280,24 +1432,32 @@ discard block |
||
| 1280 | 1432 | $tmpday=dol_time_plus_duree($firstdaytoshow, $idw, 'd'); |
| 1281 | 1433 | |
| 1282 | 1434 | $cssonholiday=''; |
| 1283 | - if (! $isavailable[$tmpday]['morning'] && ! $isavailable[$tmpday]['afternoon']) $cssonholiday.='onholidayallday '; |
|
| 1284 | - elseif (! $isavailable[$tmpday]['morning']) $cssonholiday.='onholidaymorning '; |
|
| 1285 | - elseif (! $isavailable[$tmpday]['afternoon']) $cssonholiday.='onholidayafternoon '; |
|
| 1435 | + if (! $isavailable[$tmpday]['morning'] && ! $isavailable[$tmpday]['afternoon']) { |
|
| 1436 | + $cssonholiday.='onholidayallday '; |
|
| 1437 | + } elseif (! $isavailable[$tmpday]['morning']) { |
|
| 1438 | + $cssonholiday.='onholidaymorning '; |
|
| 1439 | + } elseif (! $isavailable[$tmpday]['afternoon']) { |
|
| 1440 | + $cssonholiday.='onholidayafternoon '; |
|
| 1441 | + } |
|
| 1286 | 1442 | |
| 1287 | 1443 | $tmparray=dol_getdate($tmpday); |
| 1288 | 1444 | $dayWorkLoad = $projectstatic->weekWorkLoadPerTask[$tmpday][$lines[$i]->id]; |
| 1289 | 1445 | $totalforeachday[$tmpday]+=$dayWorkLoad; |
| 1290 | 1446 | |
| 1291 | 1447 | $alreadyspent=''; |
| 1292 | - if ($dayWorkLoad > 0) $alreadyspent=convertSecondToTime($dayWorkLoad,'allhourmin'); |
|
| 1448 | + if ($dayWorkLoad > 0) { |
|
| 1449 | + $alreadyspent=convertSecondToTime($dayWorkLoad,'allhourmin'); |
|
| 1450 | + } |
|
| 1293 | 1451 | $alttitle=$langs->trans("AddHereTimeSpentForDay",$tmparray['day'],$tmparray['mon']); |
| 1294 | 1452 | |
| 1295 | 1453 | global $numstartworkingday, $numendworkingday; |
| 1296 | 1454 | $cssweekend=''; |
| 1297 | - if (($idw + 1) < $numstartworkingday || ($idw + 1) > $numendworkingday) // This is a day is not inside the setup of working days, so we use a week-end css. |
|
| 1455 | + if (($idw + 1) < $numstartworkingday || ($idw + 1) > $numendworkingday) { |
|
| 1456 | + // This is a day is not inside the setup of working days, so we use a week-end css. |
|
| 1298 | 1457 | { |
| 1299 | 1458 | $cssweekend='weekend'; |
| 1300 | 1459 | } |
| 1460 | + } |
|
| 1301 | 1461 | |
| 1302 | 1462 | $tableCell ='<td align="center" class="hide'.$idw.($cssonholiday?' '.$cssonholiday:'').($cssweekend?' '.$cssweekend:'').'">'; |
| 1303 | 1463 | $placeholder=''; |
@@ -1317,11 +1477,14 @@ discard block |
||
| 1317 | 1477 | |
| 1318 | 1478 | // Warning |
| 1319 | 1479 | print '<td align="right">'; |
| 1320 | - if ((! $lines[$i]->public) && $disabledproject) print $form->textwithpicto('',$langs->trans("UserIsNotContactOfProject")); |
|
| 1321 | - else if ($disabledtask) |
|
| 1480 | + if ((! $lines[$i]->public) && $disabledproject) { |
|
| 1481 | + print $form->textwithpicto('',$langs->trans("UserIsNotContactOfProject")); |
|
| 1482 | + } else if ($disabledtask) |
|
| 1322 | 1483 | { |
| 1323 | 1484 | $titleassigntask = $langs->trans("AssignTaskToMe"); |
| 1324 | - if ($fuser->id != $user->id) $titleassigntask = $langs->trans("AssignTaskToUser", '...'); |
|
| 1485 | + if ($fuser->id != $user->id) { |
|
| 1486 | + $titleassigntask = $langs->trans("AssignTaskToUser", '...'); |
|
| 1487 | + } |
|
| 1325 | 1488 | |
| 1326 | 1489 | print $form->textwithpicto('',$langs->trans("TaskIsNotAssignedToUser", $titleassigntask)); |
| 1327 | 1490 | } |
@@ -1348,8 +1511,7 @@ discard block |
||
| 1348 | 1511 | //var_dump($totalforeachday); |
| 1349 | 1512 | } |
| 1350 | 1513 | $level--; |
| 1351 | - } |
|
| 1352 | - else |
|
| 1514 | + } else |
|
| 1353 | 1515 | { |
| 1354 | 1516 | //$level--; |
| 1355 | 1517 | } |
@@ -1388,7 +1550,9 @@ discard block |
||
| 1388 | 1550 | searchTaskInChild($inc, $lines[$i]->id, $lines, $taskrole); |
| 1389 | 1551 | //print 'Found inc='.$inc.'<br>'; |
| 1390 | 1552 | |
| 1391 | - if ($inc > 0) return $inc; |
|
| 1553 | + if ($inc > 0) { |
|
| 1554 | + return $inc; |
|
| 1555 | + } |
|
| 1392 | 1556 | } |
| 1393 | 1557 | } |
| 1394 | 1558 | |
@@ -1422,7 +1586,9 @@ discard block |
||
| 1422 | 1586 | $project_year_filter=0; |
| 1423 | 1587 | |
| 1424 | 1588 | $title=$langs->trans("Projects"); |
| 1425 | - if (strcmp($statut, '') && $statut >= 0) $title=$langs->trans("Projects").' '.$langs->trans($projectstatic->statuts_long[$statut]); |
|
| 1589 | + if (strcmp($statut, '') && $statut >= 0) { |
|
| 1590 | + $title=$langs->trans("Projects").' '.$langs->trans($projectstatic->statuts_long[$statut]); |
|
| 1591 | + } |
|
| 1426 | 1592 | |
| 1427 | 1593 | $arrayidtypeofcontact=array(); |
| 1428 | 1594 | |
@@ -1435,14 +1601,15 @@ discard block |
||
| 1435 | 1601 | $sql.= ", ".MAIN_DB_PREFIX."projet_task as t"; |
| 1436 | 1602 | $sql.= ", ".MAIN_DB_PREFIX."element_contact as ec"; |
| 1437 | 1603 | $sql.= ", ".MAIN_DB_PREFIX."c_type_contact as ctc"; |
| 1438 | - } |
|
| 1439 | - else |
|
| 1604 | + } else |
|
| 1440 | 1605 | { |
| 1441 | 1606 | $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."projet_task as t ON p.rowid = t.fk_projet"; |
| 1442 | 1607 | } |
| 1443 | 1608 | $sql.= " WHERE p.entity IN (".getEntity('project').")"; |
| 1444 | 1609 | $sql.= " AND p.rowid IN (".$projectsListId.")"; |
| 1445 | - if ($socid) $sql.= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")"; |
|
| 1610 | + if ($socid) { |
|
| 1611 | + $sql.= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")"; |
|
| 1612 | + } |
|
| 1446 | 1613 | if ($mytasks) |
| 1447 | 1614 | { |
| 1448 | 1615 | $sql.= " AND p.rowid = t.fk_projet"; |
@@ -1485,9 +1652,12 @@ discard block |
||
| 1485 | 1652 | $arrayidofprojects[$objp->projectid]=$objp->projectid; |
| 1486 | 1653 | $i++; |
| 1487 | 1654 | } |
| 1655 | + } else { |
|
| 1656 | + dol_print_error($db); |
|
| 1657 | + } |
|
| 1658 | + if (empty($arrayidofprojects)) { |
|
| 1659 | + $arrayidofprojects[0]=-1; |
|
| 1488 | 1660 | } |
| 1489 | - else dol_print_error($db); |
|
| 1490 | - if (empty($arrayidofprojects)) $arrayidofprojects[0]=-1; |
|
| 1491 | 1661 | |
| 1492 | 1662 | // Get list of project with calculation on tasks |
| 1493 | 1663 | $sql2 = "SELECT p.rowid as projectid, p.ref, p.title, p.fk_soc, s.nom as socname, p.fk_user_creat, p.public, p.fk_statut as status, p.fk_opp_status as opp_status, p.opp_amount,"; |
@@ -1521,8 +1691,12 @@ discard block |
||
| 1521 | 1691 | if (empty($conf->global->PROJECT_HIDE_TASKS)) |
| 1522 | 1692 | { |
| 1523 | 1693 | print_liste_field_titre("Tasks","","","","",'align="right"',$sortfield,$sortorder); |
| 1524 | - if (! in_array('plannedworkload', $hiddenfields)) print_liste_field_titre("PlannedWorkload","","","","",'align="right"',$sortfield,$sortorder); |
|
| 1525 | - if (! in_array('declaredprogress', $hiddenfields)) print_liste_field_titre("ProgressDeclared","","","","",'align="right"',$sortfield,$sortorder); |
|
| 1694 | + if (! in_array('plannedworkload', $hiddenfields)) { |
|
| 1695 | + print_liste_field_titre("PlannedWorkload","","","","",'align="right"',$sortfield,$sortorder); |
|
| 1696 | + } |
|
| 1697 | + if (! in_array('declaredprogress', $hiddenfields)) { |
|
| 1698 | + print_liste_field_titre("ProgressDeclared","","","","",'align="right"',$sortfield,$sortorder); |
|
| 1699 | + } |
|
| 1526 | 1700 | } |
| 1527 | 1701 | print_liste_field_titre("Status","","","","",'align="right"',$sortfield,$sortorder); |
| 1528 | 1702 | print "</tr>\n"; |
@@ -1551,7 +1725,9 @@ discard block |
||
| 1551 | 1725 | print '<tr class="oddeven">'; |
| 1552 | 1726 | print '<td>'; |
| 1553 | 1727 | print $projectstatic->getNomUrl(1); |
| 1554 | - if (! in_array('projectlabel', $hiddenfields)) print '<br>'.dol_trunc($objp->title,24); |
|
| 1728 | + if (! in_array('projectlabel', $hiddenfields)) { |
|
| 1729 | + print '<br>'.dol_trunc($objp->title,24); |
|
| 1730 | + } |
|
| 1555 | 1731 | print '</td>'; |
| 1556 | 1732 | print '<td>'; |
| 1557 | 1733 | if ($objp->fk_soc > 0) |
@@ -1565,11 +1741,15 @@ discard block |
||
| 1565 | 1741 | if (! empty($conf->global->PROJECT_USE_OPPORTUNITIES)) |
| 1566 | 1742 | { |
| 1567 | 1743 | print '<td align="right">'; |
| 1568 | - if ($objp->opp_amount) print price($objp->opp_amount, 0, '', 1, -1, -1, $conf->currency); |
|
| 1744 | + if ($objp->opp_amount) { |
|
| 1745 | + print price($objp->opp_amount, 0, '', 1, -1, -1, $conf->currency); |
|
| 1746 | + } |
|
| 1569 | 1747 | print '</td>'; |
| 1570 | 1748 | print '<td align="right">'; |
| 1571 | 1749 | $code = dol_getIdFromCode($db, $objp->opp_status, 'c_lead_status', 'rowid', 'code'); |
| 1572 | - if ($code) print $langs->trans("OppStatus".$code); |
|
| 1750 | + if ($code) { |
|
| 1751 | + print $langs->trans("OppStatus".$code); |
|
| 1752 | + } |
|
| 1573 | 1753 | print '</td>'; |
| 1574 | 1754 | } |
| 1575 | 1755 | if (empty($conf->global->PROJECT_HIDE_TASKS)) |
@@ -1614,15 +1794,18 @@ discard block |
||
| 1614 | 1794 | if (empty($conf->global->PROJECT_HIDE_TASKS)) |
| 1615 | 1795 | { |
| 1616 | 1796 | print '<td class="liste_total" align="right">'.$total_task.'</td>'; |
| 1617 | - if (! in_array('plannedworkload', $hiddenfields)) print '<td class="liste_total" align="right">'.($total_plannedworkload?convertSecondToTime($total_plannedworkload):'').'</td>'; |
|
| 1618 | - if (! in_array('declaredprogress', $hiddenfields)) print '<td class="liste_total" align="right">'.($total_plannedworkload?round(100*$total_declaredprogressworkload/$total_plannedworkload,0).'%':'').'</td>'; |
|
| 1797 | + if (! in_array('plannedworkload', $hiddenfields)) { |
|
| 1798 | + print '<td class="liste_total" align="right">'.($total_plannedworkload?convertSecondToTime($total_plannedworkload):'').'</td>'; |
|
| 1799 | + } |
|
| 1800 | + if (! in_array('declaredprogress', $hiddenfields)) { |
|
| 1801 | + print '<td class="liste_total" align="right">'.($total_plannedworkload?round(100*$total_declaredprogressworkload/$total_plannedworkload,0).'%':'').'</td>'; |
|
| 1802 | + } |
|
| 1619 | 1803 | } |
| 1620 | 1804 | print '<td class="liste_total"></td>'; |
| 1621 | 1805 | print '</tr>'; |
| 1622 | 1806 | |
| 1623 | 1807 | $db->free($resql); |
| 1624 | - } |
|
| 1625 | - else |
|
| 1808 | + } else |
|
| 1626 | 1809 | { |
| 1627 | 1810 | dol_print_error($db); |
| 1628 | 1811 | } |
@@ -68,9 +68,9 @@ discard block |
||
| 68 | 68 | public $label; |
| 69 | 69 | |
| 70 | 70 | /** |
| 71 | - * Product descripion |
|
| 72 | - * @var string |
|
| 73 | - */ |
|
| 71 | + * Product descripion |
|
| 72 | + * @var string |
|
| 73 | + */ |
|
| 74 | 74 | public $description; |
| 75 | 75 | |
| 76 | 76 | /** |
@@ -131,7 +131,7 @@ discard block |
||
| 131 | 131 | public $tva_tx; |
| 132 | 132 | |
| 133 | 133 | //! French VAT NPR (0 or 1) |
| 134 | - public $tva_npr=0; |
|
| 134 | + public $tva_npr=0; |
|
| 135 | 135 | |
| 136 | 136 | //! Other local taxes |
| 137 | 137 | public $localtax1_tx; |
@@ -249,7 +249,7 @@ discard block |
||
| 249 | 249 | public $stats_commande=array(); |
| 250 | 250 | public $stats_contrat=array(); |
| 251 | 251 | public $stats_facture=array(); |
| 252 | - public $stats_commande_fournisseur=array(); |
|
| 252 | + public $stats_commande_fournisseur=array(); |
|
| 253 | 253 | |
| 254 | 254 | public $multilangs=array(); |
| 255 | 255 | |
@@ -273,7 +273,7 @@ discard block |
||
| 273 | 273 | |
| 274 | 274 | public $oldcopy; |
| 275 | 275 | |
| 276 | - public $fk_price_expression; |
|
| 276 | + public $fk_price_expression; |
|
| 277 | 277 | |
| 278 | 278 | /** |
| 279 | 279 | * @deprecated |
@@ -372,7 +372,7 @@ discard block |
||
| 372 | 372 | { |
| 373 | 373 | global $conf, $langs; |
| 374 | 374 | |
| 375 | - $error=0; |
|
| 375 | + $error=0; |
|
| 376 | 376 | |
| 377 | 377 | // Clean parameters |
| 378 | 378 | $this->ref = dol_string_nospecial(trim($this->ref)); |
@@ -619,94 +619,94 @@ discard block |
||
| 619 | 619 | $this->db->rollback(); |
| 620 | 620 | return -$error; |
| 621 | 621 | } |
| 622 | - } |
|
| 623 | - else |
|
| 624 | - { |
|
| 625 | - $this->db->rollback(); |
|
| 626 | - dol_syslog(get_class($this)."::Create fails verify ".join(',',$this->errors), LOG_WARNING); |
|
| 627 | - return -3; |
|
| 628 | - } |
|
| 622 | + } |
|
| 623 | + else |
|
| 624 | + { |
|
| 625 | + $this->db->rollback(); |
|
| 626 | + dol_syslog(get_class($this)."::Create fails verify ".join(',',$this->errors), LOG_WARNING); |
|
| 627 | + return -3; |
|
| 628 | + } |
|
| 629 | 629 | |
| 630 | 630 | } |
| 631 | 631 | |
| 632 | 632 | |
| 633 | - /** |
|
| 634 | - * Check properties of product are ok (like name, barcode, ...). |
|
| 635 | - * All properties must be already loaded on object (this->barcode, this->barcode_type_code, ...). |
|
| 636 | - * |
|
| 637 | - * @return int 0 if OK, <0 if KO |
|
| 638 | - */ |
|
| 639 | - function verify() |
|
| 640 | - { |
|
| 641 | - $this->errors=array(); |
|
| 642 | - |
|
| 643 | - $result = 0; |
|
| 644 | - $this->ref = trim($this->ref); |
|
| 645 | - |
|
| 646 | - if (! $this->ref) |
|
| 647 | - { |
|
| 648 | - $this->errors[] = 'ErrorBadRef'; |
|
| 649 | - $result = -2; |
|
| 650 | - } |
|
| 651 | - |
|
| 652 | - $rescode = $this->check_barcode($this->barcode, $this->barcode_type_code); |
|
| 653 | - if ($rescode) |
|
| 654 | - { |
|
| 655 | - if ($rescode == -1) |
|
| 656 | - { |
|
| 657 | - $this->errors[] = 'ErrorBadBarCodeSyntax'; |
|
| 658 | - } |
|
| 659 | - elseif ($rescode == -2) |
|
| 660 | - { |
|
| 661 | - $this->errors[] = 'ErrorBarCodeRequired'; |
|
| 662 | - } |
|
| 663 | - elseif ($rescode == -3) |
|
| 664 | - { |
|
| 665 | - // Note: Common usage is to have barcode unique. For variants, we should have a different barcode. |
|
| 666 | - $this->errors[] = 'ErrorBarCodeAlreadyUsed'; |
|
| 667 | - } |
|
| 668 | - |
|
| 669 | - $result = -3; |
|
| 670 | - } |
|
| 671 | - |
|
| 672 | - return $result; |
|
| 673 | - } |
|
| 674 | - |
|
| 675 | - /** |
|
| 676 | - * Check barcode |
|
| 677 | - * |
|
| 678 | - * @param string $valuetotest Value to test |
|
| 679 | - * @param string $typefortest Type of barcode (ISBN, EAN, ...) |
|
| 680 | - * @return int 0 if OK |
|
| 681 | - * -1 ErrorBadBarCodeSyntax |
|
| 682 | - * -2 ErrorBarCodeRequired |
|
| 683 | - * -3 ErrorBarCodeAlreadyUsed |
|
| 684 | - */ |
|
| 685 | - function check_barcode($valuetotest,$typefortest) |
|
| 686 | - { |
|
| 687 | - global $conf; |
|
| 688 | - if (! empty($conf->barcode->enabled) && ! empty($conf->global->BARCODE_PRODUCT_ADDON_NUM)) |
|
| 689 | - { |
|
| 690 | - $module=strtolower($conf->global->BARCODE_PRODUCT_ADDON_NUM); |
|
| 691 | - |
|
| 692 | - $dirsociete=array_merge(array('/core/modules/barcode/'),$conf->modules_parts['barcode']); |
|
| 693 | - foreach ($dirsociete as $dirroot) |
|
| 694 | - { |
|
| 695 | - $res=dol_include_once($dirroot.$module.'.php'); |
|
| 696 | - if ($res) break; |
|
| 697 | - } |
|
| 698 | - |
|
| 699 | - $mod = new $module(); |
|
| 700 | - |
|
| 701 | - dol_syslog(get_class($this)."::check_barcode value=".$valuetotest." type=".$typefortest." module=".$module); |
|
| 702 | - $result = $mod->verif($this->db, $valuetotest, $this, 0, $typefortest); |
|
| 703 | - return $result; |
|
| 704 | - } |
|
| 705 | - else |
|
| 706 | - { |
|
| 707 | - return 0; |
|
| 708 | - } |
|
| 709 | - } |
|
| 633 | + /** |
|
| 634 | + * Check properties of product are ok (like name, barcode, ...). |
|
| 635 | + * All properties must be already loaded on object (this->barcode, this->barcode_type_code, ...). |
|
| 636 | + * |
|
| 637 | + * @return int 0 if OK, <0 if KO |
|
| 638 | + */ |
|
| 639 | + function verify() |
|
| 640 | + { |
|
| 641 | + $this->errors=array(); |
|
| 642 | + |
|
| 643 | + $result = 0; |
|
| 644 | + $this->ref = trim($this->ref); |
|
| 645 | + |
|
| 646 | + if (! $this->ref) |
|
| 647 | + { |
|
| 648 | + $this->errors[] = 'ErrorBadRef'; |
|
| 649 | + $result = -2; |
|
| 650 | + } |
|
| 651 | + |
|
| 652 | + $rescode = $this->check_barcode($this->barcode, $this->barcode_type_code); |
|
| 653 | + if ($rescode) |
|
| 654 | + { |
|
| 655 | + if ($rescode == -1) |
|
| 656 | + { |
|
| 657 | + $this->errors[] = 'ErrorBadBarCodeSyntax'; |
|
| 658 | + } |
|
| 659 | + elseif ($rescode == -2) |
|
| 660 | + { |
|
| 661 | + $this->errors[] = 'ErrorBarCodeRequired'; |
|
| 662 | + } |
|
| 663 | + elseif ($rescode == -3) |
|
| 664 | + { |
|
| 665 | + // Note: Common usage is to have barcode unique. For variants, we should have a different barcode. |
|
| 666 | + $this->errors[] = 'ErrorBarCodeAlreadyUsed'; |
|
| 667 | + } |
|
| 668 | + |
|
| 669 | + $result = -3; |
|
| 670 | + } |
|
| 671 | + |
|
| 672 | + return $result; |
|
| 673 | + } |
|
| 674 | + |
|
| 675 | + /** |
|
| 676 | + * Check barcode |
|
| 677 | + * |
|
| 678 | + * @param string $valuetotest Value to test |
|
| 679 | + * @param string $typefortest Type of barcode (ISBN, EAN, ...) |
|
| 680 | + * @return int 0 if OK |
|
| 681 | + * -1 ErrorBadBarCodeSyntax |
|
| 682 | + * -2 ErrorBarCodeRequired |
|
| 683 | + * -3 ErrorBarCodeAlreadyUsed |
|
| 684 | + */ |
|
| 685 | + function check_barcode($valuetotest,$typefortest) |
|
| 686 | + { |
|
| 687 | + global $conf; |
|
| 688 | + if (! empty($conf->barcode->enabled) && ! empty($conf->global->BARCODE_PRODUCT_ADDON_NUM)) |
|
| 689 | + { |
|
| 690 | + $module=strtolower($conf->global->BARCODE_PRODUCT_ADDON_NUM); |
|
| 691 | + |
|
| 692 | + $dirsociete=array_merge(array('/core/modules/barcode/'),$conf->modules_parts['barcode']); |
|
| 693 | + foreach ($dirsociete as $dirroot) |
|
| 694 | + { |
|
| 695 | + $res=dol_include_once($dirroot.$module.'.php'); |
|
| 696 | + if ($res) break; |
|
| 697 | + } |
|
| 698 | + |
|
| 699 | + $mod = new $module(); |
|
| 700 | + |
|
| 701 | + dol_syslog(get_class($this)."::check_barcode value=".$valuetotest." type=".$typefortest." module=".$module); |
|
| 702 | + $result = $mod->verif($this->db, $valuetotest, $this, 0, $typefortest); |
|
| 703 | + return $result; |
|
| 704 | + } |
|
| 705 | + else |
|
| 706 | + { |
|
| 707 | + return 0; |
|
| 708 | + } |
|
| 709 | + } |
|
| 710 | 710 | |
| 711 | 711 | /** |
| 712 | 712 | * Update a record into database. |
@@ -768,10 +768,10 @@ discard block |
||
| 768 | 768 | if (empty($this->status)) $this->status = 0; |
| 769 | 769 | if (empty($this->status_buy)) $this->status_buy = 0; |
| 770 | 770 | |
| 771 | - if (empty($this->country_id)) $this->country_id = 0; |
|
| 771 | + if (empty($this->country_id)) $this->country_id = 0; |
|
| 772 | 772 | |
| 773 | - // Barcode value |
|
| 774 | - $this->barcode=trim($this->barcode); |
|
| 773 | + // Barcode value |
|
| 774 | + $this->barcode=trim($this->barcode); |
|
| 775 | 775 | |
| 776 | 776 | $this->accountancy_code_buy = trim($this->accountancy_code_buy); |
| 777 | 777 | $this->accountancy_code_sell= trim($this->accountancy_code_sell); |
@@ -779,74 +779,74 @@ discard block |
||
| 779 | 779 | $this->accountancy_code_sell_export= trim($this->accountancy_code_sell_export); |
| 780 | 780 | |
| 781 | 781 | |
| 782 | - $this->db->begin(); |
|
| 783 | - |
|
| 784 | - // Check name is required and codes are ok or unique. |
|
| 785 | - // If error, this->errors[] is filled |
|
| 786 | - if ($action != 'add') |
|
| 787 | - { |
|
| 788 | - $result = $this->verify(); // We don't check when update called during a create because verify was already done |
|
| 789 | - } |
|
| 790 | - |
|
| 791 | - if ($result >= 0) |
|
| 792 | - { |
|
| 793 | - if (empty($this->oldcopy)) |
|
| 794 | - { |
|
| 795 | - $org=new self($this->db); |
|
| 796 | - $org->fetch($this->id); |
|
| 797 | - $this->oldcopy=$org; |
|
| 798 | - } |
|
| 799 | - |
|
| 800 | - // Test if batch management is activated on existing product |
|
| 801 | - // If yes, we create missing entries into product_batch |
|
| 802 | - if ($this->hasbatch() && !$this->oldcopy->hasbatch()) |
|
| 803 | - { |
|
| 804 | - //$valueforundefinedlot = 'Undefined'; // In previous version, 39 and lower |
|
| 805 | - $valueforundefinedlot = '000000'; |
|
| 806 | - |
|
| 807 | - dol_syslog("Flag batch of product id=".$this->id." is set to ON, so we will create missing records into product_batch"); |
|
| 808 | - |
|
| 809 | - $this->load_stock(); |
|
| 810 | - foreach ($this->stock_warehouse as $idW => $ObjW) // For each warehouse where we have stocks defined for this product (for each lines in product_stock) |
|
| 811 | - { |
|
| 812 | - $qty_batch = 0; |
|
| 813 | - foreach ($ObjW->detail_batch as $detail) // Each lines of detail in product_batch of the current $ObjW = product_stock |
|
| 814 | - { |
|
| 815 | - if ($detail->batch == $valueforundefinedlot || $detail->batch == 'Undefined') |
|
| 816 | - { |
|
| 817 | - // We discard this line, we will create it later |
|
| 818 | - $sqlclean="DELETE FROM ".MAIN_DB_PREFIX."product_batch WHERE batch in('Undefined', '".$valueforundefinedlot."') AND fk_product_stock = ".$ObjW->id; |
|
| 819 | - $result = $this->db->query($sqlclean); |
|
| 820 | - if (! $result) |
|
| 821 | - { |
|
| 822 | - dol_print_error($this->db); |
|
| 823 | - exit; |
|
| 824 | - } |
|
| 825 | - continue; |
|
| 826 | - } |
|
| 827 | - |
|
| 828 | - $qty_batch += $detail->qty; |
|
| 829 | - } |
|
| 830 | - // Quantities in batch details are not same as stock quantity, |
|
| 831 | - // so we add a default batch record to complete and get same qty in parent and child table |
|
| 832 | - if ($ObjW->real <> $qty_batch) |
|
| 833 | - { |
|
| 834 | - $ObjBatch = new Productbatch($this->db); |
|
| 835 | - $ObjBatch->batch = $valueforundefinedlot; |
|
| 836 | - $ObjBatch->qty = ($ObjW->real - $qty_batch); |
|
| 837 | - $ObjBatch->fk_product_stock = $ObjW->id; |
|
| 838 | - |
|
| 839 | - if ($ObjBatch->create($user,1) < 0) |
|
| 840 | - { |
|
| 841 | - $error++; |
|
| 842 | - $this->errors=$ObjBatch->errors; |
|
| 843 | - } |
|
| 844 | - } |
|
| 845 | - } |
|
| 846 | - } |
|
| 847 | - |
|
| 848 | - // For automatic creation |
|
| 849 | - if ($this->barcode == -1) $this->barcode = $this->get_barcode($this,$this->barcode_type_code); |
|
| 782 | + $this->db->begin(); |
|
| 783 | + |
|
| 784 | + // Check name is required and codes are ok or unique. |
|
| 785 | + // If error, this->errors[] is filled |
|
| 786 | + if ($action != 'add') |
|
| 787 | + { |
|
| 788 | + $result = $this->verify(); // We don't check when update called during a create because verify was already done |
|
| 789 | + } |
|
| 790 | + |
|
| 791 | + if ($result >= 0) |
|
| 792 | + { |
|
| 793 | + if (empty($this->oldcopy)) |
|
| 794 | + { |
|
| 795 | + $org=new self($this->db); |
|
| 796 | + $org->fetch($this->id); |
|
| 797 | + $this->oldcopy=$org; |
|
| 798 | + } |
|
| 799 | + |
|
| 800 | + // Test if batch management is activated on existing product |
|
| 801 | + // If yes, we create missing entries into product_batch |
|
| 802 | + if ($this->hasbatch() && !$this->oldcopy->hasbatch()) |
|
| 803 | + { |
|
| 804 | + //$valueforundefinedlot = 'Undefined'; // In previous version, 39 and lower |
|
| 805 | + $valueforundefinedlot = '000000'; |
|
| 806 | + |
|
| 807 | + dol_syslog("Flag batch of product id=".$this->id." is set to ON, so we will create missing records into product_batch"); |
|
| 808 | + |
|
| 809 | + $this->load_stock(); |
|
| 810 | + foreach ($this->stock_warehouse as $idW => $ObjW) // For each warehouse where we have stocks defined for this product (for each lines in product_stock) |
|
| 811 | + { |
|
| 812 | + $qty_batch = 0; |
|
| 813 | + foreach ($ObjW->detail_batch as $detail) // Each lines of detail in product_batch of the current $ObjW = product_stock |
|
| 814 | + { |
|
| 815 | + if ($detail->batch == $valueforundefinedlot || $detail->batch == 'Undefined') |
|
| 816 | + { |
|
| 817 | + // We discard this line, we will create it later |
|
| 818 | + $sqlclean="DELETE FROM ".MAIN_DB_PREFIX."product_batch WHERE batch in('Undefined', '".$valueforundefinedlot."') AND fk_product_stock = ".$ObjW->id; |
|
| 819 | + $result = $this->db->query($sqlclean); |
|
| 820 | + if (! $result) |
|
| 821 | + { |
|
| 822 | + dol_print_error($this->db); |
|
| 823 | + exit; |
|
| 824 | + } |
|
| 825 | + continue; |
|
| 826 | + } |
|
| 827 | + |
|
| 828 | + $qty_batch += $detail->qty; |
|
| 829 | + } |
|
| 830 | + // Quantities in batch details are not same as stock quantity, |
|
| 831 | + // so we add a default batch record to complete and get same qty in parent and child table |
|
| 832 | + if ($ObjW->real <> $qty_batch) |
|
| 833 | + { |
|
| 834 | + $ObjBatch = new Productbatch($this->db); |
|
| 835 | + $ObjBatch->batch = $valueforundefinedlot; |
|
| 836 | + $ObjBatch->qty = ($ObjW->real - $qty_batch); |
|
| 837 | + $ObjBatch->fk_product_stock = $ObjW->id; |
|
| 838 | + |
|
| 839 | + if ($ObjBatch->create($user,1) < 0) |
|
| 840 | + { |
|
| 841 | + $error++; |
|
| 842 | + $this->errors=$ObjBatch->errors; |
|
| 843 | + } |
|
| 844 | + } |
|
| 845 | + } |
|
| 846 | + } |
|
| 847 | + |
|
| 848 | + // For automatic creation |
|
| 849 | + if ($this->barcode == -1) $this->barcode = $this->get_barcode($this,$this->barcode_type_code); |
|
| 850 | 850 | |
| 851 | 851 | $sql = "UPDATE ".MAIN_DB_PREFIX."product"; |
| 852 | 852 | $sql.= " SET label = '" . $this->db->escape($this->label) ."'"; |
@@ -884,8 +884,8 @@ discard block |
||
| 884 | 884 | $sql.= ", description = '" . $this->db->escape($this->description) ."'"; |
| 885 | 885 | $sql.= ", url = " . ($this->url?"'".$this->db->escape($this->url)."'":'null'); |
| 886 | 886 | $sql.= ", customcode = '" . $this->db->escape($this->customcode) ."'"; |
| 887 | - $sql.= ", fk_country = " . ($this->country_id > 0 ? $this->country_id : 'null'); |
|
| 888 | - $sql.= ", note = ".(isset($this->note) ? "'" .$this->db->escape($this->note)."'" : 'null'); |
|
| 887 | + $sql.= ", fk_country = " . ($this->country_id > 0 ? $this->country_id : 'null'); |
|
| 888 | + $sql.= ", note = ".(isset($this->note) ? "'" .$this->db->escape($this->note)."'" : 'null'); |
|
| 889 | 889 | $sql.= ", duration = '" . $this->db->escape($this->duration_value . $this->duration_unit) ."'"; |
| 890 | 890 | $sql.= ", accountancy_code_buy = '" . $this->db->escape($this->accountancy_code_buy)."'"; |
| 891 | 891 | $sql.= ", accountancy_code_sell= '" . $this->db->escape($this->accountancy_code_sell)."'"; |
@@ -893,8 +893,8 @@ discard block |
||
| 893 | 893 | $sql.= ", accountancy_code_sell_export= '" . $this->db->escape($this->accountancy_code_sell_export)."'"; |
| 894 | 894 | $sql.= ", desiredstock = " . ((isset($this->desiredstock) && $this->desiredstock != '') ? $this->desiredstock : "null"); |
| 895 | 895 | $sql.= ", cost_price = " . ($this->cost_price != '' ? $this->db->escape($this->cost_price) : 'null'); |
| 896 | - $sql.= ", fk_unit= " . (!$this->fk_unit ? 'NULL' : $this->fk_unit); |
|
| 897 | - $sql.= ", price_autogen = " . (!$this->price_autogen ? 0 : 1); |
|
| 896 | + $sql.= ", fk_unit= " . (!$this->fk_unit ? 'NULL' : $this->fk_unit); |
|
| 897 | + $sql.= ", price_autogen = " . (!$this->price_autogen ? 0 : 1); |
|
| 898 | 898 | $sql.= ", fk_price_expression = ".($this->fk_price_expression != 0 ? $this->fk_price_expression : 'NULL'); |
| 899 | 899 | $sql.= ", fk_user_modif = ".($user->id > 0 ? $user->id : 'NULL'); |
| 900 | 900 | // stock field is not here because it is a denormalized value from product_stock. |
@@ -931,10 +931,10 @@ discard block |
||
| 931 | 931 | |
| 932 | 932 | if (! $error && ! $notrigger) |
| 933 | 933 | { |
| 934 | - // Call trigger |
|
| 935 | - $result=$this->call_trigger('PRODUCT_MODIFY',$user); |
|
| 936 | - if ($result < 0) { $error++; } |
|
| 937 | - // End call triggers |
|
| 934 | + // Call trigger |
|
| 935 | + $result=$this->call_trigger('PRODUCT_MODIFY',$user); |
|
| 936 | + if ($result < 0) { $error++; } |
|
| 937 | + // End call triggers |
|
| 938 | 938 | } |
| 939 | 939 | |
| 940 | 940 | if (! $error && (is_object($this->oldcopy) && $this->oldcopy->ref !== $this->ref)) |
@@ -952,7 +952,7 @@ discard block |
||
| 952 | 952 | $res = @rename($olddir, $newdir); |
| 953 | 953 | if (! $res) |
| 954 | 954 | { |
| 955 | - $langs->load("errors"); |
|
| 955 | + $langs->load("errors"); |
|
| 956 | 956 | $this->error=$langs->trans('ErrorFailToRenameDir',$olddir,$newdir); |
| 957 | 957 | $error++; |
| 958 | 958 | } |
@@ -1001,13 +1001,13 @@ discard block |
||
| 1001 | 1001 | return -2; |
| 1002 | 1002 | } |
| 1003 | 1003 | } |
| 1004 | - } |
|
| 1005 | - else |
|
| 1006 | - { |
|
| 1007 | - $this->db->rollback(); |
|
| 1008 | - dol_syslog(get_class($this)."::Update fails verify ".join(',',$this->errors), LOG_WARNING); |
|
| 1009 | - return -3; |
|
| 1010 | - } |
|
| 1004 | + } |
|
| 1005 | + else |
|
| 1006 | + { |
|
| 1007 | + $this->db->rollback(); |
|
| 1008 | + dol_syslog(get_class($this)."::Update fails verify ".join(',',$this->errors), LOG_WARNING); |
|
| 1009 | + return -3; |
|
| 1010 | + } |
|
| 1011 | 1011 | } |
| 1012 | 1012 | |
| 1013 | 1013 | /** |
@@ -1052,10 +1052,10 @@ discard block |
||
| 1052 | 1052 | |
| 1053 | 1053 | if (! $error && empty($notrigger)) |
| 1054 | 1054 | { |
| 1055 | - // Call trigger |
|
| 1056 | - $result=$this->call_trigger('PRODUCT_DELETE',$user); |
|
| 1057 | - if ($result < 0) { $error++; } |
|
| 1058 | - // End call triggers |
|
| 1055 | + // Call trigger |
|
| 1056 | + $result=$this->call_trigger('PRODUCT_DELETE',$user); |
|
| 1057 | + if ($result < 0) { $error++; } |
|
| 1058 | + // End call triggers |
|
| 1059 | 1059 | } |
| 1060 | 1060 | |
| 1061 | 1061 | // Delete from product_batch on product delete |
@@ -1078,21 +1078,21 @@ discard block |
||
| 1078 | 1078 | if (! $error) |
| 1079 | 1079 | { |
| 1080 | 1080 | $elements = array('product_fournisseur_price','product_price','product_lang','categorie_product','product_stock','product_customer_price','product_lot'); // product_batch is done before |
| 1081 | - foreach($elements as $table) |
|
| 1082 | - { |
|
| 1083 | - if (! $error) |
|
| 1084 | - { |
|
| 1085 | - $sql = "DELETE FROM ".MAIN_DB_PREFIX.$table; |
|
| 1086 | - $sql.= " WHERE fk_product = ".$id; |
|
| 1087 | - dol_syslog(get_class($this).'::delete', LOG_DEBUG); |
|
| 1088 | - $result = $this->db->query($sql); |
|
| 1089 | - if (! $result) |
|
| 1090 | - { |
|
| 1091 | - $error++; |
|
| 1092 | - $this->errors[] = $this->db->lasterror(); |
|
| 1093 | - } |
|
| 1094 | - } |
|
| 1095 | - } |
|
| 1081 | + foreach($elements as $table) |
|
| 1082 | + { |
|
| 1083 | + if (! $error) |
|
| 1084 | + { |
|
| 1085 | + $sql = "DELETE FROM ".MAIN_DB_PREFIX.$table; |
|
| 1086 | + $sql.= " WHERE fk_product = ".$id; |
|
| 1087 | + dol_syslog(get_class($this).'::delete', LOG_DEBUG); |
|
| 1088 | + $result = $this->db->query($sql); |
|
| 1089 | + if (! $result) |
|
| 1090 | + { |
|
| 1091 | + $error++; |
|
| 1092 | + $this->errors[] = $this->db->lasterror(); |
|
| 1093 | + } |
|
| 1094 | + } |
|
| 1095 | + } |
|
| 1096 | 1096 | } |
| 1097 | 1097 | |
| 1098 | 1098 | if (!$error) { |
@@ -1264,11 +1264,11 @@ discard block |
||
| 1264 | 1264 | // We do not save if main fields are empty |
| 1265 | 1265 | if ($this->multilangs["$key"]["label"] || $this->multilangs["$key"]["description"]) |
| 1266 | 1266 | { |
| 1267 | - if (! $this->db->query($sql2)) |
|
| 1268 | - { |
|
| 1269 | - $this->error=$this->db->lasterror(); |
|
| 1270 | - return -1; |
|
| 1271 | - } |
|
| 1267 | + if (! $this->db->query($sql2)) |
|
| 1268 | + { |
|
| 1269 | + $this->error=$this->db->lasterror(); |
|
| 1270 | + return -1; |
|
| 1271 | + } |
|
| 1272 | 1272 | } |
| 1273 | 1273 | } |
| 1274 | 1274 | else |
@@ -1512,7 +1512,7 @@ discard block |
||
| 1512 | 1512 | $sql = "SELECT pfp.rowid, pfp.price as price, pfp.quantity as quantity, pfp.remise_percent,"; |
| 1513 | 1513 | $sql.= " pfp.fk_product, pfp.ref_fourn, pfp.fk_soc, pfp.tva_tx, pfp.fk_supplier_price_expression"; |
| 1514 | 1514 | $sql.= " ,pfp.default_vat_code"; |
| 1515 | - $sql.= " ,pfp.multicurrency_price, pfp.multicurrency_unitprice, pfp.multicurrency_tx, pfp.fk_multicurrency, pfp.multicurrency_code"; |
|
| 1515 | + $sql.= " ,pfp.multicurrency_price, pfp.multicurrency_unitprice, pfp.multicurrency_tx, pfp.fk_multicurrency, pfp.multicurrency_code"; |
|
| 1516 | 1516 | $sql.= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price as pfp"; |
| 1517 | 1517 | $sql.= " WHERE pfp.rowid = ".$prodfournprice; |
| 1518 | 1518 | if ($qty > 0) $sql.= " AND pfp.quantity <= ".$qty; |
@@ -1525,22 +1525,22 @@ discard block |
||
| 1525 | 1525 | $obj = $this->db->fetch_object($resql); |
| 1526 | 1526 | if ($obj && $obj->quantity > 0) // If we found a supplier prices from the id of supplier price |
| 1527 | 1527 | { |
| 1528 | - if (!empty($conf->dynamicprices->enabled) && !empty($obj->fk_supplier_price_expression)) |
|
| 1529 | - { |
|
| 1528 | + if (!empty($conf->dynamicprices->enabled) && !empty($obj->fk_supplier_price_expression)) |
|
| 1529 | + { |
|
| 1530 | 1530 | require_once DOL_DOCUMENT_ROOT.'/product/dynamic_price/class/price_parser.class.php'; |
| 1531 | - $prod_supplier = new ProductFournisseur($this->db); |
|
| 1532 | - $prod_supplier->product_fourn_price_id = $obj->rowid; |
|
| 1533 | - $prod_supplier->id = $obj->fk_product; |
|
| 1534 | - $prod_supplier->fourn_qty = $obj->quantity; |
|
| 1535 | - $prod_supplier->fourn_tva_tx = $obj->tva_tx; |
|
| 1536 | - $prod_supplier->fk_supplier_price_expression = $obj->fk_supplier_price_expression; |
|
| 1537 | - $priceparser = new PriceParser($this->db); |
|
| 1538 | - $price_result = $priceparser->parseProductSupplier($prod_supplier); |
|
| 1539 | - if ($price_result >= 0) { |
|
| 1540 | - $obj->price = $price_result; |
|
| 1541 | - } |
|
| 1542 | - } |
|
| 1543 | - $this->product_fourn_price_id = $obj->rowid; |
|
| 1531 | + $prod_supplier = new ProductFournisseur($this->db); |
|
| 1532 | + $prod_supplier->product_fourn_price_id = $obj->rowid; |
|
| 1533 | + $prod_supplier->id = $obj->fk_product; |
|
| 1534 | + $prod_supplier->fourn_qty = $obj->quantity; |
|
| 1535 | + $prod_supplier->fourn_tva_tx = $obj->tva_tx; |
|
| 1536 | + $prod_supplier->fk_supplier_price_expression = $obj->fk_supplier_price_expression; |
|
| 1537 | + $priceparser = new PriceParser($this->db); |
|
| 1538 | + $price_result = $priceparser->parseProductSupplier($prod_supplier); |
|
| 1539 | + if ($price_result >= 0) { |
|
| 1540 | + $obj->price = $price_result; |
|
| 1541 | + } |
|
| 1542 | + } |
|
| 1543 | + $this->product_fourn_price_id = $obj->rowid; |
|
| 1544 | 1544 | $this->buyprice = $obj->price; // deprecated |
| 1545 | 1545 | $this->fourn_pu = $obj->price / $obj->quantity; // Unit price of product of supplier |
| 1546 | 1546 | $this->fourn_price_base_type = 'HT'; // Price base type |
@@ -1549,11 +1549,11 @@ discard block |
||
| 1549 | 1549 | $this->remise_percent = $obj->remise_percent; // remise percent if present and not typed |
| 1550 | 1550 | $this->vatrate_supplier = $obj->tva_tx; // Vat ref supplier |
| 1551 | 1551 | $this->default_vat_code = $obj->default_vat_code; // Vat code supplier |
| 1552 | - $this->fourn_multicurrency_price = $obj->multicurrency_price; |
|
| 1553 | - $this->fourn_multicurrency_unitprice = $obj->multicurrency_unitprice; |
|
| 1554 | - $this->fourn_multicurrency_tx = $obj->multicurrency_tx; |
|
| 1555 | - $this->fourn_multicurrency_id = $obj->fk_multicurrency; |
|
| 1556 | - $this->fourn_multicurrency_code = $obj->multicurrency_code; |
|
| 1552 | + $this->fourn_multicurrency_price = $obj->multicurrency_price; |
|
| 1553 | + $this->fourn_multicurrency_unitprice = $obj->multicurrency_unitprice; |
|
| 1554 | + $this->fourn_multicurrency_tx = $obj->multicurrency_tx; |
|
| 1555 | + $this->fourn_multicurrency_id = $obj->fk_multicurrency; |
|
| 1556 | + $this->fourn_multicurrency_code = $obj->multicurrency_code; |
|
| 1557 | 1557 | $result=$obj->fk_product; |
| 1558 | 1558 | return $result; |
| 1559 | 1559 | } |
@@ -1563,7 +1563,7 @@ discard block |
||
| 1563 | 1563 | $sql = "SELECT pfp.rowid, pfp.price as price, pfp.quantity as quantity, pfp.fk_soc,"; |
| 1564 | 1564 | $sql.= " pfp.fk_product, pfp.ref_fourn as ref_supplier, pfp.tva_tx, pfp.fk_supplier_price_expression"; |
| 1565 | 1565 | $sql.= " ,pfp.default_vat_code"; |
| 1566 | - $sql.= " ,pfp.multicurrency_price, pfp.multicurrency_unitprice, pfp.multicurrency_tx, pfp.fk_multicurrency, pfp.multicurrency_code"; |
|
| 1566 | + $sql.= " ,pfp.multicurrency_price, pfp.multicurrency_unitprice, pfp.multicurrency_tx, pfp.fk_multicurrency, pfp.multicurrency_code"; |
|
| 1567 | 1567 | $sql.= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price as pfp"; |
| 1568 | 1568 | $sql.= " WHERE pfp.fk_product = ".$product_id; |
| 1569 | 1569 | if ($fourn_ref != 'none') $sql.= " AND pfp.ref_fourn = '".$fourn_ref."'"; |
@@ -1579,22 +1579,22 @@ discard block |
||
| 1579 | 1579 | $obj = $this->db->fetch_object($resql); |
| 1580 | 1580 | if ($obj && $obj->quantity > 0) // If found |
| 1581 | 1581 | { |
| 1582 | - if (!empty($conf->dynamicprices->enabled) && !empty($obj->fk_supplier_price_expression)) |
|
| 1583 | - { |
|
| 1582 | + if (!empty($conf->dynamicprices->enabled) && !empty($obj->fk_supplier_price_expression)) |
|
| 1583 | + { |
|
| 1584 | 1584 | require_once DOL_DOCUMENT_ROOT.'/product/dynamic_price/class/price_parser.class.php'; |
| 1585 | - $prod_supplier = new ProductFournisseur($this->db); |
|
| 1586 | - $prod_supplier->product_fourn_price_id = $obj->rowid; |
|
| 1587 | - $prod_supplier->id = $obj->fk_product; |
|
| 1588 | - $prod_supplier->fourn_qty = $obj->quantity; |
|
| 1589 | - $prod_supplier->fourn_tva_tx = $obj->tva_tx; |
|
| 1590 | - $prod_supplier->fk_supplier_price_expression = $obj->fk_supplier_price_expression; |
|
| 1591 | - $priceparser = new PriceParser($this->db); |
|
| 1592 | - $price_result = $priceparser->parseProductSupplier($prod_supplier); |
|
| 1593 | - if ($result >= 0) { |
|
| 1594 | - $obj->price = $price_result; |
|
| 1595 | - } |
|
| 1596 | - } |
|
| 1597 | - $this->product_fourn_price_id = $obj->rowid; |
|
| 1585 | + $prod_supplier = new ProductFournisseur($this->db); |
|
| 1586 | + $prod_supplier->product_fourn_price_id = $obj->rowid; |
|
| 1587 | + $prod_supplier->id = $obj->fk_product; |
|
| 1588 | + $prod_supplier->fourn_qty = $obj->quantity; |
|
| 1589 | + $prod_supplier->fourn_tva_tx = $obj->tva_tx; |
|
| 1590 | + $prod_supplier->fk_supplier_price_expression = $obj->fk_supplier_price_expression; |
|
| 1591 | + $priceparser = new PriceParser($this->db); |
|
| 1592 | + $price_result = $priceparser->parseProductSupplier($prod_supplier); |
|
| 1593 | + if ($result >= 0) { |
|
| 1594 | + $obj->price = $price_result; |
|
| 1595 | + } |
|
| 1596 | + } |
|
| 1597 | + $this->product_fourn_price_id = $obj->rowid; |
|
| 1598 | 1598 | $this->buyprice = $obj->price; // deprecated |
| 1599 | 1599 | $this->fourn_qty = $obj->quantity; // min quantity for price for a virtual supplier |
| 1600 | 1600 | $this->fourn_pu = $obj->price / $obj->quantity; // Unit price of product for a virtual supplier |
@@ -1604,11 +1604,11 @@ discard block |
||
| 1604 | 1604 | $this->remise_percent = $obj->remise_percent; // remise percent if present and not typed |
| 1605 | 1605 | $this->vatrate_supplier = $obj->tva_tx; // Vat ref supplier |
| 1606 | 1606 | $this->default_vat_code = $obj->default_vat_code; // Vat code supplier |
| 1607 | - $this->fourn_multicurrency_price = $obj->multicurrency_price; |
|
| 1608 | - $this->fourn_multicurrency_unitprice = $obj->multicurrency_unitprice; |
|
| 1609 | - $this->fourn_multicurrency_tx = $obj->multicurrency_tx; |
|
| 1610 | - $this->fourn_multicurrency_id = $obj->fk_multicurrency; |
|
| 1611 | - $this->fourn_multicurrency_code = $obj->multicurrency_code; |
|
| 1607 | + $this->fourn_multicurrency_price = $obj->multicurrency_price; |
|
| 1608 | + $this->fourn_multicurrency_unitprice = $obj->multicurrency_unitprice; |
|
| 1609 | + $this->fourn_multicurrency_tx = $obj->multicurrency_tx; |
|
| 1610 | + $this->fourn_multicurrency_id = $obj->fk_multicurrency; |
|
| 1611 | + $this->fourn_multicurrency_code = $obj->multicurrency_code; |
|
| 1612 | 1612 | $result=$obj->fk_product; |
| 1613 | 1613 | return $result; |
| 1614 | 1614 | } |
@@ -1644,8 +1644,8 @@ discard block |
||
| 1644 | 1644 | * @param int $newnpr 0=Standard vat rate, 1=Special vat rate for French NPR VAT |
| 1645 | 1645 | * @param int $newpbq 1 if it has price by quantity |
| 1646 | 1646 | * @param int $ignore_autogen Used to avoid infinite loops |
| 1647 | - * @param array $localtaxes_array Array with localtaxes info array('0'=>type1,'1'=>rate1,'2'=>type2,'3'=>rate2) (loaded by getLocalTaxesFromRate(vatrate, 0, ...) function). |
|
| 1648 | - * @param string $newdefaultvatcode Default vat code |
|
| 1647 | + * @param array $localtaxes_array Array with localtaxes info array('0'=>type1,'1'=>rate1,'2'=>type2,'3'=>rate2) (loaded by getLocalTaxesFromRate(vatrate, 0, ...) function). |
|
| 1648 | + * @param string $newdefaultvatcode Default vat code |
|
| 1649 | 1649 | * @return int <0 if KO, >0 if OK |
| 1650 | 1650 | */ |
| 1651 | 1651 | function updatePrice($newprice, $newpricebase, $user, $newvat='',$newminprice=0, $level=0, $newnpr=0, $newpbq=0, $ignore_autogen=0, $localtaxes_array=array(), $newdefaultvatcode='') |
@@ -1658,7 +1658,7 @@ discard block |
||
| 1658 | 1658 | |
| 1659 | 1659 | // Clean parameters |
| 1660 | 1660 | if (empty($this->tva_tx)) $this->tva_tx=0; |
| 1661 | - if (empty($newnpr)) $newnpr=0; |
|
| 1661 | + if (empty($newnpr)) $newnpr=0; |
|
| 1662 | 1662 | |
| 1663 | 1663 | // Check parameters |
| 1664 | 1664 | if ($newvat == '') $newvat=$this->tva_tx; |
@@ -1719,17 +1719,17 @@ discard block |
||
| 1719 | 1719 | |
| 1720 | 1720 | if (count($localtaxes_array) > 0) |
| 1721 | 1721 | { |
| 1722 | - $localtaxtype1=$localtaxes_array['0']; |
|
| 1723 | - $localtax1=$localtaxes_array['1']; |
|
| 1724 | - $localtaxtype2=$localtaxes_array['2']; |
|
| 1725 | - $localtax2=$localtaxes_array['3']; |
|
| 1722 | + $localtaxtype1=$localtaxes_array['0']; |
|
| 1723 | + $localtax1=$localtaxes_array['1']; |
|
| 1724 | + $localtaxtype2=$localtaxes_array['2']; |
|
| 1725 | + $localtax2=$localtaxes_array['3']; |
|
| 1726 | 1726 | } |
| 1727 | 1727 | else // old method. deprecated because ot can't retreive type |
| 1728 | 1728 | { |
| 1729 | - $localtaxtype1='0'; |
|
| 1730 | - $localtax1=get_localtax($newvat,1); |
|
| 1731 | - $localtaxtype2='0'; |
|
| 1732 | - $localtax2=get_localtax($newvat,2); |
|
| 1729 | + $localtaxtype1='0'; |
|
| 1730 | + $localtax1=get_localtax($newvat,1); |
|
| 1731 | + $localtaxtype2='0'; |
|
| 1732 | + $localtax2=get_localtax($newvat,2); |
|
| 1733 | 1733 | } |
| 1734 | 1734 | if (empty($localtax1)) $localtax1=0; // If = '' then = 0 |
| 1735 | 1735 | if (empty($localtax2)) $localtax2=0; // If = '' then = 0 |
@@ -1748,9 +1748,9 @@ discard block |
||
| 1748 | 1748 | $sql.= " localtax2_tx=".($localtax2>=0?$localtax2:'NULL').","; |
| 1749 | 1749 | $sql.= " localtax1_type=".($localtaxtype1!=''?"'".$localtaxtype1."'":"'0'").","; |
| 1750 | 1750 | $sql.= " localtax2_type=".($localtaxtype2!=''?"'".$localtaxtype2."'":"'0'").","; |
| 1751 | - $sql.= " default_vat_code=".($newdefaultvatcode?"'".$this->db->escape($newdefaultvatcode)."'":"null").","; |
|
| 1751 | + $sql.= " default_vat_code=".($newdefaultvatcode?"'".$this->db->escape($newdefaultvatcode)."'":"null").","; |
|
| 1752 | 1752 | $sql.= " tva_tx='".price2num($newvat)."',"; |
| 1753 | - $sql.= " recuperableonly='".$newnpr."'"; |
|
| 1753 | + $sql.= " recuperableonly='".$newnpr."'"; |
|
| 1754 | 1754 | $sql.= " WHERE rowid = ".$id; |
| 1755 | 1755 | |
| 1756 | 1756 | dol_syslog(get_class($this)."::update_price", LOG_DEBUG); |
@@ -1787,42 +1787,42 @@ discard block |
||
| 1787 | 1787 | |
| 1788 | 1788 | $this->level = $level; // Store level of price edited for trigger |
| 1789 | 1789 | |
| 1790 | - // Call trigger |
|
| 1791 | - $result=$this->call_trigger('PRODUCT_PRICE_MODIFY',$user); |
|
| 1792 | - if ($result < 0) |
|
| 1793 | - { |
|
| 1794 | - $this->db->rollback(); |
|
| 1795 | - return -1; |
|
| 1796 | - } |
|
| 1797 | - // End call triggers |
|
| 1790 | + // Call trigger |
|
| 1791 | + $result=$this->call_trigger('PRODUCT_PRICE_MODIFY',$user); |
|
| 1792 | + if ($result < 0) |
|
| 1793 | + { |
|
| 1794 | + $this->db->rollback(); |
|
| 1795 | + return -1; |
|
| 1796 | + } |
|
| 1797 | + // End call triggers |
|
| 1798 | 1798 | |
| 1799 | - $this->db->commit(); |
|
| 1799 | + $this->db->commit(); |
|
| 1800 | 1800 | } |
| 1801 | 1801 | else |
| 1802 | 1802 | { |
| 1803 | 1803 | $this->db->rollback(); |
| 1804 | - dol_print_error($this->db); |
|
| 1804 | + dol_print_error($this->db); |
|
| 1805 | 1805 | } |
| 1806 | 1806 | } |
| 1807 | 1807 | |
| 1808 | 1808 | return 1; |
| 1809 | 1809 | } |
| 1810 | 1810 | |
| 1811 | - /** |
|
| 1812 | - * Sets the supplier price expression |
|
| 1813 | - * |
|
| 1814 | - * @param int $expression_id Expression |
|
| 1815 | - * @return int <0 if KO, >0 if OK |
|
| 1811 | + /** |
|
| 1812 | + * Sets the supplier price expression |
|
| 1813 | + * |
|
| 1814 | + * @param int $expression_id Expression |
|
| 1815 | + * @return int <0 if KO, >0 if OK |
|
| 1816 | 1816 | * @deprecated Use Product::update instead |
| 1817 | - */ |
|
| 1818 | - function setPriceExpression($expression_id) |
|
| 1819 | - { |
|
| 1817 | + */ |
|
| 1818 | + function setPriceExpression($expression_id) |
|
| 1819 | + { |
|
| 1820 | 1820 | global $user; |
| 1821 | 1821 | |
| 1822 | 1822 | $this->fk_price_expression = $expression_id; |
| 1823 | 1823 | |
| 1824 | 1824 | return $this->update($this->id, $user); |
| 1825 | - } |
|
| 1825 | + } |
|
| 1826 | 1826 | |
| 1827 | 1827 | /** |
| 1828 | 1828 | * Load a product in memory from database |
@@ -1830,12 +1830,12 @@ discard block |
||
| 1830 | 1830 | * @param int $id Id of product/service to load |
| 1831 | 1831 | * @param string $ref Ref of product/service to load |
| 1832 | 1832 | * @param string $ref_ext Ref ext of product/service to load |
| 1833 | - * @param int $ignore_expression Ignores the math expression for calculating price and uses the db value instead |
|
| 1833 | + * @param int $ignore_expression Ignores the math expression for calculating price and uses the db value instead |
|
| 1834 | 1834 | * @return int <0 if KO, 0 if not found, >0 if OK |
| 1835 | 1835 | */ |
| 1836 | 1836 | function fetch($id='', $ref='', $ref_ext='', $ignore_expression=0) |
| 1837 | 1837 | { |
| 1838 | - include_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; |
|
| 1838 | + include_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; |
|
| 1839 | 1839 | |
| 1840 | 1840 | global $langs, $conf; |
| 1841 | 1841 | |
@@ -2091,19 +2091,19 @@ discard block |
||
| 2091 | 2091 | // Not yet implemented |
| 2092 | 2092 | } |
| 2093 | 2093 | |
| 2094 | - if (!empty($conf->dynamicprices->enabled) && !empty($this->fk_price_expression) && empty($ignore_expression)) |
|
| 2095 | - { |
|
| 2094 | + if (!empty($conf->dynamicprices->enabled) && !empty($this->fk_price_expression) && empty($ignore_expression)) |
|
| 2095 | + { |
|
| 2096 | 2096 | require_once DOL_DOCUMENT_ROOT.'/product/dynamic_price/class/price_parser.class.php'; |
| 2097 | - $priceparser = new PriceParser($this->db); |
|
| 2098 | - $price_result = $priceparser->parseProduct($this); |
|
| 2099 | - if ($price_result >= 0) |
|
| 2100 | - { |
|
| 2101 | - $this->price = $price_result; |
|
| 2102 | - // Calculate the VAT |
|
| 2097 | + $priceparser = new PriceParser($this->db); |
|
| 2098 | + $price_result = $priceparser->parseProduct($this); |
|
| 2099 | + if ($price_result >= 0) |
|
| 2100 | + { |
|
| 2101 | + $this->price = $price_result; |
|
| 2102 | + // Calculate the VAT |
|
| 2103 | 2103 | $this->price_ttc = price2num($this->price) * (1 + ($this->tva_tx / 100)); |
| 2104 | 2104 | $this->price_ttc = price2num($this->price_ttc,'MU'); |
| 2105 | - } |
|
| 2106 | - } |
|
| 2105 | + } |
|
| 2106 | + } |
|
| 2107 | 2107 | |
| 2108 | 2108 | // We should not load stock during the fetch. If someone need stock of product, he must call load_stock after fetching product. |
| 2109 | 2109 | // Instead we just init the stock_warehouse array |
@@ -2596,12 +2596,12 @@ discard block |
||
| 2596 | 2596 | |
| 2597 | 2597 | if (empty($year)) |
| 2598 | 2598 | { |
| 2599 | - $year = strftime('%Y',time()); |
|
| 2600 | - $month = strftime('%m',time()); |
|
| 2599 | + $year = strftime('%Y',time()); |
|
| 2600 | + $month = strftime('%m',time()); |
|
| 2601 | 2601 | } |
| 2602 | 2602 | else |
| 2603 | 2603 | { |
| 2604 | - $month=12; // We imagine we are at end of year, so we get last 12 month before, so all correct year. |
|
| 2604 | + $month=12; // We imagine we are at end of year, so we get last 12 month before, so all correct year. |
|
| 2605 | 2605 | } |
| 2606 | 2606 | $result = array(); |
| 2607 | 2607 | |
@@ -2683,8 +2683,8 @@ discard block |
||
| 2683 | 2683 | $sql = "SELECT sum(d.qty), date_format(f.datef, '%Y%m')"; |
| 2684 | 2684 | if ($mode == 'bynumber') $sql.= ", count(DISTINCT f.rowid)"; |
| 2685 | 2685 | $sql.= " FROM ".MAIN_DB_PREFIX."facture_fourn_det as d, ".MAIN_DB_PREFIX."facture_fourn as f, ".MAIN_DB_PREFIX."societe as s"; |
| 2686 | - if ($filteronproducttype >= 0) $sql.=", ".MAIN_DB_PREFIX."product as p"; |
|
| 2687 | - if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; |
|
| 2686 | + if ($filteronproducttype >= 0) $sql.=", ".MAIN_DB_PREFIX."product as p"; |
|
| 2687 | + if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; |
|
| 2688 | 2688 | $sql.= " WHERE f.rowid = d.fk_facture_fourn"; |
| 2689 | 2689 | if ($this->id > 0) $sql.= " AND d.fk_product =".$this->id; |
| 2690 | 2690 | else $sql.=" AND d.fk_product > 0"; |
@@ -2718,7 +2718,7 @@ discard block |
||
| 2718 | 2718 | $sql = "SELECT sum(d.qty), date_format(p.datep, '%Y%m')"; |
| 2719 | 2719 | if ($mode == 'bynumber') $sql.= ", count(DISTINCT p.rowid)"; |
| 2720 | 2720 | $sql.= " FROM ".MAIN_DB_PREFIX."propaldet as d, ".MAIN_DB_PREFIX."propal as p, ".MAIN_DB_PREFIX."societe as s"; |
| 2721 | - if ($filteronproducttype >= 0) $sql.=", ".MAIN_DB_PREFIX."product as prod"; |
|
| 2721 | + if ($filteronproducttype >= 0) $sql.=", ".MAIN_DB_PREFIX."product as prod"; |
|
| 2722 | 2722 | if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; |
| 2723 | 2723 | $sql.= " WHERE p.rowid = d.fk_propal"; |
| 2724 | 2724 | if ($this->id > 0) $sql.= " AND d.fk_product =".$this->id; |
@@ -2753,7 +2753,7 @@ discard block |
||
| 2753 | 2753 | $sql = "SELECT sum(d.qty), date_format(p.date_valid, '%Y%m')"; |
| 2754 | 2754 | if ($mode == 'bynumber') $sql.= ", count(DISTINCT p.rowid)"; |
| 2755 | 2755 | $sql.= " FROM ".MAIN_DB_PREFIX."supplier_proposaldet as d, ".MAIN_DB_PREFIX."supplier_proposal as p, ".MAIN_DB_PREFIX."societe as s"; |
| 2756 | - if ($filteronproducttype >= 0) $sql.=", ".MAIN_DB_PREFIX."product as prod"; |
|
| 2756 | + if ($filteronproducttype >= 0) $sql.=", ".MAIN_DB_PREFIX."product as prod"; |
|
| 2757 | 2757 | if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; |
| 2758 | 2758 | $sql.= " WHERE p.rowid = d.fk_supplier_proposal"; |
| 2759 | 2759 | if ($this->id > 0) $sql.= " AND d.fk_product =".$this->id; |
@@ -2787,8 +2787,8 @@ discard block |
||
| 2787 | 2787 | $sql = "SELECT sum(d.qty), date_format(c.date_commande, '%Y%m')"; |
| 2788 | 2788 | if ($mode == 'bynumber') $sql.= ", count(DISTINCT c.rowid)"; |
| 2789 | 2789 | $sql.= " FROM ".MAIN_DB_PREFIX."commandedet as d, ".MAIN_DB_PREFIX."commande as c, ".MAIN_DB_PREFIX."societe as s"; |
| 2790 | - if ($filteronproducttype >= 0) $sql.=", ".MAIN_DB_PREFIX."product as p"; |
|
| 2791 | - if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; |
|
| 2790 | + if ($filteronproducttype >= 0) $sql.=", ".MAIN_DB_PREFIX."product as p"; |
|
| 2791 | + if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; |
|
| 2792 | 2792 | $sql.= " WHERE c.rowid = d.fk_commande"; |
| 2793 | 2793 | if ($this->id > 0) $sql.= " AND d.fk_product =".$this->id; |
| 2794 | 2794 | else $sql.=" AND d.fk_product > 0"; |
@@ -2821,7 +2821,7 @@ discard block |
||
| 2821 | 2821 | $sql = "SELECT sum(d.qty), date_format(c.date_commande, '%Y%m')"; |
| 2822 | 2822 | if ($mode == 'bynumber') $sql.= ", count(DISTINCT c.rowid)"; |
| 2823 | 2823 | $sql.= " FROM ".MAIN_DB_PREFIX."commande_fournisseurdet as d, ".MAIN_DB_PREFIX."commande_fournisseur as c, ".MAIN_DB_PREFIX."societe as s"; |
| 2824 | - if ($filteronproducttype >= 0) $sql.=", ".MAIN_DB_PREFIX."product as p"; |
|
| 2824 | + if ($filteronproducttype >= 0) $sql.=", ".MAIN_DB_PREFIX."product as p"; |
|
| 2825 | 2825 | if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; |
| 2826 | 2826 | $sql.= " WHERE c.rowid = d.fk_commande"; |
| 2827 | 2827 | if ($this->id > 0) $sql.= " AND d.fk_product =".$this->id; |
@@ -3010,29 +3010,29 @@ discard block |
||
| 3010 | 3010 | |
| 3011 | 3011 | $now=dol_now(); |
| 3012 | 3012 | |
| 3013 | - dol_syslog(get_class($this)."::add_fournisseur id_fourn = ".$id_fourn." ref_fourn=".$ref_fourn." quantity=".$quantity, LOG_DEBUG); |
|
| 3013 | + dol_syslog(get_class($this)."::add_fournisseur id_fourn = ".$id_fourn." ref_fourn=".$ref_fourn." quantity=".$quantity, LOG_DEBUG); |
|
| 3014 | 3014 | |
| 3015 | 3015 | if ($ref_fourn) |
| 3016 | 3016 | { |
| 3017 | - $sql = "SELECT rowid, fk_product"; |
|
| 3018 | - $sql.= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price"; |
|
| 3019 | - $sql.= " WHERE fk_soc = ".$id_fourn; |
|
| 3020 | - $sql.= " AND ref_fourn = '".$this->db->escape($ref_fourn)."'"; |
|
| 3021 | - $sql.= " AND fk_product != ".$this->id; |
|
| 3022 | - $sql.= " AND entity IN (".getEntity('productprice').")"; |
|
| 3023 | - |
|
| 3024 | - $resql=$this->db->query($sql); |
|
| 3025 | - if ($resql) |
|
| 3026 | - { |
|
| 3027 | - $obj = $this->db->fetch_object($resql); |
|
| 3028 | - if ($obj) |
|
| 3029 | - { |
|
| 3030 | - // If the supplier ref already exists but for another product (duplicate ref is accepted for different quantity only or different companies) |
|
| 3031 | - $this->product_id_already_linked = $obj->fk_product; |
|
| 3032 | - return -3; |
|
| 3033 | - } |
|
| 3034 | - $this->db->free($resql); |
|
| 3035 | - } |
|
| 3017 | + $sql = "SELECT rowid, fk_product"; |
|
| 3018 | + $sql.= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price"; |
|
| 3019 | + $sql.= " WHERE fk_soc = ".$id_fourn; |
|
| 3020 | + $sql.= " AND ref_fourn = '".$this->db->escape($ref_fourn)."'"; |
|
| 3021 | + $sql.= " AND fk_product != ".$this->id; |
|
| 3022 | + $sql.= " AND entity IN (".getEntity('productprice').")"; |
|
| 3023 | + |
|
| 3024 | + $resql=$this->db->query($sql); |
|
| 3025 | + if ($resql) |
|
| 3026 | + { |
|
| 3027 | + $obj = $this->db->fetch_object($resql); |
|
| 3028 | + if ($obj) |
|
| 3029 | + { |
|
| 3030 | + // If the supplier ref already exists but for another product (duplicate ref is accepted for different quantity only or different companies) |
|
| 3031 | + $this->product_id_already_linked = $obj->fk_product; |
|
| 3032 | + return -3; |
|
| 3033 | + } |
|
| 3034 | + $this->db->free($resql); |
|
| 3035 | + } |
|
| 3036 | 3036 | } |
| 3037 | 3037 | |
| 3038 | 3038 | $sql = "SELECT rowid"; |
@@ -3047,9 +3047,9 @@ discard block |
||
| 3047 | 3047 | $resql=$this->db->query($sql); |
| 3048 | 3048 | if ($resql) |
| 3049 | 3049 | { |
| 3050 | - $obj = $this->db->fetch_object($resql); |
|
| 3050 | + $obj = $this->db->fetch_object($resql); |
|
| 3051 | 3051 | |
| 3052 | - // The reference supplier does not exist, we create it for this product. |
|
| 3052 | + // The reference supplier does not exist, we create it for this product. |
|
| 3053 | 3053 | if (! $obj) |
| 3054 | 3054 | { |
| 3055 | 3055 | $sql = "INSERT INTO ".MAIN_DB_PREFIX."product_fournisseur_price("; |
@@ -3226,8 +3226,8 @@ discard block |
||
| 3226 | 3226 | } |
| 3227 | 3227 | else |
| 3228 | 3228 | { |
| 3229 | - $this->db->commit(); |
|
| 3230 | - return 1; |
|
| 3229 | + $this->db->commit(); |
|
| 3230 | + return 1; |
|
| 3231 | 3231 | } |
| 3232 | 3232 | } |
| 3233 | 3233 | |
@@ -3448,7 +3448,7 @@ discard block |
||
| 3448 | 3448 | */ |
| 3449 | 3449 | function get_sousproduits_arbo() |
| 3450 | 3450 | { |
| 3451 | - $parent=array(); |
|
| 3451 | + $parent=array(); |
|
| 3452 | 3452 | |
| 3453 | 3453 | foreach($this->getChildsArbo($this->id) as $keyChild => $valueChild) // Warning. getChildsArbo can call getChildsArbo recursively. Starting point is $value[0]=id of product |
| 3454 | 3454 | { |
@@ -3466,7 +3466,7 @@ discard block |
||
| 3466 | 3466 | * @param int $withpicto Add picto into link |
| 3467 | 3467 | * @param string $option Where point the link ('stock', 'composition', 'category', 'supplier', '') |
| 3468 | 3468 | * @param int $maxlength Maxlength of ref |
| 3469 | - * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking |
|
| 3469 | + * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking |
|
| 3470 | 3470 | * @return string String with URL |
| 3471 | 3471 | */ |
| 3472 | 3472 | function getNomUrl($withpicto=0, $option='', $maxlength=0, $save_lastsearch_value=-1) |
@@ -3475,67 +3475,67 @@ discard block |
||
| 3475 | 3475 | include_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php'; |
| 3476 | 3476 | |
| 3477 | 3477 | $result=''; |
| 3478 | - $newref=$this->ref; |
|
| 3479 | - if ($maxlength) $newref=dol_trunc($newref,$maxlength,'middle'); |
|
| 3480 | - |
|
| 3481 | - if ($this->type == Product::TYPE_PRODUCT) $label = '<u>' . $langs->trans("ShowProduct") . '</u>'; |
|
| 3482 | - if ($this->type == Product::TYPE_SERVICE) $label = '<u>' . $langs->trans("ShowService") . '</u>'; |
|
| 3483 | - if (! empty($this->ref)) |
|
| 3484 | - $label .= '<br><b>' . $langs->trans('ProductRef') . ':</b> ' . $this->ref; |
|
| 3485 | - if (! empty($this->label)) |
|
| 3486 | - $label .= '<br><b>' . $langs->trans('ProductLabel') . ':</b> ' . $this->label; |
|
| 3487 | - |
|
| 3488 | - if ($this->type == Product::TYPE_PRODUCT) |
|
| 3489 | - { |
|
| 3490 | - if ($this->weight) $label.="<br><b>".$langs->trans("Weight").'</b>: '.$this->weight.' '.measuring_units_string($this->weight_units,"weight"); |
|
| 3491 | - if ($this->length) $label.="<br><b>".$langs->trans("Length").'</b>: '.$this->length.' '.measuring_units_string($this->length_units,'length'); |
|
| 3492 | - if ($this->surface) $label.="<br><b>".$langs->trans("Surface").'</b>: '.$this->surface.' '.measuring_units_string($this->surface_units,'surface'); |
|
| 3493 | - if ($this->volume) $label.="<br><b>".$langs->trans("Volume").'</b>: '.$this->volume.' '.measuring_units_string($this->volume_units,'volume'); |
|
| 3494 | - } |
|
| 3495 | - |
|
| 3496 | - if ($this->type == Product::TYPE_PRODUCT || ! empty($conf->global->STOCK_SUPPORTS_SERVICES)) |
|
| 3497 | - { |
|
| 3498 | - if (! empty($conf->productbatch->enabled)) |
|
| 3499 | - { |
|
| 3500 | - $langs->load("productbatch"); |
|
| 3501 | - $label.="<br><b>".$langs->trans("ManageLotSerial").'</b>: '.$this->getLibStatut(0,2); |
|
| 3502 | - } |
|
| 3503 | - } |
|
| 3504 | - if ($this->type == Product::TYPE_SERVICE) |
|
| 3505 | - { |
|
| 3506 | - // |
|
| 3507 | - } |
|
| 3508 | - if (! empty($conf->accounting->enabled) && $this->status) |
|
| 3509 | - { |
|
| 3510 | - include_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; |
|
| 3511 | - $label.= '<br><b>' . $langs->trans('ProductAccountancySellCode') . ':</b> '. length_accountg($this->accountancy_code_sell); |
|
| 3512 | - $label.= '<br><b>' . $langs->trans('ProductAccountancySellIntraCode') . ':</b> '. length_accountg($this->accountancy_code_sell_export); |
|
| 3513 | - $label.= '<br><b>' . $langs->trans('ProductAccountancySellExportCode') . ':</b> '. length_accountg($this->accountancy_code_sell_intra); |
|
| 3514 | - } |
|
| 3515 | - if (! empty($conf->accounting->enabled) && $this->status_buy) |
|
| 3516 | - { |
|
| 3517 | - include_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; |
|
| 3518 | - $label.= '<br><b>' . $langs->trans('ProductAccountancyBuyCode') . ':</b> '. length_accountg($this->accountancy_code_buy); |
|
| 3519 | - } |
|
| 3520 | - if (! empty($this->entity)) |
|
| 3521 | - { |
|
| 3522 | - $tmpphoto = $this->show_photos('product', $conf->product->multidir_output[$this->entity], 1, 1, 0, 0, 0, 80); |
|
| 3523 | - if ($this->nbphoto > 0) $label .= '<br>' . $tmpphoto; |
|
| 3524 | - } |
|
| 3478 | + $newref=$this->ref; |
|
| 3479 | + if ($maxlength) $newref=dol_trunc($newref,$maxlength,'middle'); |
|
| 3480 | + |
|
| 3481 | + if ($this->type == Product::TYPE_PRODUCT) $label = '<u>' . $langs->trans("ShowProduct") . '</u>'; |
|
| 3482 | + if ($this->type == Product::TYPE_SERVICE) $label = '<u>' . $langs->trans("ShowService") . '</u>'; |
|
| 3483 | + if (! empty($this->ref)) |
|
| 3484 | + $label .= '<br><b>' . $langs->trans('ProductRef') . ':</b> ' . $this->ref; |
|
| 3485 | + if (! empty($this->label)) |
|
| 3486 | + $label .= '<br><b>' . $langs->trans('ProductLabel') . ':</b> ' . $this->label; |
|
| 3487 | + |
|
| 3488 | + if ($this->type == Product::TYPE_PRODUCT) |
|
| 3489 | + { |
|
| 3490 | + if ($this->weight) $label.="<br><b>".$langs->trans("Weight").'</b>: '.$this->weight.' '.measuring_units_string($this->weight_units,"weight"); |
|
| 3491 | + if ($this->length) $label.="<br><b>".$langs->trans("Length").'</b>: '.$this->length.' '.measuring_units_string($this->length_units,'length'); |
|
| 3492 | + if ($this->surface) $label.="<br><b>".$langs->trans("Surface").'</b>: '.$this->surface.' '.measuring_units_string($this->surface_units,'surface'); |
|
| 3493 | + if ($this->volume) $label.="<br><b>".$langs->trans("Volume").'</b>: '.$this->volume.' '.measuring_units_string($this->volume_units,'volume'); |
|
| 3494 | + } |
|
| 3495 | + |
|
| 3496 | + if ($this->type == Product::TYPE_PRODUCT || ! empty($conf->global->STOCK_SUPPORTS_SERVICES)) |
|
| 3497 | + { |
|
| 3498 | + if (! empty($conf->productbatch->enabled)) |
|
| 3499 | + { |
|
| 3500 | + $langs->load("productbatch"); |
|
| 3501 | + $label.="<br><b>".$langs->trans("ManageLotSerial").'</b>: '.$this->getLibStatut(0,2); |
|
| 3502 | + } |
|
| 3503 | + } |
|
| 3504 | + if ($this->type == Product::TYPE_SERVICE) |
|
| 3505 | + { |
|
| 3506 | + // |
|
| 3507 | + } |
|
| 3508 | + if (! empty($conf->accounting->enabled) && $this->status) |
|
| 3509 | + { |
|
| 3510 | + include_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; |
|
| 3511 | + $label.= '<br><b>' . $langs->trans('ProductAccountancySellCode') . ':</b> '. length_accountg($this->accountancy_code_sell); |
|
| 3512 | + $label.= '<br><b>' . $langs->trans('ProductAccountancySellIntraCode') . ':</b> '. length_accountg($this->accountancy_code_sell_export); |
|
| 3513 | + $label.= '<br><b>' . $langs->trans('ProductAccountancySellExportCode') . ':</b> '. length_accountg($this->accountancy_code_sell_intra); |
|
| 3514 | + } |
|
| 3515 | + if (! empty($conf->accounting->enabled) && $this->status_buy) |
|
| 3516 | + { |
|
| 3517 | + include_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; |
|
| 3518 | + $label.= '<br><b>' . $langs->trans('ProductAccountancyBuyCode') . ':</b> '. length_accountg($this->accountancy_code_buy); |
|
| 3519 | + } |
|
| 3520 | + if (! empty($this->entity)) |
|
| 3521 | + { |
|
| 3522 | + $tmpphoto = $this->show_photos('product', $conf->product->multidir_output[$this->entity], 1, 1, 0, 0, 0, 80); |
|
| 3523 | + if ($this->nbphoto > 0) $label .= '<br>' . $tmpphoto; |
|
| 3524 | + } |
|
| 3525 | 3525 | |
| 3526 | 3526 | $linkclose=''; |
| 3527 | 3527 | if (empty($notooltip)) |
| 3528 | 3528 | { |
| 3529 | - if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) |
|
| 3530 | - { |
|
| 3531 | - $label=$langs->trans("ShowOrder"); |
|
| 3532 | - $linkclose.=' alt="'.dol_escape_htmltag($label, 1).'"'; |
|
| 3533 | - } |
|
| 3529 | + if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) |
|
| 3530 | + { |
|
| 3531 | + $label=$langs->trans("ShowOrder"); |
|
| 3532 | + $linkclose.=' alt="'.dol_escape_htmltag($label, 1).'"'; |
|
| 3533 | + } |
|
| 3534 | 3534 | |
| 3535 | - $linkclose.= ' title="'.dol_escape_htmltag($label, 1, 1).'"'; |
|
| 3536 | - $linkclose.= ' class="classfortooltip"'; |
|
| 3535 | + $linkclose.= ' title="'.dol_escape_htmltag($label, 1, 1).'"'; |
|
| 3536 | + $linkclose.= ' class="classfortooltip"'; |
|
| 3537 | 3537 | |
| 3538 | - /*if (! is_object($hookmanager)) |
|
| 3538 | + /*if (! is_object($hookmanager)) |
|
| 3539 | 3539 | { |
| 3540 | 3540 | include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; |
| 3541 | 3541 | $hookmanager=new HookManager($this->db); |
@@ -3547,29 +3547,29 @@ discard block |
||
| 3547 | 3547 | */ |
| 3548 | 3548 | } |
| 3549 | 3549 | |
| 3550 | - if ($option == 'supplier' || $option == 'category') { |
|
| 3551 | - $url = DOL_URL_ROOT.'/product/fournisseurs.php?id='.$this->id; |
|
| 3552 | - } else if ($option == 'stock') { |
|
| 3553 | - $url = DOL_URL_ROOT.'/product/stock/product.php?id='.$this->id; |
|
| 3554 | - } else if ($option == 'composition') { |
|
| 3555 | - $url = DOL_URL_ROOT.'/product/composition/card.php?id='.$this->id; |
|
| 3556 | - } else { |
|
| 3557 | - $url = DOL_URL_ROOT.'/product/card.php?id='.$this->id; |
|
| 3558 | - } |
|
| 3559 | - |
|
| 3560 | - if ($option !== 'nolink') |
|
| 3561 | - { |
|
| 3562 | - // Add param to save lastsearch_values or not |
|
| 3563 | - $add_save_lastsearch_values=($save_lastsearch_value == 1 ? 1 : 0); |
|
| 3564 | - if ($save_lastsearch_value == -1 && preg_match('/list\.php/',$_SERVER["PHP_SELF"])) $add_save_lastsearch_values=1; |
|
| 3565 | - if ($add_save_lastsearch_values) $url.='&save_lastsearch_values=1'; |
|
| 3566 | - } |
|
| 3567 | - |
|
| 3568 | - $linkstart = '<a href="'.$url.'"'; |
|
| 3569 | - $linkstart.=$linkclose.'>'; |
|
| 3570 | - $linkend='</a>'; |
|
| 3571 | - |
|
| 3572 | - $result.=$linkstart; |
|
| 3550 | + if ($option == 'supplier' || $option == 'category') { |
|
| 3551 | + $url = DOL_URL_ROOT.'/product/fournisseurs.php?id='.$this->id; |
|
| 3552 | + } else if ($option == 'stock') { |
|
| 3553 | + $url = DOL_URL_ROOT.'/product/stock/product.php?id='.$this->id; |
|
| 3554 | + } else if ($option == 'composition') { |
|
| 3555 | + $url = DOL_URL_ROOT.'/product/composition/card.php?id='.$this->id; |
|
| 3556 | + } else { |
|
| 3557 | + $url = DOL_URL_ROOT.'/product/card.php?id='.$this->id; |
|
| 3558 | + } |
|
| 3559 | + |
|
| 3560 | + if ($option !== 'nolink') |
|
| 3561 | + { |
|
| 3562 | + // Add param to save lastsearch_values or not |
|
| 3563 | + $add_save_lastsearch_values=($save_lastsearch_value == 1 ? 1 : 0); |
|
| 3564 | + if ($save_lastsearch_value == -1 && preg_match('/list\.php/',$_SERVER["PHP_SELF"])) $add_save_lastsearch_values=1; |
|
| 3565 | + if ($add_save_lastsearch_values) $url.='&save_lastsearch_values=1'; |
|
| 3566 | + } |
|
| 3567 | + |
|
| 3568 | + $linkstart = '<a href="'.$url.'"'; |
|
| 3569 | + $linkstart.=$linkclose.'>'; |
|
| 3570 | + $linkend='</a>'; |
|
| 3571 | + |
|
| 3572 | + $result.=$linkstart; |
|
| 3573 | 3573 | if ($withpicto) { |
| 3574 | 3574 | if ($this->type == Product::TYPE_PRODUCT) $result.=(img_object(($notooltip?'':$label), 'product', ($notooltip?'class="paddingright"':'class="paddingright classfortooltip"'), 0, 0, $notooltip?0:1)); |
| 3575 | 3575 | if ($this->type == Product::TYPE_SERVICE) $result.=(img_object(($notooltip?'':$label), 'service', ($notooltip?'class="paddinright"':'class="paddingright classfortooltip"'), 0, 0, $notooltip?0:1)); |
@@ -3780,8 +3780,8 @@ discard block |
||
| 3780 | 3780 | } |
| 3781 | 3781 | else |
| 3782 | 3782 | { |
| 3783 | - $this->error=$movementstock->error; |
|
| 3784 | - $this->errors=$movementstock->errors; |
|
| 3783 | + $this->error=$movementstock->error; |
|
| 3784 | + $this->errors=$movementstock->errors; |
|
| 3785 | 3785 | |
| 3786 | 3786 | $this->db->rollback(); |
| 3787 | 3787 | return -1; |
@@ -3828,8 +3828,8 @@ discard block |
||
| 3828 | 3828 | } |
| 3829 | 3829 | else |
| 3830 | 3830 | { |
| 3831 | - $this->error=$movementstock->error; |
|
| 3832 | - $this->errors=$movementstock->errors; |
|
| 3831 | + $this->error=$movementstock->error; |
|
| 3832 | + $this->errors=$movementstock->errors; |
|
| 3833 | 3833 | |
| 3834 | 3834 | $this->db->rollback(); |
| 3835 | 3835 | return -1; |
@@ -3905,7 +3905,7 @@ discard block |
||
| 3905 | 3905 | |
| 3906 | 3906 | if (! preg_match('/novirtual/', $option)) |
| 3907 | 3907 | { |
| 3908 | - $this->load_virtual_stock(); // This also load stats_commande_fournisseur, ... |
|
| 3908 | + $this->load_virtual_stock(); // This also load stats_commande_fournisseur, ... |
|
| 3909 | 3909 | } |
| 3910 | 3910 | |
| 3911 | 3911 | return 1; |
@@ -3924,59 +3924,59 @@ discard block |
||
| 3924 | 3924 | * @return int < 0 if KO, > 0 if OK |
| 3925 | 3925 | * @see load_stock, getBatchInfo |
| 3926 | 3926 | */ |
| 3927 | - function load_virtual_stock() |
|
| 3928 | - { |
|
| 3929 | - global $conf; |
|
| 3930 | - |
|
| 3931 | - $stock_commande_client=0; |
|
| 3932 | - $stock_commande_fournisseur=0; |
|
| 3933 | - $stock_sending_client=0; |
|
| 3934 | - $stock_reception_fournisseur=0; |
|
| 3935 | - |
|
| 3936 | - if (! empty($conf->commande->enabled)) |
|
| 3937 | - { |
|
| 3938 | - $result=$this->load_stats_commande(0,'1,2', 1); |
|
| 3939 | - if ($result < 0) dol_print_error($this->db,$this->error); |
|
| 3940 | - $stock_commande_client=$this->stats_commande['qty']; |
|
| 3941 | - } |
|
| 3942 | - if (! empty($conf->expedition->enabled)) |
|
| 3943 | - { |
|
| 3944 | - $result=$this->load_stats_sending(0,'1,2', 1); |
|
| 3945 | - if ($result < 0) dol_print_error($this->db,$this->error); |
|
| 3946 | - $stock_sending_client=$this->stats_expedition['qty']; |
|
| 3947 | - } |
|
| 3948 | - if (! empty($conf->fournisseur->enabled)) |
|
| 3949 | - { |
|
| 3950 | - $result=$this->load_stats_commande_fournisseur(0,'1,2,3,4', 1); |
|
| 3951 | - if ($result < 0) dol_print_error($this->db,$this->error); |
|
| 3952 | - $stock_commande_fournisseur=$this->stats_commande_fournisseur['qty']; |
|
| 3953 | - |
|
| 3954 | - $result=$this->load_stats_reception(0,'4', 1); |
|
| 3955 | - if ($result < 0) dol_print_error($this->db,$this->error); |
|
| 3956 | - $stock_reception_fournisseur=$this->stats_reception['qty']; |
|
| 3957 | - } |
|
| 3958 | - |
|
| 3959 | - // Stock decrease mode |
|
| 3960 | - if (! empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT) || ! empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT_CLOSE)) { |
|
| 3961 | - $this->stock_theorique=$this->stock_reel-$stock_commande_client+$stock_sending_client; |
|
| 3962 | - } |
|
| 3963 | - if (! empty($conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER)) { |
|
| 3964 | - $this->stock_theorique=$this->stock_reel; |
|
| 3965 | - } |
|
| 3966 | - if (! empty($conf->global->STOCK_CALCULATE_ON_BILL)) { |
|
| 3967 | - $this->stock_theorique=$this->stock_reel-$stock_commande_client; |
|
| 3968 | - } |
|
| 3969 | - // Stock Increase mode |
|
| 3970 | - if (! empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER)) { |
|
| 3971 | - $this->stock_theorique+=$stock_commande_fournisseur-$stock_reception_fournisseur; |
|
| 3972 | - } |
|
| 3973 | - if (! empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER)) { |
|
| 3974 | - $this->stock_theorique-=$stock_reception_fournisseur; |
|
| 3975 | - } |
|
| 3976 | - if (! empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_BILL)) { |
|
| 3977 | - $this->stock_theorique+=$stock_commande_fournisseur-$stock_reception_fournisseur; |
|
| 3978 | - } |
|
| 3979 | - } |
|
| 3927 | + function load_virtual_stock() |
|
| 3928 | + { |
|
| 3929 | + global $conf; |
|
| 3930 | + |
|
| 3931 | + $stock_commande_client=0; |
|
| 3932 | + $stock_commande_fournisseur=0; |
|
| 3933 | + $stock_sending_client=0; |
|
| 3934 | + $stock_reception_fournisseur=0; |
|
| 3935 | + |
|
| 3936 | + if (! empty($conf->commande->enabled)) |
|
| 3937 | + { |
|
| 3938 | + $result=$this->load_stats_commande(0,'1,2', 1); |
|
| 3939 | + if ($result < 0) dol_print_error($this->db,$this->error); |
|
| 3940 | + $stock_commande_client=$this->stats_commande['qty']; |
|
| 3941 | + } |
|
| 3942 | + if (! empty($conf->expedition->enabled)) |
|
| 3943 | + { |
|
| 3944 | + $result=$this->load_stats_sending(0,'1,2', 1); |
|
| 3945 | + if ($result < 0) dol_print_error($this->db,$this->error); |
|
| 3946 | + $stock_sending_client=$this->stats_expedition['qty']; |
|
| 3947 | + } |
|
| 3948 | + if (! empty($conf->fournisseur->enabled)) |
|
| 3949 | + { |
|
| 3950 | + $result=$this->load_stats_commande_fournisseur(0,'1,2,3,4', 1); |
|
| 3951 | + if ($result < 0) dol_print_error($this->db,$this->error); |
|
| 3952 | + $stock_commande_fournisseur=$this->stats_commande_fournisseur['qty']; |
|
| 3953 | + |
|
| 3954 | + $result=$this->load_stats_reception(0,'4', 1); |
|
| 3955 | + if ($result < 0) dol_print_error($this->db,$this->error); |
|
| 3956 | + $stock_reception_fournisseur=$this->stats_reception['qty']; |
|
| 3957 | + } |
|
| 3958 | + |
|
| 3959 | + // Stock decrease mode |
|
| 3960 | + if (! empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT) || ! empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT_CLOSE)) { |
|
| 3961 | + $this->stock_theorique=$this->stock_reel-$stock_commande_client+$stock_sending_client; |
|
| 3962 | + } |
|
| 3963 | + if (! empty($conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER)) { |
|
| 3964 | + $this->stock_theorique=$this->stock_reel; |
|
| 3965 | + } |
|
| 3966 | + if (! empty($conf->global->STOCK_CALCULATE_ON_BILL)) { |
|
| 3967 | + $this->stock_theorique=$this->stock_reel-$stock_commande_client; |
|
| 3968 | + } |
|
| 3969 | + // Stock Increase mode |
|
| 3970 | + if (! empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER)) { |
|
| 3971 | + $this->stock_theorique+=$stock_commande_fournisseur-$stock_reception_fournisseur; |
|
| 3972 | + } |
|
| 3973 | + if (! empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER)) { |
|
| 3974 | + $this->stock_theorique-=$stock_reception_fournisseur; |
|
| 3975 | + } |
|
| 3976 | + if (! empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_BILL)) { |
|
| 3977 | + $this->stock_theorique+=$stock_commande_fournisseur-$stock_reception_fournisseur; |
|
| 3978 | + } |
|
| 3979 | + } |
|
| 3980 | 3980 | |
| 3981 | 3981 | |
| 3982 | 3982 | /** |
@@ -3986,34 +3986,34 @@ discard block |
||
| 3986 | 3986 | * @return array Array with record into product_batch |
| 3987 | 3987 | * @see load_stock, load_virtual_stock |
| 3988 | 3988 | */ |
| 3989 | - function loadBatchInfo($batch) |
|
| 3990 | - { |
|
| 3991 | - $result=array(); |
|
| 3992 | - |
|
| 3993 | - $sql = "SELECT pb.batch, pb.eatby, pb.sellby, SUM(pb.qty) FROM ".MAIN_DB_PREFIX."product_batch as pb, ".MAIN_DB_PREFIX."product_stock as ps"; |
|
| 3994 | - $sql.= " WHERE pb.fk_product_stock = ps.rowid AND ps.fk_product = ".$this->id." AND pb.batch = '".$this->db->escape($batch)."'"; |
|
| 3995 | - $sql.= " GROUP BY pb.batch, pb.eatby, pb.sellby"; |
|
| 3996 | - dol_syslog(get_class($this)."::loadBatchInfo load first entry found for lot/serial = ".$batch, LOG_DEBUG); |
|
| 3997 | - $resql = $this->db->query($sql); |
|
| 3998 | - if ($resql) |
|
| 3999 | - { |
|
| 4000 | - $num = $this->db->num_rows($resql); |
|
| 4001 | - $i=0; |
|
| 4002 | - while ($i < $num) |
|
| 4003 | - { |
|
| 4004 | - $obj = $this->db->fetch_object($resql); |
|
| 3989 | + function loadBatchInfo($batch) |
|
| 3990 | + { |
|
| 3991 | + $result=array(); |
|
| 3992 | + |
|
| 3993 | + $sql = "SELECT pb.batch, pb.eatby, pb.sellby, SUM(pb.qty) FROM ".MAIN_DB_PREFIX."product_batch as pb, ".MAIN_DB_PREFIX."product_stock as ps"; |
|
| 3994 | + $sql.= " WHERE pb.fk_product_stock = ps.rowid AND ps.fk_product = ".$this->id." AND pb.batch = '".$this->db->escape($batch)."'"; |
|
| 3995 | + $sql.= " GROUP BY pb.batch, pb.eatby, pb.sellby"; |
|
| 3996 | + dol_syslog(get_class($this)."::loadBatchInfo load first entry found for lot/serial = ".$batch, LOG_DEBUG); |
|
| 3997 | + $resql = $this->db->query($sql); |
|
| 3998 | + if ($resql) |
|
| 3999 | + { |
|
| 4000 | + $num = $this->db->num_rows($resql); |
|
| 4001 | + $i=0; |
|
| 4002 | + while ($i < $num) |
|
| 4003 | + { |
|
| 4004 | + $obj = $this->db->fetch_object($resql); |
|
| 4005 | 4005 | $result[]=array('batch'=>$batch, 'eatby'=>$this->db->jdate($obj->eatby), 'sellby'=>$this->db->jdate($obj->sellby), 'qty'=>$obj->qty); |
| 4006 | 4006 | $i++; |
| 4007 | - } |
|
| 4008 | - return $result; |
|
| 4009 | - } |
|
| 4010 | - else |
|
| 4011 | - { |
|
| 4012 | - dol_print_error($this->db); |
|
| 4013 | - $this->db->rollback(); |
|
| 4014 | - return array(); |
|
| 4015 | - } |
|
| 4016 | - } |
|
| 4007 | + } |
|
| 4008 | + return $result; |
|
| 4009 | + } |
|
| 4010 | + else |
|
| 4011 | + { |
|
| 4012 | + dol_print_error($this->db); |
|
| 4013 | + $this->db->rollback(); |
|
| 4014 | + return array(); |
|
| 4015 | + } |
|
| 4016 | + } |
|
| 4017 | 4017 | |
| 4018 | 4018 | |
| 4019 | 4019 | /** |
@@ -4065,8 +4065,8 @@ discard block |
||
| 4065 | 4065 | */ |
| 4066 | 4066 | function is_photo_available($sdir) |
| 4067 | 4067 | { |
| 4068 | - include_once DOL_DOCUMENT_ROOT .'/core/lib/files.lib.php'; |
|
| 4069 | - include_once DOL_DOCUMENT_ROOT .'/core/lib/images.lib.php'; |
|
| 4068 | + include_once DOL_DOCUMENT_ROOT .'/core/lib/files.lib.php'; |
|
| 4069 | + include_once DOL_DOCUMENT_ROOT .'/core/lib/images.lib.php'; |
|
| 4070 | 4070 | |
| 4071 | 4071 | global $conf; |
| 4072 | 4072 | |
@@ -4082,11 +4082,11 @@ discard block |
||
| 4082 | 4082 | $handle=opendir($dir_osencoded); |
| 4083 | 4083 | if (is_resource($handle)) |
| 4084 | 4084 | { |
| 4085 | - while (($file = readdir($handle)) !== false) |
|
| 4086 | - { |
|
| 4087 | - if (! utf8_check($file)) $file=utf8_encode($file); // To be sure data is stored in UTF8 in memory |
|
| 4088 | - if (dol_is_file($dir.$file) && image_format_supported($file) > 0) return true; |
|
| 4089 | - } |
|
| 4085 | + while (($file = readdir($handle)) !== false) |
|
| 4086 | + { |
|
| 4087 | + if (! utf8_check($file)) $file=utf8_encode($file); // To be sure data is stored in UTF8 in memory |
|
| 4088 | + if (dol_is_file($dir.$file) && image_format_supported($file) > 0) return true; |
|
| 4089 | + } |
|
| 4090 | 4090 | } |
| 4091 | 4091 | } |
| 4092 | 4092 | return false; |
@@ -4102,8 +4102,8 @@ discard block |
||
| 4102 | 4102 | */ |
| 4103 | 4103 | function liste_photos($dir,$nbmax=0) |
| 4104 | 4104 | { |
| 4105 | - include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; |
|
| 4106 | - include_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php'; |
|
| 4105 | + include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; |
|
| 4106 | + include_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php'; |
|
| 4107 | 4107 | |
| 4108 | 4108 | $nbphoto=0; |
| 4109 | 4109 | $tabobj=array(); |
@@ -4156,10 +4156,10 @@ discard block |
||
| 4156 | 4156 | */ |
| 4157 | 4157 | function delete_photo($file) |
| 4158 | 4158 | { |
| 4159 | - require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; |
|
| 4160 | - require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php'; |
|
| 4159 | + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; |
|
| 4160 | + require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php'; |
|
| 4161 | 4161 | |
| 4162 | - $dir = dirname($file).'/'; // Chemin du dossier contenant l'image d'origine |
|
| 4162 | + $dir = dirname($file).'/'; // Chemin du dossier contenant l'image d'origine |
|
| 4163 | 4163 | $dirthumb = $dir.'/thumbs/'; // Chemin du dossier contenant la vignette |
| 4164 | 4164 | $filename = preg_replace('/'.preg_quote($dir,'/').'/i','',$file); // Nom du fichier |
| 4165 | 4165 | |
@@ -4214,11 +4214,11 @@ discard block |
||
| 4214 | 4214 | // Add where from hooks |
| 4215 | 4215 | if (is_object($hookmanager)) |
| 4216 | 4216 | { |
| 4217 | - $parameters=array(); |
|
| 4218 | - $reshook=$hookmanager->executeHooks('printFieldListWhere',$parameters); // Note that $action and $object may have been modified by hook |
|
| 4219 | - $sql.=$hookmanager->resPrint; |
|
| 4217 | + $parameters=array(); |
|
| 4218 | + $reshook=$hookmanager->executeHooks('printFieldListWhere',$parameters); // Note that $action and $object may have been modified by hook |
|
| 4219 | + $sql.=$hookmanager->resPrint; |
|
| 4220 | 4220 | } |
| 4221 | - $sql.= ' GROUP BY fk_product_type'; |
|
| 4221 | + $sql.= ' GROUP BY fk_product_type'; |
|
| 4222 | 4222 | |
| 4223 | 4223 | $resql=$this->db->query($sql); |
| 4224 | 4224 | if ($resql) |
@@ -4228,7 +4228,7 @@ discard block |
||
| 4228 | 4228 | if ($obj->fk_product_type == 1) $this->nb["services"]=$obj->nb; |
| 4229 | 4229 | else $this->nb["products"]=$obj->nb; |
| 4230 | 4230 | } |
| 4231 | - $this->db->free($resql); |
|
| 4231 | + $this->db->free($resql); |
|
| 4232 | 4232 | return 1; |
| 4233 | 4233 | } |
| 4234 | 4234 | else |
@@ -4239,102 +4239,102 @@ discard block |
||
| 4239 | 4239 | } |
| 4240 | 4240 | } |
| 4241 | 4241 | |
| 4242 | - /** |
|
| 4243 | - * Return if object is a product |
|
| 4244 | - * |
|
| 4245 | - * @return boolean True if it's a product |
|
| 4246 | - */ |
|
| 4242 | + /** |
|
| 4243 | + * Return if object is a product |
|
| 4244 | + * |
|
| 4245 | + * @return boolean True if it's a product |
|
| 4246 | + */ |
|
| 4247 | 4247 | function isProduct() |
| 4248 | 4248 | { |
| 4249 | 4249 | return ($this->type == Product::TYPE_PRODUCT ? true : false); |
| 4250 | 4250 | } |
| 4251 | 4251 | |
| 4252 | - /** |
|
| 4253 | - * Return if object is a product |
|
| 4254 | - * |
|
| 4255 | - * @return boolean True if it's a service |
|
| 4256 | - */ |
|
| 4252 | + /** |
|
| 4253 | + * Return if object is a product |
|
| 4254 | + * |
|
| 4255 | + * @return boolean True if it's a service |
|
| 4256 | + */ |
|
| 4257 | 4257 | function isService() |
| 4258 | 4258 | { |
| 4259 | 4259 | return ($this->type == Product::TYPE_SERVICE ? true : false); |
| 4260 | 4260 | } |
| 4261 | 4261 | |
| 4262 | - /** |
|
| 4263 | - * Get a barcode from the module to generate barcode values. |
|
| 4264 | - * Return value is stored into this->barcode |
|
| 4265 | - * |
|
| 4266 | - * @param Product $object Object product or service |
|
| 4267 | - * @param string $type Barcode type (ean, isbn, ...) |
|
| 4268 | - * @return void |
|
| 4269 | - */ |
|
| 4270 | - function get_barcode($object,$type='') |
|
| 4271 | - { |
|
| 4272 | - global $conf; |
|
| 4273 | - |
|
| 4274 | - $result=''; |
|
| 4275 | - if (! empty($conf->global->BARCODE_PRODUCT_ADDON_NUM)) |
|
| 4276 | - { |
|
| 4277 | - $dirsociete=array_merge(array('/core/modules/barcode/'),$conf->modules_parts['barcode']); |
|
| 4278 | - foreach ($dirsociete as $dirroot) |
|
| 4279 | - { |
|
| 4280 | - $res=dol_include_once($dirroot.$conf->global->BARCODE_PRODUCT_ADDON_NUM.'.php'); |
|
| 4281 | - if ($res) break; |
|
| 4282 | - } |
|
| 4283 | - $var = $conf->global->BARCODE_PRODUCT_ADDON_NUM; |
|
| 4284 | - $mod = new $var; |
|
| 4285 | - |
|
| 4286 | - $result=$mod->getNextValue($object,$type); |
|
| 4287 | - |
|
| 4288 | - dol_syslog(get_class($this)."::get_barcode barcode=".$result." module=".$var); |
|
| 4289 | - } |
|
| 4290 | - return $result; |
|
| 4291 | - } |
|
| 4292 | - |
|
| 4293 | - /** |
|
| 4294 | - * Initialise an instance with random values. |
|
| 4295 | - * Used to build previews or test instances. |
|
| 4296 | - * id must be 0 if object instance is a specimen. |
|
| 4297 | - * |
|
| 4298 | - * @return void |
|
| 4299 | - */ |
|
| 4300 | - function initAsSpecimen() |
|
| 4301 | - { |
|
| 4302 | - global $user,$langs,$conf,$mysoc; |
|
| 4303 | - |
|
| 4304 | - $now=dol_now(); |
|
| 4305 | - |
|
| 4306 | - // Initialize parameters |
|
| 4307 | - $this->specimen=1; |
|
| 4308 | - $this->id=0; |
|
| 4309 | - $this->ref = 'PRODUCT_SPEC'; |
|
| 4310 | - $this->label = 'PRODUCT SPECIMEN'; |
|
| 4311 | - $this->description = 'This is description of this product specimen that was created the '.dol_print_date($now,'dayhourlog').'.'; |
|
| 4312 | - $this->specimen=1; |
|
| 4313 | - $this->country_id=1; |
|
| 4314 | - $this->tosell=1; |
|
| 4315 | - $this->tobuy=1; |
|
| 4316 | - $this->tobatch=0; |
|
| 4317 | - $this->note='This is a comment (private)'; |
|
| 4318 | - $this->date_creation = $now; |
|
| 4319 | - $this->date_modification = $now; |
|
| 4262 | + /** |
|
| 4263 | + * Get a barcode from the module to generate barcode values. |
|
| 4264 | + * Return value is stored into this->barcode |
|
| 4265 | + * |
|
| 4266 | + * @param Product $object Object product or service |
|
| 4267 | + * @param string $type Barcode type (ean, isbn, ...) |
|
| 4268 | + * @return void |
|
| 4269 | + */ |
|
| 4270 | + function get_barcode($object,$type='') |
|
| 4271 | + { |
|
| 4272 | + global $conf; |
|
| 4273 | + |
|
| 4274 | + $result=''; |
|
| 4275 | + if (! empty($conf->global->BARCODE_PRODUCT_ADDON_NUM)) |
|
| 4276 | + { |
|
| 4277 | + $dirsociete=array_merge(array('/core/modules/barcode/'),$conf->modules_parts['barcode']); |
|
| 4278 | + foreach ($dirsociete as $dirroot) |
|
| 4279 | + { |
|
| 4280 | + $res=dol_include_once($dirroot.$conf->global->BARCODE_PRODUCT_ADDON_NUM.'.php'); |
|
| 4281 | + if ($res) break; |
|
| 4282 | + } |
|
| 4283 | + $var = $conf->global->BARCODE_PRODUCT_ADDON_NUM; |
|
| 4284 | + $mod = new $var; |
|
| 4320 | 4285 | |
| 4321 | - $this->weight = 4; |
|
| 4322 | - $this->weight_unit = 1; |
|
| 4286 | + $result=$mod->getNextValue($object,$type); |
|
| 4287 | + |
|
| 4288 | + dol_syslog(get_class($this)."::get_barcode barcode=".$result." module=".$var); |
|
| 4289 | + } |
|
| 4290 | + return $result; |
|
| 4291 | + } |
|
| 4323 | 4292 | |
| 4324 | - $this->length = 5; |
|
| 4325 | - $this->length_unit = 1; |
|
| 4326 | - $this->width = 6; |
|
| 4327 | - $this->width_unit = 0; |
|
| 4328 | - $this->height = null; |
|
| 4329 | - $this->height_unit = null; |
|
| 4293 | + /** |
|
| 4294 | + * Initialise an instance with random values. |
|
| 4295 | + * Used to build previews or test instances. |
|
| 4296 | + * id must be 0 if object instance is a specimen. |
|
| 4297 | + * |
|
| 4298 | + * @return void |
|
| 4299 | + */ |
|
| 4300 | + function initAsSpecimen() |
|
| 4301 | + { |
|
| 4302 | + global $user,$langs,$conf,$mysoc; |
|
| 4330 | 4303 | |
| 4331 | - $this->surface = 30; |
|
| 4332 | - $this->surface_unit = 0; |
|
| 4333 | - $this->volume = 300; |
|
| 4334 | - $this->volume_unit = 0; |
|
| 4304 | + $now=dol_now(); |
|
| 4335 | 4305 | |
| 4336 | - $this->barcode=-1; // Create barcode automatically |
|
| 4337 | - } |
|
| 4306 | + // Initialize parameters |
|
| 4307 | + $this->specimen=1; |
|
| 4308 | + $this->id=0; |
|
| 4309 | + $this->ref = 'PRODUCT_SPEC'; |
|
| 4310 | + $this->label = 'PRODUCT SPECIMEN'; |
|
| 4311 | + $this->description = 'This is description of this product specimen that was created the '.dol_print_date($now,'dayhourlog').'.'; |
|
| 4312 | + $this->specimen=1; |
|
| 4313 | + $this->country_id=1; |
|
| 4314 | + $this->tosell=1; |
|
| 4315 | + $this->tobuy=1; |
|
| 4316 | + $this->tobatch=0; |
|
| 4317 | + $this->note='This is a comment (private)'; |
|
| 4318 | + $this->date_creation = $now; |
|
| 4319 | + $this->date_modification = $now; |
|
| 4320 | + |
|
| 4321 | + $this->weight = 4; |
|
| 4322 | + $this->weight_unit = 1; |
|
| 4323 | + |
|
| 4324 | + $this->length = 5; |
|
| 4325 | + $this->length_unit = 1; |
|
| 4326 | + $this->width = 6; |
|
| 4327 | + $this->width_unit = 0; |
|
| 4328 | + $this->height = null; |
|
| 4329 | + $this->height_unit = null; |
|
| 4330 | + |
|
| 4331 | + $this->surface = 30; |
|
| 4332 | + $this->surface_unit = 0; |
|
| 4333 | + $this->volume = 300; |
|
| 4334 | + $this->volume_unit = 0; |
|
| 4335 | + |
|
| 4336 | + $this->barcode=-1; // Create barcode automatically |
|
| 4337 | + } |
|
| 4338 | 4338 | |
| 4339 | 4339 | /** |
| 4340 | 4340 | * Returns the text label from units dictionary |
@@ -4378,11 +4378,11 @@ discard block |
||
| 4378 | 4378 | } |
| 4379 | 4379 | } |
| 4380 | 4380 | |
| 4381 | - /** |
|
| 4382 | - * Return if object has a sell-by date or eat-by date |
|
| 4383 | - * |
|
| 4384 | - * @return boolean True if it's has |
|
| 4385 | - */ |
|
| 4381 | + /** |
|
| 4382 | + * Return if object has a sell-by date or eat-by date |
|
| 4383 | + * |
|
| 4384 | + * @return boolean True if it's has |
|
| 4385 | + */ |
|
| 4386 | 4386 | function hasbatch() |
| 4387 | 4387 | { |
| 4388 | 4388 | return ($this->status_batch == 1 ? true : false); |
@@ -4390,10 +4390,10 @@ discard block |
||
| 4390 | 4390 | |
| 4391 | 4391 | |
| 4392 | 4392 | /** |
| 4393 | - * Return minimum product recommended price |
|
| 4394 | - * |
|
| 4393 | + * Return minimum product recommended price |
|
| 4394 | + * |
|
| 4395 | 4395 | * @return int Minimum recommanded price that is higher price among all suppliers * PRODUCT_MINIMUM_RECOMMENDED_PRICE |
| 4396 | - */ |
|
| 4396 | + */ |
|
| 4397 | 4397 | function min_recommended_price() |
| 4398 | 4398 | { |
| 4399 | 4399 | global $conf; |
@@ -4564,52 +4564,52 @@ discard block |
||
| 4564 | 4564 | } |
| 4565 | 4565 | } |
| 4566 | 4566 | |
| 4567 | - /** |
|
| 4568 | - * Load information for tab info |
|
| 4569 | - * |
|
| 4570 | - * @param int $id Id of thirdparty to load |
|
| 4571 | - * @return void |
|
| 4572 | - */ |
|
| 4573 | - function info($id) |
|
| 4574 | - { |
|
| 4575 | - $sql = "SELECT p.rowid, p.ref, p.datec as date_creation, p.tms as date_modification,"; |
|
| 4576 | - $sql.= " p.fk_user_author, p.fk_user_modif"; |
|
| 4577 | - $sql.= " FROM ".MAIN_DB_PREFIX.$this->table_element." as p"; |
|
| 4578 | - $sql.= " WHERE p.rowid = ".$id; |
|
| 4579 | - |
|
| 4580 | - $result=$this->db->query($sql); |
|
| 4581 | - if ($result) |
|
| 4582 | - { |
|
| 4583 | - if ($this->db->num_rows($result)) |
|
| 4584 | - { |
|
| 4585 | - $obj = $this->db->fetch_object($result); |
|
| 4586 | - |
|
| 4587 | - $this->id = $obj->rowid; |
|
| 4588 | - |
|
| 4589 | - if ($obj->fk_user_author) { |
|
| 4590 | - $cuser = new User($this->db); |
|
| 4591 | - $cuser->fetch($obj->fk_user_author); |
|
| 4592 | - $this->user_creation = $cuser; |
|
| 4593 | - } |
|
| 4594 | - |
|
| 4595 | - if ($obj->fk_user_modif) { |
|
| 4596 | - $muser = new User($this->db); |
|
| 4597 | - $muser->fetch($obj->fk_user_modif); |
|
| 4598 | - $this->user_modification = $muser; |
|
| 4599 | - } |
|
| 4600 | - |
|
| 4601 | - $this->ref = $obj->ref; |
|
| 4602 | - $this->date_creation = $this->db->jdate($obj->date_creation); |
|
| 4603 | - $this->date_modification = $this->db->jdate($obj->date_modification); |
|
| 4604 | - } |
|
| 4605 | - |
|
| 4606 | - $this->db->free($result); |
|
| 4607 | - |
|
| 4608 | - } |
|
| 4609 | - else |
|
| 4610 | - { |
|
| 4611 | - dol_print_error($this->db); |
|
| 4612 | - } |
|
| 4613 | - } |
|
| 4567 | + /** |
|
| 4568 | + * Load information for tab info |
|
| 4569 | + * |
|
| 4570 | + * @param int $id Id of thirdparty to load |
|
| 4571 | + * @return void |
|
| 4572 | + */ |
|
| 4573 | + function info($id) |
|
| 4574 | + { |
|
| 4575 | + $sql = "SELECT p.rowid, p.ref, p.datec as date_creation, p.tms as date_modification,"; |
|
| 4576 | + $sql.= " p.fk_user_author, p.fk_user_modif"; |
|
| 4577 | + $sql.= " FROM ".MAIN_DB_PREFIX.$this->table_element." as p"; |
|
| 4578 | + $sql.= " WHERE p.rowid = ".$id; |
|
| 4579 | + |
|
| 4580 | + $result=$this->db->query($sql); |
|
| 4581 | + if ($result) |
|
| 4582 | + { |
|
| 4583 | + if ($this->db->num_rows($result)) |
|
| 4584 | + { |
|
| 4585 | + $obj = $this->db->fetch_object($result); |
|
| 4586 | + |
|
| 4587 | + $this->id = $obj->rowid; |
|
| 4588 | + |
|
| 4589 | + if ($obj->fk_user_author) { |
|
| 4590 | + $cuser = new User($this->db); |
|
| 4591 | + $cuser->fetch($obj->fk_user_author); |
|
| 4592 | + $this->user_creation = $cuser; |
|
| 4593 | + } |
|
| 4594 | + |
|
| 4595 | + if ($obj->fk_user_modif) { |
|
| 4596 | + $muser = new User($this->db); |
|
| 4597 | + $muser->fetch($obj->fk_user_modif); |
|
| 4598 | + $this->user_modification = $muser; |
|
| 4599 | + } |
|
| 4600 | + |
|
| 4601 | + $this->ref = $obj->ref; |
|
| 4602 | + $this->date_creation = $this->db->jdate($obj->date_creation); |
|
| 4603 | + $this->date_modification = $this->db->jdate($obj->date_modification); |
|
| 4604 | + } |
|
| 4605 | + |
|
| 4606 | + $this->db->free($result); |
|
| 4607 | + |
|
| 4608 | + } |
|
| 4609 | + else |
|
| 4610 | + { |
|
| 4611 | + dol_print_error($this->db); |
|
| 4612 | + } |
|
| 4613 | + } |
|
| 4614 | 4614 | |
| 4615 | 4615 | } |
@@ -43,18 +43,18 @@ discard block |
||
| 43 | 43 | */ |
| 44 | 44 | class Product extends CommonObject |
| 45 | 45 | { |
| 46 | - public $element='product'; |
|
| 47 | - public $table_element='product'; |
|
| 48 | - public $fk_element='fk_product'; |
|
| 49 | - protected $childtables=array('supplier_proposaldet', 'propaldet','commandedet','facturedet','contratdet','facture_fourn_det','commande_fournisseurdet'); // To test if we can delete object |
|
| 50 | - public $ismultientitymanaged = 1; // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe |
|
| 46 | + public $element = 'product'; |
|
| 47 | + public $table_element = 'product'; |
|
| 48 | + public $fk_element = 'fk_product'; |
|
| 49 | + protected $childtables = array('supplier_proposaldet', 'propaldet', 'commandedet', 'facturedet', 'contratdet', 'facture_fourn_det', 'commande_fournisseurdet'); // To test if we can delete object |
|
| 50 | + public $ismultientitymanaged = 1; // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe |
|
| 51 | 51 | |
| 52 | 52 | /** |
| 53 | 53 | * {@inheritdoc} |
| 54 | 54 | */ |
| 55 | 55 | protected $table_ref_field = 'ref'; |
| 56 | 56 | |
| 57 | - public $regeximgext='\.gif|\.jpg|\.jpeg|\.png|\.bmp|\.xpm|\.xbm'; // See also into images.lib.php |
|
| 57 | + public $regeximgext = '\.gif|\.jpg|\.jpeg|\.png|\.bmp|\.xpm|\.xbm'; // See also into images.lib.php |
|
| 58 | 58 | |
| 59 | 59 | /* |
| 60 | 60 | * @deprecated |
@@ -83,7 +83,7 @@ discard block |
||
| 83 | 83 | * Selling price |
| 84 | 84 | * @var float |
| 85 | 85 | */ |
| 86 | - public $price; // Price net |
|
| 86 | + public $price; // Price net |
|
| 87 | 87 | |
| 88 | 88 | /** |
| 89 | 89 | * Price with tax |
@@ -110,19 +110,19 @@ discard block |
||
| 110 | 110 | public $price_base_type; |
| 111 | 111 | |
| 112 | 112 | //! Arrays for multiprices |
| 113 | - public $multiprices=array(); |
|
| 114 | - public $multiprices_ttc=array(); |
|
| 115 | - public $multiprices_base_type=array(); |
|
| 116 | - public $multiprices_min=array(); |
|
| 117 | - public $multiprices_min_ttc=array(); |
|
| 118 | - public $multiprices_tva_tx=array(); |
|
| 119 | - public $multiprices_recuperableonly=array(); |
|
| 113 | + public $multiprices = array(); |
|
| 114 | + public $multiprices_ttc = array(); |
|
| 115 | + public $multiprices_base_type = array(); |
|
| 116 | + public $multiprices_min = array(); |
|
| 117 | + public $multiprices_min_ttc = array(); |
|
| 118 | + public $multiprices_tva_tx = array(); |
|
| 119 | + public $multiprices_recuperableonly = array(); |
|
| 120 | 120 | |
| 121 | 121 | //! Price by quantity arrays |
| 122 | 122 | public $price_by_qty; |
| 123 | - public $prices_by_qty=array(); |
|
| 124 | - public $prices_by_qty_id=array(); |
|
| 125 | - public $prices_by_qty_list=array(); |
|
| 123 | + public $prices_by_qty = array(); |
|
| 124 | + public $prices_by_qty_id = array(); |
|
| 125 | + public $prices_by_qty_list = array(); |
|
| 126 | 126 | |
| 127 | 127 | //! Default VAT code for product (link to code into llx_c_tva but without foreign keys) |
| 128 | 128 | public $default_vat_code; |
@@ -131,7 +131,7 @@ discard block |
||
| 131 | 131 | public $tva_tx; |
| 132 | 132 | |
| 133 | 133 | //! French VAT NPR (0 or 1) |
| 134 | - public $tva_npr=0; |
|
| 134 | + public $tva_npr = 0; |
|
| 135 | 135 | |
| 136 | 136 | //! Other local taxes |
| 137 | 137 | public $localtax1_tx; |
@@ -164,12 +164,12 @@ discard block |
||
| 164 | 164 | * Stock alert |
| 165 | 165 | * @var int |
| 166 | 166 | */ |
| 167 | - public $seuil_stock_alerte=0; |
|
| 167 | + public $seuil_stock_alerte = 0; |
|
| 168 | 168 | |
| 169 | 169 | /** |
| 170 | 170 | * Ask for replenishment when $desiredstock < $stock_reel |
| 171 | 171 | */ |
| 172 | - public $desiredstock=0; |
|
| 172 | + public $desiredstock = 0; |
|
| 173 | 173 | |
| 174 | 174 | /* |
| 175 | 175 | * Service expiration |
@@ -185,13 +185,13 @@ discard block |
||
| 185 | 185 | * Status indicates whether the product is on sale '1' or not '0' |
| 186 | 186 | * @var int |
| 187 | 187 | */ |
| 188 | - public $status=0; |
|
| 188 | + public $status = 0; |
|
| 189 | 189 | |
| 190 | 190 | /** |
| 191 | 191 | * Status indicate whether the product is available for purchase '1' or not '0' |
| 192 | 192 | * @var int |
| 193 | 193 | */ |
| 194 | - public $status_buy=0; |
|
| 194 | + public $status_buy = 0; |
|
| 195 | 195 | |
| 196 | 196 | /** |
| 197 | 197 | * Status indicates whether the product is a finished product '1' or a raw material '0' |
@@ -203,7 +203,7 @@ discard block |
||
| 203 | 203 | * We must manage lot/batch number, sell-by date and so on : '1':yes '0':no |
| 204 | 204 | * @var int |
| 205 | 205 | */ |
| 206 | - public $status_batch=0; |
|
| 206 | + public $status_batch = 0; |
|
| 207 | 207 | |
| 208 | 208 | /** |
| 209 | 209 | * Customs code |
@@ -243,15 +243,15 @@ discard block |
||
| 243 | 243 | * Additional barcodes (Some products have different barcodes according to the country of origin of manufacture) |
| 244 | 244 | * @var array |
| 245 | 245 | */ |
| 246 | - public $barcodes_extra=array(); |
|
| 246 | + public $barcodes_extra = array(); |
|
| 247 | 247 | |
| 248 | - public $stats_propale=array(); |
|
| 249 | - public $stats_commande=array(); |
|
| 250 | - public $stats_contrat=array(); |
|
| 251 | - public $stats_facture=array(); |
|
| 252 | - public $stats_commande_fournisseur=array(); |
|
| 248 | + public $stats_propale = array(); |
|
| 249 | + public $stats_commande = array(); |
|
| 250 | + public $stats_contrat = array(); |
|
| 251 | + public $stats_facture = array(); |
|
| 252 | + public $stats_commande_fournisseur = array(); |
|
| 253 | 253 | |
| 254 | - public $multilangs=array(); |
|
| 254 | + public $multilangs = array(); |
|
| 255 | 255 | |
| 256 | 256 | //! Taille de l'image |
| 257 | 257 | public $imgWidth; |
@@ -266,10 +266,10 @@ discard block |
||
| 266 | 266 | //! Product ID already linked to a reference supplier |
| 267 | 267 | public $product_id_already_linked; |
| 268 | 268 | |
| 269 | - public $nbphoto=0; |
|
| 269 | + public $nbphoto = 0; |
|
| 270 | 270 | |
| 271 | 271 | //! Contains detail of stock of product into each warehouse |
| 272 | - public $stock_warehouse=array(); |
|
| 272 | + public $stock_warehouse = array(); |
|
| 273 | 273 | |
| 274 | 274 | public $oldcopy; |
| 275 | 275 | |
@@ -368,19 +368,19 @@ discard block |
||
| 368 | 368 | * @param int $notrigger Disable triggers |
| 369 | 369 | * @return int Id of product/service if OK, < 0 if KO |
| 370 | 370 | */ |
| 371 | - function create($user,$notrigger=0) |
|
| 371 | + function create($user, $notrigger = 0) |
|
| 372 | 372 | { |
| 373 | 373 | global $conf, $langs; |
| 374 | 374 | |
| 375 | - $error=0; |
|
| 375 | + $error = 0; |
|
| 376 | 376 | |
| 377 | 377 | // Clean parameters |
| 378 | 378 | $this->ref = dol_string_nospecial(trim($this->ref)); |
| 379 | 379 | $this->label = trim($this->label); |
| 380 | - $this->price_ttc=price2num($this->price_ttc); |
|
| 381 | - $this->price=price2num($this->price); |
|
| 382 | - $this->price_min_ttc=price2num($this->price_min_ttc); |
|
| 383 | - $this->price_min=price2num($this->price_min); |
|
| 380 | + $this->price_ttc = price2num($this->price_ttc); |
|
| 381 | + $this->price = price2num($this->price); |
|
| 382 | + $this->price_min_ttc = price2num($this->price_min_ttc); |
|
| 383 | + $this->price_min = price2num($this->price_min); |
|
| 384 | 384 | if (empty($this->tva_tx)) $this->tva_tx = 0; |
| 385 | 385 | if (empty($this->tva_npr)) $this->tva_npr = 0; |
| 386 | 386 | //Local taxes |
@@ -398,88 +398,88 @@ discard block |
||
| 398 | 398 | if (empty($this->status)) $this->status = 0; |
| 399 | 399 | if (empty($this->status_buy)) $this->status_buy = 0; |
| 400 | 400 | |
| 401 | - $price_ht=0; |
|
| 402 | - $price_ttc=0; |
|
| 403 | - $price_min_ht=0; |
|
| 404 | - $price_min_ttc=0; |
|
| 401 | + $price_ht = 0; |
|
| 402 | + $price_ttc = 0; |
|
| 403 | + $price_min_ht = 0; |
|
| 404 | + $price_min_ttc = 0; |
|
| 405 | 405 | |
| 406 | 406 | // |
| 407 | 407 | if ($this->price_base_type == 'TTC' && $this->price_ttc > 0) |
| 408 | 408 | { |
| 409 | - $price_ttc = price2num($this->price_ttc,'MU'); |
|
| 410 | - $price_ht = price2num($this->price_ttc / (1 + ($this->tva_tx / 100)),'MU'); |
|
| 409 | + $price_ttc = price2num($this->price_ttc, 'MU'); |
|
| 410 | + $price_ht = price2num($this->price_ttc / (1 + ($this->tva_tx / 100)), 'MU'); |
|
| 411 | 411 | } |
| 412 | 412 | |
| 413 | 413 | // |
| 414 | 414 | if ($this->price_base_type != 'TTC' && $this->price > 0) |
| 415 | 415 | { |
| 416 | - $price_ht = price2num($this->price,'MU'); |
|
| 417 | - $price_ttc = price2num($this->price * (1 + ($this->tva_tx / 100)),'MU'); |
|
| 416 | + $price_ht = price2num($this->price, 'MU'); |
|
| 417 | + $price_ttc = price2num($this->price * (1 + ($this->tva_tx / 100)), 'MU'); |
|
| 418 | 418 | } |
| 419 | 419 | |
| 420 | 420 | // |
| 421 | 421 | if (($this->price_min_ttc > 0) && ($this->price_base_type == 'TTC')) |
| 422 | 422 | { |
| 423 | - $price_min_ttc = price2num($this->price_min_ttc,'MU'); |
|
| 424 | - $price_min_ht = price2num($this->price_min_ttc / (1 + ($this->tva_tx / 100)),'MU'); |
|
| 423 | + $price_min_ttc = price2num($this->price_min_ttc, 'MU'); |
|
| 424 | + $price_min_ht = price2num($this->price_min_ttc / (1 + ($this->tva_tx / 100)), 'MU'); |
|
| 425 | 425 | } |
| 426 | 426 | |
| 427 | 427 | // |
| 428 | 428 | if (($this->price_min > 0) && ($this->price_base_type != 'TTC')) |
| 429 | 429 | { |
| 430 | - $price_min_ht = price2num($this->price_min,'MU'); |
|
| 431 | - $price_min_ttc = price2num($this->price_min * (1 + ($this->tva_tx / 100)),'MU'); |
|
| 430 | + $price_min_ht = price2num($this->price_min, 'MU'); |
|
| 431 | + $price_min_ttc = price2num($this->price_min * (1 + ($this->tva_tx / 100)), 'MU'); |
|
| 432 | 432 | } |
| 433 | 433 | |
| 434 | 434 | $this->accountancy_code_buy = trim($this->accountancy_code_buy); |
| 435 | - $this->accountancy_code_sell= trim($this->accountancy_code_sell); |
|
| 436 | - $this->accountancy_code_sell_intra= trim($this->accountancy_code_sell_intra); |
|
| 437 | - $this->accountancy_code_sell_export= trim($this->accountancy_code_sell_export); |
|
| 435 | + $this->accountancy_code_sell = trim($this->accountancy_code_sell); |
|
| 436 | + $this->accountancy_code_sell_intra = trim($this->accountancy_code_sell_intra); |
|
| 437 | + $this->accountancy_code_sell_export = trim($this->accountancy_code_sell_export); |
|
| 438 | 438 | |
| 439 | 439 | // Barcode value |
| 440 | - $this->barcode=trim($this->barcode); |
|
| 440 | + $this->barcode = trim($this->barcode); |
|
| 441 | 441 | |
| 442 | 442 | // Check parameters |
| 443 | 443 | if (empty($this->label)) |
| 444 | 444 | { |
| 445 | - $this->error='ErrorMandatoryParametersNotProvided'; |
|
| 445 | + $this->error = 'ErrorMandatoryParametersNotProvided'; |
|
| 446 | 446 | return -1; |
| 447 | 447 | } |
| 448 | 448 | |
| 449 | 449 | if (empty($this->ref)) |
| 450 | 450 | { |
| 451 | 451 | // Load object modCodeProduct |
| 452 | - $module=(! empty($conf->global->PRODUCT_CODEPRODUCT_ADDON)?$conf->global->PRODUCT_CODEPRODUCT_ADDON:'mod_codeproduct_leopard'); |
|
| 452 | + $module = (!empty($conf->global->PRODUCT_CODEPRODUCT_ADDON) ? $conf->global->PRODUCT_CODEPRODUCT_ADDON : 'mod_codeproduct_leopard'); |
|
| 453 | 453 | if ($module != 'mod_codeproduct_leopard') // Do not load module file for leopard |
| 454 | 454 | { |
| 455 | 455 | if (substr($module, 0, 16) == 'mod_codeproduct_' && substr($module, -3) == 'php') |
| 456 | 456 | { |
| 457 | - $module = substr($module, 0, dol_strlen($module)-4); |
|
| 457 | + $module = substr($module, 0, dol_strlen($module) - 4); |
|
| 458 | 458 | } |
| 459 | 459 | dol_include_once('/core/modules/product/'.$module.'.php'); |
| 460 | 460 | $modCodeProduct = new $module; |
| 461 | - if (! empty($modCodeProduct->code_auto)) |
|
| 461 | + if (!empty($modCodeProduct->code_auto)) |
|
| 462 | 462 | { |
| 463 | - $this->ref = $modCodeProduct->getNextValue($this,$this->type); |
|
| 463 | + $this->ref = $modCodeProduct->getNextValue($this, $this->type); |
|
| 464 | 464 | } |
| 465 | 465 | unset($modCodeProduct); |
| 466 | 466 | } |
| 467 | 467 | |
| 468 | 468 | if (empty($this->ref)) |
| 469 | 469 | { |
| 470 | - $this->error='ProductModuleNotSetupForAutoRef'; |
|
| 470 | + $this->error = 'ProductModuleNotSetupForAutoRef'; |
|
| 471 | 471 | return -2; |
| 472 | 472 | } |
| 473 | 473 | } |
| 474 | 474 | |
| 475 | 475 | dol_syslog(get_class($this)."::create ref=".$this->ref." price=".$this->price." price_ttc=".$this->price_ttc." tva_tx=".$this->tva_tx." price_base_type=".$this->price_base_type, LOG_DEBUG); |
| 476 | 476 | |
| 477 | - $now=dol_now(); |
|
| 477 | + $now = dol_now(); |
|
| 478 | 478 | |
| 479 | 479 | $this->db->begin(); |
| 480 | 480 | |
| 481 | 481 | // For automatic creation during create action (not used by Dolibarr GUI, can be used by scripts) |
| 482 | - if ($this->barcode == -1) $this->barcode = $this->get_barcode($this,$this->barcode_type_code); |
|
| 482 | + if ($this->barcode == -1) $this->barcode = $this->get_barcode($this, $this->barcode_type_code); |
|
| 483 | 483 | |
| 484 | 484 | // Check more parameters |
| 485 | 485 | // If error, this->errors[] is filled |
@@ -488,9 +488,9 @@ discard block |
||
| 488 | 488 | if ($result >= 0) |
| 489 | 489 | { |
| 490 | 490 | $sql = "SELECT count(*) as nb"; |
| 491 | - $sql.= " FROM ".MAIN_DB_PREFIX."product"; |
|
| 492 | - $sql.= " WHERE entity IN (".getEntity('product').")"; |
|
| 493 | - $sql.= " AND ref = '" .$this->db->escape($this->ref)."'"; |
|
| 491 | + $sql .= " FROM ".MAIN_DB_PREFIX."product"; |
|
| 492 | + $sql .= " WHERE entity IN (".getEntity('product').")"; |
|
| 493 | + $sql .= " AND ref = '".$this->db->escape($this->ref)."'"; |
|
| 494 | 494 | |
| 495 | 495 | $result = $this->db->query($sql); |
| 496 | 496 | if ($result) |
@@ -500,66 +500,66 @@ discard block |
||
| 500 | 500 | { |
| 501 | 501 | // Produit non deja existant |
| 502 | 502 | $sql = "INSERT INTO ".MAIN_DB_PREFIX."product ("; |
| 503 | - $sql.= "datec"; |
|
| 504 | - $sql.= ", entity"; |
|
| 505 | - $sql.= ", ref"; |
|
| 506 | - $sql.= ", ref_ext"; |
|
| 507 | - $sql.= ", price_min"; |
|
| 508 | - $sql.= ", price_min_ttc"; |
|
| 509 | - $sql.= ", label"; |
|
| 510 | - $sql.= ", fk_user_author"; |
|
| 511 | - $sql.= ", fk_product_type"; |
|
| 512 | - $sql.= ", price"; |
|
| 513 | - $sql.= ", price_ttc"; |
|
| 514 | - $sql.= ", price_base_type"; |
|
| 515 | - $sql.= ", tobuy"; |
|
| 516 | - $sql.= ", tosell"; |
|
| 517 | - $sql.= ", accountancy_code_buy"; |
|
| 518 | - $sql.= ", accountancy_code_sell"; |
|
| 519 | - $sql.= ", accountancy_code_sell_intra"; |
|
| 520 | - $sql.= ", accountancy_code_sell_export"; |
|
| 521 | - $sql.= ", canvas"; |
|
| 522 | - $sql.= ", finished"; |
|
| 523 | - $sql.= ", tobatch"; |
|
| 524 | - $sql.= ", fk_unit"; |
|
| 525 | - $sql.= ") VALUES ("; |
|
| 526 | - $sql.= "'".$this->db->idate($now)."'"; |
|
| 527 | - $sql.= ", ".$conf->entity; |
|
| 528 | - $sql.= ", '".$this->db->escape($this->ref)."'"; |
|
| 529 | - $sql.= ", ".(! empty($this->ref_ext)?"'".$this->db->escape($this->ref_ext)."'":"null"); |
|
| 530 | - $sql.= ", ".price2num($price_min_ht); |
|
| 531 | - $sql.= ", ".price2num($price_min_ttc); |
|
| 532 | - $sql.= ", ".(! empty($this->label)?"'".$this->db->escape($this->label)."'":"null"); |
|
| 533 | - $sql.= ", ".$user->id; |
|
| 534 | - $sql.= ", ".$this->type; |
|
| 535 | - $sql.= ", ".price2num($price_ht); |
|
| 536 | - $sql.= ", ".price2num($price_ttc); |
|
| 537 | - $sql.= ", '".$this->db->escape($this->price_base_type)."'"; |
|
| 538 | - $sql.= ", ".$this->status; |
|
| 539 | - $sql.= ", ".$this->status_buy; |
|
| 540 | - $sql.= ", '".$this->db->escape($this->accountancy_code_buy)."'"; |
|
| 541 | - $sql.= ", '".$this->db->escape($this->accountancy_code_sell)."'"; |
|
| 542 | - $sql.= ", '".$this->db->escape($this->accountancy_code_sell_intra)."'"; |
|
| 543 | - $sql.= ", '".$this->db->escape($this->accountancy_code_sell_export)."'"; |
|
| 544 | - $sql.= ", '".$this->db->escape($this->canvas)."'"; |
|
| 545 | - $sql.= ", ".((! isset($this->finished) || $this->finished < 0 || $this->finished == '') ? 'null' : (int) $this->finished); |
|
| 546 | - $sql.= ", ".((empty($this->status_batch) || $this->status_batch < 0)? '0':$this->status_batch); |
|
| 547 | - $sql.= ", ".(!$this->fk_unit ? 'NULL' : $this->fk_unit); |
|
| 548 | - $sql.= ")"; |
|
| 503 | + $sql .= "datec"; |
|
| 504 | + $sql .= ", entity"; |
|
| 505 | + $sql .= ", ref"; |
|
| 506 | + $sql .= ", ref_ext"; |
|
| 507 | + $sql .= ", price_min"; |
|
| 508 | + $sql .= ", price_min_ttc"; |
|
| 509 | + $sql .= ", label"; |
|
| 510 | + $sql .= ", fk_user_author"; |
|
| 511 | + $sql .= ", fk_product_type"; |
|
| 512 | + $sql .= ", price"; |
|
| 513 | + $sql .= ", price_ttc"; |
|
| 514 | + $sql .= ", price_base_type"; |
|
| 515 | + $sql .= ", tobuy"; |
|
| 516 | + $sql .= ", tosell"; |
|
| 517 | + $sql .= ", accountancy_code_buy"; |
|
| 518 | + $sql .= ", accountancy_code_sell"; |
|
| 519 | + $sql .= ", accountancy_code_sell_intra"; |
|
| 520 | + $sql .= ", accountancy_code_sell_export"; |
|
| 521 | + $sql .= ", canvas"; |
|
| 522 | + $sql .= ", finished"; |
|
| 523 | + $sql .= ", tobatch"; |
|
| 524 | + $sql .= ", fk_unit"; |
|
| 525 | + $sql .= ") VALUES ("; |
|
| 526 | + $sql .= "'".$this->db->idate($now)."'"; |
|
| 527 | + $sql .= ", ".$conf->entity; |
|
| 528 | + $sql .= ", '".$this->db->escape($this->ref)."'"; |
|
| 529 | + $sql .= ", ".(!empty($this->ref_ext) ? "'".$this->db->escape($this->ref_ext)."'" : "null"); |
|
| 530 | + $sql .= ", ".price2num($price_min_ht); |
|
| 531 | + $sql .= ", ".price2num($price_min_ttc); |
|
| 532 | + $sql .= ", ".(!empty($this->label) ? "'".$this->db->escape($this->label)."'" : "null"); |
|
| 533 | + $sql .= ", ".$user->id; |
|
| 534 | + $sql .= ", ".$this->type; |
|
| 535 | + $sql .= ", ".price2num($price_ht); |
|
| 536 | + $sql .= ", ".price2num($price_ttc); |
|
| 537 | + $sql .= ", '".$this->db->escape($this->price_base_type)."'"; |
|
| 538 | + $sql .= ", ".$this->status; |
|
| 539 | + $sql .= ", ".$this->status_buy; |
|
| 540 | + $sql .= ", '".$this->db->escape($this->accountancy_code_buy)."'"; |
|
| 541 | + $sql .= ", '".$this->db->escape($this->accountancy_code_sell)."'"; |
|
| 542 | + $sql .= ", '".$this->db->escape($this->accountancy_code_sell_intra)."'"; |
|
| 543 | + $sql .= ", '".$this->db->escape($this->accountancy_code_sell_export)."'"; |
|
| 544 | + $sql .= ", '".$this->db->escape($this->canvas)."'"; |
|
| 545 | + $sql .= ", ".((!isset($this->finished) || $this->finished < 0 || $this->finished == '') ? 'null' : (int) $this->finished); |
|
| 546 | + $sql .= ", ".((empty($this->status_batch) || $this->status_batch < 0) ? '0' : $this->status_batch); |
|
| 547 | + $sql .= ", ".(!$this->fk_unit ? 'NULL' : $this->fk_unit); |
|
| 548 | + $sql .= ")"; |
|
| 549 | 549 | |
| 550 | 550 | dol_syslog(get_class($this)."::Create", LOG_DEBUG); |
| 551 | 551 | $result = $this->db->query($sql); |
| 552 | - if ( $result ) |
|
| 552 | + if ($result) |
|
| 553 | 553 | { |
| 554 | 554 | $id = $this->db->last_insert_id(MAIN_DB_PREFIX."product"); |
| 555 | 555 | |
| 556 | 556 | if ($id > 0) |
| 557 | 557 | { |
| 558 | - $this->id = $id; |
|
| 559 | - $this->price = $price_ht; |
|
| 558 | + $this->id = $id; |
|
| 559 | + $this->price = $price_ht; |
|
| 560 | 560 | $this->price_ttc = $price_ttc; |
| 561 | 561 | $this->price_min = $price_min_ht; |
| 562 | - $this->price_min_ttc = $price_min_ttc; |
|
| 562 | + $this->price_min_ttc = $price_min_ttc; |
|
| 563 | 563 | |
| 564 | 564 | $result = $this->_log_price($user); |
| 565 | 565 | if ($result > 0) |
@@ -572,19 +572,19 @@ discard block |
||
| 572 | 572 | else |
| 573 | 573 | { |
| 574 | 574 | $error++; |
| 575 | - $this->error=$this->db->lasterror(); |
|
| 575 | + $this->error = $this->db->lasterror(); |
|
| 576 | 576 | } |
| 577 | 577 | } |
| 578 | 578 | else |
| 579 | 579 | { |
| 580 | 580 | $error++; |
| 581 | - $this->error='ErrorFailedToGetInsertedId'; |
|
| 581 | + $this->error = 'ErrorFailedToGetInsertedId'; |
|
| 582 | 582 | } |
| 583 | 583 | } |
| 584 | 584 | else |
| 585 | 585 | { |
| 586 | 586 | $error++; |
| 587 | - $this->error=$this->db->lasterror(); |
|
| 587 | + $this->error = $this->db->lasterror(); |
|
| 588 | 588 | } |
| 589 | 589 | } |
| 590 | 590 | else |
@@ -598,18 +598,18 @@ discard block |
||
| 598 | 598 | else |
| 599 | 599 | { |
| 600 | 600 | $error++; |
| 601 | - $this->error=$this->db->lasterror(); |
|
| 601 | + $this->error = $this->db->lasterror(); |
|
| 602 | 602 | } |
| 603 | 603 | |
| 604 | - if (! $error && ! $notrigger) |
|
| 604 | + if (!$error && !$notrigger) |
|
| 605 | 605 | { |
| 606 | 606 | // Call trigger |
| 607 | - $result=$this->call_trigger('PRODUCT_CREATE',$user); |
|
| 607 | + $result = $this->call_trigger('PRODUCT_CREATE', $user); |
|
| 608 | 608 | if ($result < 0) { $error++; } |
| 609 | 609 | // End call triggers |
| 610 | 610 | } |
| 611 | 611 | |
| 612 | - if (! $error) |
|
| 612 | + if (!$error) |
|
| 613 | 613 | { |
| 614 | 614 | $this->db->commit(); |
| 615 | 615 | return $this->id; |
@@ -623,7 +623,7 @@ discard block |
||
| 623 | 623 | else |
| 624 | 624 | { |
| 625 | 625 | $this->db->rollback(); |
| 626 | - dol_syslog(get_class($this)."::Create fails verify ".join(',',$this->errors), LOG_WARNING); |
|
| 626 | + dol_syslog(get_class($this)."::Create fails verify ".join(',', $this->errors), LOG_WARNING); |
|
| 627 | 627 | return -3; |
| 628 | 628 | } |
| 629 | 629 | |
@@ -638,12 +638,12 @@ discard block |
||
| 638 | 638 | */ |
| 639 | 639 | function verify() |
| 640 | 640 | { |
| 641 | - $this->errors=array(); |
|
| 641 | + $this->errors = array(); |
|
| 642 | 642 | |
| 643 | 643 | $result = 0; |
| 644 | 644 | $this->ref = trim($this->ref); |
| 645 | 645 | |
| 646 | - if (! $this->ref) |
|
| 646 | + if (!$this->ref) |
|
| 647 | 647 | { |
| 648 | 648 | $this->errors[] = 'ErrorBadRef'; |
| 649 | 649 | $result = -2; |
@@ -682,17 +682,17 @@ discard block |
||
| 682 | 682 | * -2 ErrorBarCodeRequired |
| 683 | 683 | * -3 ErrorBarCodeAlreadyUsed |
| 684 | 684 | */ |
| 685 | - function check_barcode($valuetotest,$typefortest) |
|
| 685 | + function check_barcode($valuetotest, $typefortest) |
|
| 686 | 686 | { |
| 687 | 687 | global $conf; |
| 688 | - if (! empty($conf->barcode->enabled) && ! empty($conf->global->BARCODE_PRODUCT_ADDON_NUM)) |
|
| 688 | + if (!empty($conf->barcode->enabled) && !empty($conf->global->BARCODE_PRODUCT_ADDON_NUM)) |
|
| 689 | 689 | { |
| 690 | - $module=strtolower($conf->global->BARCODE_PRODUCT_ADDON_NUM); |
|
| 690 | + $module = strtolower($conf->global->BARCODE_PRODUCT_ADDON_NUM); |
|
| 691 | 691 | |
| 692 | - $dirsociete=array_merge(array('/core/modules/barcode/'),$conf->modules_parts['barcode']); |
|
| 692 | + $dirsociete = array_merge(array('/core/modules/barcode/'), $conf->modules_parts['barcode']); |
|
| 693 | 693 | foreach ($dirsociete as $dirroot) |
| 694 | 694 | { |
| 695 | - $res=dol_include_once($dirroot.$module.'.php'); |
|
| 695 | + $res = dol_include_once($dirroot.$module.'.php'); |
|
| 696 | 696 | if ($res) break; |
| 697 | 697 | } |
| 698 | 698 | |
@@ -718,14 +718,14 @@ discard block |
||
| 718 | 718 | * @param string $action Current action for hookmanager ('add' or 'update') |
| 719 | 719 | * @return int 1 if OK, -1 if ref already exists, -2 if other error |
| 720 | 720 | */ |
| 721 | - function update($id, $user, $notrigger=false, $action='update') |
|
| 721 | + function update($id, $user, $notrigger = false, $action = 'update') |
|
| 722 | 722 | { |
| 723 | 723 | global $langs, $conf, $hookmanager; |
| 724 | 724 | |
| 725 | - $error=0; |
|
| 725 | + $error = 0; |
|
| 726 | 726 | |
| 727 | 727 | // Check parameters |
| 728 | - if (! $this->label) $this->label = 'MISSING LABEL'; |
|
| 728 | + if (!$this->label) $this->label = 'MISSING LABEL'; |
|
| 729 | 729 | |
| 730 | 730 | // Clean parameters |
| 731 | 731 | $this->ref = dol_string_nospecial(trim($this->ref)); |
@@ -741,8 +741,8 @@ discard block |
||
| 741 | 741 | $this->height = price2num($this->height); |
| 742 | 742 | $this->height_units = trim($this->height_units); |
| 743 | 743 | // set unit not defined |
| 744 | - if ($this->length_units) $this->width_units = $this->length_units; // Not used yet |
|
| 745 | - if ($this->length_units) $this->height_units = $this->length_units; // Not used yet |
|
| 744 | + if ($this->length_units) $this->width_units = $this->length_units; // Not used yet |
|
| 745 | + if ($this->length_units) $this->height_units = $this->length_units; // Not used yet |
|
| 746 | 746 | // Automated compute surface and volume if not filled |
| 747 | 747 | if (empty($this->surface) && !empty($this->length) && !empty($this->width) && $this->length_units == $this->width_units) |
| 748 | 748 | { |
@@ -751,7 +751,7 @@ discard block |
||
| 751 | 751 | } |
| 752 | 752 | if (empty($this->volume) && !empty($this->surface_units) && !empty($this->height) && $this->length_units == $this->height_units) |
| 753 | 753 | { |
| 754 | - $this->volume = $this->surface * $this->height; |
|
| 754 | + $this->volume = $this->surface * $this->height; |
|
| 755 | 755 | $this->volume_units = measuring_units_cubed($this->height_units); |
| 756 | 756 | } |
| 757 | 757 | |
@@ -771,12 +771,12 @@ discard block |
||
| 771 | 771 | if (empty($this->country_id)) $this->country_id = 0; |
| 772 | 772 | |
| 773 | 773 | // Barcode value |
| 774 | - $this->barcode=trim($this->barcode); |
|
| 774 | + $this->barcode = trim($this->barcode); |
|
| 775 | 775 | |
| 776 | 776 | $this->accountancy_code_buy = trim($this->accountancy_code_buy); |
| 777 | - $this->accountancy_code_sell= trim($this->accountancy_code_sell); |
|
| 778 | - $this->accountancy_code_sell_intra= trim($this->accountancy_code_sell_intra); |
|
| 779 | - $this->accountancy_code_sell_export= trim($this->accountancy_code_sell_export); |
|
| 777 | + $this->accountancy_code_sell = trim($this->accountancy_code_sell); |
|
| 778 | + $this->accountancy_code_sell_intra = trim($this->accountancy_code_sell_intra); |
|
| 779 | + $this->accountancy_code_sell_export = trim($this->accountancy_code_sell_export); |
|
| 780 | 780 | |
| 781 | 781 | |
| 782 | 782 | $this->db->begin(); |
@@ -785,16 +785,16 @@ discard block |
||
| 785 | 785 | // If error, this->errors[] is filled |
| 786 | 786 | if ($action != 'add') |
| 787 | 787 | { |
| 788 | - $result = $this->verify(); // We don't check when update called during a create because verify was already done |
|
| 788 | + $result = $this->verify(); // We don't check when update called during a create because verify was already done |
|
| 789 | 789 | } |
| 790 | 790 | |
| 791 | 791 | if ($result >= 0) |
| 792 | 792 | { |
| 793 | 793 | if (empty($this->oldcopy)) |
| 794 | 794 | { |
| 795 | - $org=new self($this->db); |
|
| 795 | + $org = new self($this->db); |
|
| 796 | 796 | $org->fetch($this->id); |
| 797 | - $this->oldcopy=$org; |
|
| 797 | + $this->oldcopy = $org; |
|
| 798 | 798 | } |
| 799 | 799 | |
| 800 | 800 | // Test if batch management is activated on existing product |
@@ -815,9 +815,9 @@ discard block |
||
| 815 | 815 | if ($detail->batch == $valueforundefinedlot || $detail->batch == 'Undefined') |
| 816 | 816 | { |
| 817 | 817 | // We discard this line, we will create it later |
| 818 | - $sqlclean="DELETE FROM ".MAIN_DB_PREFIX."product_batch WHERE batch in('Undefined', '".$valueforundefinedlot."') AND fk_product_stock = ".$ObjW->id; |
|
| 818 | + $sqlclean = "DELETE FROM ".MAIN_DB_PREFIX."product_batch WHERE batch in('Undefined', '".$valueforundefinedlot."') AND fk_product_stock = ".$ObjW->id; |
|
| 819 | 819 | $result = $this->db->query($sqlclean); |
| 820 | - if (! $result) |
|
| 820 | + if (!$result) |
|
| 821 | 821 | { |
| 822 | 822 | dol_print_error($this->db); |
| 823 | 823 | exit; |
@@ -836,131 +836,131 @@ discard block |
||
| 836 | 836 | $ObjBatch->qty = ($ObjW->real - $qty_batch); |
| 837 | 837 | $ObjBatch->fk_product_stock = $ObjW->id; |
| 838 | 838 | |
| 839 | - if ($ObjBatch->create($user,1) < 0) |
|
| 839 | + if ($ObjBatch->create($user, 1) < 0) |
|
| 840 | 840 | { |
| 841 | 841 | $error++; |
| 842 | - $this->errors=$ObjBatch->errors; |
|
| 842 | + $this->errors = $ObjBatch->errors; |
|
| 843 | 843 | } |
| 844 | 844 | } |
| 845 | 845 | } |
| 846 | 846 | } |
| 847 | 847 | |
| 848 | 848 | // For automatic creation |
| 849 | - if ($this->barcode == -1) $this->barcode = $this->get_barcode($this,$this->barcode_type_code); |
|
| 849 | + if ($this->barcode == -1) $this->barcode = $this->get_barcode($this, $this->barcode_type_code); |
|
| 850 | 850 | |
| 851 | 851 | $sql = "UPDATE ".MAIN_DB_PREFIX."product"; |
| 852 | - $sql.= " SET label = '" . $this->db->escape($this->label) ."'"; |
|
| 853 | - $sql.= ", ref = '" . $this->db->escape($this->ref) ."'"; |
|
| 854 | - $sql.= ", ref_ext = ".(! empty($this->ref_ext)?"'".$this->db->escape($this->ref_ext)."'":"null"); |
|
| 855 | - $sql.= ", default_vat_code = ".($this->default_vat_code ? "'".$this->db->escape($this->default_vat_code)."'" : "null"); |
|
| 856 | - $sql.= ", tva_tx = " . $this->tva_tx; |
|
| 857 | - $sql.= ", recuperableonly = " . $this->tva_npr; |
|
| 858 | - $sql.= ", localtax1_tx = " . $this->localtax1_tx; |
|
| 859 | - $sql.= ", localtax2_tx = " . $this->localtax2_tx; |
|
| 860 | - $sql.= ", localtax1_type = " . ($this->localtax1_type!=''?"'".$this->db->escape($this->localtax1_type)."'":"'0'"); |
|
| 861 | - $sql.= ", localtax2_type = " . ($this->localtax2_type!=''?"'".$this->db->escape($this->localtax2_type)."'":"'0'"); |
|
| 862 | - |
|
| 863 | - $sql.= ", barcode = ". (empty($this->barcode)?"null":"'".$this->db->escape($this->barcode)."'"); |
|
| 864 | - $sql.= ", fk_barcode_type = ". (empty($this->barcode_type)?"null":$this->db->escape($this->barcode_type)); |
|
| 865 | - |
|
| 866 | - $sql.= ", tosell = " . $this->status; |
|
| 867 | - $sql.= ", tobuy = " . $this->status_buy; |
|
| 868 | - $sql.= ", tobatch = " . ((empty($this->status_batch) || $this->status_batch < 0) ? '0' : $this->status_batch); |
|
| 869 | - $sql.= ", finished = " . ((! isset($this->finished) || $this->finished < 0) ? "null" : (int) $this->finished); |
|
| 870 | - $sql.= ", weight = " . ($this->weight!='' ? "'".$this->db->escape($this->weight)."'" : 'null'); |
|
| 871 | - $sql.= ", weight_units = " . ($this->weight_units!='' ? "'".$this->db->escape($this->weight_units)."'": 'null'); |
|
| 872 | - $sql.= ", length = " . ($this->length!='' ? "'".$this->db->escape($this->length)."'" : 'null'); |
|
| 873 | - $sql.= ", length_units = " . ($this->length_units!='' ? "'".$this->db->escape($this->length_units)."'" : 'null'); |
|
| 874 | - $sql.= ", width= " . ($this->width!='' ? "'".$this->db->escape($this->width)."'" : 'null'); |
|
| 875 | - $sql.= ", width_units = " . ($this->width_units!='' ? "'".$this->db->escape($this->width_units)."'" : 'null'); |
|
| 876 | - $sql.= ", height = " . ($this->height!='' ? "'".$this->db->escape($this->height)."'" : 'null'); |
|
| 877 | - $sql.= ", height_units = " . ($this->height_units!='' ? "'".$this->db->escape($this->height_units)."'" : 'null'); |
|
| 878 | - $sql.= ", surface = " . ($this->surface!='' ? "'".$this->db->escape($this->surface)."'" : 'null'); |
|
| 879 | - $sql.= ", surface_units = " . ($this->surface_units!='' ? "'".$this->db->escape($this->surface_units)."'" : 'null'); |
|
| 880 | - $sql.= ", volume = " . ($this->volume!='' ? "'".$this->db->escape($this->volume)."'" : 'null'); |
|
| 881 | - $sql.= ", volume_units = " . ($this->volume_units!='' ? "'".$this->db->escape($this->volume_units)."'" : 'null'); |
|
| 882 | - $sql.= ", fk_default_warehouse = " . ($this->fk_default_warehouse > 0 ? $this->db->escape($this->fk_default_warehouse) : 'null'); |
|
| 883 | - $sql.= ", seuil_stock_alerte = " . ((isset($this->seuil_stock_alerte) && $this->seuil_stock_alerte != '') ? "'".$this->db->escape($this->seuil_stock_alerte)."'" : "null"); |
|
| 884 | - $sql.= ", description = '" . $this->db->escape($this->description) ."'"; |
|
| 885 | - $sql.= ", url = " . ($this->url?"'".$this->db->escape($this->url)."'":'null'); |
|
| 886 | - $sql.= ", customcode = '" . $this->db->escape($this->customcode) ."'"; |
|
| 887 | - $sql.= ", fk_country = " . ($this->country_id > 0 ? $this->country_id : 'null'); |
|
| 888 | - $sql.= ", note = ".(isset($this->note) ? "'" .$this->db->escape($this->note)."'" : 'null'); |
|
| 889 | - $sql.= ", duration = '" . $this->db->escape($this->duration_value . $this->duration_unit) ."'"; |
|
| 890 | - $sql.= ", accountancy_code_buy = '" . $this->db->escape($this->accountancy_code_buy)."'"; |
|
| 891 | - $sql.= ", accountancy_code_sell= '" . $this->db->escape($this->accountancy_code_sell)."'"; |
|
| 892 | - $sql.= ", accountancy_code_sell_intra= '" . $this->db->escape($this->accountancy_code_sell_intra)."'"; |
|
| 893 | - $sql.= ", accountancy_code_sell_export= '" . $this->db->escape($this->accountancy_code_sell_export)."'"; |
|
| 894 | - $sql.= ", desiredstock = " . ((isset($this->desiredstock) && $this->desiredstock != '') ? $this->desiredstock : "null"); |
|
| 895 | - $sql.= ", cost_price = " . ($this->cost_price != '' ? $this->db->escape($this->cost_price) : 'null'); |
|
| 896 | - $sql.= ", fk_unit= " . (!$this->fk_unit ? 'NULL' : $this->fk_unit); |
|
| 897 | - $sql.= ", price_autogen = " . (!$this->price_autogen ? 0 : 1); |
|
| 898 | - $sql.= ", fk_price_expression = ".($this->fk_price_expression != 0 ? $this->fk_price_expression : 'NULL'); |
|
| 899 | - $sql.= ", fk_user_modif = ".($user->id > 0 ? $user->id : 'NULL'); |
|
| 852 | + $sql .= " SET label = '".$this->db->escape($this->label)."'"; |
|
| 853 | + $sql .= ", ref = '".$this->db->escape($this->ref)."'"; |
|
| 854 | + $sql .= ", ref_ext = ".(!empty($this->ref_ext) ? "'".$this->db->escape($this->ref_ext)."'" : "null"); |
|
| 855 | + $sql .= ", default_vat_code = ".($this->default_vat_code ? "'".$this->db->escape($this->default_vat_code)."'" : "null"); |
|
| 856 | + $sql .= ", tva_tx = ".$this->tva_tx; |
|
| 857 | + $sql .= ", recuperableonly = ".$this->tva_npr; |
|
| 858 | + $sql .= ", localtax1_tx = ".$this->localtax1_tx; |
|
| 859 | + $sql .= ", localtax2_tx = ".$this->localtax2_tx; |
|
| 860 | + $sql .= ", localtax1_type = ".($this->localtax1_type != '' ? "'".$this->db->escape($this->localtax1_type)."'" : "'0'"); |
|
| 861 | + $sql .= ", localtax2_type = ".($this->localtax2_type != '' ? "'".$this->db->escape($this->localtax2_type)."'" : "'0'"); |
|
| 862 | + |
|
| 863 | + $sql .= ", barcode = ".(empty($this->barcode) ? "null" : "'".$this->db->escape($this->barcode)."'"); |
|
| 864 | + $sql .= ", fk_barcode_type = ".(empty($this->barcode_type) ? "null" : $this->db->escape($this->barcode_type)); |
|
| 865 | + |
|
| 866 | + $sql .= ", tosell = ".$this->status; |
|
| 867 | + $sql .= ", tobuy = ".$this->status_buy; |
|
| 868 | + $sql .= ", tobatch = ".((empty($this->status_batch) || $this->status_batch < 0) ? '0' : $this->status_batch); |
|
| 869 | + $sql .= ", finished = ".((!isset($this->finished) || $this->finished < 0) ? "null" : (int) $this->finished); |
|
| 870 | + $sql .= ", weight = ".($this->weight != '' ? "'".$this->db->escape($this->weight)."'" : 'null'); |
|
| 871 | + $sql .= ", weight_units = ".($this->weight_units != '' ? "'".$this->db->escape($this->weight_units)."'" : 'null'); |
|
| 872 | + $sql .= ", length = ".($this->length != '' ? "'".$this->db->escape($this->length)."'" : 'null'); |
|
| 873 | + $sql .= ", length_units = ".($this->length_units != '' ? "'".$this->db->escape($this->length_units)."'" : 'null'); |
|
| 874 | + $sql .= ", width= ".($this->width != '' ? "'".$this->db->escape($this->width)."'" : 'null'); |
|
| 875 | + $sql .= ", width_units = ".($this->width_units != '' ? "'".$this->db->escape($this->width_units)."'" : 'null'); |
|
| 876 | + $sql .= ", height = ".($this->height != '' ? "'".$this->db->escape($this->height)."'" : 'null'); |
|
| 877 | + $sql .= ", height_units = ".($this->height_units != '' ? "'".$this->db->escape($this->height_units)."'" : 'null'); |
|
| 878 | + $sql .= ", surface = ".($this->surface != '' ? "'".$this->db->escape($this->surface)."'" : 'null'); |
|
| 879 | + $sql .= ", surface_units = ".($this->surface_units != '' ? "'".$this->db->escape($this->surface_units)."'" : 'null'); |
|
| 880 | + $sql .= ", volume = ".($this->volume != '' ? "'".$this->db->escape($this->volume)."'" : 'null'); |
|
| 881 | + $sql .= ", volume_units = ".($this->volume_units != '' ? "'".$this->db->escape($this->volume_units)."'" : 'null'); |
|
| 882 | + $sql .= ", fk_default_warehouse = ".($this->fk_default_warehouse > 0 ? $this->db->escape($this->fk_default_warehouse) : 'null'); |
|
| 883 | + $sql .= ", seuil_stock_alerte = ".((isset($this->seuil_stock_alerte) && $this->seuil_stock_alerte != '') ? "'".$this->db->escape($this->seuil_stock_alerte)."'" : "null"); |
|
| 884 | + $sql .= ", description = '".$this->db->escape($this->description)."'"; |
|
| 885 | + $sql .= ", url = ".($this->url ? "'".$this->db->escape($this->url)."'" : 'null'); |
|
| 886 | + $sql .= ", customcode = '".$this->db->escape($this->customcode)."'"; |
|
| 887 | + $sql .= ", fk_country = ".($this->country_id > 0 ? $this->country_id : 'null'); |
|
| 888 | + $sql .= ", note = ".(isset($this->note) ? "'".$this->db->escape($this->note)."'" : 'null'); |
|
| 889 | + $sql .= ", duration = '".$this->db->escape($this->duration_value.$this->duration_unit)."'"; |
|
| 890 | + $sql .= ", accountancy_code_buy = '".$this->db->escape($this->accountancy_code_buy)."'"; |
|
| 891 | + $sql .= ", accountancy_code_sell= '".$this->db->escape($this->accountancy_code_sell)."'"; |
|
| 892 | + $sql .= ", accountancy_code_sell_intra= '".$this->db->escape($this->accountancy_code_sell_intra)."'"; |
|
| 893 | + $sql .= ", accountancy_code_sell_export= '".$this->db->escape($this->accountancy_code_sell_export)."'"; |
|
| 894 | + $sql .= ", desiredstock = ".((isset($this->desiredstock) && $this->desiredstock != '') ? $this->desiredstock : "null"); |
|
| 895 | + $sql .= ", cost_price = ".($this->cost_price != '' ? $this->db->escape($this->cost_price) : 'null'); |
|
| 896 | + $sql .= ", fk_unit= ".(!$this->fk_unit ? 'NULL' : $this->fk_unit); |
|
| 897 | + $sql .= ", price_autogen = ".(!$this->price_autogen ? 0 : 1); |
|
| 898 | + $sql .= ", fk_price_expression = ".($this->fk_price_expression != 0 ? $this->fk_price_expression : 'NULL'); |
|
| 899 | + $sql .= ", fk_user_modif = ".($user->id > 0 ? $user->id : 'NULL'); |
|
| 900 | 900 | // stock field is not here because it is a denormalized value from product_stock. |
| 901 | - $sql.= " WHERE rowid = " . $id; |
|
| 901 | + $sql .= " WHERE rowid = ".$id; |
|
| 902 | 902 | |
| 903 | 903 | dol_syslog(get_class($this)."::update", LOG_DEBUG); |
| 904 | 904 | |
| 905 | - $resql=$this->db->query($sql); |
|
| 905 | + $resql = $this->db->query($sql); |
|
| 906 | 906 | if ($resql) |
| 907 | 907 | { |
| 908 | 908 | $this->id = $id; |
| 909 | 909 | |
| 910 | 910 | // Multilangs |
| 911 | - if (! empty($conf->global->MAIN_MULTILANGS)) |
|
| 911 | + if (!empty($conf->global->MAIN_MULTILANGS)) |
|
| 912 | 912 | { |
| 913 | - if ( $this->setMultiLangs($user) < 0) |
|
| 913 | + if ($this->setMultiLangs($user) < 0) |
|
| 914 | 914 | { |
| 915 | - $this->error=$langs->trans("Error")." : ".$this->db->error()." - ".$sql; |
|
| 915 | + $this->error = $langs->trans("Error")." : ".$this->db->error()." - ".$sql; |
|
| 916 | 916 | return -2; |
| 917 | 917 | } |
| 918 | 918 | } |
| 919 | 919 | |
| 920 | - $action='update'; |
|
| 920 | + $action = 'update'; |
|
| 921 | 921 | |
| 922 | 922 | // Actions on extra fields |
| 923 | 923 | if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used |
| 924 | 924 | { |
| 925 | - $result=$this->insertExtraFields(); |
|
| 925 | + $result = $this->insertExtraFields(); |
|
| 926 | 926 | if ($result < 0) |
| 927 | 927 | { |
| 928 | 928 | $error++; |
| 929 | 929 | } |
| 930 | 930 | } |
| 931 | 931 | |
| 932 | - if (! $error && ! $notrigger) |
|
| 932 | + if (!$error && !$notrigger) |
|
| 933 | 933 | { |
| 934 | 934 | // Call trigger |
| 935 | - $result=$this->call_trigger('PRODUCT_MODIFY',$user); |
|
| 935 | + $result = $this->call_trigger('PRODUCT_MODIFY', $user); |
|
| 936 | 936 | if ($result < 0) { $error++; } |
| 937 | 937 | // End call triggers |
| 938 | 938 | } |
| 939 | 939 | |
| 940 | - if (! $error && (is_object($this->oldcopy) && $this->oldcopy->ref !== $this->ref)) |
|
| 940 | + if (!$error && (is_object($this->oldcopy) && $this->oldcopy->ref !== $this->ref)) |
|
| 941 | 941 | { |
| 942 | 942 | // We remove directory |
| 943 | 943 | if ($conf->product->dir_output) |
| 944 | 944 | { |
| 945 | - $olddir = $conf->product->dir_output . "/" . dol_sanitizeFileName($this->oldcopy->ref); |
|
| 946 | - $newdir = $conf->product->dir_output . "/" . dol_sanitizeFileName($this->ref); |
|
| 945 | + $olddir = $conf->product->dir_output."/".dol_sanitizeFileName($this->oldcopy->ref); |
|
| 946 | + $newdir = $conf->product->dir_output."/".dol_sanitizeFileName($this->ref); |
|
| 947 | 947 | if (file_exists($olddir)) |
| 948 | 948 | { |
| 949 | 949 | //include_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; |
| 950 | 950 | //$res = dol_move($olddir, $newdir); |
| 951 | 951 | // do not use dol_move with directory |
| 952 | 952 | $res = @rename($olddir, $newdir); |
| 953 | - if (! $res) |
|
| 953 | + if (!$res) |
|
| 954 | 954 | { |
| 955 | 955 | $langs->load("errors"); |
| 956 | - $this->error=$langs->trans('ErrorFailToRenameDir',$olddir,$newdir); |
|
| 956 | + $this->error = $langs->trans('ErrorFailToRenameDir', $olddir, $newdir); |
|
| 957 | 957 | $error++; |
| 958 | 958 | } |
| 959 | 959 | } |
| 960 | 960 | } |
| 961 | 961 | } |
| 962 | 962 | |
| 963 | - if (! $error) |
|
| 963 | + if (!$error) |
|
| 964 | 964 | { |
| 965 | 965 | if ($conf->variants->enabled) { |
| 966 | 966 | |
@@ -987,16 +987,16 @@ discard block |
||
| 987 | 987 | if ($this->db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') |
| 988 | 988 | { |
| 989 | 989 | $langs->load("errors"); |
| 990 | - if (empty($conf->barcode->enabled)) $this->error=$langs->trans("Error")." : ".$langs->trans("ErrorProductAlreadyExists",$this->ref); |
|
| 991 | - else $this->error=$langs->trans("Error")." : ".$langs->trans("ErrorProductBarCodeAlreadyExists",$this->barcode); |
|
| 992 | - $this->errors[]=$this->error; |
|
| 990 | + if (empty($conf->barcode->enabled)) $this->error = $langs->trans("Error")." : ".$langs->trans("ErrorProductAlreadyExists", $this->ref); |
|
| 991 | + else $this->error = $langs->trans("Error")." : ".$langs->trans("ErrorProductBarCodeAlreadyExists", $this->barcode); |
|
| 992 | + $this->errors[] = $this->error; |
|
| 993 | 993 | $this->db->rollback(); |
| 994 | 994 | return -1; |
| 995 | 995 | } |
| 996 | 996 | else |
| 997 | 997 | { |
| 998 | - $this->error=$langs->trans("Error")." : ".$this->db->error()." - ".$sql; |
|
| 999 | - $this->errors[]=$this->error; |
|
| 998 | + $this->error = $langs->trans("Error")." : ".$this->db->error()." - ".$sql; |
|
| 999 | + $this->errors[] = $this->error; |
|
| 1000 | 1000 | $this->db->rollback(); |
| 1001 | 1001 | return -2; |
| 1002 | 1002 | } |
@@ -1005,7 +1005,7 @@ discard block |
||
| 1005 | 1005 | else |
| 1006 | 1006 | { |
| 1007 | 1007 | $this->db->rollback(); |
| 1008 | - dol_syslog(get_class($this)."::Update fails verify ".join(',',$this->errors), LOG_WARNING); |
|
| 1008 | + dol_syslog(get_class($this)."::Update fails verify ".join(',', $this->errors), LOG_WARNING); |
|
| 1009 | 1009 | return -3; |
| 1010 | 1010 | } |
| 1011 | 1011 | } |
@@ -1017,20 +1017,20 @@ discard block |
||
| 1017 | 1017 | * @param int $notrigger Do not execute trigger |
| 1018 | 1018 | * @return int < 0 if KO, 0 = Not possible, > 0 if OK |
| 1019 | 1019 | */ |
| 1020 | - function delete(User $user, $notrigger=0) |
|
| 1020 | + function delete(User $user, $notrigger = 0) |
|
| 1021 | 1021 | { |
| 1022 | 1022 | // Deprecation warning |
| 1023 | 1023 | if ($id > 0) { |
| 1024 | - dol_syslog(__METHOD__ . " with parameter is deprecated", LOG_WARNING); |
|
| 1024 | + dol_syslog(__METHOD__." with parameter is deprecated", LOG_WARNING); |
|
| 1025 | 1025 | } |
| 1026 | 1026 | |
| 1027 | 1027 | global $conf, $langs; |
| 1028 | - require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; |
|
| 1028 | + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; |
|
| 1029 | 1029 | |
| 1030 | - $error=0; |
|
| 1030 | + $error = 0; |
|
| 1031 | 1031 | |
| 1032 | 1032 | // Clean parameters |
| 1033 | - if (empty($id)) $id=$this->id; |
|
| 1033 | + if (empty($id)) $id = $this->id; |
|
| 1034 | 1034 | else $this->fetch($id); |
| 1035 | 1035 | |
| 1036 | 1036 | // Check parameters |
@@ -1050,24 +1050,24 @@ discard block |
||
| 1050 | 1050 | { |
| 1051 | 1051 | $this->db->begin(); |
| 1052 | 1052 | |
| 1053 | - if (! $error && empty($notrigger)) |
|
| 1053 | + if (!$error && empty($notrigger)) |
|
| 1054 | 1054 | { |
| 1055 | 1055 | // Call trigger |
| 1056 | - $result=$this->call_trigger('PRODUCT_DELETE',$user); |
|
| 1056 | + $result = $this->call_trigger('PRODUCT_DELETE', $user); |
|
| 1057 | 1057 | if ($result < 0) { $error++; } |
| 1058 | 1058 | // End call triggers |
| 1059 | 1059 | } |
| 1060 | 1060 | |
| 1061 | 1061 | // Delete from product_batch on product delete |
| 1062 | - if (! $error) |
|
| 1062 | + if (!$error) |
|
| 1063 | 1063 | { |
| 1064 | 1064 | $sql = "DELETE FROM ".MAIN_DB_PREFIX.'product_batch'; |
| 1065 | - $sql.= " WHERE fk_product_stock IN ("; |
|
| 1066 | - $sql.= "SELECT rowid FROM ".MAIN_DB_PREFIX.'product_stock'; |
|
| 1067 | - $sql.= " WHERE fk_product = ".$id.")"; |
|
| 1065 | + $sql .= " WHERE fk_product_stock IN ("; |
|
| 1066 | + $sql .= "SELECT rowid FROM ".MAIN_DB_PREFIX.'product_stock'; |
|
| 1067 | + $sql .= " WHERE fk_product = ".$id.")"; |
|
| 1068 | 1068 | dol_syslog(get_class($this).'::delete', LOG_DEBUG); |
| 1069 | 1069 | $result = $this->db->query($sql); |
| 1070 | - if (! $result) |
|
| 1070 | + if (!$result) |
|
| 1071 | 1071 | { |
| 1072 | 1072 | $error++; |
| 1073 | 1073 | $this->errors[] = $this->db->lasterror(); |
@@ -1075,18 +1075,18 @@ discard block |
||
| 1075 | 1075 | } |
| 1076 | 1076 | |
| 1077 | 1077 | // Delete all child tables |
| 1078 | - if (! $error) |
|
| 1078 | + if (!$error) |
|
| 1079 | 1079 | { |
| 1080 | - $elements = array('product_fournisseur_price','product_price','product_lang','categorie_product','product_stock','product_customer_price','product_lot'); // product_batch is done before |
|
| 1081 | - foreach($elements as $table) |
|
| 1080 | + $elements = array('product_fournisseur_price', 'product_price', 'product_lang', 'categorie_product', 'product_stock', 'product_customer_price', 'product_lot'); // product_batch is done before |
|
| 1081 | + foreach ($elements as $table) |
|
| 1082 | 1082 | { |
| 1083 | - if (! $error) |
|
| 1083 | + if (!$error) |
|
| 1084 | 1084 | { |
| 1085 | 1085 | $sql = "DELETE FROM ".MAIN_DB_PREFIX.$table; |
| 1086 | - $sql.= " WHERE fk_product = ".$id; |
|
| 1086 | + $sql .= " WHERE fk_product = ".$id; |
|
| 1087 | 1087 | dol_syslog(get_class($this).'::delete', LOG_DEBUG); |
| 1088 | 1088 | $result = $this->db->query($sql); |
| 1089 | - if (! $result) |
|
| 1089 | + if (!$result) |
|
| 1090 | 1090 | { |
| 1091 | 1091 | $error++; |
| 1092 | 1092 | $this->errors[] = $this->db->lasterror(); |
@@ -1116,30 +1116,30 @@ discard block |
||
| 1116 | 1116 | } |
| 1117 | 1117 | |
| 1118 | 1118 | // Delete product |
| 1119 | - if (! $error) |
|
| 1119 | + if (!$error) |
|
| 1120 | 1120 | { |
| 1121 | 1121 | $sqlz = "DELETE FROM ".MAIN_DB_PREFIX."product"; |
| 1122 | - $sqlz.= " WHERE rowid = ".$id; |
|
| 1122 | + $sqlz .= " WHERE rowid = ".$id; |
|
| 1123 | 1123 | dol_syslog(get_class($this).'::delete', LOG_DEBUG); |
| 1124 | 1124 | $resultz = $this->db->query($sqlz); |
| 1125 | - if ( ! $resultz ) |
|
| 1125 | + if (!$resultz) |
|
| 1126 | 1126 | { |
| 1127 | 1127 | $error++; |
| 1128 | 1128 | $this->errors[] = $this->db->lasterror(); |
| 1129 | 1129 | } |
| 1130 | 1130 | } |
| 1131 | 1131 | |
| 1132 | - if (! $error) |
|
| 1132 | + if (!$error) |
|
| 1133 | 1133 | { |
| 1134 | 1134 | // We remove directory |
| 1135 | 1135 | $ref = dol_sanitizeFileName($this->ref); |
| 1136 | 1136 | if ($conf->product->dir_output) |
| 1137 | 1137 | { |
| 1138 | - $dir = $conf->product->dir_output . "/" . $ref; |
|
| 1138 | + $dir = $conf->product->dir_output."/".$ref; |
|
| 1139 | 1139 | if (file_exists($dir)) |
| 1140 | 1140 | { |
| 1141 | - $res=@dol_delete_dir_recursive($dir); |
|
| 1142 | - if (! $res) |
|
| 1141 | + $res = @dol_delete_dir_recursive($dir); |
|
| 1142 | + if (!$res) |
|
| 1143 | 1143 | { |
| 1144 | 1144 | $this->errors[] = 'ErrorFailToDeleteDir'; |
| 1145 | 1145 | $error++; |
@@ -1149,9 +1149,9 @@ discard block |
||
| 1149 | 1149 | } |
| 1150 | 1150 | |
| 1151 | 1151 | // Remove extrafields |
| 1152 | - if ((! $error) && (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED))) // For avoid conflicts if trigger used |
|
| 1152 | + if ((!$error) && (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED))) // For avoid conflicts if trigger used |
|
| 1153 | 1153 | { |
| 1154 | - $result=$this->deleteExtraFields(); |
|
| 1154 | + $result = $this->deleteExtraFields(); |
|
| 1155 | 1155 | if ($result < 0) |
| 1156 | 1156 | { |
| 1157 | 1157 | $error++; |
@@ -1159,17 +1159,17 @@ discard block |
||
| 1159 | 1159 | } |
| 1160 | 1160 | } |
| 1161 | 1161 | |
| 1162 | - if (! $error) |
|
| 1162 | + if (!$error) |
|
| 1163 | 1163 | { |
| 1164 | 1164 | $this->db->commit(); |
| 1165 | 1165 | return 1; |
| 1166 | 1166 | } |
| 1167 | 1167 | else |
| 1168 | 1168 | { |
| 1169 | - foreach($this->errors as $errmsg) |
|
| 1169 | + foreach ($this->errors as $errmsg) |
|
| 1170 | 1170 | { |
| 1171 | 1171 | dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR); |
| 1172 | - $this->error.=($this->error?', '.$errmsg:$errmsg); |
|
| 1172 | + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); |
|
| 1173 | 1173 | } |
| 1174 | 1174 | $this->db->rollback(); |
| 1175 | 1175 | return -$error; |
@@ -1200,73 +1200,73 @@ discard block |
||
| 1200 | 1200 | if ($key == $current_lang) |
| 1201 | 1201 | { |
| 1202 | 1202 | $sql = "SELECT rowid"; |
| 1203 | - $sql.= " FROM ".MAIN_DB_PREFIX."product_lang"; |
|
| 1204 | - $sql.= " WHERE fk_product=".$this->id; |
|
| 1205 | - $sql.= " AND lang='".$key."'"; |
|
| 1203 | + $sql .= " FROM ".MAIN_DB_PREFIX."product_lang"; |
|
| 1204 | + $sql .= " WHERE fk_product=".$this->id; |
|
| 1205 | + $sql .= " AND lang='".$key."'"; |
|
| 1206 | 1206 | |
| 1207 | 1207 | $result = $this->db->query($sql); |
| 1208 | 1208 | |
| 1209 | 1209 | if ($this->db->num_rows($result)) // if there is already a description line for this language |
| 1210 | 1210 | { |
| 1211 | 1211 | $sql2 = "UPDATE ".MAIN_DB_PREFIX."product_lang"; |
| 1212 | - $sql2.= " SET "; |
|
| 1213 | - $sql2.= " label='".$this->db->escape($this->label)."',"; |
|
| 1214 | - $sql2.= " description='".$this->db->escape($this->description)."'"; |
|
| 1215 | - if (! empty($conf->global->PRODUCT_USE_OTHER_FIELD_IN_TRANSLATION)) $sql2.= ", note='".$this->db->escape($this->other)."'"; |
|
| 1216 | - $sql2.= " WHERE fk_product=".$this->id." AND lang='".$this->db->escape($key)."'"; |
|
| 1212 | + $sql2 .= " SET "; |
|
| 1213 | + $sql2 .= " label='".$this->db->escape($this->label)."',"; |
|
| 1214 | + $sql2 .= " description='".$this->db->escape($this->description)."'"; |
|
| 1215 | + if (!empty($conf->global->PRODUCT_USE_OTHER_FIELD_IN_TRANSLATION)) $sql2 .= ", note='".$this->db->escape($this->other)."'"; |
|
| 1216 | + $sql2 .= " WHERE fk_product=".$this->id." AND lang='".$this->db->escape($key)."'"; |
|
| 1217 | 1217 | } |
| 1218 | 1218 | else |
| 1219 | 1219 | { |
| 1220 | 1220 | $sql2 = "INSERT INTO ".MAIN_DB_PREFIX."product_lang (fk_product, lang, label, description"; |
| 1221 | - if (! empty($conf->global->PRODUCT_USE_OTHER_FIELD_IN_TRANSLATION)) $sql2.=", note"; |
|
| 1222 | - $sql2.= ")"; |
|
| 1223 | - $sql2.= " VALUES(".$this->id.",'".$this->db->escape($key)."','". $this->db->escape($this->label)."',"; |
|
| 1224 | - $sql2.= " '".$this->db->escape($this->description)."'"; |
|
| 1225 | - if (! empty($conf->global->PRODUCT_USE_OTHER_FIELD_IN_TRANSLATION)) $sql2.= ", '".$this->db->escape($this->other)."'"; |
|
| 1226 | - $sql2.= ")"; |
|
| 1221 | + if (!empty($conf->global->PRODUCT_USE_OTHER_FIELD_IN_TRANSLATION)) $sql2 .= ", note"; |
|
| 1222 | + $sql2 .= ")"; |
|
| 1223 | + $sql2 .= " VALUES(".$this->id.",'".$this->db->escape($key)."','".$this->db->escape($this->label)."',"; |
|
| 1224 | + $sql2 .= " '".$this->db->escape($this->description)."'"; |
|
| 1225 | + if (!empty($conf->global->PRODUCT_USE_OTHER_FIELD_IN_TRANSLATION)) $sql2 .= ", '".$this->db->escape($this->other)."'"; |
|
| 1226 | + $sql2 .= ")"; |
|
| 1227 | 1227 | } |
| 1228 | 1228 | dol_syslog(get_class($this).'::setMultiLangs key = current_lang = '.$key); |
| 1229 | - if (! $this->db->query($sql2)) |
|
| 1229 | + if (!$this->db->query($sql2)) |
|
| 1230 | 1230 | { |
| 1231 | - $this->error=$this->db->lasterror(); |
|
| 1231 | + $this->error = $this->db->lasterror(); |
|
| 1232 | 1232 | return -1; |
| 1233 | 1233 | } |
| 1234 | 1234 | } |
| 1235 | 1235 | else if (isset($this->multilangs[$key])) |
| 1236 | 1236 | { |
| 1237 | 1237 | $sql = "SELECT rowid"; |
| 1238 | - $sql.= " FROM ".MAIN_DB_PREFIX."product_lang"; |
|
| 1239 | - $sql.= " WHERE fk_product=".$this->id; |
|
| 1240 | - $sql.= " AND lang='".$key."'"; |
|
| 1238 | + $sql .= " FROM ".MAIN_DB_PREFIX."product_lang"; |
|
| 1239 | + $sql .= " WHERE fk_product=".$this->id; |
|
| 1240 | + $sql .= " AND lang='".$key."'"; |
|
| 1241 | 1241 | |
| 1242 | 1242 | $result = $this->db->query($sql); |
| 1243 | 1243 | |
| 1244 | 1244 | if ($this->db->num_rows($result)) // if there is already a description line for this language |
| 1245 | 1245 | { |
| 1246 | 1246 | $sql2 = "UPDATE ".MAIN_DB_PREFIX."product_lang"; |
| 1247 | - $sql2.= " SET "; |
|
| 1248 | - $sql2.= " label='".$this->db->escape($this->multilangs["$key"]["label"])."',"; |
|
| 1249 | - $sql2.= " description='".$this->db->escape($this->multilangs["$key"]["description"])."'"; |
|
| 1250 | - if (! empty($conf->global->PRODUCT_USE_OTHER_FIELD_IN_TRANSLATION)) $sql2.= ", note='".$this->db->escape($this->multilangs["$key"]["other"])."'"; |
|
| 1251 | - $sql2.= " WHERE fk_product=".$this->id." AND lang='".$this->db->escape($key)."'"; |
|
| 1247 | + $sql2 .= " SET "; |
|
| 1248 | + $sql2 .= " label='".$this->db->escape($this->multilangs["$key"]["label"])."',"; |
|
| 1249 | + $sql2 .= " description='".$this->db->escape($this->multilangs["$key"]["description"])."'"; |
|
| 1250 | + if (!empty($conf->global->PRODUCT_USE_OTHER_FIELD_IN_TRANSLATION)) $sql2 .= ", note='".$this->db->escape($this->multilangs["$key"]["other"])."'"; |
|
| 1251 | + $sql2 .= " WHERE fk_product=".$this->id." AND lang='".$this->db->escape($key)."'"; |
|
| 1252 | 1252 | } |
| 1253 | 1253 | else |
| 1254 | 1254 | { |
| 1255 | 1255 | $sql2 = "INSERT INTO ".MAIN_DB_PREFIX."product_lang (fk_product, lang, label, description"; |
| 1256 | - if (! empty($conf->global->PRODUCT_USE_OTHER_FIELD_IN_TRANSLATION)) $sql2.=", note"; |
|
| 1257 | - $sql2.= ")"; |
|
| 1258 | - $sql2.= " VALUES(".$this->id.",'".$this->db->escape($key)."','". $this->db->escape($this->multilangs["$key"]["label"])."',"; |
|
| 1259 | - $sql2.= " '".$this->db->escape($this->multilangs["$key"]["description"])."'"; |
|
| 1260 | - if (! empty($conf->global->PRODUCT_USE_OTHER_FIELD_IN_TRANSLATION)) $sql2.= ", '".$this->db->escape($this->multilangs["$key"]["other"])."'"; |
|
| 1261 | - $sql2.= ")"; |
|
| 1256 | + if (!empty($conf->global->PRODUCT_USE_OTHER_FIELD_IN_TRANSLATION)) $sql2 .= ", note"; |
|
| 1257 | + $sql2 .= ")"; |
|
| 1258 | + $sql2 .= " VALUES(".$this->id.",'".$this->db->escape($key)."','".$this->db->escape($this->multilangs["$key"]["label"])."',"; |
|
| 1259 | + $sql2 .= " '".$this->db->escape($this->multilangs["$key"]["description"])."'"; |
|
| 1260 | + if (!empty($conf->global->PRODUCT_USE_OTHER_FIELD_IN_TRANSLATION)) $sql2 .= ", '".$this->db->escape($this->multilangs["$key"]["other"])."'"; |
|
| 1261 | + $sql2 .= ")"; |
|
| 1262 | 1262 | } |
| 1263 | 1263 | |
| 1264 | 1264 | // We do not save if main fields are empty |
| 1265 | 1265 | if ($this->multilangs["$key"]["label"] || $this->multilangs["$key"]["description"]) |
| 1266 | 1266 | { |
| 1267 | - if (! $this->db->query($sql2)) |
|
| 1267 | + if (!$this->db->query($sql2)) |
|
| 1268 | 1268 | { |
| 1269 | - $this->error=$this->db->lasterror(); |
|
| 1269 | + $this->error = $this->db->lasterror(); |
|
| 1270 | 1270 | return -1; |
| 1271 | 1271 | } |
| 1272 | 1272 | } |
@@ -1278,7 +1278,7 @@ discard block |
||
| 1278 | 1278 | } |
| 1279 | 1279 | |
| 1280 | 1280 | // Call trigger |
| 1281 | - $result = $this->call_trigger('PRODUCT_SET_MULTILANGS',$user); |
|
| 1281 | + $result = $this->call_trigger('PRODUCT_SET_MULTILANGS', $user); |
|
| 1282 | 1282 | if ($result < 0) { |
| 1283 | 1283 | $this->error = $this->db->lasterror(); |
| 1284 | 1284 | return -1; |
@@ -1299,14 +1299,14 @@ discard block |
||
| 1299 | 1299 | function delMultiLangs($langtodelete, $user) |
| 1300 | 1300 | { |
| 1301 | 1301 | $sql = "DELETE FROM ".MAIN_DB_PREFIX."product_lang"; |
| 1302 | - $sql.= " WHERE fk_product=".$this->id." AND lang='".$this->db->escape($langtodelete)."'"; |
|
| 1302 | + $sql .= " WHERE fk_product=".$this->id." AND lang='".$this->db->escape($langtodelete)."'"; |
|
| 1303 | 1303 | |
| 1304 | 1304 | dol_syslog(get_class($this).'::delMultiLangs', LOG_DEBUG); |
| 1305 | 1305 | $result = $this->db->query($sql); |
| 1306 | 1306 | if ($result) |
| 1307 | 1307 | { |
| 1308 | 1308 | // Call trigger |
| 1309 | - $result = $this->call_trigger('PRODUCT_DEL_MULTILANGS',$user); |
|
| 1309 | + $result = $this->call_trigger('PRODUCT_DEL_MULTILANGS', $user); |
|
| 1310 | 1310 | if ($result < 0) { |
| 1311 | 1311 | $this->error = $this->db->lasterror(); |
| 1312 | 1312 | dol_syslog(get_class($this).'::delMultiLangs error='.$this->error, LOG_ERR); |
@@ -1317,7 +1317,7 @@ discard block |
||
| 1317 | 1317 | } |
| 1318 | 1318 | else |
| 1319 | 1319 | { |
| 1320 | - $this->error=$this->db->lasterror(); |
|
| 1320 | + $this->error = $this->db->lasterror(); |
|
| 1321 | 1321 | dol_syslog(get_class($this).'::delMultiLangs error='.$this->error, LOG_ERR); |
| 1322 | 1322 | return -1; |
| 1323 | 1323 | } |
@@ -1350,8 +1350,8 @@ discard block |
||
| 1350 | 1350 | } |
| 1351 | 1351 | |
| 1352 | 1352 | $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element." SET "; |
| 1353 | - $sql.= "$field = '".$this->db->escape($value)."'"; |
|
| 1354 | - $sql.= " WHERE rowid = ".$this->id; |
|
| 1353 | + $sql .= "$field = '".$this->db->escape($value)."'"; |
|
| 1354 | + $sql .= " WHERE rowid = ".$this->id; |
|
| 1355 | 1355 | |
| 1356 | 1356 | dol_syslog(get_class($this)."::".__FUNCTION__." sql=".$sql, LOG_DEBUG); |
| 1357 | 1357 | $resql = $this->db->query($sql); |
@@ -1359,12 +1359,12 @@ discard block |
||
| 1359 | 1359 | if ($resql) |
| 1360 | 1360 | { |
| 1361 | 1361 | // Call triggers |
| 1362 | - include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; |
|
| 1363 | - $interface=new Interfaces($this->db); |
|
| 1364 | - $result=$interface->run_triggers('PRODUCT_MODIFY',$this,$user,$langs,$conf); |
|
| 1362 | + include_once DOL_DOCUMENT_ROOT.'/core/class/interfaces.class.php'; |
|
| 1363 | + $interface = new Interfaces($this->db); |
|
| 1364 | + $result = $interface->run_triggers('PRODUCT_MODIFY', $this, $user, $langs, $conf); |
|
| 1365 | 1365 | if ($result < 0) |
| 1366 | 1366 | { |
| 1367 | - $this->errors=$interface->errors; |
|
| 1367 | + $this->errors = $interface->errors; |
|
| 1368 | 1368 | $this->db->rollback(); |
| 1369 | 1369 | return -1; |
| 1370 | 1370 | } |
@@ -1377,7 +1377,7 @@ discard block |
||
| 1377 | 1377 | } |
| 1378 | 1378 | else |
| 1379 | 1379 | { |
| 1380 | - $this->error=$this->db->lasterror(); |
|
| 1380 | + $this->error = $this->db->lasterror(); |
|
| 1381 | 1381 | $this->db->rollback(); |
| 1382 | 1382 | return -1; |
| 1383 | 1383 | } |
@@ -1395,8 +1395,8 @@ discard block |
||
| 1395 | 1395 | $current_lang = $langs->getDefaultLang(); |
| 1396 | 1396 | |
| 1397 | 1397 | $sql = "SELECT lang, label, description, note as other"; |
| 1398 | - $sql.= " FROM ".MAIN_DB_PREFIX."product_lang"; |
|
| 1399 | - $sql.= " WHERE fk_product=".$this->id; |
|
| 1398 | + $sql .= " FROM ".MAIN_DB_PREFIX."product_lang"; |
|
| 1399 | + $sql .= " WHERE fk_product=".$this->id; |
|
| 1400 | 1400 | |
| 1401 | 1401 | $result = $this->db->query($sql); |
| 1402 | 1402 | if ($result) |
@@ -1406,19 +1406,19 @@ discard block |
||
| 1406 | 1406 | //print 'lang='.$obj->lang.' current='.$current_lang.'<br>'; |
| 1407 | 1407 | if ($obj->lang == $current_lang) // si on a les traduct. dans la langue courante on les charge en infos principales. |
| 1408 | 1408 | { |
| 1409 | - $this->label = $obj->label; |
|
| 1410 | - $this->description = $obj->description; |
|
| 1411 | - $this->other = $obj->other; |
|
| 1409 | + $this->label = $obj->label; |
|
| 1410 | + $this->description = $obj->description; |
|
| 1411 | + $this->other = $obj->other; |
|
| 1412 | 1412 | } |
| 1413 | 1413 | $this->multilangs["$obj->lang"]["label"] = $obj->label; |
| 1414 | - $this->multilangs["$obj->lang"]["description"] = $obj->description; |
|
| 1414 | + $this->multilangs["$obj->lang"]["description"] = $obj->description; |
|
| 1415 | 1415 | $this->multilangs["$obj->lang"]["other"] = $obj->other; |
| 1416 | 1416 | } |
| 1417 | 1417 | return 1; |
| 1418 | 1418 | } |
| 1419 | 1419 | else |
| 1420 | 1420 | { |
| 1421 | - $this->error="Error: ".$this->db->lasterror()." - ".$sql; |
|
| 1421 | + $this->error = "Error: ".$this->db->lasterror()." - ".$sql; |
|
| 1422 | 1422 | return -1; |
| 1423 | 1423 | } |
| 1424 | 1424 | } |
@@ -1432,27 +1432,27 @@ discard block |
||
| 1432 | 1432 | * @param int $level price level to change |
| 1433 | 1433 | * @return int <0 if KO, >0 if OK |
| 1434 | 1434 | */ |
| 1435 | - function _log_price($user,$level=0) |
|
| 1435 | + function _log_price($user, $level = 0) |
|
| 1436 | 1436 | { |
| 1437 | 1437 | global $conf; |
| 1438 | 1438 | |
| 1439 | - $now=dol_now(); |
|
| 1439 | + $now = dol_now(); |
|
| 1440 | 1440 | |
| 1441 | 1441 | // Clean parameters |
| 1442 | - if (empty($this->price_by_qty)) $this->price_by_qty=0; |
|
| 1442 | + if (empty($this->price_by_qty)) $this->price_by_qty = 0; |
|
| 1443 | 1443 | |
| 1444 | 1444 | // Add new price |
| 1445 | 1445 | $sql = "INSERT INTO ".MAIN_DB_PREFIX."product_price(price_level,date_price, fk_product, fk_user_author, price, price_ttc, price_base_type,tosell, tva_tx, default_vat_code, recuperableonly,"; |
| 1446 | - $sql.= " localtax1_tx, localtax2_tx, localtax1_type, localtax2_type, price_min,price_min_ttc,price_by_qty,entity,fk_price_expression) "; |
|
| 1447 | - $sql.= " VALUES(".($level?$level:1).", '".$this->db->idate($now)."',".$this->id.",".$user->id.",".$this->price.",".$this->price_ttc.",'".$this->db->escape($this->price_base_type)."',".$this->status.",".$this->tva_tx.", ".($this->default_vat_code?("'".$this->db->escape($this->default_vat_code)."'"):"null").",".$this->tva_npr.","; |
|
| 1448 | - $sql.= " ".$this->localtax1_tx.", ".$this->localtax2_tx.", '".$this->db->escape($this->localtax1_type)."', '".$this->db->escape($this->localtax2_type)."', ".$this->price_min.",".$this->price_min_ttc.",".$this->price_by_qty.",".$conf->entity.",".($this->fk_price_expression > 0?$this->fk_price_expression:'null'); |
|
| 1449 | - $sql.= ")"; |
|
| 1446 | + $sql .= " localtax1_tx, localtax2_tx, localtax1_type, localtax2_type, price_min,price_min_ttc,price_by_qty,entity,fk_price_expression) "; |
|
| 1447 | + $sql .= " VALUES(".($level ? $level : 1).", '".$this->db->idate($now)."',".$this->id.",".$user->id.",".$this->price.",".$this->price_ttc.",'".$this->db->escape($this->price_base_type)."',".$this->status.",".$this->tva_tx.", ".($this->default_vat_code ? ("'".$this->db->escape($this->default_vat_code)."'") : "null").",".$this->tva_npr.","; |
|
| 1448 | + $sql .= " ".$this->localtax1_tx.", ".$this->localtax2_tx.", '".$this->db->escape($this->localtax1_type)."', '".$this->db->escape($this->localtax2_type)."', ".$this->price_min.",".$this->price_min_ttc.",".$this->price_by_qty.",".$conf->entity.",".($this->fk_price_expression > 0 ? $this->fk_price_expression : 'null'); |
|
| 1449 | + $sql .= ")"; |
|
| 1450 | 1450 | |
| 1451 | 1451 | dol_syslog(get_class($this)."::_log_price", LOG_DEBUG); |
| 1452 | - $resql=$this->db->query($sql); |
|
| 1453 | - if(! $resql) |
|
| 1452 | + $resql = $this->db->query($sql); |
|
| 1453 | + if (!$resql) |
|
| 1454 | 1454 | { |
| 1455 | - $this->error=$this->db->lasterror(); |
|
| 1455 | + $this->error = $this->db->lasterror(); |
|
| 1456 | 1456 | dol_print_error($this->db); |
| 1457 | 1457 | return -1; |
| 1458 | 1458 | } |
@@ -1473,19 +1473,19 @@ discard block |
||
| 1473 | 1473 | function log_price_delete($user, $rowid) |
| 1474 | 1474 | { |
| 1475 | 1475 | $sql = "DELETE FROM ".MAIN_DB_PREFIX."product_price_by_qty"; |
| 1476 | - $sql.= " WHERE fk_product_price=".$rowid; |
|
| 1477 | - $resql=$this->db->query($sql); |
|
| 1476 | + $sql .= " WHERE fk_product_price=".$rowid; |
|
| 1477 | + $resql = $this->db->query($sql); |
|
| 1478 | 1478 | |
| 1479 | 1479 | $sql = "DELETE FROM ".MAIN_DB_PREFIX."product_price"; |
| 1480 | - $sql.= " WHERE rowid=".$rowid; |
|
| 1481 | - $resql=$this->db->query($sql); |
|
| 1480 | + $sql .= " WHERE rowid=".$rowid; |
|
| 1481 | + $resql = $this->db->query($sql); |
|
| 1482 | 1482 | if ($resql) |
| 1483 | 1483 | { |
| 1484 | 1484 | return 1; |
| 1485 | 1485 | } |
| 1486 | 1486 | else |
| 1487 | 1487 | { |
| 1488 | - $this->error=$this->db->lasterror(); |
|
| 1488 | + $this->error = $this->db->lasterror(); |
|
| 1489 | 1489 | return -1; |
| 1490 | 1490 | } |
| 1491 | 1491 | } |
@@ -1503,20 +1503,20 @@ discard block |
||
| 1503 | 1503 | * @param int $fk_soc If of supplier |
| 1504 | 1504 | * @return int <-1 if KO, -1 if qty not enough, 0 if OK but nothing found, id_product if OK and found. May also initialize some properties like (->ref_supplier, buyprice, fourn_pu, vatrate_supplier...) |
| 1505 | 1505 | */ |
| 1506 | - function get_buyprice($prodfournprice, $qty, $product_id=0, $fourn_ref='', $fk_soc=0) |
|
| 1506 | + function get_buyprice($prodfournprice, $qty, $product_id = 0, $fourn_ref = '', $fk_soc = 0) |
|
| 1507 | 1507 | { |
| 1508 | 1508 | global $conf; |
| 1509 | 1509 | $result = 0; |
| 1510 | 1510 | |
| 1511 | 1511 | // We do a first seach with a select by searching with couple prodfournprice and qty only (later we will search on triplet qty/product_id/fourn_ref) |
| 1512 | 1512 | $sql = "SELECT pfp.rowid, pfp.price as price, pfp.quantity as quantity, pfp.remise_percent,"; |
| 1513 | - $sql.= " pfp.fk_product, pfp.ref_fourn, pfp.fk_soc, pfp.tva_tx, pfp.fk_supplier_price_expression"; |
|
| 1514 | - $sql.= " ,pfp.default_vat_code"; |
|
| 1515 | - $sql.= " ,pfp.multicurrency_price, pfp.multicurrency_unitprice, pfp.multicurrency_tx, pfp.fk_multicurrency, pfp.multicurrency_code"; |
|
| 1516 | - $sql.= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price as pfp"; |
|
| 1517 | - $sql.= " WHERE pfp.rowid = ".$prodfournprice; |
|
| 1518 | - if ($qty > 0) $sql.= " AND pfp.quantity <= ".$qty; |
|
| 1519 | - $sql.= " ORDER BY pfp.quantity DESC"; |
|
| 1513 | + $sql .= " pfp.fk_product, pfp.ref_fourn, pfp.fk_soc, pfp.tva_tx, pfp.fk_supplier_price_expression"; |
|
| 1514 | + $sql .= " ,pfp.default_vat_code"; |
|
| 1515 | + $sql .= " ,pfp.multicurrency_price, pfp.multicurrency_unitprice, pfp.multicurrency_tx, pfp.fk_multicurrency, pfp.multicurrency_code"; |
|
| 1516 | + $sql .= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price as pfp"; |
|
| 1517 | + $sql .= " WHERE pfp.rowid = ".$prodfournprice; |
|
| 1518 | + if ($qty > 0) $sql .= " AND pfp.quantity <= ".$qty; |
|
| 1519 | + $sql .= " ORDER BY pfp.quantity DESC"; |
|
| 1520 | 1520 | |
| 1521 | 1521 | dol_syslog(get_class($this)."::get_buyprice first search by prodfournprice/qty", LOG_DEBUG); |
| 1522 | 1522 | $resql = $this->db->query($sql); |
@@ -1541,36 +1541,36 @@ discard block |
||
| 1541 | 1541 | } |
| 1542 | 1542 | } |
| 1543 | 1543 | $this->product_fourn_price_id = $obj->rowid; |
| 1544 | - $this->buyprice = $obj->price; // deprecated |
|
| 1545 | - $this->fourn_pu = $obj->price / $obj->quantity; // Unit price of product of supplier |
|
| 1546 | - $this->fourn_price_base_type = 'HT'; // Price base type |
|
| 1547 | - $this->ref_fourn = $obj->ref_fourn; // deprecated |
|
| 1548 | - $this->ref_supplier = $obj->ref_fourn; // Ref supplier |
|
| 1549 | - $this->remise_percent = $obj->remise_percent; // remise percent if present and not typed |
|
| 1550 | - $this->vatrate_supplier = $obj->tva_tx; // Vat ref supplier |
|
| 1551 | - $this->default_vat_code = $obj->default_vat_code; // Vat code supplier |
|
| 1544 | + $this->buyprice = $obj->price; // deprecated |
|
| 1545 | + $this->fourn_pu = $obj->price / $obj->quantity; // Unit price of product of supplier |
|
| 1546 | + $this->fourn_price_base_type = 'HT'; // Price base type |
|
| 1547 | + $this->ref_fourn = $obj->ref_fourn; // deprecated |
|
| 1548 | + $this->ref_supplier = $obj->ref_fourn; // Ref supplier |
|
| 1549 | + $this->remise_percent = $obj->remise_percent; // remise percent if present and not typed |
|
| 1550 | + $this->vatrate_supplier = $obj->tva_tx; // Vat ref supplier |
|
| 1551 | + $this->default_vat_code = $obj->default_vat_code; // Vat code supplier |
|
| 1552 | 1552 | $this->fourn_multicurrency_price = $obj->multicurrency_price; |
| 1553 | 1553 | $this->fourn_multicurrency_unitprice = $obj->multicurrency_unitprice; |
| 1554 | 1554 | $this->fourn_multicurrency_tx = $obj->multicurrency_tx; |
| 1555 | 1555 | $this->fourn_multicurrency_id = $obj->fk_multicurrency; |
| 1556 | 1556 | $this->fourn_multicurrency_code = $obj->multicurrency_code; |
| 1557 | - $result=$obj->fk_product; |
|
| 1557 | + $result = $obj->fk_product; |
|
| 1558 | 1558 | return $result; |
| 1559 | 1559 | } |
| 1560 | 1560 | else // If not found |
| 1561 | 1561 | { |
| 1562 | 1562 | // We do a second search by doing a select again but searching with less reliable criteria: couple qty/id product, and if set fourn_ref or fk_soc. |
| 1563 | 1563 | $sql = "SELECT pfp.rowid, pfp.price as price, pfp.quantity as quantity, pfp.fk_soc,"; |
| 1564 | - $sql.= " pfp.fk_product, pfp.ref_fourn as ref_supplier, pfp.tva_tx, pfp.fk_supplier_price_expression"; |
|
| 1565 | - $sql.= " ,pfp.default_vat_code"; |
|
| 1566 | - $sql.= " ,pfp.multicurrency_price, pfp.multicurrency_unitprice, pfp.multicurrency_tx, pfp.fk_multicurrency, pfp.multicurrency_code"; |
|
| 1567 | - $sql.= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price as pfp"; |
|
| 1568 | - $sql.= " WHERE pfp.fk_product = ".$product_id; |
|
| 1569 | - if ($fourn_ref != 'none') $sql.= " AND pfp.ref_fourn = '".$fourn_ref."'"; |
|
| 1570 | - if ($fk_soc > 0) $sql.= " AND pfp.fk_soc = ".$fk_soc; |
|
| 1571 | - if ($qty > 0) $sql.= " AND pfp.quantity <= ".$qty; |
|
| 1572 | - $sql.= " ORDER BY pfp.quantity DESC"; |
|
| 1573 | - $sql.= " LIMIT 1"; |
|
| 1564 | + $sql .= " pfp.fk_product, pfp.ref_fourn as ref_supplier, pfp.tva_tx, pfp.fk_supplier_price_expression"; |
|
| 1565 | + $sql .= " ,pfp.default_vat_code"; |
|
| 1566 | + $sql .= " ,pfp.multicurrency_price, pfp.multicurrency_unitprice, pfp.multicurrency_tx, pfp.fk_multicurrency, pfp.multicurrency_code"; |
|
| 1567 | + $sql .= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price as pfp"; |
|
| 1568 | + $sql .= " WHERE pfp.fk_product = ".$product_id; |
|
| 1569 | + if ($fourn_ref != 'none') $sql .= " AND pfp.ref_fourn = '".$fourn_ref."'"; |
|
| 1570 | + if ($fk_soc > 0) $sql .= " AND pfp.fk_soc = ".$fk_soc; |
|
| 1571 | + if ($qty > 0) $sql .= " AND pfp.quantity <= ".$qty; |
|
| 1572 | + $sql .= " ORDER BY pfp.quantity DESC"; |
|
| 1573 | + $sql .= " LIMIT 1"; |
|
| 1574 | 1574 | |
| 1575 | 1575 | dol_syslog(get_class($this)."::get_buyprice second search from qty/ref/product_id", LOG_DEBUG); |
| 1576 | 1576 | $resql = $this->db->query($sql); |
@@ -1595,38 +1595,38 @@ discard block |
||
| 1595 | 1595 | } |
| 1596 | 1596 | } |
| 1597 | 1597 | $this->product_fourn_price_id = $obj->rowid; |
| 1598 | - $this->buyprice = $obj->price; // deprecated |
|
| 1599 | - $this->fourn_qty = $obj->quantity; // min quantity for price for a virtual supplier |
|
| 1600 | - $this->fourn_pu = $obj->price / $obj->quantity; // Unit price of product for a virtual supplier |
|
| 1601 | - $this->fourn_price_base_type = 'HT'; // Price base type for a virtual supplier |
|
| 1602 | - $this->ref_fourn = $obj->ref_supplier; // deprecated |
|
| 1603 | - $this->ref_supplier = $obj->ref_supplier; // Ref supplier |
|
| 1604 | - $this->remise_percent = $obj->remise_percent; // remise percent if present and not typed |
|
| 1605 | - $this->vatrate_supplier = $obj->tva_tx; // Vat ref supplier |
|
| 1606 | - $this->default_vat_code = $obj->default_vat_code; // Vat code supplier |
|
| 1598 | + $this->buyprice = $obj->price; // deprecated |
|
| 1599 | + $this->fourn_qty = $obj->quantity; // min quantity for price for a virtual supplier |
|
| 1600 | + $this->fourn_pu = $obj->price / $obj->quantity; // Unit price of product for a virtual supplier |
|
| 1601 | + $this->fourn_price_base_type = 'HT'; // Price base type for a virtual supplier |
|
| 1602 | + $this->ref_fourn = $obj->ref_supplier; // deprecated |
|
| 1603 | + $this->ref_supplier = $obj->ref_supplier; // Ref supplier |
|
| 1604 | + $this->remise_percent = $obj->remise_percent; // remise percent if present and not typed |
|
| 1605 | + $this->vatrate_supplier = $obj->tva_tx; // Vat ref supplier |
|
| 1606 | + $this->default_vat_code = $obj->default_vat_code; // Vat code supplier |
|
| 1607 | 1607 | $this->fourn_multicurrency_price = $obj->multicurrency_price; |
| 1608 | 1608 | $this->fourn_multicurrency_unitprice = $obj->multicurrency_unitprice; |
| 1609 | 1609 | $this->fourn_multicurrency_tx = $obj->multicurrency_tx; |
| 1610 | 1610 | $this->fourn_multicurrency_id = $obj->fk_multicurrency; |
| 1611 | 1611 | $this->fourn_multicurrency_code = $obj->multicurrency_code; |
| 1612 | - $result=$obj->fk_product; |
|
| 1612 | + $result = $obj->fk_product; |
|
| 1613 | 1613 | return $result; |
| 1614 | 1614 | } |
| 1615 | 1615 | else |
| 1616 | 1616 | { |
| 1617 | - return -1; // Ce produit n'existe pas avec cet id tarif fournisseur ou existe mais qte insuffisante, ni pour le couple produit/ref fournisseur dans la quantité. |
|
| 1617 | + return -1; // Ce produit n'existe pas avec cet id tarif fournisseur ou existe mais qte insuffisante, ni pour le couple produit/ref fournisseur dans la quantité. |
|
| 1618 | 1618 | } |
| 1619 | 1619 | } |
| 1620 | 1620 | else |
| 1621 | 1621 | { |
| 1622 | - $this->error=$this->db->lasterror(); |
|
| 1622 | + $this->error = $this->db->lasterror(); |
|
| 1623 | 1623 | return -3; |
| 1624 | 1624 | } |
| 1625 | 1625 | } |
| 1626 | 1626 | } |
| 1627 | 1627 | else |
| 1628 | 1628 | { |
| 1629 | - $this->error=$this->db->lasterror(); |
|
| 1629 | + $this->error = $this->db->lasterror(); |
|
| 1630 | 1630 | return -2; |
| 1631 | 1631 | } |
| 1632 | 1632 | } |
@@ -1648,20 +1648,20 @@ discard block |
||
| 1648 | 1648 | * @param string $newdefaultvatcode Default vat code |
| 1649 | 1649 | * @return int <0 if KO, >0 if OK |
| 1650 | 1650 | */ |
| 1651 | - function updatePrice($newprice, $newpricebase, $user, $newvat='',$newminprice=0, $level=0, $newnpr=0, $newpbq=0, $ignore_autogen=0, $localtaxes_array=array(), $newdefaultvatcode='') |
|
| 1651 | + function updatePrice($newprice, $newpricebase, $user, $newvat = '', $newminprice = 0, $level = 0, $newnpr = 0, $newpbq = 0, $ignore_autogen = 0, $localtaxes_array = array(), $newdefaultvatcode = '') |
|
| 1652 | 1652 | { |
| 1653 | - global $conf,$langs; |
|
| 1653 | + global $conf, $langs; |
|
| 1654 | 1654 | |
| 1655 | - $id=$this->id; |
|
| 1655 | + $id = $this->id; |
|
| 1656 | 1656 | |
| 1657 | 1657 | dol_syslog(get_class($this)."::update_price id=".$id." newprice=".$newprice." newpricebase=".$newpricebase." newminprice=".$newminprice." level=".$level." npr=".$newnpr." newdefaultvatcode=".$newdefaultvatcode); |
| 1658 | 1658 | |
| 1659 | 1659 | // Clean parameters |
| 1660 | - if (empty($this->tva_tx)) $this->tva_tx=0; |
|
| 1661 | - if (empty($newnpr)) $newnpr=0; |
|
| 1660 | + if (empty($this->tva_tx)) $this->tva_tx = 0; |
|
| 1661 | + if (empty($newnpr)) $newnpr = 0; |
|
| 1662 | 1662 | |
| 1663 | 1663 | // Check parameters |
| 1664 | - if ($newvat == '') $newvat=$this->tva_tx; |
|
| 1664 | + if ($newvat == '') $newvat = $this->tva_tx; |
|
| 1665 | 1665 | |
| 1666 | 1666 | // If multiprices are enabled, then we check if the current product is subject to price autogeneration |
| 1667 | 1667 | // Price will be modified ONLY when the first one is the one that is being modified |
@@ -1670,9 +1670,9 @@ discard block |
||
| 1670 | 1670 | return $this->generateMultiprices($user, $newprice, $newpricebase, $newvat, $newnpr, $newpbq); |
| 1671 | 1671 | } |
| 1672 | 1672 | |
| 1673 | - if (! empty($newminprice) && ($newminprice > $newprice)) |
|
| 1673 | + if (!empty($newminprice) && ($newminprice > $newprice)) |
|
| 1674 | 1674 | { |
| 1675 | - $this->error='ErrorPriceCantBeLowerThanMinPrice'; |
|
| 1675 | + $this->error = 'ErrorPriceCantBeLowerThanMinPrice'; |
|
| 1676 | 1676 | return -1; |
| 1677 | 1677 | } |
| 1678 | 1678 | |
@@ -1680,91 +1680,91 @@ discard block |
||
| 1680 | 1680 | { |
| 1681 | 1681 | if ($newpricebase == 'TTC') |
| 1682 | 1682 | { |
| 1683 | - $price_ttc = price2num($newprice,'MU'); |
|
| 1683 | + $price_ttc = price2num($newprice, 'MU'); |
|
| 1684 | 1684 | $price = price2num($newprice) / (1 + ($newvat / 100)); |
| 1685 | - $price = price2num($price,'MU'); |
|
| 1685 | + $price = price2num($price, 'MU'); |
|
| 1686 | 1686 | |
| 1687 | 1687 | if ($newminprice != '' || $newminprice == 0) |
| 1688 | 1688 | { |
| 1689 | - $price_min_ttc = price2num($newminprice,'MU'); |
|
| 1689 | + $price_min_ttc = price2num($newminprice, 'MU'); |
|
| 1690 | 1690 | $price_min = price2num($newminprice) / (1 + ($newvat / 100)); |
| 1691 | - $price_min = price2num($price_min,'MU'); |
|
| 1691 | + $price_min = price2num($price_min, 'MU'); |
|
| 1692 | 1692 | } |
| 1693 | 1693 | else |
| 1694 | 1694 | { |
| 1695 | - $price_min=0; |
|
| 1696 | - $price_min_ttc=0; |
|
| 1695 | + $price_min = 0; |
|
| 1696 | + $price_min_ttc = 0; |
|
| 1697 | 1697 | } |
| 1698 | 1698 | } |
| 1699 | 1699 | else |
| 1700 | 1700 | { |
| 1701 | - $price = price2num($newprice,'MU'); |
|
| 1702 | - $price_ttc = ( $newnpr != 1 ) ? price2num($newprice) * (1 + ($newvat / 100)) : $price; |
|
| 1703 | - $price_ttc = price2num($price_ttc,'MU'); |
|
| 1701 | + $price = price2num($newprice, 'MU'); |
|
| 1702 | + $price_ttc = ($newnpr != 1) ? price2num($newprice) * (1 + ($newvat / 100)) : $price; |
|
| 1703 | + $price_ttc = price2num($price_ttc, 'MU'); |
|
| 1704 | 1704 | |
| 1705 | - if ( $newminprice !== '' || $newminprice === 0) |
|
| 1705 | + if ($newminprice !== '' || $newminprice === 0) |
|
| 1706 | 1706 | { |
| 1707 | - $price_min = price2num($newminprice,'MU'); |
|
| 1707 | + $price_min = price2num($newminprice, 'MU'); |
|
| 1708 | 1708 | $price_min_ttc = price2num($newminprice) * (1 + ($newvat / 100)); |
| 1709 | - $price_min_ttc = price2num($price_min_ttc,'MU'); |
|
| 1709 | + $price_min_ttc = price2num($price_min_ttc, 'MU'); |
|
| 1710 | 1710 | //print 'X'.$newminprice.'-'.$price_min; |
| 1711 | 1711 | } |
| 1712 | 1712 | else |
| 1713 | 1713 | { |
| 1714 | - $price_min=0; |
|
| 1715 | - $price_min_ttc=0; |
|
| 1714 | + $price_min = 0; |
|
| 1715 | + $price_min_ttc = 0; |
|
| 1716 | 1716 | } |
| 1717 | 1717 | } |
| 1718 | 1718 | //print 'x'.$id.'-'.$newprice.'-'.$newpricebase.'-'.$price.'-'.$price_ttc.'-'.$price_min.'-'.$price_min_ttc; |
| 1719 | 1719 | |
| 1720 | 1720 | if (count($localtaxes_array) > 0) |
| 1721 | 1721 | { |
| 1722 | - $localtaxtype1=$localtaxes_array['0']; |
|
| 1723 | - $localtax1=$localtaxes_array['1']; |
|
| 1724 | - $localtaxtype2=$localtaxes_array['2']; |
|
| 1725 | - $localtax2=$localtaxes_array['3']; |
|
| 1722 | + $localtaxtype1 = $localtaxes_array['0']; |
|
| 1723 | + $localtax1 = $localtaxes_array['1']; |
|
| 1724 | + $localtaxtype2 = $localtaxes_array['2']; |
|
| 1725 | + $localtax2 = $localtaxes_array['3']; |
|
| 1726 | 1726 | } |
| 1727 | 1727 | else // old method. deprecated because ot can't retreive type |
| 1728 | 1728 | { |
| 1729 | - $localtaxtype1='0'; |
|
| 1730 | - $localtax1=get_localtax($newvat,1); |
|
| 1731 | - $localtaxtype2='0'; |
|
| 1732 | - $localtax2=get_localtax($newvat,2); |
|
| 1729 | + $localtaxtype1 = '0'; |
|
| 1730 | + $localtax1 = get_localtax($newvat, 1); |
|
| 1731 | + $localtaxtype2 = '0'; |
|
| 1732 | + $localtax2 = get_localtax($newvat, 2); |
|
| 1733 | 1733 | } |
| 1734 | - if (empty($localtax1)) $localtax1=0; // If = '' then = 0 |
|
| 1735 | - if (empty($localtax2)) $localtax2=0; // If = '' then = 0 |
|
| 1734 | + if (empty($localtax1)) $localtax1 = 0; // If = '' then = 0 |
|
| 1735 | + if (empty($localtax2)) $localtax2 = 0; // If = '' then = 0 |
|
| 1736 | 1736 | |
| 1737 | 1737 | $this->db->begin(); |
| 1738 | 1738 | |
| 1739 | 1739 | // Ne pas mettre de quote sur les numeriques decimaux. |
| 1740 | 1740 | // Ceci provoque des stockages avec arrondis en base au lieu des valeurs exactes. |
| 1741 | 1741 | $sql = "UPDATE ".MAIN_DB_PREFIX."product SET"; |
| 1742 | - $sql.= " price_base_type='".$newpricebase."',"; |
|
| 1743 | - $sql.= " price=".$price.","; |
|
| 1744 | - $sql.= " price_ttc=".$price_ttc.","; |
|
| 1745 | - $sql.= " price_min=".$price_min.","; |
|
| 1746 | - $sql.= " price_min_ttc=".$price_min_ttc.","; |
|
| 1747 | - $sql.= " localtax1_tx=".($localtax1>=0?$localtax1:'NULL').","; |
|
| 1748 | - $sql.= " localtax2_tx=".($localtax2>=0?$localtax2:'NULL').","; |
|
| 1749 | - $sql.= " localtax1_type=".($localtaxtype1!=''?"'".$localtaxtype1."'":"'0'").","; |
|
| 1750 | - $sql.= " localtax2_type=".($localtaxtype2!=''?"'".$localtaxtype2."'":"'0'").","; |
|
| 1751 | - $sql.= " default_vat_code=".($newdefaultvatcode?"'".$this->db->escape($newdefaultvatcode)."'":"null").","; |
|
| 1752 | - $sql.= " tva_tx='".price2num($newvat)."',"; |
|
| 1753 | - $sql.= " recuperableonly='".$newnpr."'"; |
|
| 1754 | - $sql.= " WHERE rowid = ".$id; |
|
| 1742 | + $sql .= " price_base_type='".$newpricebase."',"; |
|
| 1743 | + $sql .= " price=".$price.","; |
|
| 1744 | + $sql .= " price_ttc=".$price_ttc.","; |
|
| 1745 | + $sql .= " price_min=".$price_min.","; |
|
| 1746 | + $sql .= " price_min_ttc=".$price_min_ttc.","; |
|
| 1747 | + $sql .= " localtax1_tx=".($localtax1 >= 0 ? $localtax1 : 'NULL').","; |
|
| 1748 | + $sql .= " localtax2_tx=".($localtax2 >= 0 ? $localtax2 : 'NULL').","; |
|
| 1749 | + $sql .= " localtax1_type=".($localtaxtype1 != '' ? "'".$localtaxtype1."'" : "'0'").","; |
|
| 1750 | + $sql .= " localtax2_type=".($localtaxtype2 != '' ? "'".$localtaxtype2."'" : "'0'").","; |
|
| 1751 | + $sql .= " default_vat_code=".($newdefaultvatcode ? "'".$this->db->escape($newdefaultvatcode)."'" : "null").","; |
|
| 1752 | + $sql .= " tva_tx='".price2num($newvat)."',"; |
|
| 1753 | + $sql .= " recuperableonly='".$newnpr."'"; |
|
| 1754 | + $sql .= " WHERE rowid = ".$id; |
|
| 1755 | 1755 | |
| 1756 | 1756 | dol_syslog(get_class($this)."::update_price", LOG_DEBUG); |
| 1757 | - $resql=$this->db->query($sql); |
|
| 1757 | + $resql = $this->db->query($sql); |
|
| 1758 | 1758 | if ($resql) |
| 1759 | 1759 | { |
| 1760 | 1760 | $this->multiprices[$level] = $price; |
| 1761 | 1761 | $this->multiprices_ttc[$level] = $price_ttc; |
| 1762 | - $this->multiprices_min[$level]= $price_min; |
|
| 1763 | - $this->multiprices_min_ttc[$level]= $price_min_ttc; |
|
| 1764 | - $this->multiprices_base_type[$level]= $newpricebase; |
|
| 1765 | - $this->multiprices_default_vat_code[$level]= $newdefaultvatcode; |
|
| 1766 | - $this->multiprices_tva_tx[$level]= $newvat; |
|
| 1767 | - $this->multiprices_recuperableonly[$level]= $newnpr; |
|
| 1762 | + $this->multiprices_min[$level] = $price_min; |
|
| 1763 | + $this->multiprices_min_ttc[$level] = $price_min_ttc; |
|
| 1764 | + $this->multiprices_base_type[$level] = $newpricebase; |
|
| 1765 | + $this->multiprices_default_vat_code[$level] = $newdefaultvatcode; |
|
| 1766 | + $this->multiprices_tva_tx[$level] = $newvat; |
|
| 1767 | + $this->multiprices_recuperableonly[$level] = $newnpr; |
|
| 1768 | 1768 | |
| 1769 | 1769 | $this->price = $price; |
| 1770 | 1770 | $this->price_ttc = $price_ttc; |
@@ -1783,12 +1783,12 @@ discard block |
||
| 1783 | 1783 | // Price by quantity |
| 1784 | 1784 | $this->price_by_qty = $newpbq; |
| 1785 | 1785 | |
| 1786 | - $this->_log_price($user,$level); // Save price for level into table product_price |
|
| 1786 | + $this->_log_price($user, $level); // Save price for level into table product_price |
|
| 1787 | 1787 | |
| 1788 | - $this->level = $level; // Store level of price edited for trigger |
|
| 1788 | + $this->level = $level; // Store level of price edited for trigger |
|
| 1789 | 1789 | |
| 1790 | 1790 | // Call trigger |
| 1791 | - $result=$this->call_trigger('PRODUCT_PRICE_MODIFY',$user); |
|
| 1791 | + $result = $this->call_trigger('PRODUCT_PRICE_MODIFY', $user); |
|
| 1792 | 1792 | if ($result < 0) |
| 1793 | 1793 | { |
| 1794 | 1794 | $this->db->rollback(); |
@@ -1833,7 +1833,7 @@ discard block |
||
| 1833 | 1833 | * @param int $ignore_expression Ignores the math expression for calculating price and uses the db value instead |
| 1834 | 1834 | * @return int <0 if KO, 0 if not found, >0 if OK |
| 1835 | 1835 | */ |
| 1836 | - function fetch($id='', $ref='', $ref_ext='', $ignore_expression=0) |
|
| 1836 | + function fetch($id = '', $ref = '', $ref_ext = '', $ignore_expression = 0) |
|
| 1837 | 1837 | { |
| 1838 | 1838 | include_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; |
| 1839 | 1839 | |
@@ -1842,65 +1842,65 @@ discard block |
||
| 1842 | 1842 | dol_syslog(get_class($this)."::fetch id=".$id." ref=".$ref." ref_ext=".$ref_ext); |
| 1843 | 1843 | |
| 1844 | 1844 | // Check parameters |
| 1845 | - if (! $id && ! $ref && ! $ref_ext) |
|
| 1845 | + if (!$id && !$ref && !$ref_ext) |
|
| 1846 | 1846 | { |
| 1847 | - $this->error='ErrorWrongParameters'; |
|
| 1847 | + $this->error = 'ErrorWrongParameters'; |
|
| 1848 | 1848 | dol_print_error(get_class($this)."::fetch ".$this->error); |
| 1849 | 1849 | return -1; |
| 1850 | 1850 | } |
| 1851 | 1851 | |
| 1852 | 1852 | $sql = "SELECT rowid, ref, ref_ext, label, description, url, note as note_private, customcode, fk_country, price, price_ttc,"; |
| 1853 | - $sql.= " price_min, price_min_ttc, price_base_type, cost_price, default_vat_code, tva_tx, recuperableonly as tva_npr, localtax1_tx, localtax2_tx, localtax1_type, localtax2_type, tosell,"; |
|
| 1854 | - $sql.= " tobuy, fk_product_type, duration, fk_default_warehouse, seuil_stock_alerte, canvas, weight, weight_units,"; |
|
| 1855 | - $sql.= " length, length_units, width, width_units, height, height_units,"; |
|
| 1856 | - $sql.= " surface, surface_units, volume, volume_units, barcode, fk_barcode_type, finished,"; |
|
| 1857 | - $sql.= " accountancy_code_buy, accountancy_code_sell, accountancy_code_sell_intra, accountancy_code_sell_export, stock, pmp,"; |
|
| 1858 | - $sql.= " datec, tms, import_key, entity, desiredstock, tobatch, fk_unit,"; |
|
| 1859 | - $sql.= " fk_price_expression, price_autogen"; |
|
| 1860 | - $sql.= " FROM ".MAIN_DB_PREFIX."product"; |
|
| 1861 | - if ($id) $sql.= " WHERE rowid = ".$this->db->escape($id); |
|
| 1853 | + $sql .= " price_min, price_min_ttc, price_base_type, cost_price, default_vat_code, tva_tx, recuperableonly as tva_npr, localtax1_tx, localtax2_tx, localtax1_type, localtax2_type, tosell,"; |
|
| 1854 | + $sql .= " tobuy, fk_product_type, duration, fk_default_warehouse, seuil_stock_alerte, canvas, weight, weight_units,"; |
|
| 1855 | + $sql .= " length, length_units, width, width_units, height, height_units,"; |
|
| 1856 | + $sql .= " surface, surface_units, volume, volume_units, barcode, fk_barcode_type, finished,"; |
|
| 1857 | + $sql .= " accountancy_code_buy, accountancy_code_sell, accountancy_code_sell_intra, accountancy_code_sell_export, stock, pmp,"; |
|
| 1858 | + $sql .= " datec, tms, import_key, entity, desiredstock, tobatch, fk_unit,"; |
|
| 1859 | + $sql .= " fk_price_expression, price_autogen"; |
|
| 1860 | + $sql .= " FROM ".MAIN_DB_PREFIX."product"; |
|
| 1861 | + if ($id) $sql .= " WHERE rowid = ".$this->db->escape($id); |
|
| 1862 | 1862 | else |
| 1863 | 1863 | { |
| 1864 | - $sql.= " WHERE entity IN (".getEntity($this->element).")"; |
|
| 1865 | - if ($ref) $sql.= " AND ref = '".$this->db->escape($ref)."'"; |
|
| 1866 | - else if ($ref_ext) $sql.= " AND ref_ext = '".$this->db->escape($ref_ext)."'"; |
|
| 1864 | + $sql .= " WHERE entity IN (".getEntity($this->element).")"; |
|
| 1865 | + if ($ref) $sql .= " AND ref = '".$this->db->escape($ref)."'"; |
|
| 1866 | + else if ($ref_ext) $sql .= " AND ref_ext = '".$this->db->escape($ref_ext)."'"; |
|
| 1867 | 1867 | } |
| 1868 | 1868 | |
| 1869 | 1869 | $resql = $this->db->query($sql); |
| 1870 | - if ( $resql ) |
|
| 1870 | + if ($resql) |
|
| 1871 | 1871 | { |
| 1872 | 1872 | if ($this->db->num_rows($resql) > 0) |
| 1873 | 1873 | { |
| 1874 | 1874 | $obj = $this->db->fetch_object($resql); |
| 1875 | 1875 | |
| 1876 | - $this->id = $obj->rowid; |
|
| 1877 | - $this->ref = $obj->ref; |
|
| 1878 | - $this->ref_ext = $obj->ref_ext; |
|
| 1879 | - $this->label = $obj->label; |
|
| 1880 | - $this->description = $obj->description; |
|
| 1881 | - $this->url = $obj->url; |
|
| 1882 | - $this->note_private = $obj->note_private; |
|
| 1883 | - $this->note = $obj->note_private; // deprecated |
|
| 1876 | + $this->id = $obj->rowid; |
|
| 1877 | + $this->ref = $obj->ref; |
|
| 1878 | + $this->ref_ext = $obj->ref_ext; |
|
| 1879 | + $this->label = $obj->label; |
|
| 1880 | + $this->description = $obj->description; |
|
| 1881 | + $this->url = $obj->url; |
|
| 1882 | + $this->note_private = $obj->note_private; |
|
| 1883 | + $this->note = $obj->note_private; // deprecated |
|
| 1884 | 1884 | |
| 1885 | 1885 | $this->type = $obj->fk_product_type; |
| 1886 | - $this->status = $obj->tosell; |
|
| 1886 | + $this->status = $obj->tosell; |
|
| 1887 | 1887 | $this->status_buy = $obj->tobuy; |
| 1888 | - $this->status_batch = $obj->tobatch; |
|
| 1888 | + $this->status_batch = $obj->tobatch; |
|
| 1889 | 1889 | |
| 1890 | 1890 | $this->customcode = $obj->customcode; |
| 1891 | 1891 | $this->country_id = $obj->fk_country; |
| 1892 | - $this->country_code = getCountry($this->country_id,2,$this->db); |
|
| 1893 | - $this->price = $obj->price; |
|
| 1892 | + $this->country_code = getCountry($this->country_id, 2, $this->db); |
|
| 1893 | + $this->price = $obj->price; |
|
| 1894 | 1894 | $this->price_ttc = $obj->price_ttc; |
| 1895 | 1895 | $this->price_min = $obj->price_min; |
| 1896 | - $this->price_min_ttc = $obj->price_min_ttc; |
|
| 1897 | - $this->price_base_type = $obj->price_base_type; |
|
| 1898 | - $this->cost_price = $obj->cost_price; |
|
| 1899 | - $this->default_vat_code = $obj->default_vat_code; |
|
| 1900 | - $this->tva_tx = $obj->tva_tx; |
|
| 1896 | + $this->price_min_ttc = $obj->price_min_ttc; |
|
| 1897 | + $this->price_base_type = $obj->price_base_type; |
|
| 1898 | + $this->cost_price = $obj->cost_price; |
|
| 1899 | + $this->default_vat_code = $obj->default_vat_code; |
|
| 1900 | + $this->tva_tx = $obj->tva_tx; |
|
| 1901 | 1901 | //! French VAT NPR |
| 1902 | - $this->tva_npr = $obj->tva_npr; |
|
| 1903 | - $this->recuperableonly = $obj->tva_npr; // For backward compatibility |
|
| 1902 | + $this->tva_npr = $obj->tva_npr; |
|
| 1903 | + $this->recuperableonly = $obj->tva_npr; // For backward compatibility |
|
| 1904 | 1904 | //! Local taxes |
| 1905 | 1905 | $this->localtax1_tx = $obj->localtax1_tx; |
| 1906 | 1906 | $this->localtax2_tx = $obj->localtax2_tx; |
@@ -1909,45 +1909,45 @@ discard block |
||
| 1909 | 1909 | |
| 1910 | 1910 | $this->finished = $obj->finished; |
| 1911 | 1911 | $this->duration = $obj->duration; |
| 1912 | - $this->duration_value = substr($obj->duration,0,dol_strlen($obj->duration)-1); |
|
| 1913 | - $this->duration_unit = substr($obj->duration,-1); |
|
| 1912 | + $this->duration_value = substr($obj->duration, 0, dol_strlen($obj->duration) - 1); |
|
| 1913 | + $this->duration_unit = substr($obj->duration, -1); |
|
| 1914 | 1914 | $this->canvas = $obj->canvas; |
| 1915 | 1915 | $this->weight = $obj->weight; |
| 1916 | 1916 | $this->weight_units = $obj->weight_units; |
| 1917 | 1917 | $this->length = $obj->length; |
| 1918 | 1918 | $this->length_units = $obj->length_units; |
| 1919 | - $this->width = $obj->width; |
|
| 1920 | - $this->width_units = $obj->width_units; |
|
| 1921 | - $this->height = $obj->height; |
|
| 1919 | + $this->width = $obj->width; |
|
| 1920 | + $this->width_units = $obj->width_units; |
|
| 1921 | + $this->height = $obj->height; |
|
| 1922 | 1922 | $this->height_units = $obj->height_units; |
| 1923 | 1923 | |
| 1924 | - $this->surface = $obj->surface; |
|
| 1924 | + $this->surface = $obj->surface; |
|
| 1925 | 1925 | $this->surface_units = $obj->surface_units; |
| 1926 | - $this->volume = $obj->volume; |
|
| 1926 | + $this->volume = $obj->volume; |
|
| 1927 | 1927 | $this->volume_units = $obj->volume_units; |
| 1928 | - $this->barcode = $obj->barcode; |
|
| 1928 | + $this->barcode = $obj->barcode; |
|
| 1929 | 1929 | $this->barcode_type = $obj->fk_barcode_type; |
| 1930 | 1930 | |
| 1931 | 1931 | $this->accountancy_code_buy = $obj->accountancy_code_buy; |
| 1932 | 1932 | $this->accountancy_code_sell = $obj->accountancy_code_sell; |
| 1933 | - $this->accountancy_code_sell_intra = $obj->accountancy_code_sell_intra; |
|
| 1934 | - $this->accountancy_code_sell_export = $obj->accountancy_code_sell_export; |
|
| 1933 | + $this->accountancy_code_sell_intra = $obj->accountancy_code_sell_intra; |
|
| 1934 | + $this->accountancy_code_sell_export = $obj->accountancy_code_sell_export; |
|
| 1935 | 1935 | |
| 1936 | - $this->fk_default_warehouse = $obj->fk_default_warehouse; |
|
| 1937 | - $this->seuil_stock_alerte = $obj->seuil_stock_alerte; |
|
| 1938 | - $this->desiredstock = $obj->desiredstock; |
|
| 1939 | - $this->stock_reel = $obj->stock; |
|
| 1940 | - $this->pmp = $obj->pmp; |
|
| 1936 | + $this->fk_default_warehouse = $obj->fk_default_warehouse; |
|
| 1937 | + $this->seuil_stock_alerte = $obj->seuil_stock_alerte; |
|
| 1938 | + $this->desiredstock = $obj->desiredstock; |
|
| 1939 | + $this->stock_reel = $obj->stock; |
|
| 1940 | + $this->pmp = $obj->pmp; |
|
| 1941 | 1941 | |
| 1942 | - $this->date_creation = $obj->datec; |
|
| 1943 | - $this->date_modification = $obj->tms; |
|
| 1944 | - $this->import_key = $obj->import_key; |
|
| 1945 | - $this->entity = $obj->entity; |
|
| 1942 | + $this->date_creation = $obj->datec; |
|
| 1943 | + $this->date_modification = $obj->tms; |
|
| 1944 | + $this->import_key = $obj->import_key; |
|
| 1945 | + $this->entity = $obj->entity; |
|
| 1946 | 1946 | |
| 1947 | 1947 | $this->ref_ext = $obj->ref_ext; |
| 1948 | - $this->fk_price_expression = $obj->fk_price_expression; |
|
| 1948 | + $this->fk_price_expression = $obj->fk_price_expression; |
|
| 1949 | 1949 | $this->fk_unit = $obj->fk_unit; |
| 1950 | - $this->price_autogen = $obj->price_autogen; |
|
| 1950 | + $this->price_autogen = $obj->price_autogen; |
|
| 1951 | 1951 | |
| 1952 | 1952 | $this->db->free($resql); |
| 1953 | 1953 | |
@@ -1956,34 +1956,34 @@ discard block |
||
| 1956 | 1956 | $this->fetch_optionals(); |
| 1957 | 1957 | |
| 1958 | 1958 | // multilangs |
| 1959 | - if (! empty($conf->global->MAIN_MULTILANGS)) $this->getMultiLangs(); |
|
| 1959 | + if (!empty($conf->global->MAIN_MULTILANGS)) $this->getMultiLangs(); |
|
| 1960 | 1960 | |
| 1961 | 1961 | // Load multiprices array |
| 1962 | - if (! empty($conf->global->PRODUIT_MULTIPRICES)) // prices per segment |
|
| 1962 | + if (!empty($conf->global->PRODUIT_MULTIPRICES)) // prices per segment |
|
| 1963 | 1963 | { |
| 1964 | - for ($i=1; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i++) |
|
| 1964 | + for ($i = 1; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i++) |
|
| 1965 | 1965 | { |
| 1966 | 1966 | $sql = "SELECT price, price_ttc, price_min, price_min_ttc,"; |
| 1967 | - $sql.= " price_base_type, tva_tx, default_vat_code, tosell, price_by_qty, rowid, recuperableonly"; |
|
| 1968 | - $sql.= " FROM ".MAIN_DB_PREFIX."product_price"; |
|
| 1969 | - $sql.= " WHERE entity IN (".getEntity('productprice').")"; |
|
| 1970 | - $sql.= " AND price_level=".$i; |
|
| 1971 | - $sql.= " AND fk_product = ".$this->id; |
|
| 1972 | - $sql.= " ORDER BY date_price DESC, rowid DESC"; |
|
| 1973 | - $sql.= " LIMIT 1"; |
|
| 1967 | + $sql .= " price_base_type, tva_tx, default_vat_code, tosell, price_by_qty, rowid, recuperableonly"; |
|
| 1968 | + $sql .= " FROM ".MAIN_DB_PREFIX."product_price"; |
|
| 1969 | + $sql .= " WHERE entity IN (".getEntity('productprice').")"; |
|
| 1970 | + $sql .= " AND price_level=".$i; |
|
| 1971 | + $sql .= " AND fk_product = ".$this->id; |
|
| 1972 | + $sql .= " ORDER BY date_price DESC, rowid DESC"; |
|
| 1973 | + $sql .= " LIMIT 1"; |
|
| 1974 | 1974 | $resql = $this->db->query($sql); |
| 1975 | 1975 | if ($resql) |
| 1976 | 1976 | { |
| 1977 | 1977 | $result = $this->db->fetch_array($resql); |
| 1978 | 1978 | |
| 1979 | - $this->multiprices[$i]=$result["price"]; |
|
| 1980 | - $this->multiprices_ttc[$i]=$result["price_ttc"]; |
|
| 1981 | - $this->multiprices_min[$i]=$result["price_min"]; |
|
| 1982 | - $this->multiprices_min_ttc[$i]=$result["price_min_ttc"]; |
|
| 1983 | - $this->multiprices_base_type[$i]=$result["price_base_type"]; |
|
| 1979 | + $this->multiprices[$i] = $result["price"]; |
|
| 1980 | + $this->multiprices_ttc[$i] = $result["price_ttc"]; |
|
| 1981 | + $this->multiprices_min[$i] = $result["price_min"]; |
|
| 1982 | + $this->multiprices_min_ttc[$i] = $result["price_min_ttc"]; |
|
| 1983 | + $this->multiprices_base_type[$i] = $result["price_base_type"]; |
|
| 1984 | 1984 | // Next two fields are used only if PRODUIT_MULTIPRICES_USE_VAT_PER_LEVEL is on |
| 1985 | - $this->multiprices_tva_tx[$i]=$result["tva_tx"]; // TODO Add ' ('.$result['default_vat_code'].')' |
|
| 1986 | - $this->multiprices_recuperableonly[$i]=$result["recuperableonly"]; |
|
| 1985 | + $this->multiprices_tva_tx[$i] = $result["tva_tx"]; // TODO Add ' ('.$result['default_vat_code'].')' |
|
| 1986 | + $this->multiprices_recuperableonly[$i] = $result["recuperableonly"]; |
|
| 1987 | 1987 | |
| 1988 | 1988 | // Price by quantity |
| 1989 | 1989 | /* |
@@ -2028,50 +2028,50 @@ discard block |
||
| 2028 | 2028 | } |
| 2029 | 2029 | } |
| 2030 | 2030 | } |
| 2031 | - elseif (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) // prices per customers |
|
| 2031 | + elseif (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) // prices per customers |
|
| 2032 | 2032 | { |
| 2033 | 2033 | // Nothing loaded by default. List may be very long. |
| 2034 | 2034 | } |
| 2035 | - else if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY)) // prices per quantity |
|
| 2035 | + else if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY)) // prices per quantity |
|
| 2036 | 2036 | { |
| 2037 | 2037 | $sql = "SELECT price, price_ttc, price_min, price_min_ttc,"; |
| 2038 | - $sql.= " price_base_type, tva_tx, default_vat_code, tosell, price_by_qty, rowid"; |
|
| 2039 | - $sql.= " FROM ".MAIN_DB_PREFIX."product_price"; |
|
| 2040 | - $sql.= " WHERE fk_product = ".$this->id; |
|
| 2041 | - $sql.= " ORDER BY date_price DESC, rowid DESC"; |
|
| 2042 | - $sql.= " LIMIT 1"; |
|
| 2038 | + $sql .= " price_base_type, tva_tx, default_vat_code, tosell, price_by_qty, rowid"; |
|
| 2039 | + $sql .= " FROM ".MAIN_DB_PREFIX."product_price"; |
|
| 2040 | + $sql .= " WHERE fk_product = ".$this->id; |
|
| 2041 | + $sql .= " ORDER BY date_price DESC, rowid DESC"; |
|
| 2042 | + $sql .= " LIMIT 1"; |
|
| 2043 | 2043 | $resql = $this->db->query($sql); |
| 2044 | 2044 | if ($resql) |
| 2045 | 2045 | { |
| 2046 | 2046 | $result = $this->db->fetch_array($resql); |
| 2047 | 2047 | |
| 2048 | 2048 | // Price by quantity |
| 2049 | - $this->prices_by_qty[0]=$result["price_by_qty"]; |
|
| 2050 | - $this->prices_by_qty_id[0]=$result["rowid"]; |
|
| 2049 | + $this->prices_by_qty[0] = $result["price_by_qty"]; |
|
| 2050 | + $this->prices_by_qty_id[0] = $result["rowid"]; |
|
| 2051 | 2051 | // Récuperation de la liste des prix selon qty si flag positionné |
| 2052 | 2052 | if ($this->prices_by_qty[0] == 1) |
| 2053 | 2053 | { |
| 2054 | 2054 | $sql = "SELECT rowid,price, unitprice, quantity, remise_percent, remise, remise, price_base_type"; |
| 2055 | - $sql.= " FROM ".MAIN_DB_PREFIX."product_price_by_qty"; |
|
| 2056 | - $sql.= " WHERE fk_product_price = ".$this->prices_by_qty_id[0]; |
|
| 2057 | - $sql.= " ORDER BY quantity ASC"; |
|
| 2058 | - $resultat=array(); |
|
| 2055 | + $sql .= " FROM ".MAIN_DB_PREFIX."product_price_by_qty"; |
|
| 2056 | + $sql .= " WHERE fk_product_price = ".$this->prices_by_qty_id[0]; |
|
| 2057 | + $sql .= " ORDER BY quantity ASC"; |
|
| 2058 | + $resultat = array(); |
|
| 2059 | 2059 | $resql = $this->db->query($sql); |
| 2060 | 2060 | if ($resql) |
| 2061 | 2061 | { |
| 2062 | - $ii=0; |
|
| 2063 | - while ($result= $this->db->fetch_array($resql)) { |
|
| 2064 | - $resultat[$ii]=array(); |
|
| 2065 | - $resultat[$ii]["rowid"]=$result["rowid"]; |
|
| 2066 | - $resultat[$ii]["price"]= $result["price"]; |
|
| 2067 | - $resultat[$ii]["unitprice"]= $result["unitprice"]; |
|
| 2068 | - $resultat[$ii]["quantity"]= $result["quantity"]; |
|
| 2069 | - $resultat[$ii]["remise_percent"]= $result["remise_percent"]; |
|
| 2062 | + $ii = 0; |
|
| 2063 | + while ($result = $this->db->fetch_array($resql)) { |
|
| 2064 | + $resultat[$ii] = array(); |
|
| 2065 | + $resultat[$ii]["rowid"] = $result["rowid"]; |
|
| 2066 | + $resultat[$ii]["price"] = $result["price"]; |
|
| 2067 | + $resultat[$ii]["unitprice"] = $result["unitprice"]; |
|
| 2068 | + $resultat[$ii]["quantity"] = $result["quantity"]; |
|
| 2069 | + $resultat[$ii]["remise_percent"] = $result["remise_percent"]; |
|
| 2070 | 2070 | //$resultat[$ii]["remise"]= $result["remise"]; // deprecated |
| 2071 | - $resultat[$ii]["price_base_type"]= $result["price_base_type"]; |
|
| 2071 | + $resultat[$ii]["price_base_type"] = $result["price_base_type"]; |
|
| 2072 | 2072 | $ii++; |
| 2073 | 2073 | } |
| 2074 | - $this->prices_by_qty_list[0]=$resultat; |
|
| 2074 | + $this->prices_by_qty_list[0] = $resultat; |
|
| 2075 | 2075 | } |
| 2076 | 2076 | else |
| 2077 | 2077 | { |
@@ -2086,7 +2086,7 @@ discard block |
||
| 2086 | 2086 | return -1; |
| 2087 | 2087 | } |
| 2088 | 2088 | } |
| 2089 | - else if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) // prices per customer and quantity |
|
| 2089 | + else if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) // prices per customer and quantity |
|
| 2090 | 2090 | { |
| 2091 | 2091 | // Not yet implemented |
| 2092 | 2092 | } |
@@ -2101,7 +2101,7 @@ discard block |
||
| 2101 | 2101 | $this->price = $price_result; |
| 2102 | 2102 | // Calculate the VAT |
| 2103 | 2103 | $this->price_ttc = price2num($this->price) * (1 + ($this->tva_tx / 100)); |
| 2104 | - $this->price_ttc = price2num($this->price_ttc,'MU'); |
|
| 2104 | + $this->price_ttc = price2num($this->price_ttc, 'MU'); |
|
| 2105 | 2105 | } |
| 2106 | 2106 | } |
| 2107 | 2107 | |
@@ -2130,38 +2130,38 @@ discard block |
||
| 2130 | 2130 | * @param int $socid Id societe |
| 2131 | 2131 | * @return array Tableau des stats |
| 2132 | 2132 | */ |
| 2133 | - function load_stats_propale($socid=0) |
|
| 2133 | + function load_stats_propale($socid = 0) |
|
| 2134 | 2134 | { |
| 2135 | 2135 | global $conf; |
| 2136 | 2136 | global $user; |
| 2137 | 2137 | |
| 2138 | 2138 | $sql = "SELECT COUNT(DISTINCT p.fk_soc) as nb_customers, COUNT(DISTINCT p.rowid) as nb,"; |
| 2139 | - $sql.= " COUNT(pd.rowid) as nb_rows, SUM(pd.qty) as qty"; |
|
| 2140 | - $sql.= " FROM ".MAIN_DB_PREFIX."propaldet as pd"; |
|
| 2141 | - $sql.= ", ".MAIN_DB_PREFIX."propal as p"; |
|
| 2142 | - $sql.= ", ".MAIN_DB_PREFIX."societe as s"; |
|
| 2139 | + $sql .= " COUNT(pd.rowid) as nb_rows, SUM(pd.qty) as qty"; |
|
| 2140 | + $sql .= " FROM ".MAIN_DB_PREFIX."propaldet as pd"; |
|
| 2141 | + $sql .= ", ".MAIN_DB_PREFIX."propal as p"; |
|
| 2142 | + $sql .= ", ".MAIN_DB_PREFIX."societe as s"; |
|
| 2143 | 2143 | if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; |
| 2144 | - $sql.= " WHERE p.rowid = pd.fk_propal"; |
|
| 2145 | - $sql.= " AND p.fk_soc = s.rowid"; |
|
| 2146 | - $sql.= " AND p.entity IN (".getEntity('propal').")"; |
|
| 2147 | - $sql.= " AND pd.fk_product = ".$this->id; |
|
| 2148 | - if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND p.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id; |
|
| 2144 | + $sql .= " WHERE p.rowid = pd.fk_propal"; |
|
| 2145 | + $sql .= " AND p.fk_soc = s.rowid"; |
|
| 2146 | + $sql .= " AND p.entity IN (".getEntity('propal').")"; |
|
| 2147 | + $sql .= " AND pd.fk_product = ".$this->id; |
|
| 2148 | + if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND p.fk_soc = sc.fk_soc AND sc.fk_user = ".$user->id; |
|
| 2149 | 2149 | //$sql.= " AND pr.fk_statut != 0"; |
| 2150 | - if ($socid > 0) $sql.= " AND p.fk_soc = ".$socid; |
|
| 2150 | + if ($socid > 0) $sql .= " AND p.fk_soc = ".$socid; |
|
| 2151 | 2151 | |
| 2152 | 2152 | $result = $this->db->query($sql); |
| 2153 | - if ( $result ) |
|
| 2153 | + if ($result) |
|
| 2154 | 2154 | { |
| 2155 | - $obj=$this->db->fetch_object($result); |
|
| 2156 | - $this->stats_propale['customers']=$obj->nb_customers; |
|
| 2157 | - $this->stats_propale['nb']=$obj->nb; |
|
| 2158 | - $this->stats_propale['rows']=$obj->nb_rows; |
|
| 2159 | - $this->stats_propale['qty']=$obj->qty?$obj->qty:0; |
|
| 2155 | + $obj = $this->db->fetch_object($result); |
|
| 2156 | + $this->stats_propale['customers'] = $obj->nb_customers; |
|
| 2157 | + $this->stats_propale['nb'] = $obj->nb; |
|
| 2158 | + $this->stats_propale['rows'] = $obj->nb_rows; |
|
| 2159 | + $this->stats_propale['qty'] = $obj->qty ? $obj->qty : 0; |
|
| 2160 | 2160 | return 1; |
| 2161 | 2161 | } |
| 2162 | 2162 | else |
| 2163 | 2163 | { |
| 2164 | - $this->error=$this->db->error(); |
|
| 2164 | + $this->error = $this->db->error(); |
|
| 2165 | 2165 | return -1; |
| 2166 | 2166 | } |
| 2167 | 2167 | } |
@@ -2173,38 +2173,38 @@ discard block |
||
| 2173 | 2173 | * @param int $socid Id thirdparty |
| 2174 | 2174 | * @return array Tableau des stats |
| 2175 | 2175 | */ |
| 2176 | - function load_stats_proposal_supplier($socid=0) |
|
| 2176 | + function load_stats_proposal_supplier($socid = 0) |
|
| 2177 | 2177 | { |
| 2178 | 2178 | global $conf; |
| 2179 | 2179 | global $user; |
| 2180 | 2180 | |
| 2181 | 2181 | $sql = "SELECT COUNT(DISTINCT p.fk_soc) as nb_suppliers, COUNT(DISTINCT p.rowid) as nb,"; |
| 2182 | - $sql.= " COUNT(pd.rowid) as nb_rows, SUM(pd.qty) as qty"; |
|
| 2183 | - $sql.= " FROM ".MAIN_DB_PREFIX."supplier_proposaldet as pd"; |
|
| 2184 | - $sql.= ", ".MAIN_DB_PREFIX."supplier_proposal as p"; |
|
| 2185 | - $sql.= ", ".MAIN_DB_PREFIX."societe as s"; |
|
| 2182 | + $sql .= " COUNT(pd.rowid) as nb_rows, SUM(pd.qty) as qty"; |
|
| 2183 | + $sql .= " FROM ".MAIN_DB_PREFIX."supplier_proposaldet as pd"; |
|
| 2184 | + $sql .= ", ".MAIN_DB_PREFIX."supplier_proposal as p"; |
|
| 2185 | + $sql .= ", ".MAIN_DB_PREFIX."societe as s"; |
|
| 2186 | 2186 | if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; |
| 2187 | - $sql.= " WHERE p.rowid = pd.fk_supplier_proposal"; |
|
| 2188 | - $sql.= " AND p.fk_soc = s.rowid"; |
|
| 2189 | - $sql.= " AND p.entity IN (".getEntity('supplier_proposal').")"; |
|
| 2190 | - $sql.= " AND pd.fk_product = ".$this->id; |
|
| 2191 | - if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND p.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id; |
|
| 2187 | + $sql .= " WHERE p.rowid = pd.fk_supplier_proposal"; |
|
| 2188 | + $sql .= " AND p.fk_soc = s.rowid"; |
|
| 2189 | + $sql .= " AND p.entity IN (".getEntity('supplier_proposal').")"; |
|
| 2190 | + $sql .= " AND pd.fk_product = ".$this->id; |
|
| 2191 | + if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND p.fk_soc = sc.fk_soc AND sc.fk_user = ".$user->id; |
|
| 2192 | 2192 | //$sql.= " AND pr.fk_statut != 0"; |
| 2193 | - if ($socid > 0) $sql.= " AND p.fk_soc = ".$socid; |
|
| 2193 | + if ($socid > 0) $sql .= " AND p.fk_soc = ".$socid; |
|
| 2194 | 2194 | |
| 2195 | 2195 | $result = $this->db->query($sql); |
| 2196 | - if ( $result ) |
|
| 2196 | + if ($result) |
|
| 2197 | 2197 | { |
| 2198 | - $obj=$this->db->fetch_object($result); |
|
| 2199 | - $this->stats_proposal_supplier['suppliers']=$obj->nb_suppliers; |
|
| 2200 | - $this->stats_proposal_supplier['nb']=$obj->nb; |
|
| 2201 | - $this->stats_proposal_supplier['rows']=$obj->nb_rows; |
|
| 2202 | - $this->stats_proposal_supplier['qty']=$obj->qty?$obj->qty:0; |
|
| 2198 | + $obj = $this->db->fetch_object($result); |
|
| 2199 | + $this->stats_proposal_supplier['suppliers'] = $obj->nb_suppliers; |
|
| 2200 | + $this->stats_proposal_supplier['nb'] = $obj->nb; |
|
| 2201 | + $this->stats_proposal_supplier['rows'] = $obj->nb_rows; |
|
| 2202 | + $this->stats_proposal_supplier['qty'] = $obj->qty ? $obj->qty : 0; |
|
| 2203 | 2203 | return 1; |
| 2204 | 2204 | } |
| 2205 | 2205 | else |
| 2206 | 2206 | { |
| 2207 | - $this->error=$this->db->error(); |
|
| 2207 | + $this->error = $this->db->error(); |
|
| 2208 | 2208 | return -1; |
| 2209 | 2209 | } |
| 2210 | 2210 | } |
@@ -2218,39 +2218,39 @@ discard block |
||
| 2218 | 2218 | * @param int $forVirtualStock Ignore rights filter for virtual stock calculation. |
| 2219 | 2219 | * @return array Array of stats (nb=nb of order, qty=qty ordered) |
| 2220 | 2220 | */ |
| 2221 | - function load_stats_commande($socid=0,$filtrestatut='', $forVirtualStock = 0) |
|
| 2221 | + function load_stats_commande($socid = 0, $filtrestatut = '', $forVirtualStock = 0) |
|
| 2222 | 2222 | { |
| 2223 | - global $conf,$user; |
|
| 2223 | + global $conf, $user; |
|
| 2224 | 2224 | |
| 2225 | 2225 | $sql = "SELECT COUNT(DISTINCT c.fk_soc) as nb_customers, COUNT(DISTINCT c.rowid) as nb,"; |
| 2226 | - $sql.= " COUNT(cd.rowid) as nb_rows, SUM(cd.qty) as qty"; |
|
| 2227 | - $sql.= " FROM ".MAIN_DB_PREFIX."commandedet as cd"; |
|
| 2228 | - $sql.= ", ".MAIN_DB_PREFIX."commande as c"; |
|
| 2229 | - $sql.= ", ".MAIN_DB_PREFIX."societe as s"; |
|
| 2230 | - if (!$user->rights->societe->client->voir && !$socid && !$forVirtualStock) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; |
|
| 2231 | - $sql.= " WHERE c.rowid = cd.fk_commande"; |
|
| 2232 | - $sql.= " AND c.fk_soc = s.rowid"; |
|
| 2233 | - $sql.= " AND c.entity IN (".getEntity('commande').")"; |
|
| 2234 | - $sql.= " AND cd.fk_product = ".$this->id; |
|
| 2235 | - if (!$user->rights->societe->client->voir && !$socid && !$forVirtualStock) $sql.= " AND c.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id; |
|
| 2236 | - if ($socid > 0) $sql.= " AND c.fk_soc = ".$socid; |
|
| 2237 | - if ($filtrestatut <> '') $sql.= " AND c.fk_statut in (".$filtrestatut.")"; |
|
| 2226 | + $sql .= " COUNT(cd.rowid) as nb_rows, SUM(cd.qty) as qty"; |
|
| 2227 | + $sql .= " FROM ".MAIN_DB_PREFIX."commandedet as cd"; |
|
| 2228 | + $sql .= ", ".MAIN_DB_PREFIX."commande as c"; |
|
| 2229 | + $sql .= ", ".MAIN_DB_PREFIX."societe as s"; |
|
| 2230 | + if (!$user->rights->societe->client->voir && !$socid && !$forVirtualStock) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; |
|
| 2231 | + $sql .= " WHERE c.rowid = cd.fk_commande"; |
|
| 2232 | + $sql .= " AND c.fk_soc = s.rowid"; |
|
| 2233 | + $sql .= " AND c.entity IN (".getEntity('commande').")"; |
|
| 2234 | + $sql .= " AND cd.fk_product = ".$this->id; |
|
| 2235 | + if (!$user->rights->societe->client->voir && !$socid && !$forVirtualStock) $sql .= " AND c.fk_soc = sc.fk_soc AND sc.fk_user = ".$user->id; |
|
| 2236 | + if ($socid > 0) $sql .= " AND c.fk_soc = ".$socid; |
|
| 2237 | + if ($filtrestatut <> '') $sql .= " AND c.fk_statut in (".$filtrestatut.")"; |
|
| 2238 | 2238 | |
| 2239 | 2239 | $result = $this->db->query($sql); |
| 2240 | - if ( $result ) |
|
| 2240 | + if ($result) |
|
| 2241 | 2241 | { |
| 2242 | - $obj=$this->db->fetch_object($result); |
|
| 2243 | - $this->stats_commande['customers']=$obj->nb_customers; |
|
| 2244 | - $this->stats_commande['nb']=$obj->nb; |
|
| 2245 | - $this->stats_commande['rows']=$obj->nb_rows; |
|
| 2246 | - $this->stats_commande['qty']=$obj->qty?$obj->qty:0; |
|
| 2242 | + $obj = $this->db->fetch_object($result); |
|
| 2243 | + $this->stats_commande['customers'] = $obj->nb_customers; |
|
| 2244 | + $this->stats_commande['nb'] = $obj->nb; |
|
| 2245 | + $this->stats_commande['rows'] = $obj->nb_rows; |
|
| 2246 | + $this->stats_commande['qty'] = $obj->qty ? $obj->qty : 0; |
|
| 2247 | 2247 | |
| 2248 | 2248 | // if it's a virtual product, maybe it is in order by extension |
| 2249 | - if (! empty($conf->global->ORDER_ADD_ORDERS_WITH_PARENT_PROD_IF_INCDEC)) |
|
| 2249 | + if (!empty($conf->global->ORDER_ADD_ORDERS_WITH_PARENT_PROD_IF_INCDEC)) |
|
| 2250 | 2250 | { |
| 2251 | 2251 | $TFather = $this->getFather(); |
| 2252 | 2252 | if (is_array($TFather) && !empty($TFather)) { |
| 2253 | - foreach($TFather as &$fatherData) { |
|
| 2253 | + foreach ($TFather as &$fatherData) { |
|
| 2254 | 2254 | $pFather = new Product($this->db); |
| 2255 | 2255 | $pFather->id = $fatherData['id']; |
| 2256 | 2256 | $qtyCoef = $fatherData['qty']; |
@@ -2258,10 +2258,10 @@ discard block |
||
| 2258 | 2258 | if ($fatherData['incdec']) { |
| 2259 | 2259 | $pFather->load_stats_commande($socid, $filtrestatut); |
| 2260 | 2260 | |
| 2261 | - $this->stats_commande['customers']+=$pFather->stats_commande['customers']; |
|
| 2262 | - $this->stats_commande['nb']+=$pFather->stats_commande['nb']; |
|
| 2263 | - $this->stats_commande['rows']+=$pFather->stats_commande['rows']; |
|
| 2264 | - $this->stats_commande['qty']+=$pFather->stats_commande['qty'] * $qtyCoef; |
|
| 2261 | + $this->stats_commande['customers'] += $pFather->stats_commande['customers']; |
|
| 2262 | + $this->stats_commande['nb'] += $pFather->stats_commande['nb']; |
|
| 2263 | + $this->stats_commande['rows'] += $pFather->stats_commande['rows']; |
|
| 2264 | + $this->stats_commande['qty'] += $pFather->stats_commande['qty'] * $qtyCoef; |
|
| 2265 | 2265 | |
| 2266 | 2266 | } |
| 2267 | 2267 | } |
@@ -2271,9 +2271,9 @@ discard block |
||
| 2271 | 2271 | // If stock decrease is on invoice validation, the theorical stock continue to |
| 2272 | 2272 | // count the orders to ship in theorical stock when some are already removed b invoice validation. |
| 2273 | 2273 | // If option DECREASE_ONLY_UNINVOICEDPRODUCTS is on, we make a compensation. |
| 2274 | - if (! empty($conf->global->STOCK_CALCULATE_ON_BILL)) |
|
| 2274 | + if (!empty($conf->global->STOCK_CALCULATE_ON_BILL)) |
|
| 2275 | 2275 | { |
| 2276 | - if (! empty($conf->global->DECREASE_ONLY_UNINVOICEDPRODUCTS)) |
|
| 2276 | + if (!empty($conf->global->DECREASE_ONLY_UNINVOICEDPRODUCTS)) |
|
| 2277 | 2277 | { |
| 2278 | 2278 | $adeduire = 0; |
| 2279 | 2279 | $sql = "SELECT sum(fd.qty) as count FROM ".MAIN_DB_PREFIX."facturedet fd "; |
@@ -2284,7 +2284,7 @@ discard block |
||
| 2284 | 2284 | dol_syslog(__METHOD__.":: sql $sql", LOG_NOTICE); |
| 2285 | 2285 | |
| 2286 | 2286 | $resql = $this->db->query($sql); |
| 2287 | - if ( $resql ) |
|
| 2287 | + if ($resql) |
|
| 2288 | 2288 | { |
| 2289 | 2289 | if ($this->db->num_rows($resql) > 0) |
| 2290 | 2290 | { |
@@ -2301,7 +2301,7 @@ discard block |
||
| 2301 | 2301 | } |
| 2302 | 2302 | else |
| 2303 | 2303 | { |
| 2304 | - $this->error=$this->db->error(); |
|
| 2304 | + $this->error = $this->db->error(); |
|
| 2305 | 2305 | return -1; |
| 2306 | 2306 | } |
| 2307 | 2307 | } |
@@ -2314,37 +2314,37 @@ discard block |
||
| 2314 | 2314 | * @param int $forVirtualStock Ignore rights filter for virtual stock calculation. |
| 2315 | 2315 | * @return array Tableau des stats |
| 2316 | 2316 | */ |
| 2317 | - function load_stats_commande_fournisseur($socid=0,$filtrestatut='', $forVirtualStock = 0) |
|
| 2317 | + function load_stats_commande_fournisseur($socid = 0, $filtrestatut = '', $forVirtualStock = 0) |
|
| 2318 | 2318 | { |
| 2319 | - global $conf,$user; |
|
| 2319 | + global $conf, $user; |
|
| 2320 | 2320 | |
| 2321 | 2321 | $sql = "SELECT COUNT(DISTINCT c.fk_soc) as nb_suppliers, COUNT(DISTINCT c.rowid) as nb,"; |
| 2322 | - $sql.= " COUNT(cd.rowid) as nb_rows, SUM(cd.qty) as qty"; |
|
| 2323 | - $sql.= " FROM ".MAIN_DB_PREFIX."commande_fournisseurdet as cd"; |
|
| 2324 | - $sql.= ", ".MAIN_DB_PREFIX."commande_fournisseur as c"; |
|
| 2325 | - $sql.= ", ".MAIN_DB_PREFIX."societe as s"; |
|
| 2326 | - if (!$user->rights->societe->client->voir && !$socid && !$forVirtualStock) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; |
|
| 2327 | - $sql.= " WHERE c.rowid = cd.fk_commande"; |
|
| 2328 | - $sql.= " AND c.fk_soc = s.rowid"; |
|
| 2329 | - $sql.= " AND c.entity IN (".getEntity('supplier_order').")"; |
|
| 2330 | - $sql.= " AND cd.fk_product = ".$this->id; |
|
| 2331 | - if (!$user->rights->societe->client->voir && !$socid && !$forVirtualStock) $sql.= " AND c.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id; |
|
| 2332 | - if ($socid > 0) $sql.= " AND c.fk_soc = ".$socid; |
|
| 2333 | - if ($filtrestatut != '') $sql.= " AND c.fk_statut in (".$filtrestatut.")"; // Peut valoir 0 |
|
| 2322 | + $sql .= " COUNT(cd.rowid) as nb_rows, SUM(cd.qty) as qty"; |
|
| 2323 | + $sql .= " FROM ".MAIN_DB_PREFIX."commande_fournisseurdet as cd"; |
|
| 2324 | + $sql .= ", ".MAIN_DB_PREFIX."commande_fournisseur as c"; |
|
| 2325 | + $sql .= ", ".MAIN_DB_PREFIX."societe as s"; |
|
| 2326 | + if (!$user->rights->societe->client->voir && !$socid && !$forVirtualStock) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; |
|
| 2327 | + $sql .= " WHERE c.rowid = cd.fk_commande"; |
|
| 2328 | + $sql .= " AND c.fk_soc = s.rowid"; |
|
| 2329 | + $sql .= " AND c.entity IN (".getEntity('supplier_order').")"; |
|
| 2330 | + $sql .= " AND cd.fk_product = ".$this->id; |
|
| 2331 | + if (!$user->rights->societe->client->voir && !$socid && !$forVirtualStock) $sql .= " AND c.fk_soc = sc.fk_soc AND sc.fk_user = ".$user->id; |
|
| 2332 | + if ($socid > 0) $sql .= " AND c.fk_soc = ".$socid; |
|
| 2333 | + if ($filtrestatut != '') $sql .= " AND c.fk_statut in (".$filtrestatut.")"; // Peut valoir 0 |
|
| 2334 | 2334 | |
| 2335 | 2335 | $result = $this->db->query($sql); |
| 2336 | - if ( $result ) |
|
| 2336 | + if ($result) |
|
| 2337 | 2337 | { |
| 2338 | - $obj=$this->db->fetch_object($result); |
|
| 2339 | - $this->stats_commande_fournisseur['suppliers']=$obj->nb_suppliers; |
|
| 2340 | - $this->stats_commande_fournisseur['nb']=$obj->nb; |
|
| 2341 | - $this->stats_commande_fournisseur['rows']=$obj->nb_rows; |
|
| 2342 | - $this->stats_commande_fournisseur['qty']=$obj->qty?$obj->qty:0; |
|
| 2338 | + $obj = $this->db->fetch_object($result); |
|
| 2339 | + $this->stats_commande_fournisseur['suppliers'] = $obj->nb_suppliers; |
|
| 2340 | + $this->stats_commande_fournisseur['nb'] = $obj->nb; |
|
| 2341 | + $this->stats_commande_fournisseur['rows'] = $obj->nb_rows; |
|
| 2342 | + $this->stats_commande_fournisseur['qty'] = $obj->qty ? $obj->qty : 0; |
|
| 2343 | 2343 | return 1; |
| 2344 | 2344 | } |
| 2345 | 2345 | else |
| 2346 | 2346 | { |
| 2347 | - $this->error=$this->db->error().' sql='.$sql; |
|
| 2347 | + $this->error = $this->db->error().' sql='.$sql; |
|
| 2348 | 2348 | return -1; |
| 2349 | 2349 | } |
| 2350 | 2350 | } |
@@ -2357,41 +2357,41 @@ discard block |
||
| 2357 | 2357 | * @param int $forVirtualStock Ignore rights filter for virtual stock calculation. |
| 2358 | 2358 | * @return array Tableau des stats |
| 2359 | 2359 | */ |
| 2360 | - function load_stats_sending($socid=0,$filtrestatut='', $forVirtualStock = 0) |
|
| 2360 | + function load_stats_sending($socid = 0, $filtrestatut = '', $forVirtualStock = 0) |
|
| 2361 | 2361 | { |
| 2362 | - global $conf,$user; |
|
| 2362 | + global $conf, $user; |
|
| 2363 | 2363 | |
| 2364 | 2364 | $sql = "SELECT COUNT(DISTINCT e.fk_soc) as nb_customers, COUNT(DISTINCT e.rowid) as nb,"; |
| 2365 | - $sql.= " COUNT(ed.rowid) as nb_rows, SUM(ed.qty) as qty"; |
|
| 2366 | - $sql.= " FROM ".MAIN_DB_PREFIX."expeditiondet as ed"; |
|
| 2367 | - $sql.= ", ".MAIN_DB_PREFIX."commandedet as cd"; |
|
| 2368 | - $sql.= ", ".MAIN_DB_PREFIX."commande as c"; |
|
| 2369 | - $sql.= ", ".MAIN_DB_PREFIX."expedition as e"; |
|
| 2370 | - $sql.= ", ".MAIN_DB_PREFIX."societe as s"; |
|
| 2371 | - if (!$user->rights->societe->client->voir && !$socid && !$forVirtualStock) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; |
|
| 2372 | - $sql.= " WHERE e.rowid = ed.fk_expedition"; |
|
| 2373 | - $sql.= " AND c.rowid = cd.fk_commande"; |
|
| 2374 | - $sql.= " AND e.fk_soc = s.rowid"; |
|
| 2375 | - $sql.= " AND e.entity IN (".getEntity('expedition').")"; |
|
| 2376 | - $sql.= " AND ed.fk_origin_line = cd.rowid"; |
|
| 2377 | - $sql.= " AND cd.fk_product = ".$this->id; |
|
| 2378 | - if (!$user->rights->societe->client->voir && !$socid && !$forVirtualStock) $sql.= " AND e.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id; |
|
| 2379 | - if ($socid > 0) $sql.= " AND e.fk_soc = ".$socid; |
|
| 2380 | - if ($filtrestatut <> '') $sql.= " AND c.fk_statut in (".$filtrestatut.")"; |
|
| 2365 | + $sql .= " COUNT(ed.rowid) as nb_rows, SUM(ed.qty) as qty"; |
|
| 2366 | + $sql .= " FROM ".MAIN_DB_PREFIX."expeditiondet as ed"; |
|
| 2367 | + $sql .= ", ".MAIN_DB_PREFIX."commandedet as cd"; |
|
| 2368 | + $sql .= ", ".MAIN_DB_PREFIX."commande as c"; |
|
| 2369 | + $sql .= ", ".MAIN_DB_PREFIX."expedition as e"; |
|
| 2370 | + $sql .= ", ".MAIN_DB_PREFIX."societe as s"; |
|
| 2371 | + if (!$user->rights->societe->client->voir && !$socid && !$forVirtualStock) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; |
|
| 2372 | + $sql .= " WHERE e.rowid = ed.fk_expedition"; |
|
| 2373 | + $sql .= " AND c.rowid = cd.fk_commande"; |
|
| 2374 | + $sql .= " AND e.fk_soc = s.rowid"; |
|
| 2375 | + $sql .= " AND e.entity IN (".getEntity('expedition').")"; |
|
| 2376 | + $sql .= " AND ed.fk_origin_line = cd.rowid"; |
|
| 2377 | + $sql .= " AND cd.fk_product = ".$this->id; |
|
| 2378 | + if (!$user->rights->societe->client->voir && !$socid && !$forVirtualStock) $sql .= " AND e.fk_soc = sc.fk_soc AND sc.fk_user = ".$user->id; |
|
| 2379 | + if ($socid > 0) $sql .= " AND e.fk_soc = ".$socid; |
|
| 2380 | + if ($filtrestatut <> '') $sql .= " AND c.fk_statut in (".$filtrestatut.")"; |
|
| 2381 | 2381 | |
| 2382 | 2382 | $result = $this->db->query($sql); |
| 2383 | - if ( $result ) |
|
| 2383 | + if ($result) |
|
| 2384 | 2384 | { |
| 2385 | - $obj=$this->db->fetch_object($result); |
|
| 2386 | - $this->stats_expedition['customers']=$obj->nb_customers; |
|
| 2387 | - $this->stats_expedition['nb']=$obj->nb; |
|
| 2388 | - $this->stats_expedition['rows']=$obj->nb_rows; |
|
| 2389 | - $this->stats_expedition['qty']=$obj->qty?$obj->qty:0; |
|
| 2385 | + $obj = $this->db->fetch_object($result); |
|
| 2386 | + $this->stats_expedition['customers'] = $obj->nb_customers; |
|
| 2387 | + $this->stats_expedition['nb'] = $obj->nb; |
|
| 2388 | + $this->stats_expedition['rows'] = $obj->nb_rows; |
|
| 2389 | + $this->stats_expedition['qty'] = $obj->qty ? $obj->qty : 0; |
|
| 2390 | 2390 | return 1; |
| 2391 | 2391 | } |
| 2392 | 2392 | else |
| 2393 | 2393 | { |
| 2394 | - $this->error=$this->db->error(); |
|
| 2394 | + $this->error = $this->db->error(); |
|
| 2395 | 2395 | return -1; |
| 2396 | 2396 | } |
| 2397 | 2397 | } |
@@ -2404,37 +2404,37 @@ discard block |
||
| 2404 | 2404 | * @param int $forVirtualStock Ignore rights filter for virtual stock calculation. |
| 2405 | 2405 | * @return array Tableau des stats |
| 2406 | 2406 | */ |
| 2407 | - function load_stats_reception($socid=0,$filtrestatut='', $forVirtualStock = 0) |
|
| 2407 | + function load_stats_reception($socid = 0, $filtrestatut = '', $forVirtualStock = 0) |
|
| 2408 | 2408 | { |
| 2409 | - global $conf,$user; |
|
| 2409 | + global $conf, $user; |
|
| 2410 | 2410 | |
| 2411 | 2411 | $sql = "SELECT COUNT(DISTINCT cf.fk_soc) as nb_customers, COUNT(DISTINCT cf.rowid) as nb,"; |
| 2412 | - $sql.= " COUNT(fd.rowid) as nb_rows, SUM(fd.qty) as qty"; |
|
| 2413 | - $sql.= " FROM ".MAIN_DB_PREFIX."commande_fournisseur_dispatch as fd"; |
|
| 2414 | - $sql.= ", ".MAIN_DB_PREFIX."commande_fournisseur as cf"; |
|
| 2415 | - $sql.= ", ".MAIN_DB_PREFIX."societe as s"; |
|
| 2416 | - if (!$user->rights->societe->client->voir && !$socid && !$forVirtualStock) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; |
|
| 2417 | - $sql.= " WHERE cf.rowid = fd.fk_commande"; |
|
| 2418 | - $sql.= " AND cf.fk_soc = s.rowid"; |
|
| 2419 | - $sql.= " AND cf.entity IN (".getEntity('supplier_order').")"; |
|
| 2420 | - $sql.= " AND fd.fk_product = ".$this->id; |
|
| 2421 | - if (!$user->rights->societe->client->voir && !$socid && !$forVirtualStock) $sql.= " AND cf.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id; |
|
| 2422 | - if ($socid > 0) $sql.= " AND cf.fk_soc = ".$socid; |
|
| 2423 | - if ($filtrestatut <> '') $sql.= " AND cf.fk_statut in (".$filtrestatut.")"; |
|
| 2412 | + $sql .= " COUNT(fd.rowid) as nb_rows, SUM(fd.qty) as qty"; |
|
| 2413 | + $sql .= " FROM ".MAIN_DB_PREFIX."commande_fournisseur_dispatch as fd"; |
|
| 2414 | + $sql .= ", ".MAIN_DB_PREFIX."commande_fournisseur as cf"; |
|
| 2415 | + $sql .= ", ".MAIN_DB_PREFIX."societe as s"; |
|
| 2416 | + if (!$user->rights->societe->client->voir && !$socid && !$forVirtualStock) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; |
|
| 2417 | + $sql .= " WHERE cf.rowid = fd.fk_commande"; |
|
| 2418 | + $sql .= " AND cf.fk_soc = s.rowid"; |
|
| 2419 | + $sql .= " AND cf.entity IN (".getEntity('supplier_order').")"; |
|
| 2420 | + $sql .= " AND fd.fk_product = ".$this->id; |
|
| 2421 | + if (!$user->rights->societe->client->voir && !$socid && !$forVirtualStock) $sql .= " AND cf.fk_soc = sc.fk_soc AND sc.fk_user = ".$user->id; |
|
| 2422 | + if ($socid > 0) $sql .= " AND cf.fk_soc = ".$socid; |
|
| 2423 | + if ($filtrestatut <> '') $sql .= " AND cf.fk_statut in (".$filtrestatut.")"; |
|
| 2424 | 2424 | |
| 2425 | 2425 | $result = $this->db->query($sql); |
| 2426 | - if ( $result ) |
|
| 2426 | + if ($result) |
|
| 2427 | 2427 | { |
| 2428 | - $obj=$this->db->fetch_object($result); |
|
| 2429 | - $this->stats_reception['suppliers']=$obj->nb_customers; |
|
| 2430 | - $this->stats_reception['nb']=$obj->nb; |
|
| 2431 | - $this->stats_reception['rows']=$obj->nb_rows; |
|
| 2432 | - $this->stats_reception['qty']=$obj->qty?$obj->qty:0; |
|
| 2428 | + $obj = $this->db->fetch_object($result); |
|
| 2429 | + $this->stats_reception['suppliers'] = $obj->nb_customers; |
|
| 2430 | + $this->stats_reception['nb'] = $obj->nb; |
|
| 2431 | + $this->stats_reception['rows'] = $obj->nb_rows; |
|
| 2432 | + $this->stats_reception['qty'] = $obj->qty ? $obj->qty : 0; |
|
| 2433 | 2433 | return 1; |
| 2434 | 2434 | } |
| 2435 | 2435 | else |
| 2436 | 2436 | { |
| 2437 | - $this->error=$this->db->error(); |
|
| 2437 | + $this->error = $this->db->error(); |
|
| 2438 | 2438 | return -1; |
| 2439 | 2439 | } |
| 2440 | 2440 | } |
@@ -2445,38 +2445,38 @@ discard block |
||
| 2445 | 2445 | * @param int $socid Id societe |
| 2446 | 2446 | * @return array Tableau des stats |
| 2447 | 2447 | */ |
| 2448 | - function load_stats_contrat($socid=0) |
|
| 2448 | + function load_stats_contrat($socid = 0) |
|
| 2449 | 2449 | { |
| 2450 | 2450 | global $conf; |
| 2451 | 2451 | global $user; |
| 2452 | 2452 | |
| 2453 | 2453 | $sql = "SELECT COUNT(DISTINCT c.fk_soc) as nb_customers, COUNT(DISTINCT c.rowid) as nb,"; |
| 2454 | - $sql.= " COUNT(cd.rowid) as nb_rows, SUM(cd.qty) as qty"; |
|
| 2455 | - $sql.= " FROM ".MAIN_DB_PREFIX."contratdet as cd"; |
|
| 2456 | - $sql.= ", ".MAIN_DB_PREFIX."contrat as c"; |
|
| 2457 | - $sql.= ", ".MAIN_DB_PREFIX."societe as s"; |
|
| 2458 | - if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; |
|
| 2459 | - $sql.= " WHERE c.rowid = cd.fk_contrat"; |
|
| 2460 | - $sql.= " AND c.fk_soc = s.rowid"; |
|
| 2461 | - $sql.= " AND c.entity IN (".getEntity('contract').")"; |
|
| 2462 | - $sql.= " AND cd.fk_product = ".$this->id; |
|
| 2463 | - if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND c.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id; |
|
| 2454 | + $sql .= " COUNT(cd.rowid) as nb_rows, SUM(cd.qty) as qty"; |
|
| 2455 | + $sql .= " FROM ".MAIN_DB_PREFIX."contratdet as cd"; |
|
| 2456 | + $sql .= ", ".MAIN_DB_PREFIX."contrat as c"; |
|
| 2457 | + $sql .= ", ".MAIN_DB_PREFIX."societe as s"; |
|
| 2458 | + if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; |
|
| 2459 | + $sql .= " WHERE c.rowid = cd.fk_contrat"; |
|
| 2460 | + $sql .= " AND c.fk_soc = s.rowid"; |
|
| 2461 | + $sql .= " AND c.entity IN (".getEntity('contract').")"; |
|
| 2462 | + $sql .= " AND cd.fk_product = ".$this->id; |
|
| 2463 | + if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND c.fk_soc = sc.fk_soc AND sc.fk_user = ".$user->id; |
|
| 2464 | 2464 | //$sql.= " AND c.statut != 0"; |
| 2465 | - if ($socid > 0) $sql.= " AND c.fk_soc = ".$socid; |
|
| 2465 | + if ($socid > 0) $sql .= " AND c.fk_soc = ".$socid; |
|
| 2466 | 2466 | |
| 2467 | 2467 | $result = $this->db->query($sql); |
| 2468 | - if ( $result ) |
|
| 2468 | + if ($result) |
|
| 2469 | 2469 | { |
| 2470 | - $obj=$this->db->fetch_object($result); |
|
| 2471 | - $this->stats_contrat['customers']=$obj->nb_customers; |
|
| 2472 | - $this->stats_contrat['nb']=$obj->nb; |
|
| 2473 | - $this->stats_contrat['rows']=$obj->nb_rows; |
|
| 2474 | - $this->stats_contrat['qty']=$obj->qty?$obj->qty:0; |
|
| 2470 | + $obj = $this->db->fetch_object($result); |
|
| 2471 | + $this->stats_contrat['customers'] = $obj->nb_customers; |
|
| 2472 | + $this->stats_contrat['nb'] = $obj->nb; |
|
| 2473 | + $this->stats_contrat['rows'] = $obj->nb_rows; |
|
| 2474 | + $this->stats_contrat['qty'] = $obj->qty ? $obj->qty : 0; |
|
| 2475 | 2475 | return 1; |
| 2476 | 2476 | } |
| 2477 | 2477 | else |
| 2478 | 2478 | { |
| 2479 | - $this->error=$this->db->error().' sql='.$sql; |
|
| 2479 | + $this->error = $this->db->error().' sql='.$sql; |
|
| 2480 | 2480 | return -1; |
| 2481 | 2481 | } |
| 2482 | 2482 | } |
@@ -2487,38 +2487,38 @@ discard block |
||
| 2487 | 2487 | * @param int $socid Id societe |
| 2488 | 2488 | * @return array Tableau des stats |
| 2489 | 2489 | */ |
| 2490 | - function load_stats_facture($socid=0) |
|
| 2490 | + function load_stats_facture($socid = 0) |
|
| 2491 | 2491 | { |
| 2492 | 2492 | global $conf; |
| 2493 | 2493 | global $user; |
| 2494 | 2494 | |
| 2495 | 2495 | $sql = "SELECT COUNT(DISTINCT f.fk_soc) as nb_customers, COUNT(DISTINCT f.rowid) as nb,"; |
| 2496 | - $sql.= " COUNT(fd.rowid) as nb_rows, SUM(fd.qty) as qty"; |
|
| 2497 | - $sql.= " FROM ".MAIN_DB_PREFIX."facturedet as fd"; |
|
| 2498 | - $sql.= ", ".MAIN_DB_PREFIX."facture as f"; |
|
| 2499 | - $sql.= ", ".MAIN_DB_PREFIX."societe as s"; |
|
| 2500 | - if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; |
|
| 2501 | - $sql.= " WHERE f.rowid = fd.fk_facture"; |
|
| 2502 | - $sql.= " AND f.fk_soc = s.rowid"; |
|
| 2503 | - $sql.= " AND f.entity IN (".getEntity('facture').")"; |
|
| 2504 | - $sql.= " AND fd.fk_product = ".$this->id; |
|
| 2505 | - if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND f.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id; |
|
| 2496 | + $sql .= " COUNT(fd.rowid) as nb_rows, SUM(fd.qty) as qty"; |
|
| 2497 | + $sql .= " FROM ".MAIN_DB_PREFIX."facturedet as fd"; |
|
| 2498 | + $sql .= ", ".MAIN_DB_PREFIX."facture as f"; |
|
| 2499 | + $sql .= ", ".MAIN_DB_PREFIX."societe as s"; |
|
| 2500 | + if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; |
|
| 2501 | + $sql .= " WHERE f.rowid = fd.fk_facture"; |
|
| 2502 | + $sql .= " AND f.fk_soc = s.rowid"; |
|
| 2503 | + $sql .= " AND f.entity IN (".getEntity('facture').")"; |
|
| 2504 | + $sql .= " AND fd.fk_product = ".$this->id; |
|
| 2505 | + if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND f.fk_soc = sc.fk_soc AND sc.fk_user = ".$user->id; |
|
| 2506 | 2506 | //$sql.= " AND f.fk_statut != 0"; |
| 2507 | 2507 | if ($socid > 0) $sql .= " AND f.fk_soc = ".$socid; |
| 2508 | 2508 | |
| 2509 | 2509 | $result = $this->db->query($sql); |
| 2510 | - if ( $result ) |
|
| 2510 | + if ($result) |
|
| 2511 | 2511 | { |
| 2512 | - $obj=$this->db->fetch_object($result); |
|
| 2513 | - $this->stats_facture['customers']=$obj->nb_customers; |
|
| 2514 | - $this->stats_facture['nb']=$obj->nb; |
|
| 2515 | - $this->stats_facture['rows']=$obj->nb_rows; |
|
| 2516 | - $this->stats_facture['qty']=$obj->qty?$obj->qty:0; |
|
| 2512 | + $obj = $this->db->fetch_object($result); |
|
| 2513 | + $this->stats_facture['customers'] = $obj->nb_customers; |
|
| 2514 | + $this->stats_facture['nb'] = $obj->nb; |
|
| 2515 | + $this->stats_facture['rows'] = $obj->nb_rows; |
|
| 2516 | + $this->stats_facture['qty'] = $obj->qty ? $obj->qty : 0; |
|
| 2517 | 2517 | return 1; |
| 2518 | 2518 | } |
| 2519 | 2519 | else |
| 2520 | 2520 | { |
| 2521 | - $this->error=$this->db->error(); |
|
| 2521 | + $this->error = $this->db->error(); |
|
| 2522 | 2522 | return -1; |
| 2523 | 2523 | } |
| 2524 | 2524 | } |
@@ -2529,38 +2529,38 @@ discard block |
||
| 2529 | 2529 | * @param int $socid Id societe |
| 2530 | 2530 | * @return array Tableau des stats |
| 2531 | 2531 | */ |
| 2532 | - function load_stats_facture_fournisseur($socid=0) |
|
| 2532 | + function load_stats_facture_fournisseur($socid = 0) |
|
| 2533 | 2533 | { |
| 2534 | 2534 | global $conf; |
| 2535 | 2535 | global $user; |
| 2536 | 2536 | |
| 2537 | 2537 | $sql = "SELECT COUNT(DISTINCT f.fk_soc) as nb_suppliers, COUNT(DISTINCT f.rowid) as nb,"; |
| 2538 | - $sql.= " COUNT(fd.rowid) as nb_rows, SUM(fd.qty) as qty"; |
|
| 2539 | - $sql.= " FROM ".MAIN_DB_PREFIX."facture_fourn_det as fd"; |
|
| 2540 | - $sql.= ", ".MAIN_DB_PREFIX."facture_fourn as f"; |
|
| 2541 | - $sql.= ", ".MAIN_DB_PREFIX."societe as s"; |
|
| 2542 | - if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; |
|
| 2543 | - $sql.= " WHERE f.rowid = fd.fk_facture_fourn"; |
|
| 2544 | - $sql.= " AND f.fk_soc = s.rowid"; |
|
| 2545 | - $sql.= " AND f.entity IN (".getEntity('facture_fourn').")"; |
|
| 2546 | - $sql.= " AND fd.fk_product = ".$this->id; |
|
| 2547 | - if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND f.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id; |
|
| 2538 | + $sql .= " COUNT(fd.rowid) as nb_rows, SUM(fd.qty) as qty"; |
|
| 2539 | + $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn_det as fd"; |
|
| 2540 | + $sql .= ", ".MAIN_DB_PREFIX."facture_fourn as f"; |
|
| 2541 | + $sql .= ", ".MAIN_DB_PREFIX."societe as s"; |
|
| 2542 | + if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; |
|
| 2543 | + $sql .= " WHERE f.rowid = fd.fk_facture_fourn"; |
|
| 2544 | + $sql .= " AND f.fk_soc = s.rowid"; |
|
| 2545 | + $sql .= " AND f.entity IN (".getEntity('facture_fourn').")"; |
|
| 2546 | + $sql .= " AND fd.fk_product = ".$this->id; |
|
| 2547 | + if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND f.fk_soc = sc.fk_soc AND sc.fk_user = ".$user->id; |
|
| 2548 | 2548 | //$sql.= " AND f.fk_statut != 0"; |
| 2549 | 2549 | if ($socid > 0) $sql .= " AND f.fk_soc = ".$socid; |
| 2550 | 2550 | |
| 2551 | 2551 | $result = $this->db->query($sql); |
| 2552 | - if ( $result ) |
|
| 2552 | + if ($result) |
|
| 2553 | 2553 | { |
| 2554 | - $obj=$this->db->fetch_object($result); |
|
| 2555 | - $this->stats_facture_fournisseur['suppliers']=$obj->nb_suppliers; |
|
| 2556 | - $this->stats_facture_fournisseur['nb']=$obj->nb; |
|
| 2557 | - $this->stats_facture_fournisseur['rows']=$obj->nb_rows; |
|
| 2558 | - $this->stats_facture_fournisseur['qty']=$obj->qty?$obj->qty:0; |
|
| 2554 | + $obj = $this->db->fetch_object($result); |
|
| 2555 | + $this->stats_facture_fournisseur['suppliers'] = $obj->nb_suppliers; |
|
| 2556 | + $this->stats_facture_fournisseur['nb'] = $obj->nb; |
|
| 2557 | + $this->stats_facture_fournisseur['rows'] = $obj->nb_rows; |
|
| 2558 | + $this->stats_facture_fournisseur['qty'] = $obj->qty ? $obj->qty : 0; |
|
| 2559 | 2559 | return 1; |
| 2560 | 2560 | } |
| 2561 | 2561 | else |
| 2562 | 2562 | { |
| 2563 | - $this->error=$this->db->error(); |
|
| 2563 | + $this->error = $this->db->error(); |
|
| 2564 | 2564 | return -1; |
| 2565 | 2565 | } |
| 2566 | 2566 | } |
@@ -2573,7 +2573,7 @@ discard block |
||
| 2573 | 2573 | * @param int $year Year (0=current year) |
| 2574 | 2574 | * @return array <0 if KO, result[month]=array(valuex,valuey) where month is 0 to 11 |
| 2575 | 2575 | */ |
| 2576 | - function _get_stats($sql, $mode, $year=0) |
|
| 2576 | + function _get_stats($sql, $mode, $year = 0) |
|
| 2577 | 2577 | { |
| 2578 | 2578 | $resql = $this->db->query($sql); |
| 2579 | 2579 | if ($resql) |
@@ -2583,40 +2583,40 @@ discard block |
||
| 2583 | 2583 | while ($i < $num) |
| 2584 | 2584 | { |
| 2585 | 2585 | $arr = $this->db->fetch_array($resql); |
| 2586 | - if ($mode == 'byunit') $tab[$arr[1]] = $arr[0]; // 1st field |
|
| 2587 | - if ($mode == 'bynumber') $tab[$arr[1]] = $arr[2]; // 3rd field |
|
| 2586 | + if ($mode == 'byunit') $tab[$arr[1]] = $arr[0]; // 1st field |
|
| 2587 | + if ($mode == 'bynumber') $tab[$arr[1]] = $arr[2]; // 3rd field |
|
| 2588 | 2588 | $i++; |
| 2589 | 2589 | } |
| 2590 | 2590 | } |
| 2591 | 2591 | else |
| 2592 | 2592 | { |
| 2593 | - $this->error=$this->db->error().' sql='.$sql; |
|
| 2593 | + $this->error = $this->db->error().' sql='.$sql; |
|
| 2594 | 2594 | return -1; |
| 2595 | 2595 | } |
| 2596 | 2596 | |
| 2597 | 2597 | if (empty($year)) |
| 2598 | 2598 | { |
| 2599 | - $year = strftime('%Y',time()); |
|
| 2600 | - $month = strftime('%m',time()); |
|
| 2599 | + $year = strftime('%Y', time()); |
|
| 2600 | + $month = strftime('%m', time()); |
|
| 2601 | 2601 | } |
| 2602 | 2602 | else |
| 2603 | 2603 | { |
| 2604 | - $month=12; // We imagine we are at end of year, so we get last 12 month before, so all correct year. |
|
| 2604 | + $month = 12; // We imagine we are at end of year, so we get last 12 month before, so all correct year. |
|
| 2605 | 2605 | } |
| 2606 | 2606 | $result = array(); |
| 2607 | 2607 | |
| 2608 | - for ($j = 0 ; $j < 12 ; $j++) |
|
| 2608 | + for ($j = 0; $j < 12; $j++) |
|
| 2609 | 2609 | { |
| 2610 | - $idx=ucfirst(dol_trunc(dol_print_date(dol_mktime(12,0,0,$month,1,$year),"%b"),3,'right','UTF-8',1)); |
|
| 2611 | - $monthnum=sprintf("%02s",$month); |
|
| 2610 | + $idx = ucfirst(dol_trunc(dol_print_date(dol_mktime(12, 0, 0, $month, 1, $year), "%b"), 3, 'right', 'UTF-8', 1)); |
|
| 2611 | + $monthnum = sprintf("%02s", $month); |
|
| 2612 | 2612 | |
| 2613 | - $result[$j] = array($idx,isset($tab[$year.$month])?$tab[$year.$month]:0); |
|
| 2613 | + $result[$j] = array($idx, isset($tab[$year.$month]) ? $tab[$year.$month] : 0); |
|
| 2614 | 2614 | // $result[$j] = array($monthnum,isset($tab[$year.$month])?$tab[$year.$month]:0); |
| 2615 | 2615 | |
| 2616 | 2616 | $month = "0".($month - 1); |
| 2617 | 2617 | if (dol_strlen($month) == 3) |
| 2618 | 2618 | { |
| 2619 | - $month = substr($month,1); |
|
| 2619 | + $month = substr($month, 1); |
|
| 2620 | 2620 | } |
| 2621 | 2621 | if ($month == 0) |
| 2622 | 2622 | { |
@@ -2639,29 +2639,29 @@ discard block |
||
| 2639 | 2639 | * @param string $morefilter More sql filters |
| 2640 | 2640 | * @return array <0 if KO, result[month]=array(valuex,valuey) where month is 0 to 11 |
| 2641 | 2641 | */ |
| 2642 | - function get_nb_vente($socid, $mode, $filteronproducttype=-1, $year=0, $morefilter='') |
|
| 2642 | + function get_nb_vente($socid, $mode, $filteronproducttype = -1, $year = 0, $morefilter = '') |
|
| 2643 | 2643 | { |
| 2644 | 2644 | global $conf; |
| 2645 | 2645 | global $user; |
| 2646 | 2646 | |
| 2647 | 2647 | $sql = "SELECT sum(d.qty), date_format(f.datef, '%Y%m')"; |
| 2648 | - if ($mode == 'bynumber') $sql.= ", count(DISTINCT f.rowid)"; |
|
| 2649 | - $sql.= " FROM ".MAIN_DB_PREFIX."facturedet as d, ".MAIN_DB_PREFIX."facture as f, ".MAIN_DB_PREFIX."societe as s"; |
|
| 2650 | - if ($filteronproducttype >= 0) $sql.=", ".MAIN_DB_PREFIX."product as p"; |
|
| 2651 | - if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; |
|
| 2652 | - $sql.= " WHERE f.rowid = d.fk_facture"; |
|
| 2653 | - if ($this->id > 0) $sql.= " AND d.fk_product =".$this->id; |
|
| 2654 | - else $sql.=" AND d.fk_product > 0"; |
|
| 2655 | - if ($filteronproducttype >= 0) $sql.= " AND p.rowid = d.fk_product AND p.fk_product_type =".$filteronproducttype; |
|
| 2656 | - $sql.= " AND f.fk_soc = s.rowid"; |
|
| 2657 | - $sql.= " AND f.entity IN (".getEntity('facture').")"; |
|
| 2658 | - if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND f.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id; |
|
| 2659 | - if ($socid > 0) $sql.= " AND f.fk_soc = $socid"; |
|
| 2660 | - $sql.=$morefilter; |
|
| 2661 | - $sql.= " GROUP BY date_format(f.datef,'%Y%m')"; |
|
| 2662 | - $sql.= " ORDER BY date_format(f.datef,'%Y%m') DESC"; |
|
| 2663 | - |
|
| 2664 | - return $this->_get_stats($sql,$mode, $year); |
|
| 2648 | + if ($mode == 'bynumber') $sql .= ", count(DISTINCT f.rowid)"; |
|
| 2649 | + $sql .= " FROM ".MAIN_DB_PREFIX."facturedet as d, ".MAIN_DB_PREFIX."facture as f, ".MAIN_DB_PREFIX."societe as s"; |
|
| 2650 | + if ($filteronproducttype >= 0) $sql .= ", ".MAIN_DB_PREFIX."product as p"; |
|
| 2651 | + if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; |
|
| 2652 | + $sql .= " WHERE f.rowid = d.fk_facture"; |
|
| 2653 | + if ($this->id > 0) $sql .= " AND d.fk_product =".$this->id; |
|
| 2654 | + else $sql .= " AND d.fk_product > 0"; |
|
| 2655 | + if ($filteronproducttype >= 0) $sql .= " AND p.rowid = d.fk_product AND p.fk_product_type =".$filteronproducttype; |
|
| 2656 | + $sql .= " AND f.fk_soc = s.rowid"; |
|
| 2657 | + $sql .= " AND f.entity IN (".getEntity('facture').")"; |
|
| 2658 | + if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND f.fk_soc = sc.fk_soc AND sc.fk_user = ".$user->id; |
|
| 2659 | + if ($socid > 0) $sql .= " AND f.fk_soc = $socid"; |
|
| 2660 | + $sql .= $morefilter; |
|
| 2661 | + $sql .= " GROUP BY date_format(f.datef,'%Y%m')"; |
|
| 2662 | + $sql .= " ORDER BY date_format(f.datef,'%Y%m') DESC"; |
|
| 2663 | + |
|
| 2664 | + return $this->_get_stats($sql, $mode, $year); |
|
| 2665 | 2665 | } |
| 2666 | 2666 | |
| 2667 | 2667 | |
@@ -2675,29 +2675,29 @@ discard block |
||
| 2675 | 2675 | * @param string $morefilter More sql filters |
| 2676 | 2676 | * @return array <0 if KO, result[month]=array(valuex,valuey) where month is 0 to 11 |
| 2677 | 2677 | */ |
| 2678 | - function get_nb_achat($socid, $mode, $filteronproducttype=-1, $year=0, $morefilter='') |
|
| 2678 | + function get_nb_achat($socid, $mode, $filteronproducttype = -1, $year = 0, $morefilter = '') |
|
| 2679 | 2679 | { |
| 2680 | 2680 | global $conf; |
| 2681 | 2681 | global $user; |
| 2682 | 2682 | |
| 2683 | 2683 | $sql = "SELECT sum(d.qty), date_format(f.datef, '%Y%m')"; |
| 2684 | - if ($mode == 'bynumber') $sql.= ", count(DISTINCT f.rowid)"; |
|
| 2685 | - $sql.= " FROM ".MAIN_DB_PREFIX."facture_fourn_det as d, ".MAIN_DB_PREFIX."facture_fourn as f, ".MAIN_DB_PREFIX."societe as s"; |
|
| 2686 | - if ($filteronproducttype >= 0) $sql.=", ".MAIN_DB_PREFIX."product as p"; |
|
| 2687 | - if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; |
|
| 2688 | - $sql.= " WHERE f.rowid = d.fk_facture_fourn"; |
|
| 2689 | - if ($this->id > 0) $sql.= " AND d.fk_product =".$this->id; |
|
| 2690 | - else $sql.=" AND d.fk_product > 0"; |
|
| 2691 | - if ($filteronproducttype >= 0) $sql.= " AND p.rowid = d.fk_product AND p.fk_product_type =".$filteronproducttype; |
|
| 2692 | - $sql.= " AND f.fk_soc = s.rowid"; |
|
| 2693 | - $sql.= " AND f.entity IN (".getEntity('facture_fourn').")"; |
|
| 2694 | - if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND f.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id; |
|
| 2695 | - if ($socid > 0) $sql.= " AND f.fk_soc = $socid"; |
|
| 2696 | - $sql.=$morefilter; |
|
| 2697 | - $sql.= " GROUP BY date_format(f.datef,'%Y%m')"; |
|
| 2698 | - $sql.= " ORDER BY date_format(f.datef,'%Y%m') DESC"; |
|
| 2699 | - |
|
| 2700 | - return $this->_get_stats($sql,$mode, $year); |
|
| 2684 | + if ($mode == 'bynumber') $sql .= ", count(DISTINCT f.rowid)"; |
|
| 2685 | + $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn_det as d, ".MAIN_DB_PREFIX."facture_fourn as f, ".MAIN_DB_PREFIX."societe as s"; |
|
| 2686 | + if ($filteronproducttype >= 0) $sql .= ", ".MAIN_DB_PREFIX."product as p"; |
|
| 2687 | + if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; |
|
| 2688 | + $sql .= " WHERE f.rowid = d.fk_facture_fourn"; |
|
| 2689 | + if ($this->id > 0) $sql .= " AND d.fk_product =".$this->id; |
|
| 2690 | + else $sql .= " AND d.fk_product > 0"; |
|
| 2691 | + if ($filteronproducttype >= 0) $sql .= " AND p.rowid = d.fk_product AND p.fk_product_type =".$filteronproducttype; |
|
| 2692 | + $sql .= " AND f.fk_soc = s.rowid"; |
|
| 2693 | + $sql .= " AND f.entity IN (".getEntity('facture_fourn').")"; |
|
| 2694 | + if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND f.fk_soc = sc.fk_soc AND sc.fk_user = ".$user->id; |
|
| 2695 | + if ($socid > 0) $sql .= " AND f.fk_soc = $socid"; |
|
| 2696 | + $sql .= $morefilter; |
|
| 2697 | + $sql .= " GROUP BY date_format(f.datef,'%Y%m')"; |
|
| 2698 | + $sql .= " ORDER BY date_format(f.datef,'%Y%m') DESC"; |
|
| 2699 | + |
|
| 2700 | + return $this->_get_stats($sql, $mode, $year); |
|
| 2701 | 2701 | } |
| 2702 | 2702 | |
| 2703 | 2703 | /** |
@@ -2710,29 +2710,29 @@ discard block |
||
| 2710 | 2710 | * @param string $morefilter More sql filters |
| 2711 | 2711 | * @return array <0 if KO, result[month]=array(valuex,valuey) where month is 0 to 11 |
| 2712 | 2712 | */ |
| 2713 | - function get_nb_propal($socid, $mode, $filteronproducttype=-1, $year=0, $morefilter='') |
|
| 2713 | + function get_nb_propal($socid, $mode, $filteronproducttype = -1, $year = 0, $morefilter = '') |
|
| 2714 | 2714 | { |
| 2715 | 2715 | global $conf; |
| 2716 | 2716 | global $user; |
| 2717 | 2717 | |
| 2718 | 2718 | $sql = "SELECT sum(d.qty), date_format(p.datep, '%Y%m')"; |
| 2719 | - if ($mode == 'bynumber') $sql.= ", count(DISTINCT p.rowid)"; |
|
| 2720 | - $sql.= " FROM ".MAIN_DB_PREFIX."propaldet as d, ".MAIN_DB_PREFIX."propal as p, ".MAIN_DB_PREFIX."societe as s"; |
|
| 2721 | - if ($filteronproducttype >= 0) $sql.=", ".MAIN_DB_PREFIX."product as prod"; |
|
| 2719 | + if ($mode == 'bynumber') $sql .= ", count(DISTINCT p.rowid)"; |
|
| 2720 | + $sql .= " FROM ".MAIN_DB_PREFIX."propaldet as d, ".MAIN_DB_PREFIX."propal as p, ".MAIN_DB_PREFIX."societe as s"; |
|
| 2721 | + if ($filteronproducttype >= 0) $sql .= ", ".MAIN_DB_PREFIX."product as prod"; |
|
| 2722 | 2722 | if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; |
| 2723 | - $sql.= " WHERE p.rowid = d.fk_propal"; |
|
| 2724 | - if ($this->id > 0) $sql.= " AND d.fk_product =".$this->id; |
|
| 2725 | - else $sql.=" AND d.fk_product > 0"; |
|
| 2726 | - if ($filteronproducttype >= 0) $sql.= " AND prod.rowid = d.fk_product AND prod.fk_product_type =".$filteronproducttype; |
|
| 2727 | - $sql.= " AND p.fk_soc = s.rowid"; |
|
| 2728 | - $sql.= " AND p.entity IN (".getEntity('propal').")"; |
|
| 2729 | - if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND p.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id; |
|
| 2730 | - if ($socid > 0) $sql.= " AND p.fk_soc = ".$socid; |
|
| 2731 | - $sql.=$morefilter; |
|
| 2732 | - $sql.= " GROUP BY date_format(p.datep,'%Y%m')"; |
|
| 2733 | - $sql.= " ORDER BY date_format(p.datep,'%Y%m') DESC"; |
|
| 2734 | - |
|
| 2735 | - return $this->_get_stats($sql,$mode, $year); |
|
| 2723 | + $sql .= " WHERE p.rowid = d.fk_propal"; |
|
| 2724 | + if ($this->id > 0) $sql .= " AND d.fk_product =".$this->id; |
|
| 2725 | + else $sql .= " AND d.fk_product > 0"; |
|
| 2726 | + if ($filteronproducttype >= 0) $sql .= " AND prod.rowid = d.fk_product AND prod.fk_product_type =".$filteronproducttype; |
|
| 2727 | + $sql .= " AND p.fk_soc = s.rowid"; |
|
| 2728 | + $sql .= " AND p.entity IN (".getEntity('propal').")"; |
|
| 2729 | + if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND p.fk_soc = sc.fk_soc AND sc.fk_user = ".$user->id; |
|
| 2730 | + if ($socid > 0) $sql .= " AND p.fk_soc = ".$socid; |
|
| 2731 | + $sql .= $morefilter; |
|
| 2732 | + $sql .= " GROUP BY date_format(p.datep,'%Y%m')"; |
|
| 2733 | + $sql .= " ORDER BY date_format(p.datep,'%Y%m') DESC"; |
|
| 2734 | + |
|
| 2735 | + return $this->_get_stats($sql, $mode, $year); |
|
| 2736 | 2736 | } |
| 2737 | 2737 | |
| 2738 | 2738 | /** |
@@ -2745,29 +2745,29 @@ discard block |
||
| 2745 | 2745 | * @param string $morefilter More sql filters |
| 2746 | 2746 | * @return array <0 if KO, result[month]=array(valuex,valuey) where month is 0 to 11 |
| 2747 | 2747 | */ |
| 2748 | - function get_nb_propalsupplier($socid, $mode, $filteronproducttype=-1, $year=0, $morefilter='') |
|
| 2748 | + function get_nb_propalsupplier($socid, $mode, $filteronproducttype = -1, $year = 0, $morefilter = '') |
|
| 2749 | 2749 | { |
| 2750 | 2750 | global $conf; |
| 2751 | 2751 | global $user; |
| 2752 | 2752 | |
| 2753 | 2753 | $sql = "SELECT sum(d.qty), date_format(p.date_valid, '%Y%m')"; |
| 2754 | - if ($mode == 'bynumber') $sql.= ", count(DISTINCT p.rowid)"; |
|
| 2755 | - $sql.= " FROM ".MAIN_DB_PREFIX."supplier_proposaldet as d, ".MAIN_DB_PREFIX."supplier_proposal as p, ".MAIN_DB_PREFIX."societe as s"; |
|
| 2756 | - if ($filteronproducttype >= 0) $sql.=", ".MAIN_DB_PREFIX."product as prod"; |
|
| 2754 | + if ($mode == 'bynumber') $sql .= ", count(DISTINCT p.rowid)"; |
|
| 2755 | + $sql .= " FROM ".MAIN_DB_PREFIX."supplier_proposaldet as d, ".MAIN_DB_PREFIX."supplier_proposal as p, ".MAIN_DB_PREFIX."societe as s"; |
|
| 2756 | + if ($filteronproducttype >= 0) $sql .= ", ".MAIN_DB_PREFIX."product as prod"; |
|
| 2757 | 2757 | if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; |
| 2758 | - $sql.= " WHERE p.rowid = d.fk_supplier_proposal"; |
|
| 2759 | - if ($this->id > 0) $sql.= " AND d.fk_product =".$this->id; |
|
| 2760 | - else $sql.=" AND d.fk_product > 0"; |
|
| 2761 | - if ($filteronproducttype >= 0) $sql.= " AND prod.rowid = d.fk_product AND prod.fk_product_type =".$filteronproducttype; |
|
| 2762 | - $sql.= " AND p.fk_soc = s.rowid"; |
|
| 2763 | - $sql.= " AND p.entity IN (".getEntity('supplier_proposal').")"; |
|
| 2764 | - if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND p.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id; |
|
| 2765 | - if ($socid > 0) $sql.= " AND p.fk_soc = ".$socid; |
|
| 2766 | - $sql.=$morefilter; |
|
| 2767 | - $sql.= " GROUP BY date_format(p.date_valid,'%Y%m')"; |
|
| 2768 | - $sql.= " ORDER BY date_format(p.date_valid,'%Y%m') DESC"; |
|
| 2769 | - |
|
| 2770 | - return $this->_get_stats($sql,$mode, $year); |
|
| 2758 | + $sql .= " WHERE p.rowid = d.fk_supplier_proposal"; |
|
| 2759 | + if ($this->id > 0) $sql .= " AND d.fk_product =".$this->id; |
|
| 2760 | + else $sql .= " AND d.fk_product > 0"; |
|
| 2761 | + if ($filteronproducttype >= 0) $sql .= " AND prod.rowid = d.fk_product AND prod.fk_product_type =".$filteronproducttype; |
|
| 2762 | + $sql .= " AND p.fk_soc = s.rowid"; |
|
| 2763 | + $sql .= " AND p.entity IN (".getEntity('supplier_proposal').")"; |
|
| 2764 | + if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND p.fk_soc = sc.fk_soc AND sc.fk_user = ".$user->id; |
|
| 2765 | + if ($socid > 0) $sql .= " AND p.fk_soc = ".$socid; |
|
| 2766 | + $sql .= $morefilter; |
|
| 2767 | + $sql .= " GROUP BY date_format(p.date_valid,'%Y%m')"; |
|
| 2768 | + $sql .= " ORDER BY date_format(p.date_valid,'%Y%m') DESC"; |
|
| 2769 | + |
|
| 2770 | + return $this->_get_stats($sql, $mode, $year); |
|
| 2771 | 2771 | } |
| 2772 | 2772 | |
| 2773 | 2773 | /** |
@@ -2780,28 +2780,28 @@ discard block |
||
| 2780 | 2780 | * @param string $morefilter More sql filters |
| 2781 | 2781 | * @return array <0 if KO, result[month]=array(valuex,valuey) where month is 0 to 11 |
| 2782 | 2782 | */ |
| 2783 | - function get_nb_order($socid, $mode, $filteronproducttype=-1, $year=0, $morefilter='') |
|
| 2783 | + function get_nb_order($socid, $mode, $filteronproducttype = -1, $year = 0, $morefilter = '') |
|
| 2784 | 2784 | { |
| 2785 | 2785 | global $conf, $user; |
| 2786 | 2786 | |
| 2787 | 2787 | $sql = "SELECT sum(d.qty), date_format(c.date_commande, '%Y%m')"; |
| 2788 | - if ($mode == 'bynumber') $sql.= ", count(DISTINCT c.rowid)"; |
|
| 2789 | - $sql.= " FROM ".MAIN_DB_PREFIX."commandedet as d, ".MAIN_DB_PREFIX."commande as c, ".MAIN_DB_PREFIX."societe as s"; |
|
| 2790 | - if ($filteronproducttype >= 0) $sql.=", ".MAIN_DB_PREFIX."product as p"; |
|
| 2788 | + if ($mode == 'bynumber') $sql .= ", count(DISTINCT c.rowid)"; |
|
| 2789 | + $sql .= " FROM ".MAIN_DB_PREFIX."commandedet as d, ".MAIN_DB_PREFIX."commande as c, ".MAIN_DB_PREFIX."societe as s"; |
|
| 2790 | + if ($filteronproducttype >= 0) $sql .= ", ".MAIN_DB_PREFIX."product as p"; |
|
| 2791 | 2791 | if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; |
| 2792 | - $sql.= " WHERE c.rowid = d.fk_commande"; |
|
| 2793 | - if ($this->id > 0) $sql.= " AND d.fk_product =".$this->id; |
|
| 2794 | - else $sql.=" AND d.fk_product > 0"; |
|
| 2795 | - if ($filteronproducttype >= 0) $sql.= " AND p.rowid = d.fk_product AND p.fk_product_type =".$filteronproducttype; |
|
| 2796 | - $sql.= " AND c.fk_soc = s.rowid"; |
|
| 2797 | - $sql.= " AND c.entity IN (".getEntity('commande').")"; |
|
| 2798 | - if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND c.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id; |
|
| 2799 | - if ($socid > 0) $sql.= " AND c.fk_soc = ".$socid; |
|
| 2800 | - $sql.=$morefilter; |
|
| 2801 | - $sql.= " GROUP BY date_format(c.date_commande,'%Y%m')"; |
|
| 2802 | - $sql.= " ORDER BY date_format(c.date_commande,'%Y%m') DESC"; |
|
| 2803 | - |
|
| 2804 | - return $this->_get_stats($sql,$mode, $year); |
|
| 2792 | + $sql .= " WHERE c.rowid = d.fk_commande"; |
|
| 2793 | + if ($this->id > 0) $sql .= " AND d.fk_product =".$this->id; |
|
| 2794 | + else $sql .= " AND d.fk_product > 0"; |
|
| 2795 | + if ($filteronproducttype >= 0) $sql .= " AND p.rowid = d.fk_product AND p.fk_product_type =".$filteronproducttype; |
|
| 2796 | + $sql .= " AND c.fk_soc = s.rowid"; |
|
| 2797 | + $sql .= " AND c.entity IN (".getEntity('commande').")"; |
|
| 2798 | + if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND c.fk_soc = sc.fk_soc AND sc.fk_user = ".$user->id; |
|
| 2799 | + if ($socid > 0) $sql .= " AND c.fk_soc = ".$socid; |
|
| 2800 | + $sql .= $morefilter; |
|
| 2801 | + $sql .= " GROUP BY date_format(c.date_commande,'%Y%m')"; |
|
| 2802 | + $sql .= " ORDER BY date_format(c.date_commande,'%Y%m') DESC"; |
|
| 2803 | + |
|
| 2804 | + return $this->_get_stats($sql, $mode, $year); |
|
| 2805 | 2805 | } |
| 2806 | 2806 | |
| 2807 | 2807 | /** |
@@ -2814,28 +2814,28 @@ discard block |
||
| 2814 | 2814 | * @param string $morefilter More sql filters |
| 2815 | 2815 | * @return array <0 if KO, result[month]=array(valuex,valuey) where month is 0 to 11 |
| 2816 | 2816 | */ |
| 2817 | - function get_nb_ordersupplier($socid, $mode, $filteronproducttype=-1, $year=0, $morefilter='') |
|
| 2817 | + function get_nb_ordersupplier($socid, $mode, $filteronproducttype = -1, $year = 0, $morefilter = '') |
|
| 2818 | 2818 | { |
| 2819 | 2819 | global $conf, $user; |
| 2820 | 2820 | |
| 2821 | 2821 | $sql = "SELECT sum(d.qty), date_format(c.date_commande, '%Y%m')"; |
| 2822 | - if ($mode == 'bynumber') $sql.= ", count(DISTINCT c.rowid)"; |
|
| 2823 | - $sql.= " FROM ".MAIN_DB_PREFIX."commande_fournisseurdet as d, ".MAIN_DB_PREFIX."commande_fournisseur as c, ".MAIN_DB_PREFIX."societe as s"; |
|
| 2824 | - if ($filteronproducttype >= 0) $sql.=", ".MAIN_DB_PREFIX."product as p"; |
|
| 2822 | + if ($mode == 'bynumber') $sql .= ", count(DISTINCT c.rowid)"; |
|
| 2823 | + $sql .= " FROM ".MAIN_DB_PREFIX."commande_fournisseurdet as d, ".MAIN_DB_PREFIX."commande_fournisseur as c, ".MAIN_DB_PREFIX."societe as s"; |
|
| 2824 | + if ($filteronproducttype >= 0) $sql .= ", ".MAIN_DB_PREFIX."product as p"; |
|
| 2825 | 2825 | if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; |
| 2826 | - $sql.= " WHERE c.rowid = d.fk_commande"; |
|
| 2827 | - if ($this->id > 0) $sql.= " AND d.fk_product =".$this->id; |
|
| 2828 | - else $sql.=" AND d.fk_product > 0"; |
|
| 2829 | - if ($filteronproducttype >= 0) $sql.= " AND p.rowid = d.fk_product AND p.fk_product_type =".$filteronproducttype; |
|
| 2830 | - $sql.= " AND c.fk_soc = s.rowid"; |
|
| 2831 | - $sql.= " AND c.entity IN (".getEntity('supplier_order').")"; |
|
| 2832 | - if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND c.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id; |
|
| 2833 | - if ($socid > 0) $sql.= " AND c.fk_soc = ".$socid; |
|
| 2834 | - $sql.=$morefilter; |
|
| 2835 | - $sql.= " GROUP BY date_format(c.date_commande,'%Y%m')"; |
|
| 2836 | - $sql.= " ORDER BY date_format(c.date_commande,'%Y%m') DESC"; |
|
| 2837 | - |
|
| 2838 | - return $this->_get_stats($sql,$mode, $year); |
|
| 2826 | + $sql .= " WHERE c.rowid = d.fk_commande"; |
|
| 2827 | + if ($this->id > 0) $sql .= " AND d.fk_product =".$this->id; |
|
| 2828 | + else $sql .= " AND d.fk_product > 0"; |
|
| 2829 | + if ($filteronproducttype >= 0) $sql .= " AND p.rowid = d.fk_product AND p.fk_product_type =".$filteronproducttype; |
|
| 2830 | + $sql .= " AND c.fk_soc = s.rowid"; |
|
| 2831 | + $sql .= " AND c.entity IN (".getEntity('supplier_order').")"; |
|
| 2832 | + if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND c.fk_soc = sc.fk_soc AND sc.fk_user = ".$user->id; |
|
| 2833 | + if ($socid > 0) $sql .= " AND c.fk_soc = ".$socid; |
|
| 2834 | + $sql .= $morefilter; |
|
| 2835 | + $sql .= " GROUP BY date_format(c.date_commande,'%Y%m')"; |
|
| 2836 | + $sql .= " ORDER BY date_format(c.date_commande,'%Y%m') DESC"; |
|
| 2837 | + |
|
| 2838 | + return $this->_get_stats($sql, $mode, $year); |
|
| 2839 | 2839 | } |
| 2840 | 2840 | |
| 2841 | 2841 | /** |
@@ -2847,20 +2847,20 @@ discard block |
||
| 2847 | 2847 | * @param int $incdec 1=Increase/decrease stock of child when parent stock increase/decrease |
| 2848 | 2848 | * @return int < 0 if KO, > 0 if OK |
| 2849 | 2849 | */ |
| 2850 | - function add_sousproduit($id_pere, $id_fils, $qty, $incdec=1) |
|
| 2850 | + function add_sousproduit($id_pere, $id_fils, $qty, $incdec = 1) |
|
| 2851 | 2851 | { |
| 2852 | 2852 | // Clean parameters |
| 2853 | - if (! is_numeric($id_pere)) $id_pere=0; |
|
| 2854 | - if (! is_numeric($id_fils)) $id_fils=0; |
|
| 2855 | - if (! is_numeric($incdec)) $incdec=0; |
|
| 2853 | + if (!is_numeric($id_pere)) $id_pere = 0; |
|
| 2854 | + if (!is_numeric($id_fils)) $id_fils = 0; |
|
| 2855 | + if (!is_numeric($incdec)) $incdec = 0; |
|
| 2856 | 2856 | |
| 2857 | - $result=$this->del_sousproduit($id_pere, $id_fils); |
|
| 2857 | + $result = $this->del_sousproduit($id_pere, $id_fils); |
|
| 2858 | 2858 | if ($result < 0) return $result; |
| 2859 | 2859 | |
| 2860 | 2860 | // Check not already father of id_pere (to avoid father -> child -> father links) |
| 2861 | 2861 | $sql = 'SELECT fk_product_pere from '.MAIN_DB_PREFIX.'product_association'; |
| 2862 | 2862 | $sql .= ' WHERE fk_product_pere = '.$id_fils.' AND fk_product_fils = '.$id_pere; |
| 2863 | - if (! $this->db->query($sql)) |
|
| 2863 | + if (!$this->db->query($sql)) |
|
| 2864 | 2864 | { |
| 2865 | 2865 | dol_print_error($this->db); |
| 2866 | 2866 | return -1; |
@@ -2871,16 +2871,16 @@ discard block |
||
| 2871 | 2871 | if ($result) |
| 2872 | 2872 | { |
| 2873 | 2873 | $num = $this->db->num_rows($result); |
| 2874 | - if($num > 0) |
|
| 2874 | + if ($num > 0) |
|
| 2875 | 2875 | { |
| 2876 | - $this->error="isFatherOfThis"; |
|
| 2876 | + $this->error = "isFatherOfThis"; |
|
| 2877 | 2877 | return -1; |
| 2878 | 2878 | } |
| 2879 | 2879 | else |
| 2880 | 2880 | { |
| 2881 | 2881 | $sql = 'INSERT INTO '.MAIN_DB_PREFIX.'product_association(fk_product_pere,fk_product_fils,qty,incdec)'; |
| 2882 | 2882 | $sql .= ' VALUES ('.$id_pere.', '.$id_fils.', '.$qty.', '.$incdec.')'; |
| 2883 | - if (! $this->db->query($sql)) |
|
| 2883 | + if (!$this->db->query($sql)) |
|
| 2884 | 2884 | { |
| 2885 | 2885 | dol_print_error($this->db); |
| 2886 | 2886 | return -1; |
@@ -2903,17 +2903,17 @@ discard block |
||
| 2903 | 2903 | * @param int $incdec 1=Increase/decrease stock of child when parent stock increase/decrease |
| 2904 | 2904 | * @return int < 0 if KO, > 0 if OK |
| 2905 | 2905 | */ |
| 2906 | - function update_sousproduit($id_pere, $id_fils, $qty, $incdec=1) |
|
| 2906 | + function update_sousproduit($id_pere, $id_fils, $qty, $incdec = 1) |
|
| 2907 | 2907 | { |
| 2908 | 2908 | // Clean parameters |
| 2909 | - if (! is_numeric($id_pere)) $id_pere=0; |
|
| 2910 | - if (! is_numeric($id_fils)) $id_fils=0; |
|
| 2911 | - if (! is_numeric($incdec)) $incdec=1; |
|
| 2912 | - if (! is_numeric($qty)) $qty=1; |
|
| 2909 | + if (!is_numeric($id_pere)) $id_pere = 0; |
|
| 2910 | + if (!is_numeric($id_fils)) $id_fils = 0; |
|
| 2911 | + if (!is_numeric($incdec)) $incdec = 1; |
|
| 2912 | + if (!is_numeric($qty)) $qty = 1; |
|
| 2913 | 2913 | |
| 2914 | 2914 | $sql = 'UPDATE '.MAIN_DB_PREFIX.'product_association SET '; |
| 2915 | - $sql.= 'qty='.$qty; |
|
| 2916 | - $sql.= ',incdec='.$incdec; |
|
| 2915 | + $sql .= 'qty='.$qty; |
|
| 2916 | + $sql .= ',incdec='.$incdec; |
|
| 2917 | 2917 | $sql .= ' WHERE fk_product_pere='.$id_pere.' AND fk_product_fils='.$id_fils; |
| 2918 | 2918 | |
| 2919 | 2919 | if (!$this->db->query($sql)) |
@@ -2937,15 +2937,15 @@ discard block |
||
| 2937 | 2937 | */ |
| 2938 | 2938 | function del_sousproduit($fk_parent, $fk_child) |
| 2939 | 2939 | { |
| 2940 | - if (! is_numeric($fk_parent)) $fk_parent=0; |
|
| 2941 | - if (! is_numeric($fk_child)) $fk_child=0; |
|
| 2940 | + if (!is_numeric($fk_parent)) $fk_parent = 0; |
|
| 2941 | + if (!is_numeric($fk_child)) $fk_child = 0; |
|
| 2942 | 2942 | |
| 2943 | 2943 | $sql = "DELETE FROM ".MAIN_DB_PREFIX."product_association"; |
| 2944 | - $sql.= " WHERE fk_product_pere = ".$fk_parent; |
|
| 2945 | - $sql.= " AND fk_product_fils = ".$fk_child; |
|
| 2944 | + $sql .= " WHERE fk_product_pere = ".$fk_parent; |
|
| 2945 | + $sql .= " AND fk_product_fils = ".$fk_child; |
|
| 2946 | 2946 | |
| 2947 | 2947 | dol_syslog(get_class($this).'::del_sousproduit', LOG_DEBUG); |
| 2948 | - if (! $this->db->query($sql)) |
|
| 2948 | + if (!$this->db->query($sql)) |
|
| 2949 | 2949 | { |
| 2950 | 2950 | dol_print_error($this->db); |
| 2951 | 2951 | return -1; |
@@ -2964,16 +2964,16 @@ discard block |
||
| 2964 | 2964 | function is_sousproduit($fk_parent, $fk_child) |
| 2965 | 2965 | { |
| 2966 | 2966 | $sql = "SELECT fk_product_pere, qty, incdec"; |
| 2967 | - $sql.= " FROM ".MAIN_DB_PREFIX."product_association"; |
|
| 2968 | - $sql.= " WHERE fk_product_pere = '".$fk_parent."'"; |
|
| 2969 | - $sql.= " AND fk_product_fils = '".$fk_child."'"; |
|
| 2967 | + $sql .= " FROM ".MAIN_DB_PREFIX."product_association"; |
|
| 2968 | + $sql .= " WHERE fk_product_pere = '".$fk_parent."'"; |
|
| 2969 | + $sql .= " AND fk_product_fils = '".$fk_child."'"; |
|
| 2970 | 2970 | |
| 2971 | 2971 | $result = $this->db->query($sql); |
| 2972 | 2972 | if ($result) |
| 2973 | 2973 | { |
| 2974 | 2974 | $num = $this->db->num_rows($result); |
| 2975 | 2975 | |
| 2976 | - if($num > 0) |
|
| 2976 | + if ($num > 0) |
|
| 2977 | 2977 | { |
| 2978 | 2978 | $obj = $this->db->fetch_object($result); |
| 2979 | 2979 | $this->is_sousproduit_qty = $obj->qty; |
@@ -3008,20 +3008,20 @@ discard block |
||
| 3008 | 3008 | { |
| 3009 | 3009 | global $conf; |
| 3010 | 3010 | |
| 3011 | - $now=dol_now(); |
|
| 3011 | + $now = dol_now(); |
|
| 3012 | 3012 | |
| 3013 | 3013 | dol_syslog(get_class($this)."::add_fournisseur id_fourn = ".$id_fourn." ref_fourn=".$ref_fourn." quantity=".$quantity, LOG_DEBUG); |
| 3014 | 3014 | |
| 3015 | 3015 | if ($ref_fourn) |
| 3016 | 3016 | { |
| 3017 | 3017 | $sql = "SELECT rowid, fk_product"; |
| 3018 | - $sql.= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price"; |
|
| 3019 | - $sql.= " WHERE fk_soc = ".$id_fourn; |
|
| 3020 | - $sql.= " AND ref_fourn = '".$this->db->escape($ref_fourn)."'"; |
|
| 3021 | - $sql.= " AND fk_product != ".$this->id; |
|
| 3022 | - $sql.= " AND entity IN (".getEntity('productprice').")"; |
|
| 3018 | + $sql .= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price"; |
|
| 3019 | + $sql .= " WHERE fk_soc = ".$id_fourn; |
|
| 3020 | + $sql .= " AND ref_fourn = '".$this->db->escape($ref_fourn)."'"; |
|
| 3021 | + $sql .= " AND fk_product != ".$this->id; |
|
| 3022 | + $sql .= " AND entity IN (".getEntity('productprice').")"; |
|
| 3023 | 3023 | |
| 3024 | - $resql=$this->db->query($sql); |
|
| 3024 | + $resql = $this->db->query($sql); |
|
| 3025 | 3025 | if ($resql) |
| 3026 | 3026 | { |
| 3027 | 3027 | $obj = $this->db->fetch_object($resql); |
@@ -3036,41 +3036,41 @@ discard block |
||
| 3036 | 3036 | } |
| 3037 | 3037 | |
| 3038 | 3038 | $sql = "SELECT rowid"; |
| 3039 | - $sql.= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price"; |
|
| 3040 | - $sql.= " WHERE fk_soc = ".$id_fourn; |
|
| 3041 | - if ($ref_fourn) $sql.= " AND ref_fourn = '".$this->db->escape($ref_fourn)."'"; |
|
| 3042 | - else $sql.= " AND (ref_fourn = '' OR ref_fourn IS NULL)"; |
|
| 3043 | - $sql.= " AND quantity = '".$quantity."'"; |
|
| 3044 | - $sql.= " AND fk_product = ".$this->id; |
|
| 3045 | - $sql.= " AND entity IN (".getEntity('productprice').")"; |
|
| 3046 | - |
|
| 3047 | - $resql=$this->db->query($sql); |
|
| 3039 | + $sql .= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price"; |
|
| 3040 | + $sql .= " WHERE fk_soc = ".$id_fourn; |
|
| 3041 | + if ($ref_fourn) $sql .= " AND ref_fourn = '".$this->db->escape($ref_fourn)."'"; |
|
| 3042 | + else $sql .= " AND (ref_fourn = '' OR ref_fourn IS NULL)"; |
|
| 3043 | + $sql .= " AND quantity = '".$quantity."'"; |
|
| 3044 | + $sql .= " AND fk_product = ".$this->id; |
|
| 3045 | + $sql .= " AND entity IN (".getEntity('productprice').")"; |
|
| 3046 | + |
|
| 3047 | + $resql = $this->db->query($sql); |
|
| 3048 | 3048 | if ($resql) |
| 3049 | 3049 | { |
| 3050 | 3050 | $obj = $this->db->fetch_object($resql); |
| 3051 | 3051 | |
| 3052 | 3052 | // The reference supplier does not exist, we create it for this product. |
| 3053 | - if (! $obj) |
|
| 3053 | + if (!$obj) |
|
| 3054 | 3054 | { |
| 3055 | 3055 | $sql = "INSERT INTO ".MAIN_DB_PREFIX."product_fournisseur_price("; |
| 3056 | - $sql.= "datec"; |
|
| 3057 | - $sql.= ", entity"; |
|
| 3058 | - $sql.= ", fk_product"; |
|
| 3059 | - $sql.= ", fk_soc"; |
|
| 3060 | - $sql.= ", ref_fourn"; |
|
| 3061 | - $sql.= ", quantity"; |
|
| 3062 | - $sql.= ", fk_user"; |
|
| 3063 | - $sql.= ", tva_tx"; |
|
| 3064 | - $sql.= ") VALUES ("; |
|
| 3065 | - $sql.= "'".$this->db->idate($now)."'"; |
|
| 3066 | - $sql.= ", ".$conf->entity; |
|
| 3067 | - $sql.= ", ".$this->id; |
|
| 3068 | - $sql.= ", ".$id_fourn; |
|
| 3069 | - $sql.= ", '".$this->db->escape($ref_fourn)."'"; |
|
| 3070 | - $sql.= ", ".$quantity; |
|
| 3071 | - $sql.= ", ".$user->id; |
|
| 3072 | - $sql.= ", 0"; |
|
| 3073 | - $sql.= ")"; |
|
| 3056 | + $sql .= "datec"; |
|
| 3057 | + $sql .= ", entity"; |
|
| 3058 | + $sql .= ", fk_product"; |
|
| 3059 | + $sql .= ", fk_soc"; |
|
| 3060 | + $sql .= ", ref_fourn"; |
|
| 3061 | + $sql .= ", quantity"; |
|
| 3062 | + $sql .= ", fk_user"; |
|
| 3063 | + $sql .= ", tva_tx"; |
|
| 3064 | + $sql .= ") VALUES ("; |
|
| 3065 | + $sql .= "'".$this->db->idate($now)."'"; |
|
| 3066 | + $sql .= ", ".$conf->entity; |
|
| 3067 | + $sql .= ", ".$this->id; |
|
| 3068 | + $sql .= ", ".$id_fourn; |
|
| 3069 | + $sql .= ", '".$this->db->escape($ref_fourn)."'"; |
|
| 3070 | + $sql .= ", ".$quantity; |
|
| 3071 | + $sql .= ", ".$user->id; |
|
| 3072 | + $sql .= ", 0"; |
|
| 3073 | + $sql .= ")"; |
|
| 3074 | 3074 | |
| 3075 | 3075 | if ($this->db->query($sql)) |
| 3076 | 3076 | { |
@@ -3079,7 +3079,7 @@ discard block |
||
| 3079 | 3079 | } |
| 3080 | 3080 | else |
| 3081 | 3081 | { |
| 3082 | - $this->error=$this->db->lasterror(); |
|
| 3082 | + $this->error = $this->db->lasterror(); |
|
| 3083 | 3083 | return -1; |
| 3084 | 3084 | } |
| 3085 | 3085 | } |
@@ -3092,7 +3092,7 @@ discard block |
||
| 3092 | 3092 | } |
| 3093 | 3093 | else |
| 3094 | 3094 | { |
| 3095 | - $this->error=$this->db->lasterror(); |
|
| 3095 | + $this->error = $this->db->lasterror(); |
|
| 3096 | 3096 | return -2; |
| 3097 | 3097 | } |
| 3098 | 3098 | } |
@@ -3110,15 +3110,15 @@ discard block |
||
| 3110 | 3110 | $list = array(); |
| 3111 | 3111 | |
| 3112 | 3112 | $sql = "SELECT DISTINCT p.fk_soc"; |
| 3113 | - $sql.= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price as p"; |
|
| 3114 | - $sql.= " WHERE p.fk_product = ".$this->id; |
|
| 3115 | - $sql.= " AND p.entity = ".$conf->entity; |
|
| 3113 | + $sql .= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price as p"; |
|
| 3114 | + $sql .= " WHERE p.fk_product = ".$this->id; |
|
| 3115 | + $sql .= " AND p.entity = ".$conf->entity; |
|
| 3116 | 3116 | |
| 3117 | 3117 | $result = $this->db->query($sql); |
| 3118 | 3118 | if ($result) |
| 3119 | 3119 | { |
| 3120 | 3120 | $num = $this->db->num_rows($result); |
| 3121 | - $i=0; |
|
| 3121 | + $i = 0; |
|
| 3122 | 3122 | while ($i < $num) |
| 3123 | 3123 | { |
| 3124 | 3124 | $obj = $this->db->fetch_object($result); |
@@ -3143,13 +3143,13 @@ discard block |
||
| 3143 | 3143 | |
| 3144 | 3144 | // les prix |
| 3145 | 3145 | $sql = "INSERT ".MAIN_DB_PREFIX."product_price ("; |
| 3146 | - $sql.= " fk_product, date_price, price, tva_tx, localtax1_tx, localtax2_tx, fk_user_author, tosell)"; |
|
| 3147 | - $sql.= " SELECT ".$toId . ", date_price, price, tva_tx, localtax1_tx, localtax2_tx, fk_user_author, tosell"; |
|
| 3148 | - $sql.= " FROM ".MAIN_DB_PREFIX."product_price "; |
|
| 3149 | - $sql.= " WHERE fk_product = ". $fromId; |
|
| 3146 | + $sql .= " fk_product, date_price, price, tva_tx, localtax1_tx, localtax2_tx, fk_user_author, tosell)"; |
|
| 3147 | + $sql .= " SELECT ".$toId.", date_price, price, tva_tx, localtax1_tx, localtax2_tx, fk_user_author, tosell"; |
|
| 3148 | + $sql .= " FROM ".MAIN_DB_PREFIX."product_price "; |
|
| 3149 | + $sql .= " WHERE fk_product = ".$fromId; |
|
| 3150 | 3150 | |
| 3151 | 3151 | dol_syslog(get_class($this).'::clone_price', LOG_DEBUG); |
| 3152 | - if (! $this->db->query($sql)) |
|
| 3152 | + if (!$this->db->query($sql)) |
|
| 3153 | 3153 | { |
| 3154 | 3154 | $this->db->rollback(); |
| 3155 | 3155 | return -1; |
@@ -3170,11 +3170,11 @@ discard block |
||
| 3170 | 3170 | $this->db->begin(); |
| 3171 | 3171 | |
| 3172 | 3172 | $sql = 'INSERT INTO '.MAIN_DB_PREFIX.'product_association (fk_product_pere, fk_product_fils, qty)'; |
| 3173 | - $sql.= " SELECT ".$toId.", fk_product_fils, qty FROM ".MAIN_DB_PREFIX."product_association"; |
|
| 3174 | - $sql.= " WHERE fk_product_pere = ".$fromId; |
|
| 3173 | + $sql .= " SELECT ".$toId.", fk_product_fils, qty FROM ".MAIN_DB_PREFIX."product_association"; |
|
| 3174 | + $sql .= " WHERE fk_product_pere = ".$fromId; |
|
| 3175 | 3175 | |
| 3176 | 3176 | dol_syslog(get_class($this).'::clone_association', LOG_DEBUG); |
| 3177 | - if (! $this->db->query($sql)) |
|
| 3177 | + if (!$this->db->query($sql)) |
|
| 3178 | 3178 | { |
| 3179 | 3179 | $this->db->rollback(); |
| 3180 | 3180 | return -1; |
@@ -3195,7 +3195,7 @@ discard block |
||
| 3195 | 3195 | { |
| 3196 | 3196 | $this->db->begin(); |
| 3197 | 3197 | |
| 3198 | - $now=dol_now(); |
|
| 3198 | + $now = dol_now(); |
|
| 3199 | 3199 | |
| 3200 | 3200 | // les fournisseurs |
| 3201 | 3201 | /*$sql = "INSERT ".MAIN_DB_PREFIX."product_fournisseur (" |
@@ -3212,14 +3212,14 @@ discard block |
||
| 3212 | 3212 | |
| 3213 | 3213 | // les prix de fournisseurs. |
| 3214 | 3214 | $sql = "INSERT ".MAIN_DB_PREFIX."product_fournisseur_price ("; |
| 3215 | - $sql.= " datec, fk_product, fk_soc, price, quantity, fk_user)"; |
|
| 3216 | - $sql.= " SELECT '".$this->db->idate($now)."', ".$toId. ", fk_soc, price, quantity, fk_user"; |
|
| 3217 | - $sql.= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price"; |
|
| 3218 | - $sql.= " WHERE fk_product = ".$fromId; |
|
| 3215 | + $sql .= " datec, fk_product, fk_soc, price, quantity, fk_user)"; |
|
| 3216 | + $sql .= " SELECT '".$this->db->idate($now)."', ".$toId.", fk_soc, price, quantity, fk_user"; |
|
| 3217 | + $sql .= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price"; |
|
| 3218 | + $sql .= " WHERE fk_product = ".$fromId; |
|
| 3219 | 3219 | |
| 3220 | 3220 | dol_syslog(get_class($this).'::clone_fournisseurs', LOG_DEBUG); |
| 3221 | - $resql=$this->db->query($sql); |
|
| 3222 | - if (! $resql) |
|
| 3221 | + $resql = $this->db->query($sql); |
|
| 3222 | + if (!$resql) |
|
| 3223 | 3223 | { |
| 3224 | 3224 | $this->db->rollback(); |
| 3225 | 3225 | return -1; |
@@ -3242,38 +3242,38 @@ discard block |
||
| 3242 | 3242 | * @param int $id_parent Id parent |
| 3243 | 3243 | * @return void |
| 3244 | 3244 | */ |
| 3245 | - function fetch_prod_arbo($prod, $compl_path="", $multiply=1, $level=1, $id_parent=0) |
|
| 3245 | + function fetch_prod_arbo($prod, $compl_path = "", $multiply = 1, $level = 1, $id_parent = 0) |
|
| 3246 | 3246 | { |
| 3247 | - global $conf,$langs; |
|
| 3247 | + global $conf, $langs; |
|
| 3248 | 3248 | |
| 3249 | 3249 | $product = new Product($this->db); |
| 3250 | 3250 | //var_dump($prod); |
| 3251 | - foreach($prod as $id_product => $desc_pere) // $id_product is 0 (first call starting with root top) or an id of a sub_product |
|
| 3251 | + foreach ($prod as $id_product => $desc_pere) // $id_product is 0 (first call starting with root top) or an id of a sub_product |
|
| 3252 | 3252 | { |
| 3253 | 3253 | if (is_array($desc_pere)) // If desc_pere is an array, this means it's a child |
| 3254 | 3254 | { |
| 3255 | - $id=(! empty($desc_pere[0]) ? $desc_pere[0] :''); |
|
| 3256 | - $nb=(! empty($desc_pere[1]) ? $desc_pere[1] :''); |
|
| 3257 | - $type=(! empty($desc_pere[2]) ? $desc_pere[2] :''); |
|
| 3258 | - $label=(! empty($desc_pere[3]) ? $desc_pere[3] :''); |
|
| 3259 | - $incdec=!empty($desc_pere[4]) ? $desc_pere[4] : 0; |
|
| 3255 | + $id = (!empty($desc_pere[0]) ? $desc_pere[0] : ''); |
|
| 3256 | + $nb = (!empty($desc_pere[1]) ? $desc_pere[1] : ''); |
|
| 3257 | + $type = (!empty($desc_pere[2]) ? $desc_pere[2] : ''); |
|
| 3258 | + $label = (!empty($desc_pere[3]) ? $desc_pere[3] : ''); |
|
| 3259 | + $incdec = !empty($desc_pere[4]) ? $desc_pere[4] : 0; |
|
| 3260 | 3260 | |
| 3261 | - if ($multiply < 1) $multiply=1; |
|
| 3261 | + if ($multiply < 1) $multiply = 1; |
|
| 3262 | 3262 | |
| 3263 | 3263 | //print "XXX We add id=".$id." - label=".$label." - nb=".$nb." - multiply=".$multiply." fullpath=".$compl_path.$label."\n"; |
| 3264 | - $this->fetch($id); // Load product |
|
| 3265 | - $this->load_stock('nobatch,novirtual'); // Load stock to get true this->stock_reel |
|
| 3266 | - $this->res[]= array( |
|
| 3267 | - 'id'=>$id, // Id product |
|
| 3264 | + $this->fetch($id); // Load product |
|
| 3265 | + $this->load_stock('nobatch,novirtual'); // Load stock to get true this->stock_reel |
|
| 3266 | + $this->res[] = array( |
|
| 3267 | + 'id'=>$id, // Id product |
|
| 3268 | 3268 | 'id_parent'=>$id_parent, |
| 3269 | - 'ref'=>$this->ref, // Ref product |
|
| 3270 | - 'nb'=>$nb, // Nb of units that compose parent product |
|
| 3271 | - 'nb_total'=>$nb*$multiply, // Nb of units for all nb of product |
|
| 3272 | - 'stock'=>$this->stock_reel, // Stock |
|
| 3273 | - 'stock_alert'=>$this->seuil_stock_alerte, // Stock alert |
|
| 3269 | + 'ref'=>$this->ref, // Ref product |
|
| 3270 | + 'nb'=>$nb, // Nb of units that compose parent product |
|
| 3271 | + 'nb_total'=>$nb * $multiply, // Nb of units for all nb of product |
|
| 3272 | + 'stock'=>$this->stock_reel, // Stock |
|
| 3273 | + 'stock_alert'=>$this->seuil_stock_alerte, // Stock alert |
|
| 3274 | 3274 | 'label'=>$label, |
| 3275 | - 'fullpath'=>$compl_path.$label, // Label |
|
| 3276 | - 'type'=>$type, // Nb of units that compose parent product |
|
| 3275 | + 'fullpath'=>$compl_path.$label, // Label |
|
| 3276 | + 'type'=>$type, // Nb of units that compose parent product |
|
| 3277 | 3277 | 'desiredstock'=>$this->desiredstock, |
| 3278 | 3278 | 'level'=>$level, |
| 3279 | 3279 | 'incdec'=>$incdec, |
@@ -3284,7 +3284,7 @@ discard block |
||
| 3284 | 3284 | if (is_array($desc_pere['childs'])) |
| 3285 | 3285 | { |
| 3286 | 3286 | //print 'YYY We go down for '.$desc_pere[3]." -> \n"; |
| 3287 | - $this->fetch_prod_arbo($desc_pere['childs'], $compl_path.$desc_pere[3]." -> ", $desc_pere[1]*$multiply, $level+1, $id); |
|
| 3287 | + $this->fetch_prod_arbo($desc_pere['childs'], $compl_path.$desc_pere[3]." -> ", $desc_pere[1] * $multiply, $level + 1, $id); |
|
| 3288 | 3288 | } |
| 3289 | 3289 | } |
| 3290 | 3290 | } |
@@ -3297,14 +3297,14 @@ discard block |
||
| 3297 | 3297 | * @param int $multiply Because each sublevel must be multiplicated by parent nb |
| 3298 | 3298 | * @return array $this->res |
| 3299 | 3299 | */ |
| 3300 | - function get_arbo_each_prod($multiply=1) |
|
| 3300 | + function get_arbo_each_prod($multiply = 1) |
|
| 3301 | 3301 | { |
| 3302 | 3302 | $this->res = array(); |
| 3303 | 3303 | if (isset($this->sousprods) && is_array($this->sousprods)) |
| 3304 | 3304 | { |
| 3305 | - foreach($this->sousprods as $prod_name => $desc_product) |
|
| 3305 | + foreach ($this->sousprods as $prod_name => $desc_product) |
|
| 3306 | 3306 | { |
| 3307 | - if (is_array($desc_product)) $this->fetch_prod_arbo($desc_product,"",$multiply,1,$this->id); |
|
| 3307 | + if (is_array($desc_product)) $this->fetch_prod_arbo($desc_product, "", $multiply, 1, $this->id); |
|
| 3308 | 3308 | } |
| 3309 | 3309 | } |
| 3310 | 3310 | //var_dump($this->res); |
@@ -3321,8 +3321,8 @@ discard block |
||
| 3321 | 3321 | $nb = 0; |
| 3322 | 3322 | |
| 3323 | 3323 | $sql = "SELECT COUNT(pa.rowid) as nb"; |
| 3324 | - $sql.= " FROM ".MAIN_DB_PREFIX."product_association as pa"; |
|
| 3325 | - $sql.= " WHERE pa.fk_product_fils = ".$this->id." OR pa.fk_product_pere = ".$this->id; |
|
| 3324 | + $sql .= " FROM ".MAIN_DB_PREFIX."product_association as pa"; |
|
| 3325 | + $sql .= " WHERE pa.fk_product_fils = ".$this->id." OR pa.fk_product_pere = ".$this->id; |
|
| 3326 | 3326 | $resql = $this->db->query($sql); |
| 3327 | 3327 | if ($resql) |
| 3328 | 3328 | { |
@@ -3345,15 +3345,15 @@ discard block |
||
| 3345 | 3345 | function getFather() |
| 3346 | 3346 | { |
| 3347 | 3347 | $sql = "SELECT p.rowid, p.label as label, p.ref as ref, pa.fk_product_pere as id, p.fk_product_type, pa.qty, pa.incdec, p.entity"; |
| 3348 | - $sql.= " FROM ".MAIN_DB_PREFIX."product_association as pa,"; |
|
| 3349 | - $sql.= " ".MAIN_DB_PREFIX."product as p"; |
|
| 3350 | - $sql.= " WHERE p.rowid = pa.fk_product_pere"; |
|
| 3351 | - $sql.= " AND pa.fk_product_fils = ".$this->id; |
|
| 3348 | + $sql .= " FROM ".MAIN_DB_PREFIX."product_association as pa,"; |
|
| 3349 | + $sql .= " ".MAIN_DB_PREFIX."product as p"; |
|
| 3350 | + $sql .= " WHERE p.rowid = pa.fk_product_pere"; |
|
| 3351 | + $sql .= " AND pa.fk_product_fils = ".$this->id; |
|
| 3352 | 3352 | |
| 3353 | 3353 | $res = $this->db->query($sql); |
| 3354 | 3354 | if ($res) |
| 3355 | 3355 | { |
| 3356 | - $prods = array (); |
|
| 3356 | + $prods = array(); |
|
| 3357 | 3357 | while ($record = $this->db->fetch_array($res)) |
| 3358 | 3358 | { |
| 3359 | 3359 | // $record['id'] = $record['rowid'] = id of father |
@@ -3362,8 +3362,8 @@ discard block |
||
| 3362 | 3362 | $prods[$record['id']]['label'] = $record['label']; |
| 3363 | 3363 | $prods[$record['id']]['qty'] = $record['qty']; |
| 3364 | 3364 | $prods[$record['id']]['incdec'] = $record['incdec']; |
| 3365 | - $prods[$record['id']]['fk_product_type'] = $record['fk_product_type']; |
|
| 3366 | - $prods[$record['id']]['entity'] = $record['entity']; |
|
| 3365 | + $prods[$record['id']]['fk_product_type'] = $record['fk_product_type']; |
|
| 3366 | + $prods[$record['id']]['entity'] = $record['entity']; |
|
| 3367 | 3367 | } |
| 3368 | 3368 | return $prods; |
| 3369 | 3369 | } |
@@ -3383,36 +3383,36 @@ discard block |
||
| 3383 | 3383 | * @param int $level Level of recursing call (start to 1) |
| 3384 | 3384 | * @return array Return array(prodid=>array(0=prodid, 1=>qty, 2=> ...) |
| 3385 | 3385 | */ |
| 3386 | - function getChildsArbo($id, $firstlevelonly=0, $level=1) |
|
| 3386 | + function getChildsArbo($id, $firstlevelonly = 0, $level = 1) |
|
| 3387 | 3387 | { |
| 3388 | 3388 | global $alreadyfound; |
| 3389 | 3389 | |
| 3390 | 3390 | $sql = "SELECT p.rowid, p.label as label, pa.qty as qty, pa.fk_product_fils as id, p.fk_product_type, pa.incdec"; |
| 3391 | - $sql.= " FROM ".MAIN_DB_PREFIX."product as p"; |
|
| 3392 | - $sql.= ", ".MAIN_DB_PREFIX."product_association as pa"; |
|
| 3393 | - $sql.= " WHERE p.rowid = pa.fk_product_fils"; |
|
| 3394 | - $sql.= " AND pa.fk_product_pere = ".$id; |
|
| 3395 | - $sql.= " AND pa.fk_product_fils != ".$id; // This should not happens, it is to avoid infinite loop if it happens |
|
| 3391 | + $sql .= " FROM ".MAIN_DB_PREFIX."product as p"; |
|
| 3392 | + $sql .= ", ".MAIN_DB_PREFIX."product_association as pa"; |
|
| 3393 | + $sql .= " WHERE p.rowid = pa.fk_product_fils"; |
|
| 3394 | + $sql .= " AND pa.fk_product_pere = ".$id; |
|
| 3395 | + $sql .= " AND pa.fk_product_fils != ".$id; // This should not happens, it is to avoid infinite loop if it happens |
|
| 3396 | 3396 | |
| 3397 | 3397 | dol_syslog(get_class($this).'::getChildsArbo id='.$id.' level='.$level, LOG_DEBUG); |
| 3398 | 3398 | |
| 3399 | - if ($level == 1) $alreadyfound=array($id=>1); // We init array of found object to start of tree, so if we found it later (should not happened), we stop immediatly |
|
| 3399 | + if ($level == 1) $alreadyfound = array($id=>1); // We init array of found object to start of tree, so if we found it later (should not happened), we stop immediatly |
|
| 3400 | 3400 | // Protection against infinite loop |
| 3401 | 3401 | if ($level > 30) return array(); |
| 3402 | 3402 | |
| 3403 | - $res = $this->db->query($sql); |
|
| 3403 | + $res = $this->db->query($sql); |
|
| 3404 | 3404 | if ($res) |
| 3405 | 3405 | { |
| 3406 | 3406 | $prods = array(); |
| 3407 | 3407 | while ($rec = $this->db->fetch_array($res)) |
| 3408 | 3408 | { |
| 3409 | - if (! empty($alreadyfound[$rec['rowid']])) |
|
| 3409 | + if (!empty($alreadyfound[$rec['rowid']])) |
|
| 3410 | 3410 | { |
| 3411 | 3411 | dol_syslog(get_class($this).'::getChildsArbo the product id='.$rec['rowid'].' was already found at a higher level in tree. We discard to avoid infinite loop', LOG_WARNING); |
| 3412 | 3412 | continue; |
| 3413 | 3413 | } |
| 3414 | - $alreadyfound[$rec['rowid']]=1; |
|
| 3415 | - $prods[$rec['rowid']]= array( |
|
| 3414 | + $alreadyfound[$rec['rowid']] = 1; |
|
| 3415 | + $prods[$rec['rowid']] = array( |
|
| 3416 | 3416 | 0=>$rec['rowid'], |
| 3417 | 3417 | 1=>$rec['qty'], |
| 3418 | 3418 | 2=>$rec['fk_product_type'], |
@@ -3423,8 +3423,8 @@ discard block |
||
| 3423 | 3423 | //$prods[$this->db->escape($rec['label'])]= array(0=>$rec['id'],1=>$rec['qty']); |
| 3424 | 3424 | if (empty($firstlevelonly)) |
| 3425 | 3425 | { |
| 3426 | - $listofchilds=$this->getChildsArbo($rec['rowid'], 0, $level + 1); |
|
| 3427 | - foreach($listofchilds as $keyChild => $valueChild) |
|
| 3426 | + $listofchilds = $this->getChildsArbo($rec['rowid'], 0, $level + 1); |
|
| 3427 | + foreach ($listofchilds as $keyChild => $valueChild) |
|
| 3428 | 3428 | { |
| 3429 | 3429 | $prods[$rec['rowid']]['childs'][$keyChild] = $valueChild; |
| 3430 | 3430 | } |
@@ -3448,13 +3448,13 @@ discard block |
||
| 3448 | 3448 | */ |
| 3449 | 3449 | function get_sousproduits_arbo() |
| 3450 | 3450 | { |
| 3451 | - $parent=array(); |
|
| 3451 | + $parent = array(); |
|
| 3452 | 3452 | |
| 3453 | - foreach($this->getChildsArbo($this->id) as $keyChild => $valueChild) // Warning. getChildsArbo can call getChildsArbo recursively. Starting point is $value[0]=id of product |
|
| 3453 | + foreach ($this->getChildsArbo($this->id) as $keyChild => $valueChild) // Warning. getChildsArbo can call getChildsArbo recursively. Starting point is $value[0]=id of product |
|
| 3454 | 3454 | { |
| 3455 | 3455 | $parent[$this->label][$keyChild] = $valueChild; |
| 3456 | 3456 | } |
| 3457 | - foreach($parent as $key => $value) // key=label, value is array of childs |
|
| 3457 | + foreach ($parent as $key => $value) // key=label, value is array of childs |
|
| 3458 | 3458 | { |
| 3459 | 3459 | $this->sousprods[$key] = $value; |
| 3460 | 3460 | } |
@@ -3469,71 +3469,71 @@ discard block |
||
| 3469 | 3469 | * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking |
| 3470 | 3470 | * @return string String with URL |
| 3471 | 3471 | */ |
| 3472 | - function getNomUrl($withpicto=0, $option='', $maxlength=0, $save_lastsearch_value=-1) |
|
| 3472 | + function getNomUrl($withpicto = 0, $option = '', $maxlength = 0, $save_lastsearch_value = -1) |
|
| 3473 | 3473 | { |
| 3474 | 3474 | global $conf, $langs, $hookmanager; |
| 3475 | 3475 | include_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php'; |
| 3476 | 3476 | |
| 3477 | - $result=''; |
|
| 3478 | - $newref=$this->ref; |
|
| 3479 | - if ($maxlength) $newref=dol_trunc($newref,$maxlength,'middle'); |
|
| 3477 | + $result = ''; |
|
| 3478 | + $newref = $this->ref; |
|
| 3479 | + if ($maxlength) $newref = dol_trunc($newref, $maxlength, 'middle'); |
|
| 3480 | 3480 | |
| 3481 | - if ($this->type == Product::TYPE_PRODUCT) $label = '<u>' . $langs->trans("ShowProduct") . '</u>'; |
|
| 3482 | - if ($this->type == Product::TYPE_SERVICE) $label = '<u>' . $langs->trans("ShowService") . '</u>'; |
|
| 3483 | - if (! empty($this->ref)) |
|
| 3484 | - $label .= '<br><b>' . $langs->trans('ProductRef') . ':</b> ' . $this->ref; |
|
| 3485 | - if (! empty($this->label)) |
|
| 3486 | - $label .= '<br><b>' . $langs->trans('ProductLabel') . ':</b> ' . $this->label; |
|
| 3481 | + if ($this->type == Product::TYPE_PRODUCT) $label = '<u>'.$langs->trans("ShowProduct").'</u>'; |
|
| 3482 | + if ($this->type == Product::TYPE_SERVICE) $label = '<u>'.$langs->trans("ShowService").'</u>'; |
|
| 3483 | + if (!empty($this->ref)) |
|
| 3484 | + $label .= '<br><b>'.$langs->trans('ProductRef').':</b> '.$this->ref; |
|
| 3485 | + if (!empty($this->label)) |
|
| 3486 | + $label .= '<br><b>'.$langs->trans('ProductLabel').':</b> '.$this->label; |
|
| 3487 | 3487 | |
| 3488 | 3488 | if ($this->type == Product::TYPE_PRODUCT) |
| 3489 | 3489 | { |
| 3490 | - if ($this->weight) $label.="<br><b>".$langs->trans("Weight").'</b>: '.$this->weight.' '.measuring_units_string($this->weight_units,"weight"); |
|
| 3491 | - if ($this->length) $label.="<br><b>".$langs->trans("Length").'</b>: '.$this->length.' '.measuring_units_string($this->length_units,'length'); |
|
| 3492 | - if ($this->surface) $label.="<br><b>".$langs->trans("Surface").'</b>: '.$this->surface.' '.measuring_units_string($this->surface_units,'surface'); |
|
| 3493 | - if ($this->volume) $label.="<br><b>".$langs->trans("Volume").'</b>: '.$this->volume.' '.measuring_units_string($this->volume_units,'volume'); |
|
| 3490 | + if ($this->weight) $label .= "<br><b>".$langs->trans("Weight").'</b>: '.$this->weight.' '.measuring_units_string($this->weight_units, "weight"); |
|
| 3491 | + if ($this->length) $label .= "<br><b>".$langs->trans("Length").'</b>: '.$this->length.' '.measuring_units_string($this->length_units, 'length'); |
|
| 3492 | + if ($this->surface) $label .= "<br><b>".$langs->trans("Surface").'</b>: '.$this->surface.' '.measuring_units_string($this->surface_units, 'surface'); |
|
| 3493 | + if ($this->volume) $label .= "<br><b>".$langs->trans("Volume").'</b>: '.$this->volume.' '.measuring_units_string($this->volume_units, 'volume'); |
|
| 3494 | 3494 | } |
| 3495 | 3495 | |
| 3496 | - if ($this->type == Product::TYPE_PRODUCT || ! empty($conf->global->STOCK_SUPPORTS_SERVICES)) |
|
| 3496 | + if ($this->type == Product::TYPE_PRODUCT || !empty($conf->global->STOCK_SUPPORTS_SERVICES)) |
|
| 3497 | 3497 | { |
| 3498 | - if (! empty($conf->productbatch->enabled)) |
|
| 3498 | + if (!empty($conf->productbatch->enabled)) |
|
| 3499 | 3499 | { |
| 3500 | 3500 | $langs->load("productbatch"); |
| 3501 | - $label.="<br><b>".$langs->trans("ManageLotSerial").'</b>: '.$this->getLibStatut(0,2); |
|
| 3501 | + $label .= "<br><b>".$langs->trans("ManageLotSerial").'</b>: '.$this->getLibStatut(0, 2); |
|
| 3502 | 3502 | } |
| 3503 | 3503 | } |
| 3504 | 3504 | if ($this->type == Product::TYPE_SERVICE) |
| 3505 | 3505 | { |
| 3506 | 3506 | // |
| 3507 | 3507 | } |
| 3508 | - if (! empty($conf->accounting->enabled) && $this->status) |
|
| 3508 | + if (!empty($conf->accounting->enabled) && $this->status) |
|
| 3509 | 3509 | { |
| 3510 | 3510 | include_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; |
| 3511 | - $label.= '<br><b>' . $langs->trans('ProductAccountancySellCode') . ':</b> '. length_accountg($this->accountancy_code_sell); |
|
| 3512 | - $label.= '<br><b>' . $langs->trans('ProductAccountancySellIntraCode') . ':</b> '. length_accountg($this->accountancy_code_sell_export); |
|
| 3513 | - $label.= '<br><b>' . $langs->trans('ProductAccountancySellExportCode') . ':</b> '. length_accountg($this->accountancy_code_sell_intra); |
|
| 3511 | + $label .= '<br><b>'.$langs->trans('ProductAccountancySellCode').':</b> '.length_accountg($this->accountancy_code_sell); |
|
| 3512 | + $label .= '<br><b>'.$langs->trans('ProductAccountancySellIntraCode').':</b> '.length_accountg($this->accountancy_code_sell_export); |
|
| 3513 | + $label .= '<br><b>'.$langs->trans('ProductAccountancySellExportCode').':</b> '.length_accountg($this->accountancy_code_sell_intra); |
|
| 3514 | 3514 | } |
| 3515 | - if (! empty($conf->accounting->enabled) && $this->status_buy) |
|
| 3515 | + if (!empty($conf->accounting->enabled) && $this->status_buy) |
|
| 3516 | 3516 | { |
| 3517 | 3517 | include_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; |
| 3518 | - $label.= '<br><b>' . $langs->trans('ProductAccountancyBuyCode') . ':</b> '. length_accountg($this->accountancy_code_buy); |
|
| 3518 | + $label .= '<br><b>'.$langs->trans('ProductAccountancyBuyCode').':</b> '.length_accountg($this->accountancy_code_buy); |
|
| 3519 | 3519 | } |
| 3520 | - if (! empty($this->entity)) |
|
| 3520 | + if (!empty($this->entity)) |
|
| 3521 | 3521 | { |
| 3522 | 3522 | $tmpphoto = $this->show_photos('product', $conf->product->multidir_output[$this->entity], 1, 1, 0, 0, 0, 80); |
| 3523 | - if ($this->nbphoto > 0) $label .= '<br>' . $tmpphoto; |
|
| 3523 | + if ($this->nbphoto > 0) $label .= '<br>'.$tmpphoto; |
|
| 3524 | 3524 | } |
| 3525 | 3525 | |
| 3526 | - $linkclose=''; |
|
| 3526 | + $linkclose = ''; |
|
| 3527 | 3527 | if (empty($notooltip)) |
| 3528 | 3528 | { |
| 3529 | - if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) |
|
| 3529 | + if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) |
|
| 3530 | 3530 | { |
| 3531 | - $label=$langs->trans("ShowOrder"); |
|
| 3532 | - $linkclose.=' alt="'.dol_escape_htmltag($label, 1).'"'; |
|
| 3531 | + $label = $langs->trans("ShowOrder"); |
|
| 3532 | + $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; |
|
| 3533 | 3533 | } |
| 3534 | 3534 | |
| 3535 | - $linkclose.= ' title="'.dol_escape_htmltag($label, 1, 1).'"'; |
|
| 3536 | - $linkclose.= ' class="classfortooltip"'; |
|
| 3535 | + $linkclose .= ' title="'.dol_escape_htmltag($label, 1, 1).'"'; |
|
| 3536 | + $linkclose .= ' class="classfortooltip"'; |
|
| 3537 | 3537 | |
| 3538 | 3538 | /*if (! is_object($hookmanager)) |
| 3539 | 3539 | { |
@@ -3560,32 +3560,32 @@ discard block |
||
| 3560 | 3560 | if ($option !== 'nolink') |
| 3561 | 3561 | { |
| 3562 | 3562 | // Add param to save lastsearch_values or not |
| 3563 | - $add_save_lastsearch_values=($save_lastsearch_value == 1 ? 1 : 0); |
|
| 3564 | - if ($save_lastsearch_value == -1 && preg_match('/list\.php/',$_SERVER["PHP_SELF"])) $add_save_lastsearch_values=1; |
|
| 3565 | - if ($add_save_lastsearch_values) $url.='&save_lastsearch_values=1'; |
|
| 3563 | + $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); |
|
| 3564 | + if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values = 1; |
|
| 3565 | + if ($add_save_lastsearch_values) $url .= '&save_lastsearch_values=1'; |
|
| 3566 | 3566 | } |
| 3567 | 3567 | |
| 3568 | 3568 | $linkstart = '<a href="'.$url.'"'; |
| 3569 | - $linkstart.=$linkclose.'>'; |
|
| 3570 | - $linkend='</a>'; |
|
| 3569 | + $linkstart .= $linkclose.'>'; |
|
| 3570 | + $linkend = '</a>'; |
|
| 3571 | 3571 | |
| 3572 | - $result.=$linkstart; |
|
| 3572 | + $result .= $linkstart; |
|
| 3573 | 3573 | if ($withpicto) { |
| 3574 | - if ($this->type == Product::TYPE_PRODUCT) $result.=(img_object(($notooltip?'':$label), 'product', ($notooltip?'class="paddingright"':'class="paddingright classfortooltip"'), 0, 0, $notooltip?0:1)); |
|
| 3575 | - if ($this->type == Product::TYPE_SERVICE) $result.=(img_object(($notooltip?'':$label), 'service', ($notooltip?'class="paddinright"':'class="paddingright classfortooltip"'), 0, 0, $notooltip?0:1)); |
|
| 3574 | + if ($this->type == Product::TYPE_PRODUCT) $result .= (img_object(($notooltip ? '' : $label), 'product', ($notooltip ? 'class="paddingright"' : 'class="paddingright classfortooltip"'), 0, 0, $notooltip ? 0 : 1)); |
|
| 3575 | + if ($this->type == Product::TYPE_SERVICE) $result .= (img_object(($notooltip ? '' : $label), 'service', ($notooltip ? 'class="paddinright"' : 'class="paddingright classfortooltip"'), 0, 0, $notooltip ? 0 : 1)); |
|
| 3576 | 3576 | } |
| 3577 | - $result.= $newref; |
|
| 3578 | - $result.= $linkend; |
|
| 3577 | + $result .= $newref; |
|
| 3578 | + $result .= $linkend; |
|
| 3579 | 3579 | |
| 3580 | 3580 | global $action; |
| 3581 | - if (! is_object($hookmanager)) |
|
| 3581 | + if (!is_object($hookmanager)) |
|
| 3582 | 3582 | { |
| 3583 | 3583 | include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; |
| 3584 | - $hookmanager=new HookManager($this->db); |
|
| 3584 | + $hookmanager = new HookManager($this->db); |
|
| 3585 | 3585 | } |
| 3586 | 3586 | $hookmanager->initHooks(array('productdao')); |
| 3587 | - $parameters=array('id'=>$this->id, 'getnomurl'=>$result); |
|
| 3588 | - $reshook=$hookmanager->executeHooks('getNomUrl',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks |
|
| 3587 | + $parameters = array('id'=>$this->id, 'getnomurl'=>$result); |
|
| 3588 | + $reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks |
|
| 3589 | 3589 | if ($reshook > 0) $result = $hookmanager->resPrint; |
| 3590 | 3590 | else $result .= $hookmanager->resPrint; |
| 3591 | 3591 | |
@@ -3603,16 +3603,16 @@ discard block |
||
| 3603 | 3603 | * @param int $hideref Hide ref |
| 3604 | 3604 | * @return int 0 if KO, 1 if OK |
| 3605 | 3605 | */ |
| 3606 | - public function generateDocument($modele, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0) |
|
| 3606 | + public function generateDocument($modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0) |
|
| 3607 | 3607 | { |
| 3608 | - global $conf,$user,$langs; |
|
| 3608 | + global $conf, $user, $langs; |
|
| 3609 | 3609 | |
| 3610 | 3610 | $langs->load("products"); |
| 3611 | 3611 | |
| 3612 | 3612 | // Positionne le modele sur le nom du modele a utiliser |
| 3613 | - if (! dol_strlen($modele)) |
|
| 3613 | + if (!dol_strlen($modele)) |
|
| 3614 | 3614 | { |
| 3615 | - if (! empty($conf->global->PRODUCT_ADDON_PDF)) |
|
| 3615 | + if (!empty($conf->global->PRODUCT_ADDON_PDF)) |
|
| 3616 | 3616 | { |
| 3617 | 3617 | $modele = $conf->global->PRODUCT_ADDON_PDF; |
| 3618 | 3618 | } |
@@ -3634,19 +3634,19 @@ discard block |
||
| 3634 | 3634 | * @param int $type 0=Sell, 1=Buy, 2=Batch Number management |
| 3635 | 3635 | * @return string Label of status |
| 3636 | 3636 | */ |
| 3637 | - function getLibStatut($mode=0, $type=0) |
|
| 3637 | + function getLibStatut($mode = 0, $type = 0) |
|
| 3638 | 3638 | { |
| 3639 | 3639 | switch ($type) |
| 3640 | 3640 | { |
| 3641 | 3641 | case 0: |
| 3642 | - return $this->LibStatut($this->status,$mode,$type); |
|
| 3642 | + return $this->LibStatut($this->status, $mode, $type); |
|
| 3643 | 3643 | case 1: |
| 3644 | - return $this->LibStatut($this->status_buy,$mode,$type); |
|
| 3644 | + return $this->LibStatut($this->status_buy, $mode, $type); |
|
| 3645 | 3645 | case 2: |
| 3646 | - return $this->LibStatut($this->status_batch,$mode,$type); |
|
| 3646 | + return $this->LibStatut($this->status_batch, $mode, $type); |
|
| 3647 | 3647 | default: |
| 3648 | 3648 | //Simulate previous behavior but should return an error string |
| 3649 | - return $this->LibStatut($this->status_buy,$mode,$type); |
|
| 3649 | + return $this->LibStatut($this->status_buy, $mode, $type); |
|
| 3650 | 3650 | } |
| 3651 | 3651 | } |
| 3652 | 3652 | |
@@ -3658,12 +3658,12 @@ discard block |
||
| 3658 | 3658 | * @param int $type 0=Status "to sell", 1=Status "to buy", 2=Status "to Batch" |
| 3659 | 3659 | * @return string Label of status |
| 3660 | 3660 | */ |
| 3661 | - function LibStatut($status,$mode=0,$type=0) |
|
| 3661 | + function LibStatut($status, $mode = 0, $type = 0) |
|
| 3662 | 3662 | { |
| 3663 | 3663 | global $conf, $langs; |
| 3664 | 3664 | |
| 3665 | 3665 | $langs->load('products'); |
| 3666 | - if (! empty($conf->productbatch->enabled)) $langs->load("productbatch"); |
|
| 3666 | + if (!empty($conf->productbatch->enabled)) $langs->load("productbatch"); |
|
| 3667 | 3667 | |
| 3668 | 3668 | if ($type == 2) |
| 3669 | 3669 | { |
@@ -3674,55 +3674,55 @@ discard block |
||
| 3674 | 3674 | case 1: |
| 3675 | 3675 | return ($status == 0 ? $langs->trans('ProductStatusNotOnBatchShort') : $langs->trans('ProductStatusOnBatchShort')); |
| 3676 | 3676 | case 2: |
| 3677 | - return $this->LibStatut($status,3,2).' '.$this->LibStatut($status,1,2); |
|
| 3677 | + return $this->LibStatut($status, 3, 2).' '.$this->LibStatut($status, 1, 2); |
|
| 3678 | 3678 | case 3: |
| 3679 | 3679 | if ($status == 0) |
| 3680 | 3680 | { |
| 3681 | - return img_picto($langs->trans('ProductStatusNotOnBatch'),'statut5'); |
|
| 3681 | + return img_picto($langs->trans('ProductStatusNotOnBatch'), 'statut5'); |
|
| 3682 | 3682 | } |
| 3683 | - return img_picto($langs->trans('ProductStatusOnBatch'),'statut4'); |
|
| 3683 | + return img_picto($langs->trans('ProductStatusOnBatch'), 'statut4'); |
|
| 3684 | 3684 | case 4: |
| 3685 | - return $this->LibStatut($status,3,2).' '.$this->LibStatut($status,0,2); |
|
| 3685 | + return $this->LibStatut($status, 3, 2).' '.$this->LibStatut($status, 0, 2); |
|
| 3686 | 3686 | case 5: |
| 3687 | - return $this->LibStatut($status,1,2).' '.$this->LibStatut($status,3,2); |
|
| 3687 | + return $this->LibStatut($status, 1, 2).' '.$this->LibStatut($status, 3, 2); |
|
| 3688 | 3688 | default: |
| 3689 | 3689 | return $langs->trans('Unknown'); |
| 3690 | 3690 | } |
| 3691 | 3691 | } |
| 3692 | 3692 | if ($mode == 0) |
| 3693 | 3693 | { |
| 3694 | - if ($status == 0) return ($type==0 ? $langs->trans('ProductStatusNotOnSellShort'):$langs->trans('ProductStatusNotOnBuyShort')); |
|
| 3695 | - if ($status == 1) return ($type==0 ? $langs->trans('ProductStatusOnSellShort'):$langs->trans('ProductStatusOnBuyShort')); |
|
| 3694 | + if ($status == 0) return ($type == 0 ? $langs->trans('ProductStatusNotOnSellShort') : $langs->trans('ProductStatusNotOnBuyShort')); |
|
| 3695 | + if ($status == 1) return ($type == 0 ? $langs->trans('ProductStatusOnSellShort') : $langs->trans('ProductStatusOnBuyShort')); |
|
| 3696 | 3696 | } |
| 3697 | 3697 | if ($mode == 1) |
| 3698 | 3698 | { |
| 3699 | - if ($status == 0) return ($type==0 ? $langs->trans('ProductStatusNotOnSell'):$langs->trans('ProductStatusNotOnBuy')); |
|
| 3700 | - if ($status == 1) return ($type==0 ? $langs->trans('ProductStatusOnSell'):$langs->trans('ProductStatusOnBuy')); |
|
| 3699 | + if ($status == 0) return ($type == 0 ? $langs->trans('ProductStatusNotOnSell') : $langs->trans('ProductStatusNotOnBuy')); |
|
| 3700 | + if ($status == 1) return ($type == 0 ? $langs->trans('ProductStatusOnSell') : $langs->trans('ProductStatusOnBuy')); |
|
| 3701 | 3701 | } |
| 3702 | 3702 | if ($mode == 2) |
| 3703 | 3703 | { |
| 3704 | - if ($status == 0) return img_picto($langs->trans('ProductStatusNotOnSell'),'statut5', 'class="pictostatus"').' '.($type==0 ? $langs->trans('ProductStatusNotOnSellShort'):$langs->trans('ProductStatusNotOnBuyShort')); |
|
| 3705 | - if ($status == 1) return img_picto($langs->trans('ProductStatusOnSell'),'statut4', 'class="pictostatus"').' '.($type==0 ? $langs->trans('ProductStatusOnSellShort'):$langs->trans('ProductStatusOnBuyShort')); |
|
| 3704 | + if ($status == 0) return img_picto($langs->trans('ProductStatusNotOnSell'), 'statut5', 'class="pictostatus"').' '.($type == 0 ? $langs->trans('ProductStatusNotOnSellShort') : $langs->trans('ProductStatusNotOnBuyShort')); |
|
| 3705 | + if ($status == 1) return img_picto($langs->trans('ProductStatusOnSell'), 'statut4', 'class="pictostatus"').' '.($type == 0 ? $langs->trans('ProductStatusOnSellShort') : $langs->trans('ProductStatusOnBuyShort')); |
|
| 3706 | 3706 | } |
| 3707 | 3707 | if ($mode == 3) |
| 3708 | 3708 | { |
| 3709 | - if ($status == 0) return img_picto(($type==0 ? $langs->trans('ProductStatusNotOnSell') : $langs->trans('ProductStatusNotOnBuy')),'statut5', 'class="pictostatus"'); |
|
| 3710 | - if ($status == 1) return img_picto(($type==0 ? $langs->trans('ProductStatusOnSell') : $langs->trans('ProductStatusOnBuy')),'statut4', 'class="pictostatus"'); |
|
| 3709 | + if ($status == 0) return img_picto(($type == 0 ? $langs->trans('ProductStatusNotOnSell') : $langs->trans('ProductStatusNotOnBuy')), 'statut5', 'class="pictostatus"'); |
|
| 3710 | + if ($status == 1) return img_picto(($type == 0 ? $langs->trans('ProductStatusOnSell') : $langs->trans('ProductStatusOnBuy')), 'statut4', 'class="pictostatus"'); |
|
| 3711 | 3711 | } |
| 3712 | 3712 | if ($mode == 4) |
| 3713 | 3713 | { |
| 3714 | - if ($status == 0) return img_picto($langs->trans('ProductStatusNotOnSell'),'statut5', 'class="pictostatus"').' '.($type==0 ? $langs->trans('ProductStatusNotOnSell'):$langs->trans('ProductStatusNotOnBuy')); |
|
| 3715 | - if ($status == 1) return img_picto($langs->trans('ProductStatusOnSell'),'statut4', 'class="pictostatus"').' '.($type==0 ? $langs->trans('ProductStatusOnSell'):$langs->trans('ProductStatusOnBuy')); |
|
| 3714 | + if ($status == 0) return img_picto($langs->trans('ProductStatusNotOnSell'), 'statut5', 'class="pictostatus"').' '.($type == 0 ? $langs->trans('ProductStatusNotOnSell') : $langs->trans('ProductStatusNotOnBuy')); |
|
| 3715 | + if ($status == 1) return img_picto($langs->trans('ProductStatusOnSell'), 'statut4', 'class="pictostatus"').' '.($type == 0 ? $langs->trans('ProductStatusOnSell') : $langs->trans('ProductStatusOnBuy')); |
|
| 3716 | 3716 | } |
| 3717 | 3717 | if ($mode == 5) |
| 3718 | 3718 | { |
| 3719 | - if ($status == 0) return ($type==0 ? $langs->trans('ProductStatusNotOnSellShort'):$langs->trans('ProductStatusNotOnBuyShort')).' '.img_picto(($type==0 ? $langs->trans('ProductStatusNotOnSell'):$langs->trans('ProductStatusNotOnBuy')), 'statut5', 'class="pictostatus"'); |
|
| 3720 | - if ($status == 1) return ($type==0 ? $langs->trans('ProductStatusOnSellShort'):$langs->trans('ProductStatusOnBuyShort')).' '.img_picto(($type==0 ? $langs->trans('ProductStatusOnSell'):$langs->trans('ProductStatusOnBuy')),'statut4', 'class="pictostatus"'); |
|
| 3719 | + if ($status == 0) return ($type == 0 ? $langs->trans('ProductStatusNotOnSellShort') : $langs->trans('ProductStatusNotOnBuyShort')).' '.img_picto(($type == 0 ? $langs->trans('ProductStatusNotOnSell') : $langs->trans('ProductStatusNotOnBuy')), 'statut5', 'class="pictostatus"'); |
|
| 3720 | + if ($status == 1) return ($type == 0 ? $langs->trans('ProductStatusOnSellShort') : $langs->trans('ProductStatusOnBuyShort')).' '.img_picto(($type == 0 ? $langs->trans('ProductStatusOnSell') : $langs->trans('ProductStatusOnBuy')), 'statut4', 'class="pictostatus"'); |
|
| 3721 | 3721 | } |
| 3722 | 3722 | if ($mode == 6) |
| 3723 | 3723 | { |
| 3724 | - if ($status == 0) return ($type==0 ? $langs->trans('ProductStatusNotOnSellShort'):$langs->trans('ProductStatusNotOnBuyShort')).' '.img_picto(($type==0 ? $langs->trans('ProductStatusNotOnSell'):$langs->trans('ProductStatusNotOnBuy')), 'statut5', 'class="pictostatus"'); |
|
| 3725 | - if ($status == 1) return ($type==0 ? $langs->trans('ProductStatusOnSellShort'):$langs->trans('ProductStatusOnBuyShort')).' '.img_picto(($type==0 ? $langs->trans('ProductStatusOnSell'):$langs->trans('ProductStatusOnBuy')),'statut4', 'class="pictostatus"'); |
|
| 3724 | + if ($status == 0) return ($type == 0 ? $langs->trans('ProductStatusNotOnSellShort') : $langs->trans('ProductStatusNotOnBuyShort')).' '.img_picto(($type == 0 ? $langs->trans('ProductStatusNotOnSell') : $langs->trans('ProductStatusNotOnBuy')), 'statut5', 'class="pictostatus"'); |
|
| 3725 | + if ($status == 1) return ($type == 0 ? $langs->trans('ProductStatusOnSellShort') : $langs->trans('ProductStatusOnBuyShort')).' '.img_picto(($type == 0 ? $langs->trans('ProductStatusOnSell') : $langs->trans('ProductStatusOnBuy')), 'statut4', 'class="pictostatus"'); |
|
| 3726 | 3726 | } |
| 3727 | 3727 | return $langs->trans('Unknown'); |
| 3728 | 3728 | } |
@@ -3758,20 +3758,20 @@ discard block |
||
| 3758 | 3758 | * @param int $origin_id Origin id of element |
| 3759 | 3759 | * @return int <0 if KO, >0 if OK |
| 3760 | 3760 | */ |
| 3761 | - function correct_stock($user, $id_entrepot, $nbpiece, $movement, $label='', $price=0, $inventorycode='', $origin_element='', $origin_id=null) |
|
| 3761 | + function correct_stock($user, $id_entrepot, $nbpiece, $movement, $label = '', $price = 0, $inventorycode = '', $origin_element = '', $origin_id = null) |
|
| 3762 | 3762 | { |
| 3763 | 3763 | if ($id_entrepot) |
| 3764 | 3764 | { |
| 3765 | 3765 | $this->db->begin(); |
| 3766 | 3766 | |
| 3767 | - require_once DOL_DOCUMENT_ROOT .'/product/stock/class/mouvementstock.class.php'; |
|
| 3767 | + require_once DOL_DOCUMENT_ROOT.'/product/stock/class/mouvementstock.class.php'; |
|
| 3768 | 3768 | |
| 3769 | 3769 | $op[0] = "+".trim($nbpiece); |
| 3770 | 3770 | $op[1] = "-".trim($nbpiece); |
| 3771 | 3771 | |
| 3772 | - $movementstock=new MouvementStock($this->db); |
|
| 3772 | + $movementstock = new MouvementStock($this->db); |
|
| 3773 | 3773 | $movementstock->setOrigin($origin_element, $origin_id); |
| 3774 | - $result=$movementstock->_create($user,$this->id,$id_entrepot,$op[$movement],$movement,$price,$label,$inventorycode); |
|
| 3774 | + $result = $movementstock->_create($user, $this->id, $id_entrepot, $op[$movement], $movement, $price, $label, $inventorycode); |
|
| 3775 | 3775 | |
| 3776 | 3776 | if ($result >= 0) |
| 3777 | 3777 | { |
@@ -3780,8 +3780,8 @@ discard block |
||
| 3780 | 3780 | } |
| 3781 | 3781 | else |
| 3782 | 3782 | { |
| 3783 | - $this->error=$movementstock->error; |
|
| 3784 | - $this->errors=$movementstock->errors; |
|
| 3783 | + $this->error = $movementstock->error; |
|
| 3784 | + $this->errors = $movementstock->errors; |
|
| 3785 | 3785 | |
| 3786 | 3786 | $this->db->rollback(); |
| 3787 | 3787 | return -1; |
@@ -3806,20 +3806,20 @@ discard block |
||
| 3806 | 3806 | * @param int $origin_id Origin id of element |
| 3807 | 3807 | * @return int <0 if KO, >0 if OK |
| 3808 | 3808 | */ |
| 3809 | - function correct_stock_batch($user, $id_entrepot, $nbpiece, $movement, $label='', $price=0, $dlc='', $dluo='',$lot='', $inventorycode='', $origin_element='', $origin_id=null) |
|
| 3809 | + function correct_stock_batch($user, $id_entrepot, $nbpiece, $movement, $label = '', $price = 0, $dlc = '', $dluo = '', $lot = '', $inventorycode = '', $origin_element = '', $origin_id = null) |
|
| 3810 | 3810 | { |
| 3811 | 3811 | if ($id_entrepot) |
| 3812 | 3812 | { |
| 3813 | 3813 | $this->db->begin(); |
| 3814 | 3814 | |
| 3815 | - require_once DOL_DOCUMENT_ROOT .'/product/stock/class/mouvementstock.class.php'; |
|
| 3815 | + require_once DOL_DOCUMENT_ROOT.'/product/stock/class/mouvementstock.class.php'; |
|
| 3816 | 3816 | |
| 3817 | 3817 | $op[0] = "+".trim($nbpiece); |
| 3818 | 3818 | $op[1] = "-".trim($nbpiece); |
| 3819 | 3819 | |
| 3820 | - $movementstock=new MouvementStock($this->db); |
|
| 3820 | + $movementstock = new MouvementStock($this->db); |
|
| 3821 | 3821 | $movementstock->setOrigin($origin_element, $origin_id); |
| 3822 | - $result=$movementstock->_create($user,$this->id,$id_entrepot,$op[$movement],$movement,$price,$label,$inventorycode,'',$dlc,$dluo,$lot); |
|
| 3822 | + $result = $movementstock->_create($user, $this->id, $id_entrepot, $op[$movement], $movement, $price, $label, $inventorycode, '', $dlc, $dluo, $lot); |
|
| 3823 | 3823 | |
| 3824 | 3824 | if ($result >= 0) |
| 3825 | 3825 | { |
@@ -3828,8 +3828,8 @@ discard block |
||
| 3828 | 3828 | } |
| 3829 | 3829 | else |
| 3830 | 3830 | { |
| 3831 | - $this->error=$movementstock->error; |
|
| 3832 | - $this->errors=$movementstock->errors; |
|
| 3831 | + $this->error = $movementstock->error; |
|
| 3832 | + $this->errors = $movementstock->errors; |
|
| 3833 | 3833 | |
| 3834 | 3834 | $this->db->rollback(); |
| 3835 | 3835 | return -1; |
@@ -3851,7 +3851,7 @@ discard block |
||
| 3851 | 3851 | * @return int < 0 if KO, > 0 if OK |
| 3852 | 3852 | * @see load_virtual_stock, getBatchInfo |
| 3853 | 3853 | */ |
| 3854 | - function load_stock($option='') |
|
| 3854 | + function load_stock($option = '') |
|
| 3855 | 3855 | { |
| 3856 | 3856 | global $conf; |
| 3857 | 3857 | |
@@ -3875,19 +3875,19 @@ discard block |
||
| 3875 | 3875 | } |
| 3876 | 3876 | |
| 3877 | 3877 | $sql = "SELECT ps.rowid, ps.reel, ps.fk_entrepot"; |
| 3878 | - $sql.= " FROM ".MAIN_DB_PREFIX."product_stock as ps"; |
|
| 3879 | - $sql.= ", ".MAIN_DB_PREFIX."entrepot as w"; |
|
| 3880 | - $sql.= " WHERE w.entity IN (".getEntity('stock').")"; |
|
| 3881 | - $sql.= " AND w.rowid = ps.fk_entrepot"; |
|
| 3882 | - $sql.= " AND ps.fk_product = ".$this->id; |
|
| 3883 | - if ($conf->global->ENTREPOT_EXTRA_STATUS && count($warehouseStatus)) $sql.= " AND w.statut IN (".$this->db->escape(implode(',',$warehouseStatus)).")"; |
|
| 3878 | + $sql .= " FROM ".MAIN_DB_PREFIX."product_stock as ps"; |
|
| 3879 | + $sql .= ", ".MAIN_DB_PREFIX."entrepot as w"; |
|
| 3880 | + $sql .= " WHERE w.entity IN (".getEntity('stock').")"; |
|
| 3881 | + $sql .= " AND w.rowid = ps.fk_entrepot"; |
|
| 3882 | + $sql .= " AND ps.fk_product = ".$this->id; |
|
| 3883 | + if ($conf->global->ENTREPOT_EXTRA_STATUS && count($warehouseStatus)) $sql .= " AND w.statut IN (".$this->db->escape(implode(',', $warehouseStatus)).")"; |
|
| 3884 | 3884 | |
| 3885 | 3885 | dol_syslog(get_class($this)."::load_stock", LOG_DEBUG); |
| 3886 | 3886 | $result = $this->db->query($sql); |
| 3887 | 3887 | if ($result) |
| 3888 | 3888 | { |
| 3889 | 3889 | $num = $this->db->num_rows($result); |
| 3890 | - $i=0; |
|
| 3890 | + $i = 0; |
|
| 3891 | 3891 | if ($num > 0) |
| 3892 | 3892 | { |
| 3893 | 3893 | while ($i < $num) |
@@ -3896,23 +3896,23 @@ discard block |
||
| 3896 | 3896 | $this->stock_warehouse[$row->fk_entrepot] = new stdClass(); |
| 3897 | 3897 | $this->stock_warehouse[$row->fk_entrepot]->real = $row->reel; |
| 3898 | 3898 | $this->stock_warehouse[$row->fk_entrepot]->id = $row->rowid; |
| 3899 | - if ((! preg_match('/nobatch/', $option)) && $this->hasbatch()) $this->stock_warehouse[$row->fk_entrepot]->detail_batch=Productbatch::findAll($this->db, $row->rowid, 1, $this->id); |
|
| 3900 | - $this->stock_reel+=$row->reel; |
|
| 3899 | + if ((!preg_match('/nobatch/', $option)) && $this->hasbatch()) $this->stock_warehouse[$row->fk_entrepot]->detail_batch = Productbatch::findAll($this->db, $row->rowid, 1, $this->id); |
|
| 3900 | + $this->stock_reel += $row->reel; |
|
| 3901 | 3901 | $i++; |
| 3902 | 3902 | } |
| 3903 | 3903 | } |
| 3904 | 3904 | $this->db->free($result); |
| 3905 | 3905 | |
| 3906 | - if (! preg_match('/novirtual/', $option)) |
|
| 3906 | + if (!preg_match('/novirtual/', $option)) |
|
| 3907 | 3907 | { |
| 3908 | - $this->load_virtual_stock(); // This also load stats_commande_fournisseur, ... |
|
| 3908 | + $this->load_virtual_stock(); // This also load stats_commande_fournisseur, ... |
|
| 3909 | 3909 | } |
| 3910 | 3910 | |
| 3911 | 3911 | return 1; |
| 3912 | 3912 | } |
| 3913 | 3913 | else |
| 3914 | 3914 | { |
| 3915 | - $this->error=$this->db->lasterror(); |
|
| 3915 | + $this->error = $this->db->lasterror(); |
|
| 3916 | 3916 | return -1; |
| 3917 | 3917 | } |
| 3918 | 3918 | } |
@@ -3928,53 +3928,53 @@ discard block |
||
| 3928 | 3928 | { |
| 3929 | 3929 | global $conf; |
| 3930 | 3930 | |
| 3931 | - $stock_commande_client=0; |
|
| 3932 | - $stock_commande_fournisseur=0; |
|
| 3933 | - $stock_sending_client=0; |
|
| 3934 | - $stock_reception_fournisseur=0; |
|
| 3931 | + $stock_commande_client = 0; |
|
| 3932 | + $stock_commande_fournisseur = 0; |
|
| 3933 | + $stock_sending_client = 0; |
|
| 3934 | + $stock_reception_fournisseur = 0; |
|
| 3935 | 3935 | |
| 3936 | - if (! empty($conf->commande->enabled)) |
|
| 3936 | + if (!empty($conf->commande->enabled)) |
|
| 3937 | 3937 | { |
| 3938 | - $result=$this->load_stats_commande(0,'1,2', 1); |
|
| 3939 | - if ($result < 0) dol_print_error($this->db,$this->error); |
|
| 3940 | - $stock_commande_client=$this->stats_commande['qty']; |
|
| 3938 | + $result = $this->load_stats_commande(0, '1,2', 1); |
|
| 3939 | + if ($result < 0) dol_print_error($this->db, $this->error); |
|
| 3940 | + $stock_commande_client = $this->stats_commande['qty']; |
|
| 3941 | 3941 | } |
| 3942 | - if (! empty($conf->expedition->enabled)) |
|
| 3942 | + if (!empty($conf->expedition->enabled)) |
|
| 3943 | 3943 | { |
| 3944 | - $result=$this->load_stats_sending(0,'1,2', 1); |
|
| 3945 | - if ($result < 0) dol_print_error($this->db,$this->error); |
|
| 3946 | - $stock_sending_client=$this->stats_expedition['qty']; |
|
| 3944 | + $result = $this->load_stats_sending(0, '1,2', 1); |
|
| 3945 | + if ($result < 0) dol_print_error($this->db, $this->error); |
|
| 3946 | + $stock_sending_client = $this->stats_expedition['qty']; |
|
| 3947 | 3947 | } |
| 3948 | - if (! empty($conf->fournisseur->enabled)) |
|
| 3948 | + if (!empty($conf->fournisseur->enabled)) |
|
| 3949 | 3949 | { |
| 3950 | - $result=$this->load_stats_commande_fournisseur(0,'1,2,3,4', 1); |
|
| 3951 | - if ($result < 0) dol_print_error($this->db,$this->error); |
|
| 3952 | - $stock_commande_fournisseur=$this->stats_commande_fournisseur['qty']; |
|
| 3950 | + $result = $this->load_stats_commande_fournisseur(0, '1,2,3,4', 1); |
|
| 3951 | + if ($result < 0) dol_print_error($this->db, $this->error); |
|
| 3952 | + $stock_commande_fournisseur = $this->stats_commande_fournisseur['qty']; |
|
| 3953 | 3953 | |
| 3954 | - $result=$this->load_stats_reception(0,'4', 1); |
|
| 3955 | - if ($result < 0) dol_print_error($this->db,$this->error); |
|
| 3956 | - $stock_reception_fournisseur=$this->stats_reception['qty']; |
|
| 3954 | + $result = $this->load_stats_reception(0, '4', 1); |
|
| 3955 | + if ($result < 0) dol_print_error($this->db, $this->error); |
|
| 3956 | + $stock_reception_fournisseur = $this->stats_reception['qty']; |
|
| 3957 | 3957 | } |
| 3958 | 3958 | |
| 3959 | 3959 | // Stock decrease mode |
| 3960 | - if (! empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT) || ! empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT_CLOSE)) { |
|
| 3961 | - $this->stock_theorique=$this->stock_reel-$stock_commande_client+$stock_sending_client; |
|
| 3960 | + if (!empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT) || !empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT_CLOSE)) { |
|
| 3961 | + $this->stock_theorique = $this->stock_reel - $stock_commande_client + $stock_sending_client; |
|
| 3962 | 3962 | } |
| 3963 | - if (! empty($conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER)) { |
|
| 3964 | - $this->stock_theorique=$this->stock_reel; |
|
| 3963 | + if (!empty($conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER)) { |
|
| 3964 | + $this->stock_theorique = $this->stock_reel; |
|
| 3965 | 3965 | } |
| 3966 | - if (! empty($conf->global->STOCK_CALCULATE_ON_BILL)) { |
|
| 3967 | - $this->stock_theorique=$this->stock_reel-$stock_commande_client; |
|
| 3966 | + if (!empty($conf->global->STOCK_CALCULATE_ON_BILL)) { |
|
| 3967 | + $this->stock_theorique = $this->stock_reel - $stock_commande_client; |
|
| 3968 | 3968 | } |
| 3969 | 3969 | // Stock Increase mode |
| 3970 | - if (! empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER)) { |
|
| 3971 | - $this->stock_theorique+=$stock_commande_fournisseur-$stock_reception_fournisseur; |
|
| 3970 | + if (!empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER)) { |
|
| 3971 | + $this->stock_theorique += $stock_commande_fournisseur - $stock_reception_fournisseur; |
|
| 3972 | 3972 | } |
| 3973 | - if (! empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER)) { |
|
| 3974 | - $this->stock_theorique-=$stock_reception_fournisseur; |
|
| 3973 | + if (!empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER)) { |
|
| 3974 | + $this->stock_theorique -= $stock_reception_fournisseur; |
|
| 3975 | 3975 | } |
| 3976 | - if (! empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_BILL)) { |
|
| 3977 | - $this->stock_theorique+=$stock_commande_fournisseur-$stock_reception_fournisseur; |
|
| 3976 | + if (!empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_BILL)) { |
|
| 3977 | + $this->stock_theorique += $stock_commande_fournisseur - $stock_reception_fournisseur; |
|
| 3978 | 3978 | } |
| 3979 | 3979 | } |
| 3980 | 3980 | |
@@ -3988,21 +3988,21 @@ discard block |
||
| 3988 | 3988 | */ |
| 3989 | 3989 | function loadBatchInfo($batch) |
| 3990 | 3990 | { |
| 3991 | - $result=array(); |
|
| 3991 | + $result = array(); |
|
| 3992 | 3992 | |
| 3993 | 3993 | $sql = "SELECT pb.batch, pb.eatby, pb.sellby, SUM(pb.qty) FROM ".MAIN_DB_PREFIX."product_batch as pb, ".MAIN_DB_PREFIX."product_stock as ps"; |
| 3994 | - $sql.= " WHERE pb.fk_product_stock = ps.rowid AND ps.fk_product = ".$this->id." AND pb.batch = '".$this->db->escape($batch)."'"; |
|
| 3995 | - $sql.= " GROUP BY pb.batch, pb.eatby, pb.sellby"; |
|
| 3994 | + $sql .= " WHERE pb.fk_product_stock = ps.rowid AND ps.fk_product = ".$this->id." AND pb.batch = '".$this->db->escape($batch)."'"; |
|
| 3995 | + $sql .= " GROUP BY pb.batch, pb.eatby, pb.sellby"; |
|
| 3996 | 3996 | dol_syslog(get_class($this)."::loadBatchInfo load first entry found for lot/serial = ".$batch, LOG_DEBUG); |
| 3997 | 3997 | $resql = $this->db->query($sql); |
| 3998 | 3998 | if ($resql) |
| 3999 | 3999 | { |
| 4000 | 4000 | $num = $this->db->num_rows($resql); |
| 4001 | - $i=0; |
|
| 4001 | + $i = 0; |
|
| 4002 | 4002 | while ($i < $num) |
| 4003 | 4003 | { |
| 4004 | 4004 | $obj = $this->db->fetch_object($resql); |
| 4005 | - $result[]=array('batch'=>$batch, 'eatby'=>$this->db->jdate($obj->eatby), 'sellby'=>$this->db->jdate($obj->sellby), 'qty'=>$obj->qty); |
|
| 4005 | + $result[] = array('batch'=>$batch, 'eatby'=>$this->db->jdate($obj->eatby), 'sellby'=>$this->db->jdate($obj->sellby), 'qty'=>$obj->qty); |
|
| 4006 | 4006 | $i++; |
| 4007 | 4007 | } |
| 4008 | 4008 | return $result; |
@@ -4032,19 +4032,19 @@ discard block |
||
| 4032 | 4032 | $result = 0; |
| 4033 | 4033 | |
| 4034 | 4034 | $dir = $sdir; |
| 4035 | - if (! empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) $dir .= '/'. get_exdir($this->id,2,0,0,$this,'product') . $this->id ."/photos"; |
|
| 4036 | - else $dir .= '/'.get_exdir(0,0,0,0,$this,'product').dol_sanitizeFileName($this->ref); |
|
| 4035 | + if (!empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) $dir .= '/'.get_exdir($this->id, 2, 0, 0, $this, 'product').$this->id."/photos"; |
|
| 4036 | + else $dir .= '/'.get_exdir(0, 0, 0, 0, $this, 'product').dol_sanitizeFileName($this->ref); |
|
| 4037 | 4037 | |
| 4038 | 4038 | dol_mkdir($dir); |
| 4039 | 4039 | |
| 4040 | - $dir_osencoded=$dir; |
|
| 4040 | + $dir_osencoded = $dir; |
|
| 4041 | 4041 | |
| 4042 | 4042 | if (is_dir($dir_osencoded)) |
| 4043 | 4043 | { |
| 4044 | - $originImage = $dir . '/' . $file['name']; |
|
| 4044 | + $originImage = $dir.'/'.$file['name']; |
|
| 4045 | 4045 | |
| 4046 | 4046 | // Cree fichier en taille origine |
| 4047 | - $result=dol_move_uploaded_file($file['tmp_name'], $originImage, 1); |
|
| 4047 | + $result = dol_move_uploaded_file($file['tmp_name'], $originImage, 1); |
|
| 4048 | 4048 | |
| 4049 | 4049 | if (file_exists(dol_osencode($originImage))) |
| 4050 | 4050 | { |
@@ -4065,26 +4065,26 @@ discard block |
||
| 4065 | 4065 | */ |
| 4066 | 4066 | function is_photo_available($sdir) |
| 4067 | 4067 | { |
| 4068 | - include_once DOL_DOCUMENT_ROOT .'/core/lib/files.lib.php'; |
|
| 4069 | - include_once DOL_DOCUMENT_ROOT .'/core/lib/images.lib.php'; |
|
| 4068 | + include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; |
|
| 4069 | + include_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php'; |
|
| 4070 | 4070 | |
| 4071 | 4071 | global $conf; |
| 4072 | 4072 | |
| 4073 | 4073 | $dir = $sdir; |
| 4074 | - if (! empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) $dir .= '/'. get_exdir($this->id,2,0,0,$this,'product') . $this->id ."/photos/"; |
|
| 4075 | - else $dir .= '/'.get_exdir(0,0,0,0,$this,'product').dol_sanitizeFileName($this->ref).'/'; |
|
| 4074 | + if (!empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) $dir .= '/'.get_exdir($this->id, 2, 0, 0, $this, 'product').$this->id."/photos/"; |
|
| 4075 | + else $dir .= '/'.get_exdir(0, 0, 0, 0, $this, 'product').dol_sanitizeFileName($this->ref).'/'; |
|
| 4076 | 4076 | |
| 4077 | - $nbphoto=0; |
|
| 4077 | + $nbphoto = 0; |
|
| 4078 | 4078 | |
| 4079 | - $dir_osencoded=dol_osencode($dir); |
|
| 4079 | + $dir_osencoded = dol_osencode($dir); |
|
| 4080 | 4080 | if (file_exists($dir_osencoded)) |
| 4081 | 4081 | { |
| 4082 | - $handle=opendir($dir_osencoded); |
|
| 4082 | + $handle = opendir($dir_osencoded); |
|
| 4083 | 4083 | if (is_resource($handle)) |
| 4084 | 4084 | { |
| 4085 | 4085 | while (($file = readdir($handle)) !== false) |
| 4086 | 4086 | { |
| 4087 | - if (! utf8_check($file)) $file=utf8_encode($file); // To be sure data is stored in UTF8 in memory |
|
| 4087 | + if (!utf8_check($file)) $file = utf8_encode($file); // To be sure data is stored in UTF8 in memory |
|
| 4088 | 4088 | if (dol_is_file($dir.$file) && image_format_supported($file) > 0) return true; |
| 4089 | 4089 | } |
| 4090 | 4090 | } |
@@ -4100,42 +4100,42 @@ discard block |
||
| 4100 | 4100 | * @param int $nbmax Nombre maximum de photos (0=pas de max) |
| 4101 | 4101 | * @return array Tableau de photos |
| 4102 | 4102 | */ |
| 4103 | - function liste_photos($dir,$nbmax=0) |
|
| 4103 | + function liste_photos($dir, $nbmax = 0) |
|
| 4104 | 4104 | { |
| 4105 | 4105 | include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; |
| 4106 | 4106 | include_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php'; |
| 4107 | 4107 | |
| 4108 | - $nbphoto=0; |
|
| 4109 | - $tabobj=array(); |
|
| 4108 | + $nbphoto = 0; |
|
| 4109 | + $tabobj = array(); |
|
| 4110 | 4110 | |
| 4111 | - $dir_osencoded=dol_osencode($dir); |
|
| 4112 | - $handle=@opendir($dir_osencoded); |
|
| 4111 | + $dir_osencoded = dol_osencode($dir); |
|
| 4112 | + $handle = @opendir($dir_osencoded); |
|
| 4113 | 4113 | if (is_resource($handle)) |
| 4114 | 4114 | { |
| 4115 | 4115 | while (($file = readdir($handle)) !== false) |
| 4116 | 4116 | { |
| 4117 | - if (! utf8_check($file)) $file=utf8_encode($file); // readdir returns ISO |
|
| 4117 | + if (!utf8_check($file)) $file = utf8_encode($file); // readdir returns ISO |
|
| 4118 | 4118 | if (dol_is_file($dir.$file) && image_format_supported($file) >= 0) |
| 4119 | 4119 | { |
| 4120 | 4120 | $nbphoto++; |
| 4121 | 4121 | |
| 4122 | 4122 | // On determine nom du fichier vignette |
| 4123 | - $photo=$file; |
|
| 4124 | - $photo_vignette=''; |
|
| 4123 | + $photo = $file; |
|
| 4124 | + $photo_vignette = ''; |
|
| 4125 | 4125 | if (preg_match('/('.$this->regeximgext.')$/i', $photo, $regs)) |
| 4126 | 4126 | { |
| 4127 | - $photo_vignette=preg_replace('/'.$regs[0].'/i', '', $photo).'_small'.$regs[0]; |
|
| 4127 | + $photo_vignette = preg_replace('/'.$regs[0].'/i', '', $photo).'_small'.$regs[0]; |
|
| 4128 | 4128 | } |
| 4129 | 4129 | |
| 4130 | 4130 | $dirthumb = $dir.'thumbs/'; |
| 4131 | 4131 | |
| 4132 | 4132 | // Objet |
| 4133 | - $obj=array(); |
|
| 4134 | - $obj['photo']=$photo; |
|
| 4135 | - if ($photo_vignette && dol_is_file($dirthumb.$photo_vignette)) $obj['photo_vignette']='thumbs/' . $photo_vignette; |
|
| 4136 | - else $obj['photo_vignette']=""; |
|
| 4133 | + $obj = array(); |
|
| 4134 | + $obj['photo'] = $photo; |
|
| 4135 | + if ($photo_vignette && dol_is_file($dirthumb.$photo_vignette)) $obj['photo_vignette'] = 'thumbs/'.$photo_vignette; |
|
| 4136 | + else $obj['photo_vignette'] = ""; |
|
| 4137 | 4137 | |
| 4138 | - $tabobj[$nbphoto-1]=$obj; |
|
| 4138 | + $tabobj[$nbphoto - 1] = $obj; |
|
| 4139 | 4139 | |
| 4140 | 4140 | // On continue ou on arrete de boucler ? |
| 4141 | 4141 | if ($nbmax && $nbphoto >= $nbmax) break; |
@@ -4161,21 +4161,21 @@ discard block |
||
| 4161 | 4161 | |
| 4162 | 4162 | $dir = dirname($file).'/'; // Chemin du dossier contenant l'image d'origine |
| 4163 | 4163 | $dirthumb = $dir.'/thumbs/'; // Chemin du dossier contenant la vignette |
| 4164 | - $filename = preg_replace('/'.preg_quote($dir,'/').'/i','',$file); // Nom du fichier |
|
| 4164 | + $filename = preg_replace('/'.preg_quote($dir, '/').'/i', '', $file); // Nom du fichier |
|
| 4165 | 4165 | |
| 4166 | 4166 | // On efface l'image d'origine |
| 4167 | 4167 | dol_delete_file($file, 0, 0, 0, $this); // For triggers |
| 4168 | 4168 | |
| 4169 | 4169 | // Si elle existe, on efface la vignette |
| 4170 | - if (preg_match('/('.$this->regeximgext.')$/i',$filename,$regs)) |
|
| 4170 | + if (preg_match('/('.$this->regeximgext.')$/i', $filename, $regs)) |
|
| 4171 | 4171 | { |
| 4172 | - $photo_vignette=preg_replace('/'.$regs[0].'/i','',$filename).'_small'.$regs[0]; |
|
| 4172 | + $photo_vignette = preg_replace('/'.$regs[0].'/i', '', $filename).'_small'.$regs[0]; |
|
| 4173 | 4173 | if (file_exists(dol_osencode($dirthumb.$photo_vignette))) |
| 4174 | 4174 | { |
| 4175 | 4175 | dol_delete_file($dirthumb.$photo_vignette); |
| 4176 | 4176 | } |
| 4177 | 4177 | |
| 4178 | - $photo_vignette=preg_replace('/'.$regs[0].'/i','',$filename).'_mini'.$regs[0]; |
|
| 4178 | + $photo_vignette = preg_replace('/'.$regs[0].'/i', '', $filename).'_mini'.$regs[0]; |
|
| 4179 | 4179 | if (file_exists(dol_osencode($dirthumb.$photo_vignette))) |
| 4180 | 4180 | { |
| 4181 | 4181 | dol_delete_file($dirthumb.$photo_vignette); |
@@ -4191,7 +4191,7 @@ discard block |
||
| 4191 | 4191 | */ |
| 4192 | 4192 | function get_image_size($file) |
| 4193 | 4193 | { |
| 4194 | - $file_osencoded=dol_osencode($file); |
|
| 4194 | + $file_osencoded = dol_osencode($file); |
|
| 4195 | 4195 | $infoImg = getimagesize($file_osencoded); // Get information on image |
| 4196 | 4196 | $this->imgWidth = $infoImg[0]; // Largeur de l'image |
| 4197 | 4197 | $this->imgHeight = $infoImg[1]; // Hauteur de l'image |
@@ -4206,27 +4206,27 @@ discard block |
||
| 4206 | 4206 | { |
| 4207 | 4207 | global $conf, $user, $hookmanager; |
| 4208 | 4208 | |
| 4209 | - $this->nb=array(); |
|
| 4209 | + $this->nb = array(); |
|
| 4210 | 4210 | |
| 4211 | 4211 | $sql = "SELECT count(p.rowid) as nb, fk_product_type"; |
| 4212 | - $sql.= " FROM ".MAIN_DB_PREFIX."product as p"; |
|
| 4213 | - $sql.= ' WHERE p.entity IN ('.getEntity($this->element, 1).')'; |
|
| 4212 | + $sql .= " FROM ".MAIN_DB_PREFIX."product as p"; |
|
| 4213 | + $sql .= ' WHERE p.entity IN ('.getEntity($this->element, 1).')'; |
|
| 4214 | 4214 | // Add where from hooks |
| 4215 | 4215 | if (is_object($hookmanager)) |
| 4216 | 4216 | { |
| 4217 | - $parameters=array(); |
|
| 4218 | - $reshook=$hookmanager->executeHooks('printFieldListWhere',$parameters); // Note that $action and $object may have been modified by hook |
|
| 4219 | - $sql.=$hookmanager->resPrint; |
|
| 4217 | + $parameters = array(); |
|
| 4218 | + $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook |
|
| 4219 | + $sql .= $hookmanager->resPrint; |
|
| 4220 | 4220 | } |
| 4221 | - $sql.= ' GROUP BY fk_product_type'; |
|
| 4221 | + $sql .= ' GROUP BY fk_product_type'; |
|
| 4222 | 4222 | |
| 4223 | - $resql=$this->db->query($sql); |
|
| 4223 | + $resql = $this->db->query($sql); |
|
| 4224 | 4224 | if ($resql) |
| 4225 | 4225 | { |
| 4226 | - while ($obj=$this->db->fetch_object($resql)) |
|
| 4226 | + while ($obj = $this->db->fetch_object($resql)) |
|
| 4227 | 4227 | { |
| 4228 | - if ($obj->fk_product_type == 1) $this->nb["services"]=$obj->nb; |
|
| 4229 | - else $this->nb["products"]=$obj->nb; |
|
| 4228 | + if ($obj->fk_product_type == 1) $this->nb["services"] = $obj->nb; |
|
| 4229 | + else $this->nb["products"] = $obj->nb; |
|
| 4230 | 4230 | } |
| 4231 | 4231 | $this->db->free($resql); |
| 4232 | 4232 | return 1; |
@@ -4234,7 +4234,7 @@ discard block |
||
| 4234 | 4234 | else |
| 4235 | 4235 | { |
| 4236 | 4236 | dol_print_error($this->db); |
| 4237 | - $this->error=$this->db->error(); |
|
| 4237 | + $this->error = $this->db->error(); |
|
| 4238 | 4238 | return -1; |
| 4239 | 4239 | } |
| 4240 | 4240 | } |
@@ -4267,23 +4267,23 @@ discard block |
||
| 4267 | 4267 | * @param string $type Barcode type (ean, isbn, ...) |
| 4268 | 4268 | * @return void |
| 4269 | 4269 | */ |
| 4270 | - function get_barcode($object,$type='') |
|
| 4270 | + function get_barcode($object, $type = '') |
|
| 4271 | 4271 | { |
| 4272 | 4272 | global $conf; |
| 4273 | 4273 | |
| 4274 | - $result=''; |
|
| 4275 | - if (! empty($conf->global->BARCODE_PRODUCT_ADDON_NUM)) |
|
| 4274 | + $result = ''; |
|
| 4275 | + if (!empty($conf->global->BARCODE_PRODUCT_ADDON_NUM)) |
|
| 4276 | 4276 | { |
| 4277 | - $dirsociete=array_merge(array('/core/modules/barcode/'),$conf->modules_parts['barcode']); |
|
| 4277 | + $dirsociete = array_merge(array('/core/modules/barcode/'), $conf->modules_parts['barcode']); |
|
| 4278 | 4278 | foreach ($dirsociete as $dirroot) |
| 4279 | 4279 | { |
| 4280 | - $res=dol_include_once($dirroot.$conf->global->BARCODE_PRODUCT_ADDON_NUM.'.php'); |
|
| 4280 | + $res = dol_include_once($dirroot.$conf->global->BARCODE_PRODUCT_ADDON_NUM.'.php'); |
|
| 4281 | 4281 | if ($res) break; |
| 4282 | 4282 | } |
| 4283 | 4283 | $var = $conf->global->BARCODE_PRODUCT_ADDON_NUM; |
| 4284 | 4284 | $mod = new $var; |
| 4285 | 4285 | |
| 4286 | - $result=$mod->getNextValue($object,$type); |
|
| 4286 | + $result = $mod->getNextValue($object, $type); |
|
| 4287 | 4287 | |
| 4288 | 4288 | dol_syslog(get_class($this)."::get_barcode barcode=".$result." module=".$var); |
| 4289 | 4289 | } |
@@ -4299,22 +4299,22 @@ discard block |
||
| 4299 | 4299 | */ |
| 4300 | 4300 | function initAsSpecimen() |
| 4301 | 4301 | { |
| 4302 | - global $user,$langs,$conf,$mysoc; |
|
| 4302 | + global $user, $langs, $conf, $mysoc; |
|
| 4303 | 4303 | |
| 4304 | - $now=dol_now(); |
|
| 4304 | + $now = dol_now(); |
|
| 4305 | 4305 | |
| 4306 | 4306 | // Initialize parameters |
| 4307 | - $this->specimen=1; |
|
| 4308 | - $this->id=0; |
|
| 4307 | + $this->specimen = 1; |
|
| 4308 | + $this->id = 0; |
|
| 4309 | 4309 | $this->ref = 'PRODUCT_SPEC'; |
| 4310 | 4310 | $this->label = 'PRODUCT SPECIMEN'; |
| 4311 | - $this->description = 'This is description of this product specimen that was created the '.dol_print_date($now,'dayhourlog').'.'; |
|
| 4312 | - $this->specimen=1; |
|
| 4313 | - $this->country_id=1; |
|
| 4314 | - $this->tosell=1; |
|
| 4315 | - $this->tobuy=1; |
|
| 4316 | - $this->tobatch=0; |
|
| 4317 | - $this->note='This is a comment (private)'; |
|
| 4311 | + $this->description = 'This is description of this product specimen that was created the '.dol_print_date($now, 'dayhourlog').'.'; |
|
| 4312 | + $this->specimen = 1; |
|
| 4313 | + $this->country_id = 1; |
|
| 4314 | + $this->tosell = 1; |
|
| 4315 | + $this->tobuy = 1; |
|
| 4316 | + $this->tobatch = 0; |
|
| 4317 | + $this->note = 'This is a comment (private)'; |
|
| 4318 | 4318 | $this->date_creation = $now; |
| 4319 | 4319 | $this->date_modification = $now; |
| 4320 | 4320 | |
@@ -4333,7 +4333,7 @@ discard block |
||
| 4333 | 4333 | $this->volume = 300; |
| 4334 | 4334 | $this->volume_unit = 0; |
| 4335 | 4335 | |
| 4336 | - $this->barcode=-1; // Create barcode automatically |
|
| 4336 | + $this->barcode = -1; // Create barcode automatically |
|
| 4337 | 4337 | } |
| 4338 | 4338 | |
| 4339 | 4339 | /** |
@@ -4342,7 +4342,7 @@ discard block |
||
| 4342 | 4342 | * @param string $type Label type (long or short) |
| 4343 | 4343 | * @return string|int <0 if ko, label if ok |
| 4344 | 4344 | */ |
| 4345 | - function getLabelOfUnit($type='long') |
|
| 4345 | + function getLabelOfUnit($type = 'long') |
|
| 4346 | 4346 | { |
| 4347 | 4347 | global $langs; |
| 4348 | 4348 | |
@@ -4363,7 +4363,7 @@ discard block |
||
| 4363 | 4363 | |
| 4364 | 4364 | $sql = 'select '.$label_type.' from '.MAIN_DB_PREFIX.'c_units where rowid='.$this->fk_unit; |
| 4365 | 4365 | $resql = $this->db->query($sql); |
| 4366 | - if($resql && $this->db->num_rows($resql) > 0) |
|
| 4366 | + if ($resql && $this->db->num_rows($resql) > 0) |
|
| 4367 | 4367 | { |
| 4368 | 4368 | $res = $this->db->fetch_array($resql); |
| 4369 | 4369 | $label = $res[$label_type]; |
@@ -4372,7 +4372,7 @@ discard block |
||
| 4372 | 4372 | } |
| 4373 | 4373 | else |
| 4374 | 4374 | { |
| 4375 | - $this->error=$this->db->error().' sql='.$sql; |
|
| 4375 | + $this->error = $this->db->error().' sql='.$sql; |
|
| 4376 | 4376 | dol_syslog(get_class($this)."::getLabelOfUnit Error ".$this->error, LOG_ERR); |
| 4377 | 4377 | return -1; |
| 4378 | 4378 | } |
@@ -4398,17 +4398,17 @@ discard block |
||
| 4398 | 4398 | { |
| 4399 | 4399 | global $conf; |
| 4400 | 4400 | |
| 4401 | - $maxpricesupplier=0; |
|
| 4401 | + $maxpricesupplier = 0; |
|
| 4402 | 4402 | |
| 4403 | - if (! empty($conf->global->PRODUCT_MINIMUM_RECOMMENDED_PRICE)) |
|
| 4403 | + if (!empty($conf->global->PRODUCT_MINIMUM_RECOMMENDED_PRICE)) |
|
| 4404 | 4404 | { |
| 4405 | 4405 | require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php'; |
| 4406 | 4406 | $product_fourn = new ProductFournisseur($this->db); |
| 4407 | 4407 | $product_fourn_list = $product_fourn->list_product_fournisseur_price($this->id, '', ''); |
| 4408 | 4408 | |
| 4409 | - if (is_array($product_fourn_list) && count($product_fourn_list)>0) |
|
| 4409 | + if (is_array($product_fourn_list) && count($product_fourn_list) > 0) |
|
| 4410 | 4410 | { |
| 4411 | - foreach($product_fourn_list as $productfourn) |
|
| 4411 | + foreach ($product_fourn_list as $productfourn) |
|
| 4412 | 4412 | { |
| 4413 | 4413 | if ($productfourn->fourn_unitprice > $maxpricesupplier) |
| 4414 | 4414 | { |
@@ -4435,12 +4435,12 @@ discard block |
||
| 4435 | 4435 | */ |
| 4436 | 4436 | public function setCategories($categories) { |
| 4437 | 4437 | // Handle single category |
| 4438 | - if (! is_array($categories)) { |
|
| 4438 | + if (!is_array($categories)) { |
|
| 4439 | 4439 | $categories = array($categories); |
| 4440 | 4440 | } |
| 4441 | 4441 | |
| 4442 | 4442 | // Get current categories |
| 4443 | - require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php'; |
|
| 4443 | + require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; |
|
| 4444 | 4444 | $c = new Categorie($this->db); |
| 4445 | 4445 | $existing = $c->containing($this->id, Categorie::TYPE_PRODUCT, 'id'); |
| 4446 | 4446 | |
@@ -4454,7 +4454,7 @@ discard block |
||
| 4454 | 4454 | } |
| 4455 | 4455 | |
| 4456 | 4456 | // Process |
| 4457 | - foreach($to_del as $del) { |
|
| 4457 | + foreach ($to_del as $del) { |
|
| 4458 | 4458 | if ($c->fetch($del) > 0) { |
| 4459 | 4459 | $c->del_type($this, 'product'); |
| 4460 | 4460 | } |
@@ -4523,14 +4523,14 @@ discard block |
||
| 4523 | 4523 | //We have to make sure it does exist and it is > 0 |
| 4524 | 4524 | //First price level only allows changing min_price |
| 4525 | 4525 | if ($i > 1 && isset($rules[$i]->var_percent) && $rules[$i]->var_percent) { |
| 4526 | - $price = $prices[$rules[$i]->fk_level] * (1 + ($rules[$i]->var_percent/100)); |
|
| 4526 | + $price = $prices[$rules[$i]->fk_level] * (1 + ($rules[$i]->var_percent / 100)); |
|
| 4527 | 4527 | } |
| 4528 | 4528 | |
| 4529 | 4529 | $prices[$i] = $price; |
| 4530 | 4530 | |
| 4531 | 4531 | //We have to make sure it does exist and it is > 0 |
| 4532 | 4532 | if (isset($rules[$i]->var_min_percent) && $rules[$i]->var_min_percent) { |
| 4533 | - $price_min = $price * (1 - ($rules[$i]->var_min_percent/100)); |
|
| 4533 | + $price_min = $price * (1 - ($rules[$i]->var_min_percent / 100)); |
|
| 4534 | 4534 | } |
| 4535 | 4535 | |
| 4536 | 4536 | //Little check to make sure the price is modified before triggering generation |
@@ -4573,11 +4573,11 @@ discard block |
||
| 4573 | 4573 | function info($id) |
| 4574 | 4574 | { |
| 4575 | 4575 | $sql = "SELECT p.rowid, p.ref, p.datec as date_creation, p.tms as date_modification,"; |
| 4576 | - $sql.= " p.fk_user_author, p.fk_user_modif"; |
|
| 4577 | - $sql.= " FROM ".MAIN_DB_PREFIX.$this->table_element." as p"; |
|
| 4578 | - $sql.= " WHERE p.rowid = ".$id; |
|
| 4576 | + $sql .= " p.fk_user_author, p.fk_user_modif"; |
|
| 4577 | + $sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element." as p"; |
|
| 4578 | + $sql .= " WHERE p.rowid = ".$id; |
|
| 4579 | 4579 | |
| 4580 | - $result=$this->db->query($sql); |
|
| 4580 | + $result = $this->db->query($sql); |
|
| 4581 | 4581 | if ($result) |
| 4582 | 4582 | { |
| 4583 | 4583 | if ($this->db->num_rows($result)) |
@@ -4589,7 +4589,7 @@ discard block |
||
| 4589 | 4589 | if ($obj->fk_user_author) { |
| 4590 | 4590 | $cuser = new User($this->db); |
| 4591 | 4591 | $cuser->fetch($obj->fk_user_author); |
| 4592 | - $this->user_creation = $cuser; |
|
| 4592 | + $this->user_creation = $cuser; |
|
| 4593 | 4593 | } |
| 4594 | 4594 | |
| 4595 | 4595 | if ($obj->fk_user_modif) { |
@@ -4598,7 +4598,7 @@ discard block |
||
| 4598 | 4598 | $this->user_modification = $muser; |
| 4599 | 4599 | } |
| 4600 | 4600 | |
| 4601 | - $this->ref = $obj->ref; |
|
| 4601 | + $this->ref = $obj->ref; |
|
| 4602 | 4602 | $this->date_creation = $this->db->jdate($obj->date_creation); |
| 4603 | 4603 | $this->date_modification = $this->db->jdate($obj->date_modification); |
| 4604 | 4604 | } |
@@ -37,8 +37,8 @@ discard block |
||
| 37 | 37 | $ref = GETPOST('ref', 'alpha'); |
| 38 | 38 | $taskref = GETPOST('taskref', 'alpha'); |
| 39 | 39 | $action = GETPOST('action', 'alpha'); |
| 40 | -$backtopage=GETPOST('backtopage','alpha'); |
|
| 41 | -$cancel=GETPOST('cancel','alpha'); |
|
| 40 | +$backtopage = GETPOST('backtopage', 'alpha'); |
|
| 41 | +$cancel = GETPOST('cancel', 'alpha'); |
|
| 42 | 42 | |
| 43 | 43 | $search_user_id = GETPOST('search_user_id', 'int'); |
| 44 | 44 | |
@@ -49,86 +49,86 @@ discard block |
||
| 49 | 49 | $extrafields_project = new ExtraFields($db); |
| 50 | 50 | $extrafields_task = new ExtraFields($db); |
| 51 | 51 | |
| 52 | -include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once |
|
| 52 | +include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once |
|
| 53 | 53 | |
| 54 | -if ($id > 0 || ! empty($ref)) |
|
| 54 | +if ($id > 0 || !empty($ref)) |
|
| 55 | 55 | { |
| 56 | 56 | // fetch optionals attributes and labels |
| 57 | - $extralabels_projet=$extrafields_project->fetch_name_optionals_label($object->table_element); |
|
| 57 | + $extralabels_projet = $extrafields_project->fetch_name_optionals_label($object->table_element); |
|
| 58 | 58 | } |
| 59 | -$extralabels_task=$extrafields_task->fetch_name_optionals_label($taskstatic->table_element); |
|
| 59 | +$extralabels_task = $extrafields_task->fetch_name_optionals_label($taskstatic->table_element); |
|
| 60 | 60 | |
| 61 | 61 | // Security check |
| 62 | -$socid=0; |
|
| 62 | +$socid = 0; |
|
| 63 | 63 | //if ($user->societe_id > 0) $socid = $user->societe_id; // For external user, no check is done on company because readability is managed by public status of project and assignement. |
| 64 | 64 | $result = restrictedArea($user, 'projet', $id, 'projet&project'); |
| 65 | 65 | |
| 66 | 66 | // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context |
| 67 | -$hookmanager->initHooks(array('projecttaskcard','globalcard')); |
|
| 67 | +$hookmanager->initHooks(array('projecttaskcard', 'globalcard')); |
|
| 68 | 68 | |
| 69 | -$progress=GETPOST('progress', 'int'); |
|
| 70 | -$label=GETPOST('label', 'alpha'); |
|
| 71 | -$description=GETPOST('description'); |
|
| 72 | -$planned_workloadhour=(GETPOST('planned_workloadhour','int')?GETPOST('planned_workloadhour','int'):0); |
|
| 73 | -$planned_workloadmin=(GETPOST('planned_workloadmin','int')?GETPOST('planned_workloadmin','int'):0); |
|
| 74 | -$planned_workload=$planned_workloadhour*3600+$planned_workloadmin*60; |
|
| 69 | +$progress = GETPOST('progress', 'int'); |
|
| 70 | +$label = GETPOST('label', 'alpha'); |
|
| 71 | +$description = GETPOST('description'); |
|
| 72 | +$planned_workloadhour = (GETPOST('planned_workloadhour', 'int') ?GETPOST('planned_workloadhour', 'int') : 0); |
|
| 73 | +$planned_workloadmin = (GETPOST('planned_workloadmin', 'int') ?GETPOST('planned_workloadmin', 'int') : 0); |
|
| 74 | +$planned_workload = $planned_workloadhour * 3600 + $planned_workloadmin * 60; |
|
| 75 | 75 | |
| 76 | -$userAccess=0; |
|
| 76 | +$userAccess = 0; |
|
| 77 | 77 | |
| 78 | 78 | |
| 79 | -$parameters=array('id'=>$id); |
|
| 80 | -$reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks |
|
| 79 | +$parameters = array('id'=>$id); |
|
| 80 | +$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks |
|
| 81 | 81 | if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); |
| 82 | 82 | /* |
| 83 | 83 | * Actions |
| 84 | 84 | */ |
| 85 | 85 | |
| 86 | 86 | // Purge search criteria |
| 87 | -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 |
|
| 87 | +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 |
|
| 88 | 88 | { |
| 89 | - $search_user_id=""; |
|
| 90 | - $toselect=''; |
|
| 91 | - $search_array_options=array(); |
|
| 89 | + $search_user_id = ""; |
|
| 90 | + $toselect = ''; |
|
| 91 | + $search_array_options = array(); |
|
| 92 | 92 | } |
| 93 | 93 | |
| 94 | 94 | if ($action == 'createtask' && $user->rights->projet->creer) |
| 95 | 95 | { |
| 96 | - $error=0; |
|
| 96 | + $error = 0; |
|
| 97 | 97 | |
| 98 | 98 | // If we use user timezone, we must change also view/list to use user timezone everywhere |
| 99 | 99 | //$date_start = dol_mktime($_POST['dateohour'],$_POST['dateomin'],0,$_POST['dateomonth'],$_POST['dateoday'],$_POST['dateoyear'],'user'); |
| 100 | 100 | //$date_end = dol_mktime($_POST['dateehour'],$_POST['dateemin'],0,$_POST['dateemonth'],$_POST['dateeday'],$_POST['dateeyear'],'user'); |
| 101 | - $date_start = dol_mktime($_POST['dateohour'],$_POST['dateomin'],0,$_POST['dateomonth'],$_POST['dateoday'],$_POST['dateoyear']); |
|
| 102 | - $date_end = dol_mktime($_POST['dateehour'],$_POST['dateemin'],0,$_POST['dateemonth'],$_POST['dateeday'],$_POST['dateeyear']); |
|
| 101 | + $date_start = dol_mktime($_POST['dateohour'], $_POST['dateomin'], 0, $_POST['dateomonth'], $_POST['dateoday'], $_POST['dateoyear']); |
|
| 102 | + $date_end = dol_mktime($_POST['dateehour'], $_POST['dateemin'], 0, $_POST['dateemonth'], $_POST['dateeday'], $_POST['dateeyear']); |
|
| 103 | 103 | |
| 104 | - if (! $cancel) |
|
| 104 | + if (!$cancel) |
|
| 105 | 105 | { |
| 106 | 106 | if (empty($taskref)) |
| 107 | 107 | { |
| 108 | 108 | setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Ref")), null, 'errors'); |
| 109 | - $action='create'; |
|
| 109 | + $action = 'create'; |
|
| 110 | 110 | $error++; |
| 111 | 111 | } |
| 112 | 112 | if (empty($label)) |
| 113 | 113 | { |
| 114 | 114 | setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Label")), null, 'errors'); |
| 115 | - $action='create'; |
|
| 115 | + $action = 'create'; |
|
| 116 | 116 | $error++; |
| 117 | 117 | } |
| 118 | 118 | else if (empty($_POST['task_parent'])) |
| 119 | 119 | { |
| 120 | 120 | setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("ChildOfProjectTask")), null, 'errors'); |
| 121 | - $action='create'; |
|
| 121 | + $action = 'create'; |
|
| 122 | 122 | $error++; |
| 123 | 123 | } |
| 124 | 124 | |
| 125 | - if (! $error) |
|
| 125 | + if (!$error) |
|
| 126 | 126 | { |
| 127 | - $tmparray=explode('_',$_POST['task_parent']); |
|
| 128 | - $projectid=$tmparray[0]; |
|
| 127 | + $tmparray = explode('_', $_POST['task_parent']); |
|
| 128 | + $projectid = $tmparray[0]; |
|
| 129 | 129 | if (empty($projectid)) $projectid = $id; // If projectid is '' |
| 130 | - $task_parent=$tmparray[1]; |
|
| 131 | - if (empty($task_parent)) $task_parent = 0; // If task_parent is '' |
|
| 130 | + $task_parent = $tmparray[1]; |
|
| 131 | + if (empty($task_parent)) $task_parent = 0; // If task_parent is '' |
|
| 132 | 132 | |
| 133 | 133 | $task = new Task($db); |
| 134 | 134 | |
@@ -144,7 +144,7 @@ discard block |
||
| 144 | 144 | $task->progress = $progress; |
| 145 | 145 | |
| 146 | 146 | // Fill array 'array_options' with data from add form |
| 147 | - $ret = $extrafields_task->setOptionalsFromPost($extralabels_task,$task); |
|
| 147 | + $ret = $extrafields_task->setOptionalsFromPost($extralabels_task, $task); |
|
| 148 | 148 | |
| 149 | 149 | $taskid = $task->create($user); |
| 150 | 150 | |
@@ -154,20 +154,20 @@ discard block |
||
| 154 | 154 | } |
| 155 | 155 | else |
| 156 | 156 | { |
| 157 | - setEventMessages($task->error,$task->errors,'errors'); |
|
| 157 | + setEventMessages($task->error, $task->errors, 'errors'); |
|
| 158 | 158 | } |
| 159 | 159 | } |
| 160 | 160 | |
| 161 | - if (! $error) |
|
| 161 | + if (!$error) |
|
| 162 | 162 | { |
| 163 | - if (! empty($backtopage)) |
|
| 163 | + if (!empty($backtopage)) |
|
| 164 | 164 | { |
| 165 | 165 | header("Location: ".$backtopage); |
| 166 | 166 | exit; |
| 167 | 167 | } |
| 168 | 168 | else if (empty($projectid)) |
| 169 | 169 | { |
| 170 | - header("Location: ".DOL_URL_ROOT.'/projet/tasks/list.php'.(empty($mode)?'':'?mode='.$mode)); |
|
| 170 | + header("Location: ".DOL_URL_ROOT.'/projet/tasks/list.php'.(empty($mode) ? '' : '?mode='.$mode)); |
|
| 171 | 171 | exit; |
| 172 | 172 | } |
| 173 | 173 | $id = $projectid; |
@@ -175,7 +175,7 @@ discard block |
||
| 175 | 175 | } |
| 176 | 176 | else |
| 177 | 177 | { |
| 178 | - if (! empty($backtopage)) |
|
| 178 | + if (!empty($backtopage)) |
|
| 179 | 179 | { |
| 180 | 180 | header("Location: ".$backtopage); |
| 181 | 181 | exit; |
@@ -183,7 +183,7 @@ discard block |
||
| 183 | 183 | else if (empty($id)) |
| 184 | 184 | { |
| 185 | 185 | // We go back on task list |
| 186 | - header("Location: ".DOL_URL_ROOT.'/projet/tasks/list.php'.(empty($mode)?'':'?mode='.$mode)); |
|
| 186 | + header("Location: ".DOL_URL_ROOT.'/projet/tasks/list.php'.(empty($mode) ? '' : '?mode='.$mode)); |
|
| 187 | 187 | exit; |
| 188 | 188 | } |
| 189 | 189 | } |
@@ -194,57 +194,57 @@ discard block |
||
| 194 | 194 | * View |
| 195 | 195 | */ |
| 196 | 196 | |
| 197 | -$form=new Form($db); |
|
| 198 | -$formother=new FormOther($db); |
|
| 197 | +$form = new Form($db); |
|
| 198 | +$formother = new FormOther($db); |
|
| 199 | 199 | $taskstatic = new Task($db); |
| 200 | -$userstatic=new User($db); |
|
| 200 | +$userstatic = new User($db); |
|
| 201 | 201 | |
| 202 | -$title=$langs->trans("Project").' - '.$langs->trans("Tasks").' - '.$object->ref.' '.$object->name; |
|
| 203 | -if (! empty($conf->global->MAIN_HTML_TITLE) && preg_match('/projectnameonly/',$conf->global->MAIN_HTML_TITLE) && $object->name) $title=$object->ref.' '.$object->name.' - '.$langs->trans("Tasks"); |
|
| 204 | -$help_url="EN:Module_Projects|FR:Module_Projets|ES:Módulo_Proyectos"; |
|
| 205 | -llxHeader("",$title,$help_url); |
|
| 202 | +$title = $langs->trans("Project").' - '.$langs->trans("Tasks").' - '.$object->ref.' '.$object->name; |
|
| 203 | +if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/projectnameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) $title = $object->ref.' '.$object->name.' - '.$langs->trans("Tasks"); |
|
| 204 | +$help_url = "EN:Module_Projects|FR:Module_Projets|ES:Módulo_Proyectos"; |
|
| 205 | +llxHeader("", $title, $help_url); |
|
| 206 | 206 | |
| 207 | -if ($id > 0 || ! empty($ref)) |
|
| 207 | +if ($id > 0 || !empty($ref)) |
|
| 208 | 208 | { |
| 209 | 209 | $object->fetch($id, $ref); |
| 210 | 210 | $object->fetch_thirdparty(); |
| 211 | - $res=$object->fetch_optionals(); |
|
| 211 | + $res = $object->fetch_optionals(); |
|
| 212 | 212 | |
| 213 | 213 | |
| 214 | 214 | // To verify role of users |
| 215 | 215 | //$userAccess = $object->restrictedProjectArea($user,'read'); |
| 216 | - $userWrite = $object->restrictedProjectArea($user,'write'); |
|
| 216 | + $userWrite = $object->restrictedProjectArea($user, 'write'); |
|
| 217 | 217 | //$userDelete = $object->restrictedProjectArea($user,'delete'); |
| 218 | 218 | //print "userAccess=".$userAccess." userWrite=".$userWrite." userDelete=".$userDelete; |
| 219 | 219 | |
| 220 | 220 | |
| 221 | - $tab=GETPOST('tab')?GETPOST('tab'):'tasks'; |
|
| 221 | + $tab = GETPOST('tab') ?GETPOST('tab') : 'tasks'; |
|
| 222 | 222 | |
| 223 | - $head=project_prepare_head($object); |
|
| 224 | - dol_fiche_head($head, $tab, $langs->trans("Project"), -1, ($object->public?'projectpub':'project')); |
|
| 223 | + $head = project_prepare_head($object); |
|
| 224 | + dol_fiche_head($head, $tab, $langs->trans("Project"), -1, ($object->public ? 'projectpub' : 'project')); |
|
| 225 | 225 | |
| 226 | - $param=''; |
|
| 227 | - if ($search_user_id > 0) $param.='&search_user_id='.dol_escape_htmltag($search_user_id); |
|
| 226 | + $param = ''; |
|
| 227 | + if ($search_user_id > 0) $param .= '&search_user_id='.dol_escape_htmltag($search_user_id); |
|
| 228 | 228 | |
| 229 | 229 | // Project card |
| 230 | 230 | |
| 231 | 231 | $linkback = '<a href="'.DOL_URL_ROOT.'/projet/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>'; |
| 232 | 232 | |
| 233 | - $morehtmlref='<div class="refidno">'; |
|
| 233 | + $morehtmlref = '<div class="refidno">'; |
|
| 234 | 234 | // Title |
| 235 | - $morehtmlref.=$object->title; |
|
| 235 | + $morehtmlref .= $object->title; |
|
| 236 | 236 | // Thirdparty |
| 237 | 237 | if ($object->thirdparty->id > 0) |
| 238 | 238 | { |
| 239 | - $morehtmlref.='<br>'.$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1, 'project'); |
|
| 239 | + $morehtmlref .= '<br>'.$langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1, 'project'); |
|
| 240 | 240 | } |
| 241 | - $morehtmlref.='</div>'; |
|
| 241 | + $morehtmlref .= '</div>'; |
|
| 242 | 242 | |
| 243 | 243 | // Define a complementary filter for search of next/prev ref. |
| 244 | - if (! $user->rights->projet->all->lire) |
|
| 244 | + if (!$user->rights->projet->all->lire) |
|
| 245 | 245 | { |
| 246 | - $objectsListId = $object->getProjectsAuthorizedForUser($user,0,0); |
|
| 247 | - $object->next_prev_filter=" rowid in (".(count($objectsListId)?join(',',array_keys($objectsListId)):'0').")"; |
|
| 246 | + $objectsListId = $object->getProjectsAuthorizedForUser($user, 0, 0); |
|
| 247 | + $object->next_prev_filter = " rowid in (".(count($objectsListId) ?join(',', array_keys($objectsListId)) : '0').")"; |
|
| 248 | 248 | } |
| 249 | 249 | |
| 250 | 250 | dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); |
@@ -282,22 +282,22 @@ discard block |
||
| 282 | 282 | |
| 283 | 283 | // Date start - end |
| 284 | 284 | print '<tr><td>'.$langs->trans("DateStart").' - '.$langs->trans("DateEnd").'</td><td>'; |
| 285 | - $start = dol_print_date($object->date_start,'day'); |
|
| 286 | - print ($start?$start:'?'); |
|
| 287 | - $end = dol_print_date($object->date_end,'day'); |
|
| 285 | + $start = dol_print_date($object->date_start, 'day'); |
|
| 286 | + print ($start ? $start : '?'); |
|
| 287 | + $end = dol_print_date($object->date_end, 'day'); |
|
| 288 | 288 | print ' - '; |
| 289 | - print ($end?$end:'?'); |
|
| 289 | + print ($end ? $end : '?'); |
|
| 290 | 290 | if ($object->hasDelay()) print img_warning("Late"); |
| 291 | 291 | print '</td></tr>'; |
| 292 | 292 | |
| 293 | 293 | // Budget |
| 294 | 294 | print '<tr><td>'.$langs->trans("Budget").'</td><td>'; |
| 295 | - if (strcmp($object->budget_amount, '')) print price($object->budget_amount,'',$langs,1,0,0,$conf->currency); |
|
| 295 | + if (strcmp($object->budget_amount, '')) print price($object->budget_amount, '', $langs, 1, 0, 0, $conf->currency); |
|
| 296 | 296 | print '</td></tr>'; |
| 297 | 297 | |
| 298 | 298 | // Other attributes |
| 299 | 299 | $cols = 2; |
| 300 | - include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; |
|
| 300 | + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; |
|
| 301 | 301 | |
| 302 | 302 | print '</table>'; |
| 303 | 303 | |
@@ -314,9 +314,9 @@ discard block |
||
| 314 | 314 | print '</td></tr>'; |
| 315 | 315 | |
| 316 | 316 | // Categories |
| 317 | - if($conf->categorie->enabled) { |
|
| 317 | + if ($conf->categorie->enabled) { |
|
| 318 | 318 | print '<tr><td valign="middle">'.$langs->trans("Categories").'</td><td>'; |
| 319 | - print $form->showCategories($object->id,'project',1); |
|
| 319 | + print $form->showCategories($object->id, 'project', 1); |
|
| 320 | 320 | print "</td></tr>"; |
| 321 | 321 | } |
| 322 | 322 | |
@@ -335,7 +335,7 @@ discard block |
||
| 335 | 335 | |
| 336 | 336 | if ($action == 'create' && $user->rights->projet->creer && (empty($object->thirdparty->id) || $userWrite > 0)) |
| 337 | 337 | { |
| 338 | - if ($id > 0 || ! empty($ref)) print '<br>'; |
|
| 338 | + if ($id > 0 || !empty($ref)) print '<br>'; |
|
| 339 | 339 | |
| 340 | 340 | print load_fiche_titre($langs->trans("NewTask"), '', 'title_project'); |
| 341 | 341 | |
@@ -343,27 +343,27 @@ discard block |
||
| 343 | 343 | print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
| 344 | 344 | print '<input type="hidden" name="action" value="createtask">'; |
| 345 | 345 | print '<input type="hidden" name="backtopage" value="'.$backtopage.'">'; |
| 346 | - if (! empty($object->id)) print '<input type="hidden" name="id" value="'.$object->id.'">'; |
|
| 346 | + if (!empty($object->id)) print '<input type="hidden" name="id" value="'.$object->id.'">'; |
|
| 347 | 347 | |
| 348 | 348 | dol_fiche_head(''); |
| 349 | 349 | |
| 350 | 350 | print '<table class="border" width="100%">'; |
| 351 | 351 | |
| 352 | - $defaultref=''; |
|
| 353 | - $obj = empty($conf->global->PROJECT_TASK_ADDON)?'mod_task_simple':$conf->global->PROJECT_TASK_ADDON; |
|
| 354 | - if (! empty($conf->global->PROJECT_TASK_ADDON) && is_readable(DOL_DOCUMENT_ROOT ."/core/modules/project/task/".$conf->global->PROJECT_TASK_ADDON.".php")) |
|
| 352 | + $defaultref = ''; |
|
| 353 | + $obj = empty($conf->global->PROJECT_TASK_ADDON) ? 'mod_task_simple' : $conf->global->PROJECT_TASK_ADDON; |
|
| 354 | + if (!empty($conf->global->PROJECT_TASK_ADDON) && is_readable(DOL_DOCUMENT_ROOT."/core/modules/project/task/".$conf->global->PROJECT_TASK_ADDON.".php")) |
|
| 355 | 355 | { |
| 356 | - require_once DOL_DOCUMENT_ROOT ."/core/modules/project/task/".$conf->global->PROJECT_TASK_ADDON.'.php'; |
|
| 356 | + require_once DOL_DOCUMENT_ROOT."/core/modules/project/task/".$conf->global->PROJECT_TASK_ADDON.'.php'; |
|
| 357 | 357 | $modTask = new $obj; |
| 358 | - $defaultref = $modTask->getNextValue($object->thirdparty,null); |
|
| 358 | + $defaultref = $modTask->getNextValue($object->thirdparty, null); |
|
| 359 | 359 | } |
| 360 | 360 | |
| 361 | - if (is_numeric($defaultref) && $defaultref <= 0) $defaultref=''; |
|
| 361 | + if (is_numeric($defaultref) && $defaultref <= 0) $defaultref = ''; |
|
| 362 | 362 | |
| 363 | 363 | // Ref |
| 364 | 364 | print '<tr><td class="titlefieldcreate"><span class="fieldrequired">'.$langs->trans("Ref").'</span></td><td>'; |
| 365 | - print ($_POST["ref"]?$_POST["ref"]:$defaultref); |
|
| 366 | - print '<input type="hidden" name="taskref" value="'.($_POST["ref"]?$_POST["ref"]:$defaultref).'">'; |
|
| 365 | + print ($_POST["ref"] ? $_POST["ref"] : $defaultref); |
|
| 366 | + print '<input type="hidden" name="taskref" value="'.($_POST["ref"] ? $_POST["ref"] : $defaultref).'">'; |
|
| 367 | 367 | print '</td></tr>'; |
| 368 | 368 | |
| 369 | 369 | print '<tr><td class="fieldrequired">'.$langs->trans("Label").'</td><td>'; |
@@ -372,11 +372,11 @@ discard block |
||
| 372 | 372 | |
| 373 | 373 | // List of projects |
| 374 | 374 | print '<tr><td class="fieldrequired">'.$langs->trans("ChildOfProjectTask").'</td><td>'; |
| 375 | - print $formother->selectProjectTasks(GETPOST('task_parent'),$projectid?$projectid:$object->id, 'task_parent', 0, 0, 1, 1); |
|
| 375 | + print $formother->selectProjectTasks(GETPOST('task_parent'), $projectid ? $projectid : $object->id, 'task_parent', 0, 0, 1, 1); |
|
| 376 | 376 | print '</td></tr>'; |
| 377 | 377 | |
| 378 | 378 | print '<tr><td>'.$langs->trans("AffectedTo").'</td><td>'; |
| 379 | - $contactsofproject=(! empty($object->id)?$object->getListContactId('internal'):''); |
|
| 379 | + $contactsofproject = (!empty($object->id) ? $object->getListContactId('internal') : ''); |
|
| 380 | 380 | if (count($contactsofproject)) |
| 381 | 381 | { |
| 382 | 382 | print $form->select_dolusers($user->id, 'userid', 0, '', 0, '', $contactsofproject, 0, 0, 0, '', 0, '', 'maxwidth300'); |
@@ -389,22 +389,22 @@ discard block |
||
| 389 | 389 | |
| 390 | 390 | // Date start |
| 391 | 391 | print '<tr><td>'.$langs->trans("DateStart").'</td><td>'; |
| 392 | - print $form->select_date(($date_start?$date_start:''),'dateo',1,1,0,'',1,1,1); |
|
| 392 | + print $form->select_date(($date_start ? $date_start : ''), 'dateo', 1, 1, 0, '', 1, 1, 1); |
|
| 393 | 393 | print '</td></tr>'; |
| 394 | 394 | |
| 395 | 395 | // Date end |
| 396 | 396 | print '<tr><td>'.$langs->trans("DateEnd").'</td><td>'; |
| 397 | - print $form->select_date(($date_end?$date_end:-1),'datee',-1,1,0,'',1,1,1); |
|
| 397 | + print $form->select_date(($date_end ? $date_end : -1), 'datee', -1, 1, 0, '', 1, 1, 1); |
|
| 398 | 398 | print '</td></tr>'; |
| 399 | 399 | |
| 400 | 400 | // Planned workload |
| 401 | 401 | print '<tr><td>'.$langs->trans("PlannedWorkload").'</td><td>'; |
| 402 | - print $form->select_duration('planned_workload', $planned_workload?$planned_workload : $object->planned_workload,0,'text'); |
|
| 402 | + print $form->select_duration('planned_workload', $planned_workload ? $planned_workload : $object->planned_workload, 0, 'text'); |
|
| 403 | 403 | print '</td></tr>'; |
| 404 | 404 | |
| 405 | 405 | // Progress |
| 406 | 406 | print '<tr><td>'.$langs->trans("ProgressDeclared").'</td><td colspan="3">'; |
| 407 | - print $formother->select_percent($progress,'progress',0,5,0,100,1); |
|
| 407 | + print $formother->select_percent($progress, 'progress', 0, 5, 0, 100, 1); |
|
| 408 | 408 | print '</td></tr>'; |
| 409 | 409 | |
| 410 | 410 | // Description |
@@ -414,12 +414,12 @@ discard block |
||
| 414 | 414 | print '</td></tr>'; |
| 415 | 415 | |
| 416 | 416 | // Other options |
| 417 | - $parameters=array(); |
|
| 418 | - $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook |
|
| 417 | + $parameters = array(); |
|
| 418 | + $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook |
|
| 419 | 419 | print $hookmanager->resPrint; |
| 420 | 420 | if (empty($reshook)) |
| 421 | 421 | { |
| 422 | - print $object->showOptionals($extrafields_task,'edit'); |
|
| 422 | + print $object->showOptionals($extrafields_task, 'edit'); |
|
| 423 | 423 | } |
| 424 | 424 | |
| 425 | 425 | print '</table>'; |
@@ -435,24 +435,24 @@ discard block |
||
| 435 | 435 | print '</form>'; |
| 436 | 436 | |
| 437 | 437 | } |
| 438 | -else if ($id > 0 || ! empty($ref)) |
|
| 438 | +else if ($id > 0 || !empty($ref)) |
|
| 439 | 439 | { |
| 440 | 440 | /* |
| 441 | 441 | * Projet card in view mode |
| 442 | 442 | */ |
| 443 | 443 | |
| 444 | 444 | // Definition of fields for list |
| 445 | - $arrayfields=array(); |
|
| 446 | - $arrayfields['t.task_ref']=array('label'=>$langs->trans("RefTask"), 'checked'=>1); |
|
| 447 | - $arrayfields['t.task_label']=array('label'=>$langs->trans("LabelTask"), 'checked'=>1); |
|
| 448 | - $arrayfields['t.task_date_start']=array('label'=>$langs->trans("DateStart"), 'checked'=>1); |
|
| 449 | - $arrayfields['t.task_date_end']=array('label'=>$langs->trans("DateEnd"), 'checked'=>1); |
|
| 445 | + $arrayfields = array(); |
|
| 446 | + $arrayfields['t.task_ref'] = array('label'=>$langs->trans("RefTask"), 'checked'=>1); |
|
| 447 | + $arrayfields['t.task_label'] = array('label'=>$langs->trans("LabelTask"), 'checked'=>1); |
|
| 448 | + $arrayfields['t.task_date_start'] = array('label'=>$langs->trans("DateStart"), 'checked'=>1); |
|
| 449 | + $arrayfields['t.task_date_end'] = array('label'=>$langs->trans("DateEnd"), 'checked'=>1); |
|
| 450 | 450 | // Extra fields |
| 451 | 451 | if (is_array($extrafields_task->attribute_label) && count($extrafields_task->attribute_label)) |
| 452 | 452 | { |
| 453 | - foreach($extrafields_task->attribute_label as $key => $val) |
|
| 453 | + foreach ($extrafields_task->attribute_label as $key => $val) |
|
| 454 | 454 | { |
| 455 | - if (! empty($extrafields_task->attribute_list[$key])) $arrayfields["ef.".$key]=array('label'=>$extrafields_task->attribute_label[$key], 'checked'=>(($extrafields_task->attribute_list[$key]<0)?0:1), 'position'=>$extrafields_task->attribute_pos[$key], 'enabled'=>(abs($extrafields_task->attribute_list[$key])!=3 && $extrafields_task->attribute_perms[$key])); |
|
| 455 | + if (!empty($extrafields_task->attribute_list[$key])) $arrayfields["ef.".$key] = array('label'=>$extrafields_task->attribute_label[$key], 'checked'=>(($extrafields_task->attribute_list[$key] < 0) ? 0 : 1), 'position'=>$extrafields_task->attribute_pos[$key], 'enabled'=>(abs($extrafields_task->attribute_list[$key]) != 3 && $extrafields_task->attribute_perms[$key])); |
|
| 456 | 456 | } |
| 457 | 457 | } |
| 458 | 458 | |
@@ -487,8 +487,8 @@ discard block |
||
| 487 | 487 | print '<input type="hidden" name="page" value="'.$page.'">'; |
| 488 | 488 | print '<input type="hidden" name="contextpage" value="'.$contextpage.'">'; |
| 489 | 489 | |
| 490 | - $title=$langs->trans("ListOfTasks"); |
|
| 491 | - $linktotasks='<a href="'.DOL_URL_ROOT.'/projet/ganttview.php?id='.$object->id.'&withproject=1">'.$langs->trans("GoToGanttView").'<span class="paddingleft fa fa-calendar-minus-o valignmiddle"></span></a>'; |
|
| 490 | + $title = $langs->trans("ListOfTasks"); |
|
| 491 | + $linktotasks = '<a href="'.DOL_URL_ROOT.'/projet/ganttview.php?id='.$object->id.'&withproject=1">'.$langs->trans("GoToGanttView").'<span class="paddingleft fa fa-calendar-minus-o valignmiddle"></span></a>'; |
|
| 492 | 492 | |
| 493 | 493 | //print_barre_liste($title, 0, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, $linktotasks, $num, $totalnboflines, 'title_generic.png', 0, '', '', 0, 1); |
| 494 | 494 | print load_fiche_titre($title, $linktotasks.' '.$linktocreatetask, 'title_generic.png'); |
@@ -496,22 +496,22 @@ discard block |
||
| 496 | 496 | // Get list of tasks in tasksarray and taskarrayfiltered |
| 497 | 497 | // We need all tasks (even not limited to a user because a task to user can have a parent that is not affected to him). |
| 498 | 498 | $filteronthirdpartyid = $socid; |
| 499 | - $tasksarray=$taskstatic->getTasksArray(0, 0, $object->id, $filteronthirdpartyid, 0); |
|
| 499 | + $tasksarray = $taskstatic->getTasksArray(0, 0, $object->id, $filteronthirdpartyid, 0); |
|
| 500 | 500 | // We load also tasks limited to a particular user |
| 501 | - $tmpuser=new User($db); |
|
| 501 | + $tmpuser = new User($db); |
|
| 502 | 502 | if ($search_user_id > 0) $tmpuser->fetch($search_user_id); |
| 503 | 503 | |
| 504 | - $tasksrole=($tmpuser->id > 0 ? $taskstatic->getUserRolesForProjectsOrTasks(0, $tmpuser, $object->id, 0) : ''); |
|
| 504 | + $tasksrole = ($tmpuser->id > 0 ? $taskstatic->getUserRolesForProjectsOrTasks(0, $tmpuser, $object->id, 0) : ''); |
|
| 505 | 505 | //var_dump($tasksarray); |
| 506 | 506 | //var_dump($tasksrole); |
| 507 | 507 | |
| 508 | - if (! empty($conf->use_javascript_ajax)) |
|
| 508 | + if (!empty($conf->use_javascript_ajax)) |
|
| 509 | 509 | { |
| 510 | 510 | include DOL_DOCUMENT_ROOT.'/core/tpl/ajaxrow.tpl.php'; |
| 511 | 511 | } |
| 512 | 512 | |
| 513 | - $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; |
|
| 514 | - $selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields |
|
| 513 | + $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; |
|
| 514 | + $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields |
|
| 515 | 515 | |
| 516 | 516 | print '<div class="div-table-responsive">'; |
| 517 | 517 | print '<table id="tablelines" class="noborder" width="100%">'; |
@@ -526,30 +526,30 @@ discard block |
||
| 526 | 526 | |
| 527 | 527 | // Action column |
| 528 | 528 | print '<td class="liste_titre" align="right">'; |
| 529 | - $searchpicto=$form->showFilterButtons(); |
|
| 529 | + $searchpicto = $form->showFilterButtons(); |
|
| 530 | 530 | print $searchpicto; |
| 531 | 531 | print '</td>'; |
| 532 | 532 | } |
| 533 | 533 | |
| 534 | 534 | print '<tr class="liste_titre nodrag nodrop">'; |
| 535 | 535 | // print '<td>'.$langs->trans("Project").'</td>'; |
| 536 | - print_liste_field_titre("RefTask", $_SERVER["PHP_SELF"],"",'','','',$sortfield,$sortorder,''); |
|
| 537 | - print_liste_field_titre("LabelTask", $_SERVER["PHP_SELF"],"",'','','',$sortfield,$sortorder,''); |
|
| 538 | - print_liste_field_titre("DateStart", $_SERVER["PHP_SELF"],"",'','','align="center"',$sortfield,$sortorder,''); |
|
| 539 | - print_liste_field_titre("DateEnd", $_SERVER["PHP_SELF"],"",'','','align="center"',$sortfield,$sortorder,''); |
|
| 540 | - print_liste_field_titre("PlannedWorkload", $_SERVER["PHP_SELF"],"",'','','align="right"',$sortfield,$sortorder,''); |
|
| 541 | - print_liste_field_titre("TimeSpent", $_SERVER["PHP_SELF"],"",'','','align="right"',$sortfield,$sortorder,''); |
|
| 542 | - print_liste_field_titre("ProgressCalculated", $_SERVER["PHP_SELF"],"",'','','align="right"',$sortfield,$sortorder,''); |
|
| 543 | - print_liste_field_titre("ProgressDeclared", $_SERVER["PHP_SELF"],"",'','','align="right"',$sortfield,$sortorder,''); |
|
| 536 | + print_liste_field_titre("RefTask", $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, ''); |
|
| 537 | + print_liste_field_titre("LabelTask", $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, ''); |
|
| 538 | + print_liste_field_titre("DateStart", $_SERVER["PHP_SELF"], "", '', '', 'align="center"', $sortfield, $sortorder, ''); |
|
| 539 | + print_liste_field_titre("DateEnd", $_SERVER["PHP_SELF"], "", '', '', 'align="center"', $sortfield, $sortorder, ''); |
|
| 540 | + print_liste_field_titre("PlannedWorkload", $_SERVER["PHP_SELF"], "", '', '', 'align="right"', $sortfield, $sortorder, ''); |
|
| 541 | + print_liste_field_titre("TimeSpent", $_SERVER["PHP_SELF"], "", '', '', 'align="right"', $sortfield, $sortorder, ''); |
|
| 542 | + print_liste_field_titre("ProgressCalculated", $_SERVER["PHP_SELF"], "", '', '', 'align="right"', $sortfield, $sortorder, ''); |
|
| 543 | + print_liste_field_titre("ProgressDeclared", $_SERVER["PHP_SELF"], "", '', '', 'align="right"', $sortfield, $sortorder, ''); |
|
| 544 | 544 | //print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"],"",'','','align="center" width="80"',$sortfield,$sortorder,'maxwidthsearch '); |
| 545 | - print_liste_field_titre('', $_SERVER["PHP_SELF"],"",'','','align="center" width="80"',$sortfield,$sortorder,'maxwidthsearch '); |
|
| 545 | + print_liste_field_titre('', $_SERVER["PHP_SELF"], "", '', '', 'align="center" width="80"', $sortfield, $sortorder, 'maxwidthsearch '); |
|
| 546 | 546 | print "</tr>\n"; |
| 547 | 547 | |
| 548 | 548 | if (count($tasksarray) > 0) |
| 549 | 549 | { |
| 550 | 550 | // Show all lines in taskarray (recursive function to go down on tree) |
| 551 | - $j=0; $level=0; |
|
| 552 | - $nboftaskshown=projectLinesa($j, 0, $tasksarray, $level, true, 0, $tasksrole, $object->id, 1, $object->id); |
|
| 551 | + $j = 0; $level = 0; |
|
| 552 | + $nboftaskshown = projectLinesa($j, 0, $tasksarray, $level, true, 0, $tasksrole, $object->id, 1, $object->id); |
|
| 553 | 553 | } |
| 554 | 554 | else |
| 555 | 555 | { |
@@ -564,7 +564,7 @@ discard block |
||
| 564 | 564 | |
| 565 | 565 | // Test if database is clean. If not we clean it. |
| 566 | 566 | //print 'mode='.$_REQUEST["mode"].' $nboftaskshown='.$nboftaskshown.' count($tasksarray)='.count($tasksarray).' count($tasksrole)='.count($tasksrole).'<br>'; |
| 567 | - if (! empty($user->rights->projet->all->lire)) // We make test to clean only if user has permission to see all (test may report false positive otherwise) |
|
| 567 | + if (!empty($user->rights->projet->all->lire)) // We make test to clean only if user has permission to see all (test may report false positive otherwise) |
|
| 568 | 568 | { |
| 569 | 569 | if ($search_user_id == $user->id) |
| 570 | 570 | { |
@@ -576,7 +576,7 @@ discard block |
||
| 576 | 576 | } |
| 577 | 577 | else |
| 578 | 578 | { |
| 579 | - if ($nboftaskshown < count($tasksarray) && ! GETPOST('search_user_id','int')) |
|
| 579 | + if ($nboftaskshown < count($tasksarray) && !GETPOST('search_user_id', 'int')) |
|
| 580 | 580 | { |
| 581 | 581 | include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; |
| 582 | 582 | cleanCorruptedTree($db, 'projet_task', 'fk_task_parent'); |
@@ -94,102 +94,102 @@ discard block |
||
| 94 | 94 | //$userDelete = $object->restrictedProjectArea($user,'delete'); |
| 95 | 95 | //print "userAccess=".$userAccess." userWrite=".$userWrite." userDelete=".$userDelete; |
| 96 | 96 | |
| 97 | - $tab='tasks'; |
|
| 97 | + $tab='tasks'; |
|
| 98 | 98 | |
| 99 | - $head=project_prepare_head($object); |
|
| 100 | - dol_fiche_head($head, $tab, $langs->trans("Project"), -1, ($object->public?'projectpub':'project')); |
|
| 99 | + $head=project_prepare_head($object); |
|
| 100 | + dol_fiche_head($head, $tab, $langs->trans("Project"), -1, ($object->public?'projectpub':'project')); |
|
| 101 | 101 | |
| 102 | - $param=($mode=='mine'?'&mode=mine':''); |
|
| 102 | + $param=($mode=='mine'?'&mode=mine':''); |
|
| 103 | 103 | |
| 104 | 104 | |
| 105 | 105 | |
| 106 | - // Project card |
|
| 106 | + // Project card |
|
| 107 | 107 | |
| 108 | - $linkback = '<a href="'.DOL_URL_ROOT.'/projet/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>'; |
|
| 108 | + $linkback = '<a href="'.DOL_URL_ROOT.'/projet/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>'; |
|
| 109 | 109 | |
| 110 | - $morehtmlref='<div class="refidno">'; |
|
| 111 | - // Title |
|
| 112 | - $morehtmlref.=$object->title; |
|
| 113 | - // Thirdparty |
|
| 114 | - if ($object->thirdparty->id > 0) |
|
| 115 | - { |
|
| 116 | - $morehtmlref.='<br>'.$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1, 'project'); |
|
| 117 | - } |
|
| 118 | - $morehtmlref.='</div>'; |
|
| 110 | + $morehtmlref='<div class="refidno">'; |
|
| 111 | + // Title |
|
| 112 | + $morehtmlref.=$object->title; |
|
| 113 | + // Thirdparty |
|
| 114 | + if ($object->thirdparty->id > 0) |
|
| 115 | + { |
|
| 116 | + $morehtmlref.='<br>'.$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1, 'project'); |
|
| 117 | + } |
|
| 118 | + $morehtmlref.='</div>'; |
|
| 119 | 119 | |
| 120 | - // Define a complementary filter for search of next/prev ref. |
|
| 121 | - if (! $user->rights->projet->all->lire) |
|
| 122 | - { |
|
| 123 | - $objectsListId = $object->getProjectsAuthorizedForUser($user,0,0); |
|
| 124 | - $object->next_prev_filter=" rowid in (".(count($objectsListId)?join(',',array_keys($objectsListId)):'0').")"; |
|
| 125 | - } |
|
| 120 | + // Define a complementary filter for search of next/prev ref. |
|
| 121 | + if (! $user->rights->projet->all->lire) |
|
| 122 | + { |
|
| 123 | + $objectsListId = $object->getProjectsAuthorizedForUser($user,0,0); |
|
| 124 | + $object->next_prev_filter=" rowid in (".(count($objectsListId)?join(',',array_keys($objectsListId)):'0').")"; |
|
| 125 | + } |
|
| 126 | 126 | |
| 127 | - dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); |
|
| 127 | + dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); |
|
| 128 | 128 | |
| 129 | 129 | |
| 130 | - print '<div class="fichecenter">'; |
|
| 131 | - print '<div class="fichehalfleft">'; |
|
| 132 | - print '<div class="underbanner clearboth"></div>'; |
|
| 130 | + print '<div class="fichecenter">'; |
|
| 131 | + print '<div class="fichehalfleft">'; |
|
| 132 | + print '<div class="underbanner clearboth"></div>'; |
|
| 133 | 133 | |
| 134 | - print '<table class="border" width="100%">'; |
|
| 134 | + print '<table class="border" width="100%">'; |
|
| 135 | 135 | |
| 136 | - // Visibility |
|
| 137 | - print '<tr><td class="titlefield">'.$langs->trans("Visibility").'</td><td>'; |
|
| 138 | - if ($object->public) print $langs->trans('SharedProject'); |
|
| 139 | - else print $langs->trans('PrivateProject'); |
|
| 140 | - print '</td></tr>'; |
|
| 136 | + // Visibility |
|
| 137 | + print '<tr><td class="titlefield">'.$langs->trans("Visibility").'</td><td>'; |
|
| 138 | + if ($object->public) print $langs->trans('SharedProject'); |
|
| 139 | + else print $langs->trans('PrivateProject'); |
|
| 140 | + print '</td></tr>'; |
|
| 141 | 141 | |
| 142 | - // Date start - end |
|
| 143 | - print '<tr><td>'.$langs->trans("DateStart").' - '.$langs->trans("DateEnd").'</td><td>'; |
|
| 142 | + // Date start - end |
|
| 143 | + print '<tr><td>'.$langs->trans("DateStart").' - '.$langs->trans("DateEnd").'</td><td>'; |
|
| 144 | 144 | $start = dol_print_date($object->date_start,'day'); |
| 145 | 145 | print ($start?$start:'?'); |
| 146 | 146 | $end = dol_print_date($object->date_end,'day'); |
| 147 | 147 | print ' - '; |
| 148 | 148 | print ($end?$end:'?'); |
| 149 | 149 | if ($object->hasDelay()) print img_warning("Late"); |
| 150 | - print '</td></tr>'; |
|
| 150 | + print '</td></tr>'; |
|
| 151 | 151 | |
| 152 | - // Budget |
|
| 153 | - print '<tr><td>'.$langs->trans("Budget").'</td><td>'; |
|
| 154 | - if (strcmp($object->budget_amount, '')) print price($object->budget_amount,'',$langs,1,0,0,$conf->currency); |
|
| 155 | - print '</td></tr>'; |
|
| 152 | + // Budget |
|
| 153 | + print '<tr><td>'.$langs->trans("Budget").'</td><td>'; |
|
| 154 | + if (strcmp($object->budget_amount, '')) print price($object->budget_amount,'',$langs,1,0,0,$conf->currency); |
|
| 155 | + print '</td></tr>'; |
|
| 156 | 156 | |
| 157 | - // Other attributes |
|
| 158 | - $cols = 2; |
|
| 159 | - include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; |
|
| 157 | + // Other attributes |
|
| 158 | + $cols = 2; |
|
| 159 | + include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; |
|
| 160 | 160 | |
| 161 | - print '</table>'; |
|
| 161 | + print '</table>'; |
|
| 162 | 162 | |
| 163 | - print '</div>'; |
|
| 164 | - print '<div class="fichehalfright">'; |
|
| 165 | - print '<div class="ficheaddleft">'; |
|
| 166 | - print '<div class="underbanner clearboth"></div>'; |
|
| 163 | + print '</div>'; |
|
| 164 | + print '<div class="fichehalfright">'; |
|
| 165 | + print '<div class="ficheaddleft">'; |
|
| 166 | + print '<div class="underbanner clearboth"></div>'; |
|
| 167 | 167 | |
| 168 | - print '<table class="border" width="100%">'; |
|
| 168 | + print '<table class="border" width="100%">'; |
|
| 169 | 169 | |
| 170 | - // Description |
|
| 171 | - print '<td class="titlefield tdtop">'.$langs->trans("Description").'</td><td>'; |
|
| 172 | - print nl2br($object->description); |
|
| 173 | - print '</td></tr>'; |
|
| 170 | + // Description |
|
| 171 | + print '<td class="titlefield tdtop">'.$langs->trans("Description").'</td><td>'; |
|
| 172 | + print nl2br($object->description); |
|
| 173 | + print '</td></tr>'; |
|
| 174 | 174 | |
| 175 | - // Categories |
|
| 176 | - if($conf->categorie->enabled) { |
|
| 177 | - print '<tr><td valign="middle">'.$langs->trans("Categories").'</td><td>'; |
|
| 178 | - print $form->showCategories($object->id,'project',1); |
|
| 179 | - print "</td></tr>"; |
|
| 180 | - } |
|
| 175 | + // Categories |
|
| 176 | + if($conf->categorie->enabled) { |
|
| 177 | + print '<tr><td valign="middle">'.$langs->trans("Categories").'</td><td>'; |
|
| 178 | + print $form->showCategories($object->id,'project',1); |
|
| 179 | + print "</td></tr>"; |
|
| 180 | + } |
|
| 181 | 181 | |
| 182 | - print '</table>'; |
|
| 182 | + print '</table>'; |
|
| 183 | 183 | |
| 184 | - print '</div>'; |
|
| 185 | - print '</div>'; |
|
| 186 | - print '</div>'; |
|
| 184 | + print '</div>'; |
|
| 185 | + print '</div>'; |
|
| 186 | + print '</div>'; |
|
| 187 | 187 | |
| 188 | - print '<div class="clearboth"></div>'; |
|
| 188 | + print '<div class="clearboth"></div>'; |
|
| 189 | 189 | |
| 190 | - dol_fiche_end(); |
|
| 190 | + dol_fiche_end(); |
|
| 191 | 191 | |
| 192 | - print '<br>'; |
|
| 192 | + print '<br>'; |
|
| 193 | 193 | } |
| 194 | 194 | |
| 195 | 195 | // Link to create task |
@@ -248,21 +248,21 @@ discard block |
||
| 248 | 248 | $tasks[$taskcursor]['task_parent']=$idparent; |
| 249 | 249 | |
| 250 | 250 | $tasks[$taskcursor]['task_is_group'] = 0; |
| 251 | - $tasks[$taskcursor]['task_css'] = 'gtaskblue'; |
|
| 252 | - $tasks[$taskcursor]['task_position'] = $val->rang; |
|
| 253 | - $tasks[$taskcursor]['task_planned_workload'] = $val->planned_workload; |
|
| 254 | - |
|
| 255 | - if ($val->fk_parent != 0 && $task->hasChildren()> 0){ |
|
| 256 | - $tasks[$taskcursor]['task_is_group']=1; |
|
| 257 | - $tasks[$taskcursor]['task_css']='ggroupblack'; |
|
| 258 | - //$tasks[$taskcursor]['task_css'] = 'gtaskblue'; |
|
| 259 | - } |
|
| 260 | - elseif ($task->hasChildren()> 0) { |
|
| 261 | - $tasks[$taskcursor]['task_is_group'] = 1; |
|
| 262 | - //$tasks[$taskcursor]['task_is_group'] = 0; |
|
| 263 | - $tasks[$taskcursor]['task_css'] = 'ggroupblack'; |
|
| 264 | - //$tasks[$taskcursor]['task_css'] = 'gtaskblue'; |
|
| 265 | - } |
|
| 251 | + $tasks[$taskcursor]['task_css'] = 'gtaskblue'; |
|
| 252 | + $tasks[$taskcursor]['task_position'] = $val->rang; |
|
| 253 | + $tasks[$taskcursor]['task_planned_workload'] = $val->planned_workload; |
|
| 254 | + |
|
| 255 | + if ($val->fk_parent != 0 && $task->hasChildren()> 0){ |
|
| 256 | + $tasks[$taskcursor]['task_is_group']=1; |
|
| 257 | + $tasks[$taskcursor]['task_css']='ggroupblack'; |
|
| 258 | + //$tasks[$taskcursor]['task_css'] = 'gtaskblue'; |
|
| 259 | + } |
|
| 260 | + elseif ($task->hasChildren()> 0) { |
|
| 261 | + $tasks[$taskcursor]['task_is_group'] = 1; |
|
| 262 | + //$tasks[$taskcursor]['task_is_group'] = 0; |
|
| 263 | + $tasks[$taskcursor]['task_css'] = 'ggroupblack'; |
|
| 264 | + //$tasks[$taskcursor]['task_css'] = 'gtaskblue'; |
|
| 265 | + } |
|
| 266 | 266 | $tasks[$taskcursor]['task_milestone']='0'; |
| 267 | 267 | $tasks[$taskcursor]['task_percent_complete']=$val->progress; |
| 268 | 268 | //$tasks[$taskcursor]['task_name']=$task->getNomUrl(1); |
@@ -312,9 +312,9 @@ discard block |
||
| 312 | 312 | //if ($s) $tasks[$taskcursor]['task_resources']='<a href="'.DOL_URL_ROOT.'/projet/tasks/contact.php?id='.$val->id.'&withproject=1" title="'.dol_escape_htmltag($s).'">'.$langs->trans("List").'</a>'; |
| 313 | 313 | /* For JSGanttImproved */ |
| 314 | 314 | //if ($s) $tasks[$taskcursor]['task_resources']=implode(',',$idofusers); |
| 315 | - $tasks[$taskcursor]['task_resources'] = $s; |
|
| 315 | + $tasks[$taskcursor]['task_resources'] = $s; |
|
| 316 | 316 | //print "xxx".$val->id.$tasks[$taskcursor]['task_resources']; |
| 317 | - $tasks[$taskcursor]['note']=$task->note_public; |
|
| 317 | + $tasks[$taskcursor]['note']=$task->note_public; |
|
| 318 | 318 | $taskcursor++; |
| 319 | 319 | } |
| 320 | 320 | |
@@ -336,18 +336,18 @@ discard block |
||
| 336 | 336 | |
| 337 | 337 | if (! empty($conf->use_javascript_ajax)) |
| 338 | 338 | { |
| 339 | - //var_dump($_SESSION); |
|
| 339 | + //var_dump($_SESSION); |
|
| 340 | 340 | |
| 341 | 341 | // How the date for data are formated (format used bu jsgantt) |
| 342 | - $dateformatinput='yyyy-mm-dd'; |
|
| 343 | - // How the date for data are formated (format used by dol_print_date) |
|
| 344 | - $dateformatinput2='standard'; |
|
| 345 | - //var_dump($dateformatinput); |
|
| 342 | + $dateformatinput='yyyy-mm-dd'; |
|
| 343 | + // How the date for data are formated (format used by dol_print_date) |
|
| 344 | + $dateformatinput2='standard'; |
|
| 345 | + //var_dump($dateformatinput); |
|
| 346 | 346 | //var_dump($dateformatinput2); |
| 347 | 347 | |
| 348 | - print '<div class="div-table-responsive">'; |
|
| 348 | + print '<div class="div-table-responsive">'; |
|
| 349 | 349 | |
| 350 | - print '<div id="tabs" class="gantt" style="width: 80vw;">'."\n"; |
|
| 350 | + print '<div id="tabs" class="gantt" style="width: 80vw;">'."\n"; |
|
| 351 | 351 | include_once DOL_DOCUMENT_ROOT.'/projet/ganttchart.inc.php'; |
| 352 | 352 | print '</div>'."\n"; |
| 353 | 353 | |
@@ -32,8 +32,8 @@ discard block |
||
| 32 | 32 | require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; |
| 33 | 33 | require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; |
| 34 | 34 | |
| 35 | -$id=GETPOST('id','intcomma'); |
|
| 36 | -$ref=GETPOST('ref','alpha'); |
|
| 35 | +$id = GETPOST('id', 'intcomma'); |
|
| 36 | +$ref = GETPOST('ref', 'alpha'); |
|
| 37 | 37 | |
| 38 | 38 | $mode = GETPOST('mode', 'alpha'); |
| 39 | 39 | $mine = ($mode == 'mine' ? 1 : 0); |
@@ -41,10 +41,10 @@ discard block |
||
| 41 | 41 | |
| 42 | 42 | $object = new Project($db); |
| 43 | 43 | |
| 44 | -include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once |
|
| 44 | +include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once |
|
| 45 | 45 | |
| 46 | 46 | // Security check |
| 47 | -$socid=0; |
|
| 47 | +$socid = 0; |
|
| 48 | 48 | //if ($user->societe_id > 0) $socid = $user->societe_id; // For external user, no check is done on company because readability is managed by public status of project and assignement. |
| 49 | 49 | $result = restrictedArea($user, 'projet', $id, 'projet&project'); |
| 50 | 50 | |
@@ -63,43 +63,43 @@ discard block |
||
| 63 | 63 | * View |
| 64 | 64 | */ |
| 65 | 65 | |
| 66 | -$form=new Form($db); |
|
| 67 | -$formother=new FormOther($db); |
|
| 68 | -$userstatic=new User($db); |
|
| 69 | -$companystatic=new Societe($db); |
|
| 70 | -$contactstatic=new Contact($db); |
|
| 66 | +$form = new Form($db); |
|
| 67 | +$formother = new FormOther($db); |
|
| 68 | +$userstatic = new User($db); |
|
| 69 | +$companystatic = new Societe($db); |
|
| 70 | +$contactstatic = new Contact($db); |
|
| 71 | 71 | $task = new Task($db); |
| 72 | 72 | |
| 73 | -$arrayofcss=array('/includes/jsgantt/jsgantt.css'); |
|
| 73 | +$arrayofcss = array('/includes/jsgantt/jsgantt.css'); |
|
| 74 | 74 | |
| 75 | -if (! empty($conf->use_javascript_ajax)) |
|
| 75 | +if (!empty($conf->use_javascript_ajax)) |
|
| 76 | 76 | { |
| 77 | - $arrayofjs=array( |
|
| 77 | + $arrayofjs = array( |
|
| 78 | 78 | '/includes/jsgantt/jsgantt.js', |
| 79 | 79 | '/projet/jsgantt_language.js.php?lang='.$langs->defaultlang |
| 80 | 80 | ); |
| 81 | 81 | } |
| 82 | 82 | |
| 83 | 83 | //$title=$langs->trans("Gantt").($object->ref?' - '.$object->ref.' '.$object->name:''); |
| 84 | -$title=$langs->trans("Gantt"); |
|
| 85 | -if (! empty($conf->global->MAIN_HTML_TITLE) && preg_match('/projectnameonly/',$conf->global->MAIN_HTML_TITLE) && $object->name) $title=($object->ref?$object->ref.' '.$object->name.' - ':'').$langs->trans("Gantt"); |
|
| 86 | -$help_url="EN:Module_Projects|FR:Module_Projets|ES:Módulo_Proyectos"; |
|
| 87 | -llxHeader("",$title,$help_url,'',0,0,$arrayofjs,$arrayofcss); |
|
| 84 | +$title = $langs->trans("Gantt"); |
|
| 85 | +if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/projectnameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) $title = ($object->ref ? $object->ref.' '.$object->name.' - ' : '').$langs->trans("Gantt"); |
|
| 86 | +$help_url = "EN:Module_Projects|FR:Module_Projets|ES:Módulo_Proyectos"; |
|
| 87 | +llxHeader("", $title, $help_url, '', 0, 0, $arrayofjs, $arrayofcss); |
|
| 88 | 88 | |
| 89 | -if (($id > 0 && is_numeric($id)) || ! empty($ref)) |
|
| 89 | +if (($id > 0 && is_numeric($id)) || !empty($ref)) |
|
| 90 | 90 | { |
| 91 | 91 | // To verify role of users |
| 92 | 92 | //$userAccess = $object->restrictedProjectArea($user,'read'); |
| 93 | - $userWrite = $object->restrictedProjectArea($user,'write'); |
|
| 93 | + $userWrite = $object->restrictedProjectArea($user, 'write'); |
|
| 94 | 94 | //$userDelete = $object->restrictedProjectArea($user,'delete'); |
| 95 | 95 | //print "userAccess=".$userAccess." userWrite=".$userWrite." userDelete=".$userDelete; |
| 96 | 96 | |
| 97 | - $tab='tasks'; |
|
| 97 | + $tab = 'tasks'; |
|
| 98 | 98 | |
| 99 | - $head=project_prepare_head($object); |
|
| 100 | - dol_fiche_head($head, $tab, $langs->trans("Project"), -1, ($object->public?'projectpub':'project')); |
|
| 99 | + $head = project_prepare_head($object); |
|
| 100 | + dol_fiche_head($head, $tab, $langs->trans("Project"), -1, ($object->public ? 'projectpub' : 'project')); |
|
| 101 | 101 | |
| 102 | - $param=($mode=='mine'?'&mode=mine':''); |
|
| 102 | + $param = ($mode == 'mine' ? '&mode=mine' : ''); |
|
| 103 | 103 | |
| 104 | 104 | |
| 105 | 105 | |
@@ -107,21 +107,21 @@ discard block |
||
| 107 | 107 | |
| 108 | 108 | $linkback = '<a href="'.DOL_URL_ROOT.'/projet/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>'; |
| 109 | 109 | |
| 110 | - $morehtmlref='<div class="refidno">'; |
|
| 110 | + $morehtmlref = '<div class="refidno">'; |
|
| 111 | 111 | // Title |
| 112 | - $morehtmlref.=$object->title; |
|
| 112 | + $morehtmlref .= $object->title; |
|
| 113 | 113 | // Thirdparty |
| 114 | 114 | if ($object->thirdparty->id > 0) |
| 115 | 115 | { |
| 116 | - $morehtmlref.='<br>'.$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1, 'project'); |
|
| 116 | + $morehtmlref .= '<br>'.$langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1, 'project'); |
|
| 117 | 117 | } |
| 118 | - $morehtmlref.='</div>'; |
|
| 118 | + $morehtmlref .= '</div>'; |
|
| 119 | 119 | |
| 120 | 120 | // Define a complementary filter for search of next/prev ref. |
| 121 | - if (! $user->rights->projet->all->lire) |
|
| 121 | + if (!$user->rights->projet->all->lire) |
|
| 122 | 122 | { |
| 123 | - $objectsListId = $object->getProjectsAuthorizedForUser($user,0,0); |
|
| 124 | - $object->next_prev_filter=" rowid in (".(count($objectsListId)?join(',',array_keys($objectsListId)):'0').")"; |
|
| 123 | + $objectsListId = $object->getProjectsAuthorizedForUser($user, 0, 0); |
|
| 124 | + $object->next_prev_filter = " rowid in (".(count($objectsListId) ?join(',', array_keys($objectsListId)) : '0').")"; |
|
| 125 | 125 | } |
| 126 | 126 | |
| 127 | 127 | dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); |
@@ -141,22 +141,22 @@ discard block |
||
| 141 | 141 | |
| 142 | 142 | // Date start - end |
| 143 | 143 | print '<tr><td>'.$langs->trans("DateStart").' - '.$langs->trans("DateEnd").'</td><td>'; |
| 144 | - $start = dol_print_date($object->date_start,'day'); |
|
| 145 | - print ($start?$start:'?'); |
|
| 146 | - $end = dol_print_date($object->date_end,'day'); |
|
| 144 | + $start = dol_print_date($object->date_start, 'day'); |
|
| 145 | + print ($start ? $start : '?'); |
|
| 146 | + $end = dol_print_date($object->date_end, 'day'); |
|
| 147 | 147 | print ' - '; |
| 148 | - print ($end?$end:'?'); |
|
| 148 | + print ($end ? $end : '?'); |
|
| 149 | 149 | if ($object->hasDelay()) print img_warning("Late"); |
| 150 | 150 | print '</td></tr>'; |
| 151 | 151 | |
| 152 | 152 | // Budget |
| 153 | 153 | print '<tr><td>'.$langs->trans("Budget").'</td><td>'; |
| 154 | - if (strcmp($object->budget_amount, '')) print price($object->budget_amount,'',$langs,1,0,0,$conf->currency); |
|
| 154 | + if (strcmp($object->budget_amount, '')) print price($object->budget_amount, '', $langs, 1, 0, 0, $conf->currency); |
|
| 155 | 155 | print '</td></tr>'; |
| 156 | 156 | |
| 157 | 157 | // Other attributes |
| 158 | 158 | $cols = 2; |
| 159 | - include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; |
|
| 159 | + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; |
|
| 160 | 160 | |
| 161 | 161 | print '</table>'; |
| 162 | 162 | |
@@ -173,9 +173,9 @@ discard block |
||
| 173 | 173 | print '</td></tr>'; |
| 174 | 174 | |
| 175 | 175 | // Categories |
| 176 | - if($conf->categorie->enabled) { |
|
| 176 | + if ($conf->categorie->enabled) { |
|
| 177 | 177 | print '<tr><td valign="middle">'.$langs->trans("Categories").'</td><td>'; |
| 178 | - print $form->showCategories($object->id,'project',1); |
|
| 178 | + print $form->showCategories($object->id, 'project', 1); |
|
| 179 | 179 | print "</td></tr>"; |
| 180 | 180 | } |
| 181 | 181 | |
@@ -209,7 +209,7 @@ discard block |
||
| 209 | 209 | $linktocreatetask = '<a class="butActionNewRefused" href="#" title="'.$langs->trans("NotEnoughPermissions").'">'.$langs->trans('AddTask').'<span class="fa fa-plus-circle valignmiddle"></span></a>'; |
| 210 | 210 | } |
| 211 | 211 | |
| 212 | -$linktolist='<a href="'.DOL_URL_ROOT.'/projet/tasks.php?id='.$object->id.'">'.$langs->trans("GoToListOfTasks").'<span class="paddingleft fa fa-list-ul valignmiddle"></span></a>'; |
|
| 212 | +$linktolist = '<a href="'.DOL_URL_ROOT.'/projet/tasks.php?id='.$object->id.'">'.$langs->trans("GoToListOfTasks").'<span class="paddingleft fa fa-list-ul valignmiddle"></span></a>'; |
|
| 213 | 213 | |
| 214 | 214 | //print_barre_liste($title, 0, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, $linktotasks, $num, $totalnboflines, 'title_generic.png', 0, '', '', 0, 1); |
| 215 | 215 | print load_fiche_titre($title, $linktolist.' '.$linktocreatetask, 'title_generic.png'); |
@@ -218,92 +218,92 @@ discard block |
||
| 218 | 218 | // Get list of tasks in tasksarray and taskarrayfiltered |
| 219 | 219 | // We need all tasks (even not limited to a user because a task to user |
| 220 | 220 | // can have a parent that is not affected to him). |
| 221 | -$tasksarray=$task->getTasksArray(0, 0, ($object->id ? $object->id : $id), $socid, 0); |
|
| 221 | +$tasksarray = $task->getTasksArray(0, 0, ($object->id ? $object->id : $id), $socid, 0); |
|
| 222 | 222 | // We load also tasks limited to a particular user |
| 223 | 223 | //$tasksrole=($_REQUEST["mode"]=='mine' ? $task->getUserRolesForProjectsOrTasks(0,$user,$object->id,0) : ''); |
| 224 | 224 | //var_dump($tasksarray); |
| 225 | 225 | //var_dump($tasksrole); |
| 226 | 226 | |
| 227 | 227 | |
| 228 | -if (count($tasksarray)>0) |
|
| 228 | +if (count($tasksarray) > 0) |
|
| 229 | 229 | { |
| 230 | 230 | |
| 231 | 231 | // Show Gant diagram from $taskarray using JSGantt |
| 232 | 232 | |
| 233 | - $dateformat=$langs->trans("FormatDateShortJQuery"); // Used by include ganttchart.inc.php later |
|
| 234 | - $datehourformat=$langs->trans("FormatDateShortJQuery").' '.$langs->trans("FormatHourShortJQuery"); // Used by include ganttchart.inc.php later |
|
| 235 | - $array_contacts=array(); |
|
| 236 | - $tasks=array(); |
|
| 237 | - $task_dependencies=array(); |
|
| 238 | - $taskcursor=0; |
|
| 239 | - foreach($tasksarray as $key => $val) // Task array are sorted by "project, position, dateo" |
|
| 233 | + $dateformat = $langs->trans("FormatDateShortJQuery"); // Used by include ganttchart.inc.php later |
|
| 234 | + $datehourformat = $langs->trans("FormatDateShortJQuery").' '.$langs->trans("FormatHourShortJQuery"); // Used by include ganttchart.inc.php later |
|
| 235 | + $array_contacts = array(); |
|
| 236 | + $tasks = array(); |
|
| 237 | + $task_dependencies = array(); |
|
| 238 | + $taskcursor = 0; |
|
| 239 | + foreach ($tasksarray as $key => $val) // Task array are sorted by "project, position, dateo" |
|
| 240 | 240 | { |
| 241 | 241 | $task->fetch($val->id, ''); |
| 242 | 242 | |
| 243 | - $idparent = ($val->fk_parent ? $val->fk_parent : '-'.$val->fk_project); // If start with -, id is a project id |
|
| 243 | + $idparent = ($val->fk_parent ? $val->fk_parent : '-'.$val->fk_project); // If start with -, id is a project id |
|
| 244 | 244 | |
| 245 | - $tasks[$taskcursor]['task_id']=$val->id; |
|
| 246 | - $tasks[$taskcursor]['task_alternate_id']=($taskcursor+1); // An id that has same order than position (requird by ganttchart) |
|
| 247 | - $tasks[$taskcursor]['task_project_id']=$val->fk_project; |
|
| 248 | - $tasks[$taskcursor]['task_parent']=$idparent; |
|
| 245 | + $tasks[$taskcursor]['task_id'] = $val->id; |
|
| 246 | + $tasks[$taskcursor]['task_alternate_id'] = ($taskcursor + 1); // An id that has same order than position (requird by ganttchart) |
|
| 247 | + $tasks[$taskcursor]['task_project_id'] = $val->fk_project; |
|
| 248 | + $tasks[$taskcursor]['task_parent'] = $idparent; |
|
| 249 | 249 | |
| 250 | 250 | $tasks[$taskcursor]['task_is_group'] = 0; |
| 251 | 251 | $tasks[$taskcursor]['task_css'] = 'gtaskblue'; |
| 252 | 252 | $tasks[$taskcursor]['task_position'] = $val->rang; |
| 253 | 253 | $tasks[$taskcursor]['task_planned_workload'] = $val->planned_workload; |
| 254 | 254 | |
| 255 | - if ($val->fk_parent != 0 && $task->hasChildren()> 0){ |
|
| 256 | - $tasks[$taskcursor]['task_is_group']=1; |
|
| 257 | - $tasks[$taskcursor]['task_css']='ggroupblack'; |
|
| 255 | + if ($val->fk_parent != 0 && $task->hasChildren() > 0) { |
|
| 256 | + $tasks[$taskcursor]['task_is_group'] = 1; |
|
| 257 | + $tasks[$taskcursor]['task_css'] = 'ggroupblack'; |
|
| 258 | 258 | //$tasks[$taskcursor]['task_css'] = 'gtaskblue'; |
| 259 | 259 | } |
| 260 | - elseif ($task->hasChildren()> 0) { |
|
| 260 | + elseif ($task->hasChildren() > 0) { |
|
| 261 | 261 | $tasks[$taskcursor]['task_is_group'] = 1; |
| 262 | 262 | //$tasks[$taskcursor]['task_is_group'] = 0; |
| 263 | 263 | $tasks[$taskcursor]['task_css'] = 'ggroupblack'; |
| 264 | 264 | //$tasks[$taskcursor]['task_css'] = 'gtaskblue'; |
| 265 | 265 | } |
| 266 | - $tasks[$taskcursor]['task_milestone']='0'; |
|
| 267 | - $tasks[$taskcursor]['task_percent_complete']=$val->progress; |
|
| 266 | + $tasks[$taskcursor]['task_milestone'] = '0'; |
|
| 267 | + $tasks[$taskcursor]['task_percent_complete'] = $val->progress; |
|
| 268 | 268 | //$tasks[$taskcursor]['task_name']=$task->getNomUrl(1); |
| 269 | 269 | //print dol_print_date($val->date_start).dol_print_date($val->date_end).'<br>'."\n"; |
| 270 | - $tasks[$taskcursor]['task_name']=$val->ref.' - '.$val->label; |
|
| 271 | - $tasks[$taskcursor]['task_start_date']=$val->date_start; |
|
| 272 | - $tasks[$taskcursor]['task_end_date']=$val->date_end; |
|
| 273 | - $tasks[$taskcursor]['task_color']='b4d1ea'; |
|
| 274 | - |
|
| 275 | - $idofusers=$task->getListContactId('internal'); |
|
| 276 | - $idofcontacts=$task->getListContactId('external'); |
|
| 277 | - $s=''; |
|
| 278 | - if (count($idofusers)>0) |
|
| 270 | + $tasks[$taskcursor]['task_name'] = $val->ref.' - '.$val->label; |
|
| 271 | + $tasks[$taskcursor]['task_start_date'] = $val->date_start; |
|
| 272 | + $tasks[$taskcursor]['task_end_date'] = $val->date_end; |
|
| 273 | + $tasks[$taskcursor]['task_color'] = 'b4d1ea'; |
|
| 274 | + |
|
| 275 | + $idofusers = $task->getListContactId('internal'); |
|
| 276 | + $idofcontacts = $task->getListContactId('external'); |
|
| 277 | + $s = ''; |
|
| 278 | + if (count($idofusers) > 0) |
|
| 279 | 279 | { |
| 280 | - $s.=$langs->trans("Internals").': '; |
|
| 281 | - $i=0; |
|
| 282 | - foreach($idofusers as $valid) |
|
| 280 | + $s .= $langs->trans("Internals").': '; |
|
| 281 | + $i = 0; |
|
| 282 | + foreach ($idofusers as $valid) |
|
| 283 | 283 | { |
| 284 | 284 | $userstatic->fetch($valid); |
| 285 | - if ($i) $s.=', '; |
|
| 286 | - $s.=$userstatic->login; |
|
| 285 | + if ($i) $s .= ', '; |
|
| 286 | + $s .= $userstatic->login; |
|
| 287 | 287 | $i++; |
| 288 | 288 | } |
| 289 | 289 | } |
| 290 | 290 | //if (count($idofusers)>0 && (count($idofcontacts)>0)) $s.=' - '; |
| 291 | - if (count($idofcontacts)>0) |
|
| 291 | + if (count($idofcontacts) > 0) |
|
| 292 | 292 | { |
| 293 | - if ($s) $s.=' - '; |
|
| 294 | - $s.=$langs->trans("Externals").': '; |
|
| 295 | - $i=0; |
|
| 296 | - $contactidfound=array(); |
|
| 297 | - foreach($idofcontacts as $valid) |
|
| 293 | + if ($s) $s .= ' - '; |
|
| 294 | + $s .= $langs->trans("Externals").': '; |
|
| 295 | + $i = 0; |
|
| 296 | + $contactidfound = array(); |
|
| 297 | + foreach ($idofcontacts as $valid) |
|
| 298 | 298 | { |
| 299 | 299 | if (empty($contactidfound[$valid])) |
| 300 | 300 | { |
| 301 | 301 | $res = $contactstatic->fetch($valid); |
| 302 | 302 | if ($res > 0) |
| 303 | 303 | { |
| 304 | - if ($i) $s.=', '; |
|
| 305 | - $s.=$contactstatic->getFullName($langs); |
|
| 306 | - $contactidfound[$valid]=1; |
|
| 304 | + if ($i) $s .= ', '; |
|
| 305 | + $s .= $contactstatic->getFullName($langs); |
|
| 306 | + $contactidfound[$valid] = 1; |
|
| 307 | 307 | $i++; |
| 308 | 308 | } |
| 309 | 309 | } |
@@ -314,18 +314,18 @@ discard block |
||
| 314 | 314 | //if ($s) $tasks[$taskcursor]['task_resources']=implode(',',$idofusers); |
| 315 | 315 | $tasks[$taskcursor]['task_resources'] = $s; |
| 316 | 316 | //print "xxx".$val->id.$tasks[$taskcursor]['task_resources']; |
| 317 | - $tasks[$taskcursor]['note']=$task->note_public; |
|
| 317 | + $tasks[$taskcursor]['note'] = $task->note_public; |
|
| 318 | 318 | $taskcursor++; |
| 319 | 319 | } |
| 320 | 320 | |
| 321 | 321 | // Search parent to set task_parent_alternate_id (requird by ganttchart) |
| 322 | - foreach($tasks as $tmpkey => $tmptask) |
|
| 322 | + foreach ($tasks as $tmpkey => $tmptask) |
|
| 323 | 323 | { |
| 324 | - foreach($tasks as $tmptask2) |
|
| 324 | + foreach ($tasks as $tmptask2) |
|
| 325 | 325 | { |
| 326 | 326 | if ($tmptask2['task_id'] == $tmptask['task_parent']) |
| 327 | 327 | { |
| 328 | - $tasks[$tmpkey]['task_parent_alternate_id']=$tmptask2['task_alternate_id']; |
|
| 328 | + $tasks[$tmpkey]['task_parent_alternate_id'] = $tmptask2['task_alternate_id']; |
|
| 329 | 329 | break; |
| 330 | 330 | } |
| 331 | 331 | } |
@@ -334,14 +334,14 @@ discard block |
||
| 334 | 334 | |
| 335 | 335 | print "\n"; |
| 336 | 336 | |
| 337 | - if (! empty($conf->use_javascript_ajax)) |
|
| 337 | + if (!empty($conf->use_javascript_ajax)) |
|
| 338 | 338 | { |
| 339 | 339 | //var_dump($_SESSION); |
| 340 | 340 | |
| 341 | 341 | // How the date for data are formated (format used bu jsgantt) |
| 342 | - $dateformatinput='yyyy-mm-dd'; |
|
| 342 | + $dateformatinput = 'yyyy-mm-dd'; |
|
| 343 | 343 | // How the date for data are formated (format used by dol_print_date) |
| 344 | - $dateformatinput2='standard'; |
|
| 344 | + $dateformatinput2 = 'standard'; |
|
| 345 | 345 | //var_dump($dateformatinput); |
| 346 | 346 | //var_dump($dateformatinput2); |
| 347 | 347 | |
@@ -82,7 +82,9 @@ discard block |
||
| 82 | 82 | |
| 83 | 83 | //$title=$langs->trans("Gantt").($object->ref?' - '.$object->ref.' '.$object->name:''); |
| 84 | 84 | $title=$langs->trans("Gantt"); |
| 85 | -if (! empty($conf->global->MAIN_HTML_TITLE) && preg_match('/projectnameonly/',$conf->global->MAIN_HTML_TITLE) && $object->name) $title=($object->ref?$object->ref.' '.$object->name.' - ':'').$langs->trans("Gantt"); |
|
| 85 | +if (! empty($conf->global->MAIN_HTML_TITLE) && preg_match('/projectnameonly/',$conf->global->MAIN_HTML_TITLE) && $object->name) { |
|
| 86 | + $title=($object->ref?$object->ref.' '.$object->name.' - ':'').$langs->trans("Gantt"); |
|
| 87 | +} |
|
| 86 | 88 | $help_url="EN:Module_Projects|FR:Module_Projets|ES:Módulo_Proyectos"; |
| 87 | 89 | llxHeader("",$title,$help_url,'',0,0,$arrayofjs,$arrayofcss); |
| 88 | 90 | |
@@ -135,8 +137,11 @@ discard block |
||
| 135 | 137 | |
| 136 | 138 | // Visibility |
| 137 | 139 | print '<tr><td class="titlefield">'.$langs->trans("Visibility").'</td><td>'; |
| 138 | - if ($object->public) print $langs->trans('SharedProject'); |
|
| 139 | - else print $langs->trans('PrivateProject'); |
|
| 140 | + if ($object->public) { |
|
| 141 | + print $langs->trans('SharedProject'); |
|
| 142 | + } else { |
|
| 143 | + print $langs->trans('PrivateProject'); |
|
| 144 | + } |
|
| 140 | 145 | print '</td></tr>'; |
| 141 | 146 | |
| 142 | 147 | // Date start - end |
@@ -146,12 +151,16 @@ discard block |
||
| 146 | 151 | $end = dol_print_date($object->date_end,'day'); |
| 147 | 152 | print ' - '; |
| 148 | 153 | print ($end?$end:'?'); |
| 149 | - if ($object->hasDelay()) print img_warning("Late"); |
|
| 154 | + if ($object->hasDelay()) { |
|
| 155 | + print img_warning("Late"); |
|
| 156 | + } |
|
| 150 | 157 | print '</td></tr>'; |
| 151 | 158 | |
| 152 | 159 | // Budget |
| 153 | 160 | print '<tr><td>'.$langs->trans("Budget").'</td><td>'; |
| 154 | - if (strcmp($object->budget_amount, '')) print price($object->budget_amount,'',$langs,1,0,0,$conf->currency); |
|
| 161 | + if (strcmp($object->budget_amount, '')) { |
|
| 162 | + print price($object->budget_amount,'',$langs,1,0,0,$conf->currency); |
|
| 163 | + } |
|
| 155 | 164 | print '</td></tr>'; |
| 156 | 165 | |
| 157 | 166 | // Other attributes |
@@ -198,13 +207,11 @@ discard block |
||
| 198 | 207 | if ($object->public || $userWrite > 0) |
| 199 | 208 | { |
| 200 | 209 | $linktocreatetask = '<a class="butActionNew" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=create'.$param.'&backtopage='.urlencode($_SERVER['PHP_SELF'].'?id='.$object->id).'">'.$langs->trans('AddTask').'<span class="fa fa-plus-circle valignmiddle"></span></a>'; |
| 201 | - } |
|
| 202 | - else |
|
| 210 | + } else |
|
| 203 | 211 | { |
| 204 | 212 | $linktocreatetask = '<a class="butActionNewRefused" href="#" title="'.$langs->trans("NotOwnerOfProject").'">'.$langs->trans('AddTask').'<span class="fa fa-plus-circle valignmiddle"></span></a>'; |
| 205 | 213 | } |
| 206 | -} |
|
| 207 | -else |
|
| 214 | +} else |
|
| 208 | 215 | { |
| 209 | 216 | $linktocreatetask = '<a class="butActionNewRefused" href="#" title="'.$langs->trans("NotEnoughPermissions").'">'.$langs->trans('AddTask').'<span class="fa fa-plus-circle valignmiddle"></span></a>'; |
| 210 | 217 | } |
@@ -236,9 +243,11 @@ discard block |
||
| 236 | 243 | $tasks=array(); |
| 237 | 244 | $task_dependencies=array(); |
| 238 | 245 | $taskcursor=0; |
| 239 | - foreach($tasksarray as $key => $val) // Task array are sorted by "project, position, dateo" |
|
| 246 | + foreach($tasksarray as $key => $val) { |
|
| 247 | + // Task array are sorted by "project, position, dateo" |
|
| 240 | 248 | { |
| 241 | 249 | $task->fetch($val->id, ''); |
| 250 | + } |
|
| 242 | 251 | |
| 243 | 252 | $idparent = ($val->fk_parent ? $val->fk_parent : '-'.$val->fk_project); // If start with -, id is a project id |
| 244 | 253 | |
@@ -256,8 +265,7 @@ discard block |
||
| 256 | 265 | $tasks[$taskcursor]['task_is_group']=1; |
| 257 | 266 | $tasks[$taskcursor]['task_css']='ggroupblack'; |
| 258 | 267 | //$tasks[$taskcursor]['task_css'] = 'gtaskblue'; |
| 259 | - } |
|
| 260 | - elseif ($task->hasChildren()> 0) { |
|
| 268 | + } elseif ($task->hasChildren()> 0) { |
|
| 261 | 269 | $tasks[$taskcursor]['task_is_group'] = 1; |
| 262 | 270 | //$tasks[$taskcursor]['task_is_group'] = 0; |
| 263 | 271 | $tasks[$taskcursor]['task_css'] = 'ggroupblack'; |
@@ -282,7 +290,9 @@ discard block |
||
| 282 | 290 | foreach($idofusers as $valid) |
| 283 | 291 | { |
| 284 | 292 | $userstatic->fetch($valid); |
| 285 | - if ($i) $s.=', '; |
|
| 293 | + if ($i) { |
|
| 294 | + $s.=', '; |
|
| 295 | + } |
|
| 286 | 296 | $s.=$userstatic->login; |
| 287 | 297 | $i++; |
| 288 | 298 | } |
@@ -290,7 +300,9 @@ discard block |
||
| 290 | 300 | //if (count($idofusers)>0 && (count($idofcontacts)>0)) $s.=' - '; |
| 291 | 301 | if (count($idofcontacts)>0) |
| 292 | 302 | { |
| 293 | - if ($s) $s.=' - '; |
|
| 303 | + if ($s) { |
|
| 304 | + $s.=' - '; |
|
| 305 | + } |
|
| 294 | 306 | $s.=$langs->trans("Externals").': '; |
| 295 | 307 | $i=0; |
| 296 | 308 | $contactidfound=array(); |
@@ -301,7 +313,9 @@ discard block |
||
| 301 | 313 | $res = $contactstatic->fetch($valid); |
| 302 | 314 | if ($res > 0) |
| 303 | 315 | { |
| 304 | - if ($i) $s.=', '; |
|
| 316 | + if ($i) { |
|
| 317 | + $s.=', '; |
|
| 318 | + } |
|
| 305 | 319 | $s.=$contactstatic->getFullName($langs); |
| 306 | 320 | $contactidfound[$valid]=1; |
| 307 | 321 | $i++; |
@@ -329,7 +343,9 @@ discard block |
||
| 329 | 343 | break; |
| 330 | 344 | } |
| 331 | 345 | } |
| 332 | - if (empty($tasks[$tmpkey]['task_parent_alternate_id'])) $tasks[$tmpkey]['task_parent_alternate_id'] = $tasks[$tmpkey]['task_parent']; |
|
| 346 | + if (empty($tasks[$tmpkey]['task_parent_alternate_id'])) { |
|
| 347 | + $tasks[$tmpkey]['task_parent_alternate_id'] = $tasks[$tmpkey]['task_parent']; |
|
| 348 | + } |
|
| 333 | 349 | } |
| 334 | 350 | |
| 335 | 351 | print "\n"; |
@@ -352,14 +368,12 @@ discard block |
||
| 352 | 368 | print '</div>'."\n"; |
| 353 | 369 | |
| 354 | 370 | print '</div>'; |
| 355 | - } |
|
| 356 | - else |
|
| 371 | + } else |
|
| 357 | 372 | { |
| 358 | 373 | $langs->load("admin"); |
| 359 | 374 | print $langs->trans("AvailableOnlyIfJavascriptAndAjaxNotDisabled"); |
| 360 | 375 | } |
| 361 | -} |
|
| 362 | -else |
|
| 376 | +} else |
|
| 363 | 377 | { |
| 364 | 378 | print '<div class="opacitymedium">'.$langs->trans("NoTasks").'</div>'; |
| 365 | 379 | } |
@@ -104,19 +104,19 @@ discard block |
||
| 104 | 104 | $search_month=''; |
| 105 | 105 | $search_year=''; |
| 106 | 106 | $search_date=''; |
| 107 | - $search_datehour=''; |
|
| 108 | - $search_datewithhour=''; |
|
| 109 | - $search_note=''; |
|
| 110 | - $search_duration=''; |
|
| 111 | - $search_value=''; |
|
| 112 | - $search_date_creation=''; |
|
| 113 | - $search_date_update=''; |
|
| 114 | - $search_task_ref=''; |
|
| 115 | - $search_task_label=''; |
|
| 116 | - $search_user=0; |
|
| 117 | - $toselect=''; |
|
| 118 | - $search_array_options=array(); |
|
| 119 | - $action=''; |
|
| 107 | + $search_datehour=''; |
|
| 108 | + $search_datewithhour=''; |
|
| 109 | + $search_note=''; |
|
| 110 | + $search_duration=''; |
|
| 111 | + $search_value=''; |
|
| 112 | + $search_date_creation=''; |
|
| 113 | + $search_date_update=''; |
|
| 114 | + $search_task_ref=''; |
|
| 115 | + $search_task_label=''; |
|
| 116 | + $search_user=0; |
|
| 117 | + $toselect=''; |
|
| 118 | + $search_array_options=array(); |
|
| 119 | + $action=''; |
|
| 120 | 120 | } |
| 121 | 121 | |
| 122 | 122 | if ($action == 'addtimespent' && $user->rights->projet->lire) |
@@ -160,12 +160,12 @@ discard block |
||
| 160 | 160 | $object->progress = GETPOST('progress', 'int'); |
| 161 | 161 | $object->timespent_duration = $_POST["timespent_durationhour"]*60*60; // We store duration in seconds |
| 162 | 162 | $object->timespent_duration+= $_POST["timespent_durationmin"]*60; // We store duration in seconds |
| 163 | - if (GETPOST("timehour") != '' && GETPOST("timehour") >= 0) // If hour was entered |
|
| 164 | - { |
|
| 163 | + if (GETPOST("timehour") != '' && GETPOST("timehour") >= 0) // If hour was entered |
|
| 164 | + { |
|
| 165 | 165 | $object->timespent_date = dol_mktime(GETPOST("timehour"),GETPOST("timemin"),0,GETPOST("timemonth"),GETPOST("timeday"),GETPOST("timeyear")); |
| 166 | 166 | $object->timespent_withhour = 1; |
| 167 | - } |
|
| 168 | - else |
|
| 167 | + } |
|
| 168 | + else |
|
| 169 | 169 | { |
| 170 | 170 | $object->timespent_date = dol_mktime(12,0,0,GETPOST("timemonth"),GETPOST("timeday"),GETPOST("timeyear")); |
| 171 | 171 | } |
@@ -209,12 +209,12 @@ discard block |
||
| 209 | 209 | $object->timespent_old_duration = $_POST["old_duration"]; |
| 210 | 210 | $object->timespent_duration = $_POST["new_durationhour"]*60*60; // We store duration in seconds |
| 211 | 211 | $object->timespent_duration+= $_POST["new_durationmin"]*60; // We store duration in seconds |
| 212 | - if (GETPOST("timelinehour") != '' && GETPOST("timelinehour") >= 0) // If hour was entered |
|
| 213 | - { |
|
| 212 | + if (GETPOST("timelinehour") != '' && GETPOST("timelinehour") >= 0) // If hour was entered |
|
| 213 | + { |
|
| 214 | 214 | $object->timespent_date = dol_mktime(GETPOST("timelinehour"),GETPOST("timelinemin"),0,GETPOST("timelinemonth"),GETPOST("timelineday"),GETPOST("timelineyear")); |
| 215 | 215 | $object->timespent_withhour = 1; |
| 216 | - } |
|
| 217 | - else |
|
| 216 | + } |
|
| 217 | + else |
|
| 218 | 218 | { |
| 219 | 219 | $object->timespent_date = dol_mktime(12,0,0,GETPOST("timelinemonth"),GETPOST("timelineday"),GETPOST("timelineyear")); |
| 220 | 220 | } |
@@ -298,22 +298,22 @@ discard block |
||
| 298 | 298 | /* |
| 299 | 299 | * Fiche projet en mode visu |
| 300 | 300 | */ |
| 301 | - if ($projectidforalltimes) |
|
| 302 | - { |
|
| 303 | - $result=$projectstatic->fetch($projectidforalltimes); |
|
| 304 | - if (! empty($projectstatic->socid)) $projectstatic->fetch_thirdparty(); |
|
| 305 | - $res=$projectstatic->fetch_optionals(); |
|
| 306 | - } |
|
| 307 | - elseif ($object->fetch($id, $ref) >= 0) |
|
| 301 | + if ($projectidforalltimes) |
|
| 302 | + { |
|
| 303 | + $result=$projectstatic->fetch($projectidforalltimes); |
|
| 304 | + if (! empty($projectstatic->socid)) $projectstatic->fetch_thirdparty(); |
|
| 305 | + $res=$projectstatic->fetch_optionals(); |
|
| 306 | + } |
|
| 307 | + elseif ($object->fetch($id, $ref) >= 0) |
|
| 308 | 308 | { |
| 309 | 309 | $result=$projectstatic->fetch($object->fk_project); |
| 310 | 310 | if (! empty($projectstatic->socid)) $projectstatic->fetch_thirdparty(); |
| 311 | 311 | $res=$projectstatic->fetch_optionals(); |
| 312 | 312 | |
| 313 | 313 | $object->project = clone $projectstatic; |
| 314 | - } |
|
| 314 | + } |
|
| 315 | 315 | |
| 316 | - $userWrite = $projectstatic->restrictedProjectArea($user,'write'); |
|
| 316 | + $userWrite = $projectstatic->restrictedProjectArea($user,'write'); |
|
| 317 | 317 | |
| 318 | 318 | if ($projectstatic->id > 0) |
| 319 | 319 | { |
@@ -329,86 +329,86 @@ discard block |
||
| 329 | 329 | |
| 330 | 330 | // Project card |
| 331 | 331 | |
| 332 | - $linkback = '<a href="'.DOL_URL_ROOT.'/projet/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>'; |
|
| 333 | - |
|
| 334 | - $morehtmlref='<div class="refidno">'; |
|
| 335 | - // Title |
|
| 336 | - $morehtmlref.=$projectstatic->title; |
|
| 337 | - // Thirdparty |
|
| 338 | - if ($projectstatic->thirdparty->id > 0) |
|
| 339 | - { |
|
| 340 | - $morehtmlref.='<br>'.$langs->trans('ThirdParty') . ' : ' . $projectstatic->thirdparty->getNomUrl(1, 'project'); |
|
| 341 | - } |
|
| 342 | - $morehtmlref.='</div>'; |
|
| 343 | - |
|
| 344 | - // Define a complementary filter for search of next/prev ref. |
|
| 345 | - if (! $user->rights->projet->all->lire) |
|
| 346 | - { |
|
| 347 | - $objectsListId = $projectstatic->getProjectsAuthorizedForUser($user,0,0); |
|
| 348 | - $projectstatic->next_prev_filter=" rowid in (".(count($objectsListId)?join(',',array_keys($objectsListId)):'0').")"; |
|
| 349 | - } |
|
| 350 | - |
|
| 351 | - dol_banner_tab($projectstatic, 'project_ref', $linkback, 1, 'ref', 'ref', $morehtmlref); |
|
| 352 | - |
|
| 353 | - print '<div class="fichecenter">'; |
|
| 354 | - print '<div class="fichehalfleft">'; |
|
| 355 | - print '<div class="underbanner clearboth"></div>'; |
|
| 356 | - |
|
| 357 | - print '<table class="border" width="100%">'; |
|
| 358 | - |
|
| 359 | - // Visibility |
|
| 360 | - print '<tr><td class="titlefield">'.$langs->trans("Visibility").'</td><td>'; |
|
| 361 | - if ($projectstatic->public) print $langs->trans('SharedProject'); |
|
| 362 | - else print $langs->trans('PrivateProject'); |
|
| 363 | - print '</td></tr>'; |
|
| 364 | - |
|
| 365 | - // Date start - end |
|
| 366 | - print '<tr><td>'.$langs->trans("DateStart").' - '.$langs->trans("DateEnd").'</td><td>'; |
|
| 367 | - $start = dol_print_date($projectstatic->date_start,'day'); |
|
| 368 | - print ($start?$start:'?'); |
|
| 369 | - $end = dol_print_date($projectstatic->date_end,'day'); |
|
| 370 | - print ' - '; |
|
| 371 | - print ($end?$end:'?'); |
|
| 372 | - if ($projectstatic->hasDelay()) print img_warning("Late"); |
|
| 373 | - print '</td></tr>'; |
|
| 374 | - |
|
| 375 | - // Budget |
|
| 376 | - print '<tr><td>'.$langs->trans("Budget").'</td><td>'; |
|
| 377 | - if (strcmp($projectstatic->budget_amount, '')) print price($projectstatic->budget_amount,'',$langs,1,0,0,$conf->currency); |
|
| 378 | - print '</td></tr>'; |
|
| 379 | - |
|
| 380 | - // Other attributes |
|
| 381 | - $cols = 2; |
|
| 382 | - //include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; |
|
| 383 | - |
|
| 384 | - print '</table>'; |
|
| 385 | - |
|
| 386 | - print '</div>'; |
|
| 387 | - print '<div class="fichehalfright">'; |
|
| 388 | - print '<div class="ficheaddleft">'; |
|
| 389 | - print '<div class="underbanner clearboth"></div>'; |
|
| 390 | - |
|
| 391 | - print '<table class="border" width="100%">'; |
|
| 392 | - |
|
| 393 | - // Description |
|
| 394 | - print '<td class="titlefield tdtop">'.$langs->trans("Description").'</td><td>'; |
|
| 395 | - print nl2br($projectstatic->description); |
|
| 396 | - print '</td></tr>'; |
|
| 397 | - |
|
| 398 | - // Categories |
|
| 399 | - if($conf->categorie->enabled) { |
|
| 400 | - print '<tr><td valign="middle">'.$langs->trans("Categories").'</td><td>'; |
|
| 401 | - print $form->showCategories($projectstatic->id,'project',1); |
|
| 402 | - print "</td></tr>"; |
|
| 403 | - } |
|
| 404 | - |
|
| 405 | - print '</table>'; |
|
| 406 | - |
|
| 407 | - print '</div>'; |
|
| 408 | - print '</div>'; |
|
| 409 | - print '</div>'; |
|
| 410 | - |
|
| 411 | - print '<div class="clearboth"></div>'; |
|
| 332 | + $linkback = '<a href="'.DOL_URL_ROOT.'/projet/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>'; |
|
| 333 | + |
|
| 334 | + $morehtmlref='<div class="refidno">'; |
|
| 335 | + // Title |
|
| 336 | + $morehtmlref.=$projectstatic->title; |
|
| 337 | + // Thirdparty |
|
| 338 | + if ($projectstatic->thirdparty->id > 0) |
|
| 339 | + { |
|
| 340 | + $morehtmlref.='<br>'.$langs->trans('ThirdParty') . ' : ' . $projectstatic->thirdparty->getNomUrl(1, 'project'); |
|
| 341 | + } |
|
| 342 | + $morehtmlref.='</div>'; |
|
| 343 | + |
|
| 344 | + // Define a complementary filter for search of next/prev ref. |
|
| 345 | + if (! $user->rights->projet->all->lire) |
|
| 346 | + { |
|
| 347 | + $objectsListId = $projectstatic->getProjectsAuthorizedForUser($user,0,0); |
|
| 348 | + $projectstatic->next_prev_filter=" rowid in (".(count($objectsListId)?join(',',array_keys($objectsListId)):'0').")"; |
|
| 349 | + } |
|
| 350 | + |
|
| 351 | + dol_banner_tab($projectstatic, 'project_ref', $linkback, 1, 'ref', 'ref', $morehtmlref); |
|
| 352 | + |
|
| 353 | + print '<div class="fichecenter">'; |
|
| 354 | + print '<div class="fichehalfleft">'; |
|
| 355 | + print '<div class="underbanner clearboth"></div>'; |
|
| 356 | + |
|
| 357 | + print '<table class="border" width="100%">'; |
|
| 358 | + |
|
| 359 | + // Visibility |
|
| 360 | + print '<tr><td class="titlefield">'.$langs->trans("Visibility").'</td><td>'; |
|
| 361 | + if ($projectstatic->public) print $langs->trans('SharedProject'); |
|
| 362 | + else print $langs->trans('PrivateProject'); |
|
| 363 | + print '</td></tr>'; |
|
| 364 | + |
|
| 365 | + // Date start - end |
|
| 366 | + print '<tr><td>'.$langs->trans("DateStart").' - '.$langs->trans("DateEnd").'</td><td>'; |
|
| 367 | + $start = dol_print_date($projectstatic->date_start,'day'); |
|
| 368 | + print ($start?$start:'?'); |
|
| 369 | + $end = dol_print_date($projectstatic->date_end,'day'); |
|
| 370 | + print ' - '; |
|
| 371 | + print ($end?$end:'?'); |
|
| 372 | + if ($projectstatic->hasDelay()) print img_warning("Late"); |
|
| 373 | + print '</td></tr>'; |
|
| 374 | + |
|
| 375 | + // Budget |
|
| 376 | + print '<tr><td>'.$langs->trans("Budget").'</td><td>'; |
|
| 377 | + if (strcmp($projectstatic->budget_amount, '')) print price($projectstatic->budget_amount,'',$langs,1,0,0,$conf->currency); |
|
| 378 | + print '</td></tr>'; |
|
| 379 | + |
|
| 380 | + // Other attributes |
|
| 381 | + $cols = 2; |
|
| 382 | + //include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; |
|
| 383 | + |
|
| 384 | + print '</table>'; |
|
| 385 | + |
|
| 386 | + print '</div>'; |
|
| 387 | + print '<div class="fichehalfright">'; |
|
| 388 | + print '<div class="ficheaddleft">'; |
|
| 389 | + print '<div class="underbanner clearboth"></div>'; |
|
| 390 | + |
|
| 391 | + print '<table class="border" width="100%">'; |
|
| 392 | + |
|
| 393 | + // Description |
|
| 394 | + print '<td class="titlefield tdtop">'.$langs->trans("Description").'</td><td>'; |
|
| 395 | + print nl2br($projectstatic->description); |
|
| 396 | + print '</td></tr>'; |
|
| 397 | + |
|
| 398 | + // Categories |
|
| 399 | + if($conf->categorie->enabled) { |
|
| 400 | + print '<tr><td valign="middle">'.$langs->trans("Categories").'</td><td>'; |
|
| 401 | + print $form->showCategories($projectstatic->id,'project',1); |
|
| 402 | + print "</td></tr>"; |
|
| 403 | + } |
|
| 404 | + |
|
| 405 | + print '</table>'; |
|
| 406 | + |
|
| 407 | + print '</div>'; |
|
| 408 | + print '</div>'; |
|
| 409 | + print '</div>'; |
|
| 410 | + |
|
| 411 | + print '<div class="clearboth"></div>'; |
|
| 412 | 412 | |
| 413 | 413 | dol_fiche_end(); |
| 414 | 414 | |
@@ -417,21 +417,21 @@ discard block |
||
| 417 | 417 | // Link to create time |
| 418 | 418 | //if ((empty($id) && empty($ref)) || ! empty($projectidforalltimes)) |
| 419 | 419 | //{ |
| 420 | - if ($user->rights->projet->all->creer || $user->rights->projet->creer) |
|
| 421 | - { |
|
| 422 | - if ($projectstatic->public || $userWrite > 0) |
|
| 423 | - { |
|
| 424 | - $linktocreatetime = '<a class="butActionNew" href="'.$_SERVER['PHP_SELF'].'?withproject=1'.($object->id > 0 ? '&id='.$object->id : '&projectid='.$projectstatic->id).'&action=createtime'.$param.'&backtopage='.urlencode($_SERVER['PHP_SELF'].'?id='.$object->id).'">'.$langs->trans('AddTimeSpent').'<span class="fa fa-plus-circle valignmiddle"></span></a>'; |
|
| 425 | - } |
|
| 426 | - else |
|
| 427 | - { |
|
| 428 | - $linktocreatetime = '<a class="butActionNewRefused" href="#" title="'.$langs->trans("NotOwnerOfProject").'">'.$langs->trans('AddTime').'<span class="fa fa-plus-circle valignmiddle"></span></a>'; |
|
| 429 | - } |
|
| 430 | - } |
|
| 431 | - else |
|
| 432 | - { |
|
| 433 | - $linktocreatetime = '<a class="butActionNewRefused" href="#" title="'.$langs->trans("NotEnoughPermissions").'">'.$langs->trans('AddTime').'<span class="fa fa-plus-circle valignmiddle"></span></a>'; |
|
| 434 | - } |
|
| 420 | + if ($user->rights->projet->all->creer || $user->rights->projet->creer) |
|
| 421 | + { |
|
| 422 | + if ($projectstatic->public || $userWrite > 0) |
|
| 423 | + { |
|
| 424 | + $linktocreatetime = '<a class="butActionNew" href="'.$_SERVER['PHP_SELF'].'?withproject=1'.($object->id > 0 ? '&id='.$object->id : '&projectid='.$projectstatic->id).'&action=createtime'.$param.'&backtopage='.urlencode($_SERVER['PHP_SELF'].'?id='.$object->id).'">'.$langs->trans('AddTimeSpent').'<span class="fa fa-plus-circle valignmiddle"></span></a>'; |
|
| 425 | + } |
|
| 426 | + else |
|
| 427 | + { |
|
| 428 | + $linktocreatetime = '<a class="butActionNewRefused" href="#" title="'.$langs->trans("NotOwnerOfProject").'">'.$langs->trans('AddTime').'<span class="fa fa-plus-circle valignmiddle"></span></a>'; |
|
| 429 | + } |
|
| 430 | + } |
|
| 431 | + else |
|
| 432 | + { |
|
| 433 | + $linktocreatetime = '<a class="butActionNewRefused" href="#" title="'.$langs->trans("NotEnoughPermissions").'">'.$langs->trans('AddTime').'<span class="fa fa-plus-circle valignmiddle"></span></a>'; |
|
| 434 | + } |
|
| 435 | 435 | //} |
| 436 | 436 | } |
| 437 | 437 | } |
@@ -461,17 +461,17 @@ discard block |
||
| 461 | 461 | // Project |
| 462 | 462 | if (empty($withproject)) |
| 463 | 463 | { |
| 464 | - $morehtmlref.='<div class="refidno">'; |
|
| 465 | - $morehtmlref.=$langs->trans("Project").': '; |
|
| 466 | - $morehtmlref.=$projectstatic->getNomUrl(1); |
|
| 467 | - $morehtmlref.='<br>'; |
|
| 468 | - |
|
| 469 | - // Third party |
|
| 470 | - $morehtmlref.=$langs->trans("ThirdParty").': '; |
|
| 471 | - if (is_object($projectstatic->thirdparty)) { |
|
| 472 | - $morehtmlref.=$projectstatic->thirdparty->getNomUrl(1); |
|
| 473 | - } |
|
| 474 | - $morehtmlref.='</div>'; |
|
| 464 | + $morehtmlref.='<div class="refidno">'; |
|
| 465 | + $morehtmlref.=$langs->trans("Project").': '; |
|
| 466 | + $morehtmlref.=$projectstatic->getNomUrl(1); |
|
| 467 | + $morehtmlref.='<br>'; |
|
| 468 | + |
|
| 469 | + // Third party |
|
| 470 | + $morehtmlref.=$langs->trans("ThirdParty").': '; |
|
| 471 | + if (is_object($projectstatic->thirdparty)) { |
|
| 472 | + $morehtmlref.=$projectstatic->thirdparty->getNomUrl(1); |
|
| 473 | + } |
|
| 474 | + $morehtmlref.='</div>'; |
|
| 475 | 475 | } |
| 476 | 476 | |
| 477 | 477 | dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref, $param); |
@@ -479,7 +479,7 @@ discard block |
||
| 479 | 479 | print '<div class="fichecenter">'; |
| 480 | 480 | print '<div class="fichehalfleft">'; |
| 481 | 481 | |
| 482 | - print '<div class="underbanner clearboth"></div>'; |
|
| 482 | + print '<div class="underbanner clearboth"></div>'; |
|
| 483 | 483 | print '<table class="border" width="100%">'; |
| 484 | 484 | |
| 485 | 485 | // Date start - Date end |
@@ -623,31 +623,31 @@ discard block |
||
| 623 | 623 | print $form->formconfirm($_SERVER["PHP_SELF"]."?".($object->id>0?"id=".$object->id:'projectid='.$projectstatic->id).'&lineid='.GETPOST('lineid','int').($withproject?'&withproject=1':''),$langs->trans("DeleteATimeSpent"),$langs->trans("ConfirmDeleteATimeSpent"),"confirm_delete",'','',1); |
| 624 | 624 | } |
| 625 | 625 | |
| 626 | - // Initialize technical object to manage hooks. Note that conf->hooks_modules contains array |
|
| 627 | - $hookmanager->initHooks(array('tasktimelist')); |
|
| 628 | - $extrafields = new ExtraFields($db); |
|
| 626 | + // Initialize technical object to manage hooks. Note that conf->hooks_modules contains array |
|
| 627 | + $hookmanager->initHooks(array('tasktimelist')); |
|
| 628 | + $extrafields = new ExtraFields($db); |
|
| 629 | 629 | |
| 630 | - // Definition of fields for list |
|
| 631 | - $arrayfields=array(); |
|
| 632 | - $arrayfields['t.task_date']=array('label'=>$langs->trans("Date"), 'checked'=>1); |
|
| 630 | + // Definition of fields for list |
|
| 631 | + $arrayfields=array(); |
|
| 632 | + $arrayfields['t.task_date']=array('label'=>$langs->trans("Date"), 'checked'=>1); |
|
| 633 | 633 | if ((empty($id) && empty($ref)) || ! empty($projectidforalltimes)) // Not a dedicated task |
| 634 | - { |
|
| 635 | - $arrayfields['t.task_ref']=array('label'=>$langs->trans("RefTask"), 'checked'=>1); |
|
| 636 | - $arrayfields['t.task_label']=array('label'=>$langs->trans("LabelTask"), 'checked'=>1); |
|
| 637 | - } |
|
| 638 | - $arrayfields['author']=array('label'=>$langs->trans("By"), 'checked'=>1); |
|
| 639 | - $arrayfields['t.note']=array('label'=>$langs->trans("Note"), 'checked'=>1); |
|
| 640 | - $arrayfields['t.task_duration']=array('label'=>$langs->trans("Duration"), 'checked'=>1); |
|
| 641 | - $arrayfields['value'] =array('label'=>$langs->trans("Value"), 'checked'=>1, 'enabled'=>(empty($conf->salaries->enabled)?0:1)); |
|
| 642 | - $arrayfields['valuebilled'] =array('label'=>$langs->trans("AmountInvoiced"), 'checked'=>1, 'enabled'=>(empty($conf->global->PROJECT_BILL_TIME_SPENT)?0:1)); |
|
| 643 | - // Extra fields |
|
| 644 | - if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) |
|
| 645 | - { |
|
| 646 | - foreach($extrafields->attribute_label as $key => $val) |
|
| 647 | - { |
|
| 634 | + { |
|
| 635 | + $arrayfields['t.task_ref']=array('label'=>$langs->trans("RefTask"), 'checked'=>1); |
|
| 636 | + $arrayfields['t.task_label']=array('label'=>$langs->trans("LabelTask"), 'checked'=>1); |
|
| 637 | + } |
|
| 638 | + $arrayfields['author']=array('label'=>$langs->trans("By"), 'checked'=>1); |
|
| 639 | + $arrayfields['t.note']=array('label'=>$langs->trans("Note"), 'checked'=>1); |
|
| 640 | + $arrayfields['t.task_duration']=array('label'=>$langs->trans("Duration"), 'checked'=>1); |
|
| 641 | + $arrayfields['value'] =array('label'=>$langs->trans("Value"), 'checked'=>1, 'enabled'=>(empty($conf->salaries->enabled)?0:1)); |
|
| 642 | + $arrayfields['valuebilled'] =array('label'=>$langs->trans("AmountInvoiced"), 'checked'=>1, 'enabled'=>(empty($conf->global->PROJECT_BILL_TIME_SPENT)?0:1)); |
|
| 643 | + // Extra fields |
|
| 644 | + if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) |
|
| 645 | + { |
|
| 646 | + foreach($extrafields->attribute_label as $key => $val) |
|
| 647 | + { |
|
| 648 | 648 | if (! empty($extrafields->attribute_list[$key])) $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>(($extrafields->attribute_list[$key]<0)?0:1), 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>(abs($extrafields->attribute_list[$key])!=3 && $extrafields->attribute_perms[$key])); |
| 649 | - } |
|
| 650 | - } |
|
| 649 | + } |
|
| 650 | + } |
|
| 651 | 651 | |
| 652 | 652 | /* |
| 653 | 653 | * List of time spent |
@@ -696,9 +696,9 @@ discard block |
||
| 696 | 696 | print '<!-- List of time spent for project -->'."\n"; |
| 697 | 697 | |
| 698 | 698 | $title=$langs->trans("ListTaskTimeUserProject"); |
| 699 | - //$linktotasks='<a href="'.DOL_URL_ROOT.'/projet/tasks.php?id='.$projectstatic->id.'">'.$langs->trans("GoToListOfTasks").'</a>'; |
|
| 700 | - //print_barre_liste($title, 0, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, $linktotasks, $num, $totalnboflines, 'title_generic.png', 0, '', '', 0, 1); |
|
| 701 | - print load_fiche_titre($title, $linktocreatetime, 'title_generic.png'); |
|
| 699 | + //$linktotasks='<a href="'.DOL_URL_ROOT.'/projet/tasks.php?id='.$projectstatic->id.'">'.$langs->trans("GoToListOfTasks").'</a>'; |
|
| 700 | + //print_barre_liste($title, 0, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, $linktotasks, $num, $totalnboflines, 'title_generic.png', 0, '', '', 0, 1); |
|
| 701 | + print load_fiche_titre($title, $linktocreatetime, 'title_generic.png'); |
|
| 702 | 702 | } |
| 703 | 703 | |
| 704 | 704 | $i = 0; |
@@ -821,8 +821,8 @@ discard block |
||
| 821 | 821 | |
| 822 | 822 | |
| 823 | 823 | $arrayofmassactions = array( |
| 824 | - //'presend'=>$langs->trans("SendByMail"), |
|
| 825 | - //'builddoc'=>$langs->trans("PDFMerge"), |
|
| 824 | + //'presend'=>$langs->trans("SendByMail"), |
|
| 825 | + //'builddoc'=>$langs->trans("PDFMerge"), |
|
| 826 | 826 | ); |
| 827 | 827 | //if ($user->rights->projet->creer) $arrayofmassactions['predelete']=$langs->trans("Delete"); |
| 828 | 828 | if (in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array(); |
@@ -830,14 +830,14 @@ discard block |
||
| 830 | 830 | |
| 831 | 831 | |
| 832 | 832 | print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'?id='.$id.'">'; |
| 833 | - if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">'; |
|
| 833 | + if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">'; |
|
| 834 | 834 | print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
| 835 | - print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">'; |
|
| 835 | + print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">'; |
|
| 836 | 836 | if ($action == 'editline') print '<input type="hidden" name="action" value="updateline">'; |
| 837 | 837 | else print '<input type="hidden" name="action" value="list">'; |
| 838 | - print '<input type="hidden" name="sortfield" value="'.$sortfield.'">'; |
|
| 839 | - print '<input type="hidden" name="sortorder" value="'.$sortorder.'">'; |
|
| 840 | - print '<input type="hidden" name="page" value="'.$page.'">'; |
|
| 838 | + print '<input type="hidden" name="sortfield" value="'.$sortfield.'">'; |
|
| 839 | + print '<input type="hidden" name="sortorder" value="'.$sortorder.'">'; |
|
| 840 | + print '<input type="hidden" name="page" value="'.$page.'">'; |
|
| 841 | 841 | |
| 842 | 842 | print '<input type="hidden" name="id" value="'.$id.'">'; |
| 843 | 843 | print '<input type="hidden" name="projectid" value="'.$projectidforalltimes.'">'; |
@@ -852,15 +852,15 @@ discard block |
||
| 852 | 852 | |
| 853 | 853 | if (! empty($moreforfilter)) |
| 854 | 854 | { |
| 855 | - print '<div class="liste_titre liste_titre_bydiv centpercent">'; |
|
| 856 | - print $moreforfilter; |
|
| 857 | - print '</div>'; |
|
| 855 | + print '<div class="liste_titre liste_titre_bydiv centpercent">'; |
|
| 856 | + print $moreforfilter; |
|
| 857 | + print '</div>'; |
|
| 858 | 858 | } |
| 859 | 859 | |
| 860 | 860 | $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; |
| 861 | 861 | $selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields |
| 862 | 862 | |
| 863 | - print '<div class="div-table-responsive">'; |
|
| 863 | + print '<div class="div-table-responsive">'; |
|
| 864 | 864 | print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n"; |
| 865 | 865 | |
| 866 | 866 | // Fields title search |
@@ -875,21 +875,21 @@ discard block |
||
| 875 | 875 | print '</td>'; |
| 876 | 876 | } |
| 877 | 877 | if ((empty($id) && empty($ref)) || ! empty($projectidforalltimes)) // Not a dedicated task |
| 878 | - { |
|
| 879 | - if (! empty($arrayfields['t.task_ref']['checked'])) print '<td class="liste_titre"><input type="text" class="flat maxwidth100" name="search_task_ref" value="'.dol_escape_htmltag($search_task_ref).'"></td>'; |
|
| 880 | - if (! empty($arrayfields['t.task_label']['checked'])) print '<td class="liste_titre"><input type="text" class="flat maxwidth100" name="search_task_label" value="'.dol_escape_htmltag($search_task_label).'"></td>'; |
|
| 881 | - } |
|
| 882 | - // Author |
|
| 883 | - if (! empty($arrayfields['author']['checked'])) print '<td class="liste_titre">'.$form->select_dolusers(($search_user > 0 ? $search_user : -1), 'search_user', 1, null, 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth200').'</td>'; |
|
| 878 | + { |
|
| 879 | + if (! empty($arrayfields['t.task_ref']['checked'])) print '<td class="liste_titre"><input type="text" class="flat maxwidth100" name="search_task_ref" value="'.dol_escape_htmltag($search_task_ref).'"></td>'; |
|
| 880 | + if (! empty($arrayfields['t.task_label']['checked'])) print '<td class="liste_titre"><input type="text" class="flat maxwidth100" name="search_task_label" value="'.dol_escape_htmltag($search_task_label).'"></td>'; |
|
| 881 | + } |
|
| 882 | + // Author |
|
| 883 | + if (! empty($arrayfields['author']['checked'])) print '<td class="liste_titre">'.$form->select_dolusers(($search_user > 0 ? $search_user : -1), 'search_user', 1, null, 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth200').'</td>'; |
|
| 884 | 884 | // Note |
| 885 | - if (! empty($arrayfields['t.note']['checked'])) print '<td class="liste_titre"><input type="text" class="flat maxwidth100" name="search_note" value="'.dol_escape_htmltag($search_note).'"></td>'; |
|
| 885 | + if (! empty($arrayfields['t.note']['checked'])) print '<td class="liste_titre"><input type="text" class="flat maxwidth100" name="search_note" value="'.dol_escape_htmltag($search_note).'"></td>'; |
|
| 886 | 886 | // Duration |
| 887 | - if (! empty($arrayfields['t.task_duration']['checked'])) print '<td class="liste_titre right"></td>'; |
|
| 887 | + if (! empty($arrayfields['t.task_duration']['checked'])) print '<td class="liste_titre right"></td>'; |
|
| 888 | 888 | // Value in main currency |
| 889 | - if (! empty($arrayfields['value']['checked'])) print '<td class="liste_titre"></td>'; |
|
| 890 | - // Value billed |
|
| 891 | - if (! empty($arrayfields['valuebilled']['checked'])) print '<td class="liste_titre"></td>'; |
|
| 892 | - /* |
|
| 889 | + if (! empty($arrayfields['value']['checked'])) print '<td class="liste_titre"></td>'; |
|
| 890 | + // Value billed |
|
| 891 | + if (! empty($arrayfields['valuebilled']['checked'])) print '<td class="liste_titre"></td>'; |
|
| 892 | + /* |
|
| 893 | 893 | // Extra fields |
| 894 | 894 | include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; |
| 895 | 895 | */ |
@@ -907,11 +907,11 @@ discard block |
||
| 907 | 907 | print '<tr class="liste_titre">'; |
| 908 | 908 | if (! empty($arrayfields['t.task_date']['checked'])) print_liste_field_titre($arrayfields['t.task_date']['label'],$_SERVER['PHP_SELF'],'t.task_date,t.task_datehour,t.rowid','',$param,'',$sortfield,$sortorder); |
| 909 | 909 | if ((empty($id) && empty($ref)) || ! empty($projectidforalltimes)) // Not a dedicated task |
| 910 | - { |
|
| 911 | - if (! empty($arrayfields['t.task_ref']['checked'])) print_liste_field_titre($arrayfields['t.task_ref']['label'],$_SERVER['PHP_SELF'],'pt.ref','',$param,'',$sortfield,$sortorder); |
|
| 912 | - if (! empty($arrayfields['t.task_label']['checked'])) print_liste_field_titre($arrayfields['t.task_label']['label'],$_SERVER['PHP_SELF'],'pt.label','',$param,'',$sortfield,$sortorder); |
|
| 913 | - } |
|
| 914 | - if (! empty($arrayfields['author']['checked'])) print_liste_field_titre($arrayfields['author']['label'],$_SERVER['PHP_SELF'],'','',$param,'',$sortfield,$sortorder); |
|
| 910 | + { |
|
| 911 | + if (! empty($arrayfields['t.task_ref']['checked'])) print_liste_field_titre($arrayfields['t.task_ref']['label'],$_SERVER['PHP_SELF'],'pt.ref','',$param,'',$sortfield,$sortorder); |
|
| 912 | + if (! empty($arrayfields['t.task_label']['checked'])) print_liste_field_titre($arrayfields['t.task_label']['label'],$_SERVER['PHP_SELF'],'pt.label','',$param,'',$sortfield,$sortorder); |
|
| 913 | + } |
|
| 914 | + if (! empty($arrayfields['author']['checked'])) print_liste_field_titre($arrayfields['author']['label'],$_SERVER['PHP_SELF'],'','',$param,'',$sortfield,$sortorder); |
|
| 915 | 915 | if (! empty($arrayfields['t.note']['checked'])) print_liste_field_titre($arrayfields['t.note']['label'],$_SERVER['PHP_SELF'],'t.note','',$param,'',$sortfield,$sortorder); |
| 916 | 916 | if (! empty($arrayfields['t.task_duration']['checked'])) print_liste_field_titre($arrayfields['t.task_duration']['label'],$_SERVER['PHP_SELF'],'t.task_duration','',$param,'align="right"',$sortfield,$sortorder); |
| 917 | 917 | if (! empty($arrayfields['value']['checked'])) print_liste_field_titre($arrayfields['value']['label'],$_SERVER['PHP_SELF'],'','',$param,'align="right"',$sortfield,$sortorder); |
@@ -920,11 +920,11 @@ discard block |
||
| 920 | 920 | // Extra fields |
| 921 | 921 | include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; |
| 922 | 922 | */ |
| 923 | - // Hook fields |
|
| 923 | + // Hook fields |
|
| 924 | 924 | $parameters=array('arrayfields'=>$arrayfields,'param'=>$param,'sortfield'=>$sortfield,'sortorder'=>$sortorder); |
| 925 | - $reshook=$hookmanager->executeHooks('printFieldListTitle',$parameters); // Note that $action and $object may have been modified by hook |
|
| 926 | - print $hookmanager->resPrint; |
|
| 927 | - print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"],"",'','','align="center" width="80"',$sortfield,$sortorder,'maxwidthsearch '); |
|
| 925 | + $reshook=$hookmanager->executeHooks('printFieldListTitle',$parameters); // Note that $action and $object may have been modified by hook |
|
| 926 | + print $hookmanager->resPrint; |
|
| 927 | + print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"],"",'','','align="center" width="80"',$sortfield,$sortorder,'maxwidthsearch '); |
|
| 928 | 928 | print "</tr>\n"; |
| 929 | 929 | |
| 930 | 930 | $tasktmp = new Task($db); |
@@ -947,140 +947,140 @@ discard block |
||
| 947 | 947 | // Date |
| 948 | 948 | if (! empty($arrayfields['t.task_date']['checked'])) |
| 949 | 949 | { |
| 950 | - print '<td class="nowrap">'; |
|
| 951 | - if ($_GET['action'] == 'editline' && $_GET['lineid'] == $task_time->rowid) |
|
| 952 | - { |
|
| 953 | - if (empty($task_time->task_date_withhour)) |
|
| 954 | - { |
|
| 955 | - print $form->select_date(($date2?$date2:$date1),'timeline',3,3,2,"timespent_date",1,0,1); |
|
| 956 | - } |
|
| 957 | - else print $form->select_date(($date2?$date2:$date1),'timeline',1,1,2,"timespent_date",1,0,1); |
|
| 958 | - } |
|
| 959 | - else |
|
| 960 | - { |
|
| 961 | - print dol_print_date(($date2?$date2:$date1),($task_time->task_date_withhour?'dayhour':'day')); |
|
| 962 | - } |
|
| 963 | - print '</td>'; |
|
| 964 | - if (! $i) $totalarray['nbfield']++; |
|
| 950 | + print '<td class="nowrap">'; |
|
| 951 | + if ($_GET['action'] == 'editline' && $_GET['lineid'] == $task_time->rowid) |
|
| 952 | + { |
|
| 953 | + if (empty($task_time->task_date_withhour)) |
|
| 954 | + { |
|
| 955 | + print $form->select_date(($date2?$date2:$date1),'timeline',3,3,2,"timespent_date",1,0,1); |
|
| 956 | + } |
|
| 957 | + else print $form->select_date(($date2?$date2:$date1),'timeline',1,1,2,"timespent_date",1,0,1); |
|
| 958 | + } |
|
| 959 | + else |
|
| 960 | + { |
|
| 961 | + print dol_print_date(($date2?$date2:$date1),($task_time->task_date_withhour?'dayhour':'day')); |
|
| 962 | + } |
|
| 963 | + print '</td>'; |
|
| 964 | + if (! $i) $totalarray['nbfield']++; |
|
| 965 | 965 | } |
| 966 | 966 | |
| 967 | 967 | // Task ref |
| 968 | - if (! empty($arrayfields['t.task_ref']['checked'])) |
|
| 969 | - { |
|
| 970 | - if ((empty($id) && empty($ref)) || ! empty($projectidforalltimes)) // Not a dedicated task |
|
| 971 | - { |
|
| 972 | - print '<td class="nowrap">'; |
|
| 973 | - $tasktmp->id = $task_time->fk_task; |
|
| 974 | - $tasktmp->ref = $task_time->ref; |
|
| 975 | - $tasktmp->label = $task_time->label; |
|
| 976 | - print $tasktmp->getNomUrl(1, 'withproject', 'time'); |
|
| 977 | - print '</td>'; |
|
| 978 | - if (! $i) $totalarray['nbfield']++; |
|
| 979 | - } |
|
| 980 | - } |
|
| 968 | + if (! empty($arrayfields['t.task_ref']['checked'])) |
|
| 969 | + { |
|
| 970 | + if ((empty($id) && empty($ref)) || ! empty($projectidforalltimes)) // Not a dedicated task |
|
| 971 | + { |
|
| 972 | + print '<td class="nowrap">'; |
|
| 973 | + $tasktmp->id = $task_time->fk_task; |
|
| 974 | + $tasktmp->ref = $task_time->ref; |
|
| 975 | + $tasktmp->label = $task_time->label; |
|
| 976 | + print $tasktmp->getNomUrl(1, 'withproject', 'time'); |
|
| 977 | + print '</td>'; |
|
| 978 | + if (! $i) $totalarray['nbfield']++; |
|
| 979 | + } |
|
| 980 | + } |
|
| 981 | 981 | |
| 982 | 982 | // Task label |
| 983 | - if (! empty($arrayfields['t.task_label']['checked'])) |
|
| 984 | - { |
|
| 985 | - if ((empty($id) && empty($ref)) || ! empty($projectidforalltimes)) // Not a dedicated task |
|
| 986 | - { |
|
| 987 | - print '<td class="nowrap">'; |
|
| 988 | - print $task_time->label; |
|
| 989 | - print '</td>'; |
|
| 990 | - if (! $i) $totalarray['nbfield']++; |
|
| 991 | - } |
|
| 992 | - } |
|
| 993 | - |
|
| 994 | - // User |
|
| 995 | - if (! empty($arrayfields['author']['checked'])) |
|
| 996 | - { |
|
| 997 | - print '<td>'; |
|
| 998 | - if ($_GET['action'] == 'editline' && $_GET['lineid'] == $task_time->rowid) |
|
| 999 | - { |
|
| 1000 | - if (empty($object->id)) $object->fetch($id); |
|
| 1001 | - $contactsoftask=$object->getListContactId('internal'); |
|
| 1002 | - if (!in_array($task_time->fk_user,$contactsoftask)) { |
|
| 1003 | - $contactsoftask[]=$task_time->fk_user; |
|
| 1004 | - } |
|
| 1005 | - if (count($contactsoftask)>0) { |
|
| 1006 | - print img_object('','user','class="hideonsmartphone"'); |
|
| 1007 | - print $form->select_dolusers($task_time->fk_user,'userid_line',0,'',0,'',$contactsoftask); |
|
| 1008 | - }else { |
|
| 1009 | - print img_error($langs->trans('FirstAddRessourceToAllocateTime')).$langs->trans('FirstAddRessourceToAllocateTime'); |
|
| 1010 | - } |
|
| 1011 | - } |
|
| 1012 | - else |
|
| 1013 | - { |
|
| 1014 | - $userstatic->id = $task_time->fk_user; |
|
| 1015 | - $userstatic->lastname = $task_time->lastname; |
|
| 1016 | - $userstatic->firstname = $task_time->firstname; |
|
| 1017 | - $userstatic->photo = $task_time->photo; |
|
| 1018 | - print $userstatic->getNomUrl(-1); |
|
| 1019 | - } |
|
| 1020 | - print '</td>'; |
|
| 1021 | - if (! $i) $totalarray['nbfield']++; |
|
| 1022 | - } |
|
| 983 | + if (! empty($arrayfields['t.task_label']['checked'])) |
|
| 984 | + { |
|
| 985 | + if ((empty($id) && empty($ref)) || ! empty($projectidforalltimes)) // Not a dedicated task |
|
| 986 | + { |
|
| 987 | + print '<td class="nowrap">'; |
|
| 988 | + print $task_time->label; |
|
| 989 | + print '</td>'; |
|
| 990 | + if (! $i) $totalarray['nbfield']++; |
|
| 991 | + } |
|
| 992 | + } |
|
| 993 | + |
|
| 994 | + // User |
|
| 995 | + if (! empty($arrayfields['author']['checked'])) |
|
| 996 | + { |
|
| 997 | + print '<td>'; |
|
| 998 | + if ($_GET['action'] == 'editline' && $_GET['lineid'] == $task_time->rowid) |
|
| 999 | + { |
|
| 1000 | + if (empty($object->id)) $object->fetch($id); |
|
| 1001 | + $contactsoftask=$object->getListContactId('internal'); |
|
| 1002 | + if (!in_array($task_time->fk_user,$contactsoftask)) { |
|
| 1003 | + $contactsoftask[]=$task_time->fk_user; |
|
| 1004 | + } |
|
| 1005 | + if (count($contactsoftask)>0) { |
|
| 1006 | + print img_object('','user','class="hideonsmartphone"'); |
|
| 1007 | + print $form->select_dolusers($task_time->fk_user,'userid_line',0,'',0,'',$contactsoftask); |
|
| 1008 | + }else { |
|
| 1009 | + print img_error($langs->trans('FirstAddRessourceToAllocateTime')).$langs->trans('FirstAddRessourceToAllocateTime'); |
|
| 1010 | + } |
|
| 1011 | + } |
|
| 1012 | + else |
|
| 1013 | + { |
|
| 1014 | + $userstatic->id = $task_time->fk_user; |
|
| 1015 | + $userstatic->lastname = $task_time->lastname; |
|
| 1016 | + $userstatic->firstname = $task_time->firstname; |
|
| 1017 | + $userstatic->photo = $task_time->photo; |
|
| 1018 | + print $userstatic->getNomUrl(-1); |
|
| 1019 | + } |
|
| 1020 | + print '</td>'; |
|
| 1021 | + if (! $i) $totalarray['nbfield']++; |
|
| 1022 | + } |
|
| 1023 | 1023 | |
| 1024 | 1024 | // Note |
| 1025 | - if (! empty($arrayfields['t.note']['checked'])) |
|
| 1026 | - { |
|
| 1027 | - print '<td align="left">'; |
|
| 1028 | - if ($_GET['action'] == 'editline' && $_GET['lineid'] == $task_time->rowid) |
|
| 1029 | - { |
|
| 1030 | - print '<textarea name="timespent_note_line" width="95%" rows="'.ROWS_2.'">'.$task_time->note.'</textarea>'; |
|
| 1031 | - } |
|
| 1032 | - else |
|
| 1033 | - { |
|
| 1034 | - print dol_nl2br($task_time->note); |
|
| 1035 | - } |
|
| 1036 | - print '</td>'; |
|
| 1037 | - if (! $i) $totalarray['nbfield']++; |
|
| 1038 | - } |
|
| 1025 | + if (! empty($arrayfields['t.note']['checked'])) |
|
| 1026 | + { |
|
| 1027 | + print '<td align="left">'; |
|
| 1028 | + if ($_GET['action'] == 'editline' && $_GET['lineid'] == $task_time->rowid) |
|
| 1029 | + { |
|
| 1030 | + print '<textarea name="timespent_note_line" width="95%" rows="'.ROWS_2.'">'.$task_time->note.'</textarea>'; |
|
| 1031 | + } |
|
| 1032 | + else |
|
| 1033 | + { |
|
| 1034 | + print dol_nl2br($task_time->note); |
|
| 1035 | + } |
|
| 1036 | + print '</td>'; |
|
| 1037 | + if (! $i) $totalarray['nbfield']++; |
|
| 1038 | + } |
|
| 1039 | 1039 | |
| 1040 | 1040 | // Time spent |
| 1041 | - if (! empty($arrayfields['t.task_duration']['checked'])) |
|
| 1042 | - { |
|
| 1043 | - print '<td align="right">'; |
|
| 1044 | - if ($_GET['action'] == 'editline' && $_GET['lineid'] == $task_time->rowid) |
|
| 1045 | - { |
|
| 1046 | - print '<input type="hidden" name="old_duration" value="'.$task_time->task_duration.'">'; |
|
| 1047 | - print $form->select_duration('new_duration',$task_time->task_duration,0,'text'); |
|
| 1048 | - } |
|
| 1049 | - else |
|
| 1050 | - { |
|
| 1051 | - print convertSecondToTime($task_time->task_duration,'allhourmin'); |
|
| 1052 | - } |
|
| 1053 | - print '</td>'; |
|
| 1054 | - if (! $i) $totalarray['nbfield']++; |
|
| 1055 | - if (! $i) $totalarray['totaldurationfield']=$totalarray['nbfield']; |
|
| 1056 | - $totalarray['totalduration'] += $task_time->task_duration; |
|
| 1057 | - } |
|
| 1041 | + if (! empty($arrayfields['t.task_duration']['checked'])) |
|
| 1042 | + { |
|
| 1043 | + print '<td align="right">'; |
|
| 1044 | + if ($_GET['action'] == 'editline' && $_GET['lineid'] == $task_time->rowid) |
|
| 1045 | + { |
|
| 1046 | + print '<input type="hidden" name="old_duration" value="'.$task_time->task_duration.'">'; |
|
| 1047 | + print $form->select_duration('new_duration',$task_time->task_duration,0,'text'); |
|
| 1048 | + } |
|
| 1049 | + else |
|
| 1050 | + { |
|
| 1051 | + print convertSecondToTime($task_time->task_duration,'allhourmin'); |
|
| 1052 | + } |
|
| 1053 | + print '</td>'; |
|
| 1054 | + if (! $i) $totalarray['nbfield']++; |
|
| 1055 | + if (! $i) $totalarray['totaldurationfield']=$totalarray['nbfield']; |
|
| 1056 | + $totalarray['totalduration'] += $task_time->task_duration; |
|
| 1057 | + } |
|
| 1058 | 1058 | |
| 1059 | 1059 | // Value spent |
| 1060 | - if (! empty($arrayfields['value']['checked'])) |
|
| 1061 | - { |
|
| 1060 | + if (! empty($arrayfields['value']['checked'])) |
|
| 1061 | + { |
|
| 1062 | 1062 | print '<td align="right">'; |
| 1063 | 1063 | $value = price2num($task_time->thm * $task_time->task_duration / 3600); |
| 1064 | 1064 | print price($value, 1, $langs, 1, -1, -1, $conf->currency); |
| 1065 | 1065 | print '</td>'; |
| 1066 | 1066 | if (! $i) $totalarray['nbfield']++; |
| 1067 | - if (! $i) $totalarray['totalvaluefield']=$totalarray['nbfield']; |
|
| 1068 | - $totalarray['totalvalue'] += $value; |
|
| 1069 | - } |
|
| 1070 | - |
|
| 1071 | - // Value billed |
|
| 1072 | - if (! empty($arrayfields['valuebilled']['checked'])) |
|
| 1073 | - { |
|
| 1074 | - print '<td align="right">'; |
|
| 1075 | - $valuebilled = price2num($task_time->total_ht); |
|
| 1076 | - if (isset($task_time->total_ht)) print price($valuebilled, 1, $langs, 1, -1, -1, $conf->currency); |
|
| 1077 | - print '</td>'; |
|
| 1078 | - if (! $i) $totalarray['nbfield']++; |
|
| 1079 | - if (! $i) $totalarray['totalvaluefield']=$totalarray['nbfield']; |
|
| 1080 | - $totalarray['totalvaluebilled'] += $valuebilled; |
|
| 1081 | - } |
|
| 1082 | - |
|
| 1083 | - /* |
|
| 1067 | + if (! $i) $totalarray['totalvaluefield']=$totalarray['nbfield']; |
|
| 1068 | + $totalarray['totalvalue'] += $value; |
|
| 1069 | + } |
|
| 1070 | + |
|
| 1071 | + // Value billed |
|
| 1072 | + if (! empty($arrayfields['valuebilled']['checked'])) |
|
| 1073 | + { |
|
| 1074 | + print '<td align="right">'; |
|
| 1075 | + $valuebilled = price2num($task_time->total_ht); |
|
| 1076 | + if (isset($task_time->total_ht)) print price($valuebilled, 1, $langs, 1, -1, -1, $conf->currency); |
|
| 1077 | + print '</td>'; |
|
| 1078 | + if (! $i) $totalarray['nbfield']++; |
|
| 1079 | + if (! $i) $totalarray['totalvaluefield']=$totalarray['nbfield']; |
|
| 1080 | + $totalarray['totalvaluebilled'] += $valuebilled; |
|
| 1081 | + } |
|
| 1082 | + |
|
| 1083 | + /* |
|
| 1084 | 1084 | // Extra fields |
| 1085 | 1085 | include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; |
| 1086 | 1086 | */ |
@@ -1090,7 +1090,7 @@ discard block |
||
| 1090 | 1090 | $reshook=$hookmanager->executeHooks('printFieldListValue',$parameters); // Note that $action and $object may have been modified by hook |
| 1091 | 1091 | print $hookmanager->resPrint; |
| 1092 | 1092 | |
| 1093 | - // Action column |
|
| 1093 | + // Action column |
|
| 1094 | 1094 | print '<td class="center nowraponall">'; |
| 1095 | 1095 | if ($action == 'editline' && $_GET['lineid'] == $task_time->rowid) |
| 1096 | 1096 | { |
@@ -1113,10 +1113,10 @@ discard block |
||
| 1113 | 1113 | print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?id='.$task_time->fk_task.'&action=deleteline&lineid='.$task_time->rowid.$param.'">'; |
| 1114 | 1114 | print img_delete(); |
| 1115 | 1115 | print '</a>'; |
| 1116 | - } |
|
| 1116 | + } |
|
| 1117 | 1117 | } |
| 1118 | - print '</td>'; |
|
| 1119 | - if (! $i) $totalarray['nbfield']++; |
|
| 1118 | + print '</td>'; |
|
| 1119 | + if (! $i) $totalarray['nbfield']++; |
|
| 1120 | 1120 | |
| 1121 | 1121 | print "</tr>\n"; |
| 1122 | 1122 | |
@@ -1126,21 +1126,21 @@ discard block |
||
| 1126 | 1126 | // Show total line |
| 1127 | 1127 | if (isset($totalarray['totaldurationfield']) || isset($totalarray['totalvaluefield'])) |
| 1128 | 1128 | { |
| 1129 | - print '<tr class="liste_total">'; |
|
| 1130 | - $i=0; |
|
| 1131 | - while ($i < $totalarray['nbfield']) |
|
| 1132 | - { |
|
| 1133 | - $i++; |
|
| 1134 | - if ($i == 1) |
|
| 1135 | - { |
|
| 1136 | - if ($num < $limit && empty($offset)) print '<td align="left">'.$langs->trans("Total").'</td>'; |
|
| 1137 | - else print '<td align="left">'.$langs->trans("Totalforthispage").'</td>'; |
|
| 1138 | - } |
|
| 1139 | - elseif ($totalarray['totaldurationfield'] == $i) print '<td align="right">'.convertSecondToTime($totalarray['totalduration'],'allhourmin').'</td>'; |
|
| 1140 | - elseif ($totalarray['totalvaluefield'] == $i) print '<td align="right">'.price($totalarray['totalvalue']).'</td>'; |
|
| 1141 | - else print '<td></td>'; |
|
| 1142 | - } |
|
| 1143 | - print '</tr>'; |
|
| 1129 | + print '<tr class="liste_total">'; |
|
| 1130 | + $i=0; |
|
| 1131 | + while ($i < $totalarray['nbfield']) |
|
| 1132 | + { |
|
| 1133 | + $i++; |
|
| 1134 | + if ($i == 1) |
|
| 1135 | + { |
|
| 1136 | + if ($num < $limit && empty($offset)) print '<td align="left">'.$langs->trans("Total").'</td>'; |
|
| 1137 | + else print '<td align="left">'.$langs->trans("Totalforthispage").'</td>'; |
|
| 1138 | + } |
|
| 1139 | + elseif ($totalarray['totaldurationfield'] == $i) print '<td align="right">'.convertSecondToTime($totalarray['totalduration'],'allhourmin').'</td>'; |
|
| 1140 | + elseif ($totalarray['totalvaluefield'] == $i) print '<td align="right">'.price($totalarray['totalvalue']).'</td>'; |
|
| 1141 | + else print '<td></td>'; |
|
| 1142 | + } |
|
| 1143 | + print '</tr>'; |
|
| 1144 | 1144 | } |
| 1145 | 1145 | |
| 1146 | 1146 | print '</tr>'; |
@@ -35,99 +35,99 @@ discard block |
||
| 35 | 35 | |
| 36 | 36 | $langs->load('projects'); |
| 37 | 37 | |
| 38 | -$id=GETPOST('id','int'); |
|
| 39 | -$projectid=GETPOST('projectid','int'); |
|
| 40 | -$ref=GETPOST('ref','alpha'); |
|
| 41 | -$action=GETPOST('action','alpha'); |
|
| 42 | -$confirm=GETPOST('confirm','alpha'); |
|
| 43 | -$cancel=GETPOST('cancel','alpha'); |
|
| 44 | -$withproject=GETPOST('withproject','int'); |
|
| 45 | -$project_ref=GETPOST('project_ref','alpha'); |
|
| 46 | - |
|
| 47 | -$search_day=GETPOST('search_day','int'); |
|
| 48 | -$search_month=GETPOST('search_month','int'); |
|
| 49 | -$search_year=GETPOST('search_year','int'); |
|
| 50 | -$search_datehour=''; |
|
| 51 | -$search_datewithhour=''; |
|
| 52 | -$search_note=GETPOST('search_note','alpha'); |
|
| 53 | -$search_duration=GETPOST('search_duration','int'); |
|
| 54 | -$search_value=GETPOST('search_value','int'); |
|
| 55 | -$search_task_ref=GETPOST('search_task_ref','alpha'); |
|
| 56 | -$search_task_label=GETPOST('search_task_label','alpha'); |
|
| 57 | -$search_user=GETPOST('search_user','int'); |
|
| 38 | +$id = GETPOST('id', 'int'); |
|
| 39 | +$projectid = GETPOST('projectid', 'int'); |
|
| 40 | +$ref = GETPOST('ref', 'alpha'); |
|
| 41 | +$action = GETPOST('action', 'alpha'); |
|
| 42 | +$confirm = GETPOST('confirm', 'alpha'); |
|
| 43 | +$cancel = GETPOST('cancel', 'alpha'); |
|
| 44 | +$withproject = GETPOST('withproject', 'int'); |
|
| 45 | +$project_ref = GETPOST('project_ref', 'alpha'); |
|
| 46 | + |
|
| 47 | +$search_day = GETPOST('search_day', 'int'); |
|
| 48 | +$search_month = GETPOST('search_month', 'int'); |
|
| 49 | +$search_year = GETPOST('search_year', 'int'); |
|
| 50 | +$search_datehour = ''; |
|
| 51 | +$search_datewithhour = ''; |
|
| 52 | +$search_note = GETPOST('search_note', 'alpha'); |
|
| 53 | +$search_duration = GETPOST('search_duration', 'int'); |
|
| 54 | +$search_value = GETPOST('search_value', 'int'); |
|
| 55 | +$search_task_ref = GETPOST('search_task_ref', 'alpha'); |
|
| 56 | +$search_task_label = GETPOST('search_task_label', 'alpha'); |
|
| 57 | +$search_user = GETPOST('search_user', 'int'); |
|
| 58 | 58 | |
| 59 | 59 | // Security check |
| 60 | -$socid=0; |
|
| 60 | +$socid = 0; |
|
| 61 | 61 | //if ($user->societe_id > 0) $socid = $user->societe_id; // For external user, no check is done on company because readability is managed by public status of project and assignement. |
| 62 | 62 | if (!$user->rights->projet->lire) accessforbidden(); |
| 63 | 63 | |
| 64 | -$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; |
|
| 65 | -$sortfield = GETPOST("sortfield",'alpha'); |
|
| 66 | -$sortorder = GETPOST("sortorder",'alpha'); |
|
| 67 | -$page = GETPOST("page",'int'); |
|
| 64 | +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; |
|
| 65 | +$sortfield = GETPOST("sortfield", 'alpha'); |
|
| 66 | +$sortorder = GETPOST("sortorder", 'alpha'); |
|
| 67 | +$page = GETPOST("page", 'int'); |
|
| 68 | 68 | if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 |
| 69 | 69 | $offset = $limit * $page; |
| 70 | 70 | $pageprev = $page - 1; |
| 71 | 71 | $pagenext = $page + 1; |
| 72 | -if (! $sortfield) $sortfield='t.task_date,t.task_datehour,t.rowid'; |
|
| 73 | -if (! $sortorder) $sortorder='DESC'; |
|
| 72 | +if (!$sortfield) $sortfield = 't.task_date,t.task_datehour,t.rowid'; |
|
| 73 | +if (!$sortorder) $sortorder = 'DESC'; |
|
| 74 | 74 | |
| 75 | 75 | // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context |
| 76 | 76 | //$object = new TaskTime($db); |
| 77 | -$hookmanager->initHooks(array('projecttaskcard','globalcard')); |
|
| 77 | +$hookmanager->initHooks(array('projecttaskcard', 'globalcard')); |
|
| 78 | 78 | |
| 79 | 79 | $object = new Task($db); |
| 80 | 80 | $projectstatic = new Project($db); |
| 81 | 81 | $extrafields_project = new ExtraFields($db); |
| 82 | 82 | $extrafields_task = new ExtraFields($db); |
| 83 | 83 | |
| 84 | -$extralabels_projet=$extrafields_project->fetch_name_optionals_label($projectstatic->table_element); |
|
| 85 | -$extralabels_task=$extrafields_task->fetch_name_optionals_label($object->table_element); |
|
| 84 | +$extralabels_projet = $extrafields_project->fetch_name_optionals_label($projectstatic->table_element); |
|
| 85 | +$extralabels_task = $extrafields_task->fetch_name_optionals_label($object->table_element); |
|
| 86 | 86 | |
| 87 | 87 | |
| 88 | 88 | /* |
| 89 | 89 | * Actions |
| 90 | 90 | */ |
| 91 | 91 | |
| 92 | -if (GETPOST('cancel','alpha')) { $action=''; } |
|
| 92 | +if (GETPOST('cancel', 'alpha')) { $action = ''; } |
|
| 93 | 93 | |
| 94 | -$parameters=array('socid'=>$socid, 'projectid'=>$projectid); |
|
| 95 | -$reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks |
|
| 94 | +$parameters = array('socid'=>$socid, 'projectid'=>$projectid); |
|
| 95 | +$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks |
|
| 96 | 96 | if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); |
| 97 | 97 | |
| 98 | 98 | include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; |
| 99 | 99 | |
| 100 | 100 | // Purge search criteria |
| 101 | -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 |
|
| 101 | +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 |
|
| 102 | 102 | { |
| 103 | - $search_day=''; |
|
| 104 | - $search_month=''; |
|
| 105 | - $search_year=''; |
|
| 106 | - $search_date=''; |
|
| 107 | - $search_datehour=''; |
|
| 108 | - $search_datewithhour=''; |
|
| 109 | - $search_note=''; |
|
| 110 | - $search_duration=''; |
|
| 111 | - $search_value=''; |
|
| 112 | - $search_date_creation=''; |
|
| 113 | - $search_date_update=''; |
|
| 114 | - $search_task_ref=''; |
|
| 115 | - $search_task_label=''; |
|
| 116 | - $search_user=0; |
|
| 117 | - $toselect=''; |
|
| 118 | - $search_array_options=array(); |
|
| 119 | - $action=''; |
|
| 103 | + $search_day = ''; |
|
| 104 | + $search_month = ''; |
|
| 105 | + $search_year = ''; |
|
| 106 | + $search_date = ''; |
|
| 107 | + $search_datehour = ''; |
|
| 108 | + $search_datewithhour = ''; |
|
| 109 | + $search_note = ''; |
|
| 110 | + $search_duration = ''; |
|
| 111 | + $search_value = ''; |
|
| 112 | + $search_date_creation = ''; |
|
| 113 | + $search_date_update = ''; |
|
| 114 | + $search_task_ref = ''; |
|
| 115 | + $search_task_label = ''; |
|
| 116 | + $search_user = 0; |
|
| 117 | + $toselect = ''; |
|
| 118 | + $search_array_options = array(); |
|
| 119 | + $action = ''; |
|
| 120 | 120 | } |
| 121 | 121 | |
| 122 | 122 | if ($action == 'addtimespent' && $user->rights->projet->lire) |
| 123 | 123 | { |
| 124 | - $error=0; |
|
| 124 | + $error = 0; |
|
| 125 | 125 | |
| 126 | - $timespent_durationhour = GETPOST('timespent_durationhour','int'); |
|
| 127 | - $timespent_durationmin = GETPOST('timespent_durationmin','int'); |
|
| 126 | + $timespent_durationhour = GETPOST('timespent_durationhour', 'int'); |
|
| 127 | + $timespent_durationmin = GETPOST('timespent_durationmin', 'int'); |
|
| 128 | 128 | if (empty($timespent_durationhour) && empty($timespent_durationmin)) |
| 129 | 129 | { |
| 130 | - setEventMessages($langs->trans('ErrorFieldRequired',$langs->transnoentitiesnoconv("Duration")), null, 'errors'); |
|
| 130 | + setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("Duration")), null, 'errors'); |
|
| 131 | 131 | $error++; |
| 132 | 132 | } |
| 133 | 133 | if (empty($_POST["userid"])) |
@@ -137,7 +137,7 @@ discard block |
||
| 137 | 137 | $error++; |
| 138 | 138 | } |
| 139 | 139 | |
| 140 | - if (! $error) |
|
| 140 | + if (!$error) |
|
| 141 | 141 | { |
| 142 | 142 | if ($id || $ref) |
| 143 | 143 | { |
@@ -145,7 +145,7 @@ discard block |
||
| 145 | 145 | } |
| 146 | 146 | else |
| 147 | 147 | { |
| 148 | - $object->fetch(GETPOST('taskid','int')); |
|
| 148 | + $object->fetch(GETPOST('taskid', 'int')); |
|
| 149 | 149 | } |
| 150 | 150 | $object->fetch_projet(); |
| 151 | 151 | |
@@ -158,19 +158,19 @@ discard block |
||
| 158 | 158 | { |
| 159 | 159 | $object->timespent_note = $_POST["timespent_note"]; |
| 160 | 160 | $object->progress = GETPOST('progress', 'int'); |
| 161 | - $object->timespent_duration = $_POST["timespent_durationhour"]*60*60; // We store duration in seconds |
|
| 162 | - $object->timespent_duration+= $_POST["timespent_durationmin"]*60; // We store duration in seconds |
|
| 161 | + $object->timespent_duration = $_POST["timespent_durationhour"] * 60 * 60; // We store duration in seconds |
|
| 162 | + $object->timespent_duration += $_POST["timespent_durationmin"] * 60; // We store duration in seconds |
|
| 163 | 163 | if (GETPOST("timehour") != '' && GETPOST("timehour") >= 0) // If hour was entered |
| 164 | 164 | { |
| 165 | - $object->timespent_date = dol_mktime(GETPOST("timehour"),GETPOST("timemin"),0,GETPOST("timemonth"),GETPOST("timeday"),GETPOST("timeyear")); |
|
| 165 | + $object->timespent_date = dol_mktime(GETPOST("timehour"), GETPOST("timemin"), 0, GETPOST("timemonth"), GETPOST("timeday"), GETPOST("timeyear")); |
|
| 166 | 166 | $object->timespent_withhour = 1; |
| 167 | 167 | } |
| 168 | 168 | else |
| 169 | 169 | { |
| 170 | - $object->timespent_date = dol_mktime(12,0,0,GETPOST("timemonth"),GETPOST("timeday"),GETPOST("timeyear")); |
|
| 170 | + $object->timespent_date = dol_mktime(12, 0, 0, GETPOST("timemonth"), GETPOST("timeday"), GETPOST("timeyear")); |
|
| 171 | 171 | } |
| 172 | 172 | $object->timespent_fk_user = $_POST["userid"]; |
| 173 | - $result=$object->addTimeSpent($user); |
|
| 173 | + $result = $object->addTimeSpent($user); |
|
| 174 | 174 | if ($result >= 0) |
| 175 | 175 | { |
| 176 | 176 | setEventMessages($langs->trans("RecordSaved"), null, 'mesgs'); |
@@ -184,22 +184,22 @@ discard block |
||
| 184 | 184 | } |
| 185 | 185 | else |
| 186 | 186 | { |
| 187 | - if (empty($id)) $action='createtime'; |
|
| 188 | - else $action='createtime'; |
|
| 187 | + if (empty($id)) $action = 'createtime'; |
|
| 188 | + else $action = 'createtime'; |
|
| 189 | 189 | } |
| 190 | 190 | } |
| 191 | 191 | |
| 192 | -if ($action == 'updateline' && ! $_POST["cancel"] && $user->rights->projet->lire) |
|
| 192 | +if ($action == 'updateline' && !$_POST["cancel"] && $user->rights->projet->lire) |
|
| 193 | 193 | { |
| 194 | - $error=0; |
|
| 194 | + $error = 0; |
|
| 195 | 195 | |
| 196 | 196 | if (empty($_POST["new_durationhour"]) && empty($_POST["new_durationmin"])) |
| 197 | 197 | { |
| 198 | - setEventMessages($langs->trans('ErrorFieldRequired',$langs->transnoentitiesnoconv("Duration")), null, 'errors'); |
|
| 198 | + setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("Duration")), null, 'errors'); |
|
| 199 | 199 | $error++; |
| 200 | 200 | } |
| 201 | 201 | |
| 202 | - if (! $error) |
|
| 202 | + if (!$error) |
|
| 203 | 203 | { |
| 204 | 204 | $object->fetch($id, $ref); |
| 205 | 205 | // TODO Check that ($task_time->fk_user == $user->id || in_array($task_time->fk_user, $childids)) |
@@ -207,20 +207,20 @@ discard block |
||
| 207 | 207 | $object->timespent_id = $_POST["lineid"]; |
| 208 | 208 | $object->timespent_note = $_POST["timespent_note_line"]; |
| 209 | 209 | $object->timespent_old_duration = $_POST["old_duration"]; |
| 210 | - $object->timespent_duration = $_POST["new_durationhour"]*60*60; // We store duration in seconds |
|
| 211 | - $object->timespent_duration+= $_POST["new_durationmin"]*60; // We store duration in seconds |
|
| 210 | + $object->timespent_duration = $_POST["new_durationhour"] * 60 * 60; // We store duration in seconds |
|
| 211 | + $object->timespent_duration += $_POST["new_durationmin"] * 60; // We store duration in seconds |
|
| 212 | 212 | if (GETPOST("timelinehour") != '' && GETPOST("timelinehour") >= 0) // If hour was entered |
| 213 | 213 | { |
| 214 | - $object->timespent_date = dol_mktime(GETPOST("timelinehour"),GETPOST("timelinemin"),0,GETPOST("timelinemonth"),GETPOST("timelineday"),GETPOST("timelineyear")); |
|
| 214 | + $object->timespent_date = dol_mktime(GETPOST("timelinehour"), GETPOST("timelinemin"), 0, GETPOST("timelinemonth"), GETPOST("timelineday"), GETPOST("timelineyear")); |
|
| 215 | 215 | $object->timespent_withhour = 1; |
| 216 | 216 | } |
| 217 | 217 | else |
| 218 | 218 | { |
| 219 | - $object->timespent_date = dol_mktime(12,0,0,GETPOST("timelinemonth"),GETPOST("timelineday"),GETPOST("timelineyear")); |
|
| 219 | + $object->timespent_date = dol_mktime(12, 0, 0, GETPOST("timelinemonth"), GETPOST("timelineday"), GETPOST("timelineyear")); |
|
| 220 | 220 | } |
| 221 | 221 | $object->timespent_fk_user = $_POST["userid_line"]; |
| 222 | 222 | |
| 223 | - $result=$object->updateTimeSpent($user); |
|
| 223 | + $result = $object->updateTimeSpent($user); |
|
| 224 | 224 | if ($result >= 0) |
| 225 | 225 | { |
| 226 | 226 | setEventMessages($langs->trans("RecordSaved"), null, 'mesgs'); |
@@ -233,13 +233,13 @@ discard block |
||
| 233 | 233 | } |
| 234 | 234 | else |
| 235 | 235 | { |
| 236 | - $action=''; |
|
| 236 | + $action = ''; |
|
| 237 | 237 | } |
| 238 | 238 | } |
| 239 | 239 | |
| 240 | 240 | if ($action == 'confirm_delete' && $confirm == "yes" && $user->rights->projet->lire) |
| 241 | 241 | { |
| 242 | - $object->fetchTimeSpent(GETPOST('lineid','int')); |
|
| 242 | + $object->fetchTimeSpent(GETPOST('lineid', 'int')); |
|
| 243 | 243 | // TODO Check that ($task_time->fk_user == $user->id || in_array($task_time->fk_user, $childids)) |
| 244 | 244 | $result = $object->delTimeSpent($user); |
| 245 | 245 | |
@@ -248,7 +248,7 @@ discard block |
||
| 248 | 248 | $langs->load("errors"); |
| 249 | 249 | setEventMessages($langs->trans($object->error), null, 'errors'); |
| 250 | 250 | $error++; |
| 251 | - $action=''; |
|
| 251 | + $action = ''; |
|
| 252 | 252 | } |
| 253 | 253 | else |
| 254 | 254 | { |
@@ -257,28 +257,28 @@ discard block |
||
| 257 | 257 | } |
| 258 | 258 | |
| 259 | 259 | // Retreive First Task ID of Project if withprojet is on to allow project prev next to work |
| 260 | -if (! empty($project_ref) && ! empty($withproject)) |
|
| 260 | +if (!empty($project_ref) && !empty($withproject)) |
|
| 261 | 261 | { |
| 262 | - if ($projectstatic->fetch(0,$project_ref) > 0) |
|
| 262 | + if ($projectstatic->fetch(0, $project_ref) > 0) |
|
| 263 | 263 | { |
| 264 | - $tasksarray=$object->getTasksArray(0, 0, $projectstatic->id, $socid, 0); |
|
| 264 | + $tasksarray = $object->getTasksArray(0, 0, $projectstatic->id, $socid, 0); |
|
| 265 | 265 | if (count($tasksarray) > 0) |
| 266 | 266 | { |
| 267 | - $id=$tasksarray[0]->id; |
|
| 267 | + $id = $tasksarray[0]->id; |
|
| 268 | 268 | } |
| 269 | 269 | else |
| 270 | 270 | { |
| 271 | - header("Location: ".DOL_URL_ROOT.'/projet/tasks.php?id='.$projectstatic->id.($withproject?'&withproject=1':'').(empty($mode)?'':'&mode='.$mode)); |
|
| 271 | + header("Location: ".DOL_URL_ROOT.'/projet/tasks.php?id='.$projectstatic->id.($withproject ? '&withproject=1' : '').(empty($mode) ? '' : '&mode='.$mode)); |
|
| 272 | 272 | exit; |
| 273 | 273 | } |
| 274 | 274 | } |
| 275 | 275 | } |
| 276 | 276 | |
| 277 | 277 | // To show all time lines for project |
| 278 | -$projectidforalltimes=0; |
|
| 279 | -if (GETPOST('projectid','none')) |
|
| 278 | +$projectidforalltimes = 0; |
|
| 279 | +if (GETPOST('projectid', 'none')) |
|
| 280 | 280 | { |
| 281 | - $projectidforalltimes=GETPOST('projectid','int'); |
|
| 281 | + $projectidforalltimes = GETPOST('projectid', 'int'); |
|
| 282 | 282 | } |
| 283 | 283 | |
| 284 | 284 | |
@@ -286,66 +286,66 @@ discard block |
||
| 286 | 286 | * View |
| 287 | 287 | */ |
| 288 | 288 | |
| 289 | -llxHeader("",$langs->trans("Task")); |
|
| 289 | +llxHeader("", $langs->trans("Task")); |
|
| 290 | 290 | |
| 291 | 291 | $form = new Form($db); |
| 292 | 292 | $formother = new FormOther($db); |
| 293 | 293 | $formproject = new FormProjets($db); |
| 294 | 294 | $userstatic = new User($db); |
| 295 | 295 | |
| 296 | -if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) |
|
| 296 | +if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0) |
|
| 297 | 297 | { |
| 298 | 298 | /* |
| 299 | 299 | * Fiche projet en mode visu |
| 300 | 300 | */ |
| 301 | 301 | if ($projectidforalltimes) |
| 302 | 302 | { |
| 303 | - $result=$projectstatic->fetch($projectidforalltimes); |
|
| 304 | - if (! empty($projectstatic->socid)) $projectstatic->fetch_thirdparty(); |
|
| 305 | - $res=$projectstatic->fetch_optionals(); |
|
| 303 | + $result = $projectstatic->fetch($projectidforalltimes); |
|
| 304 | + if (!empty($projectstatic->socid)) $projectstatic->fetch_thirdparty(); |
|
| 305 | + $res = $projectstatic->fetch_optionals(); |
|
| 306 | 306 | } |
| 307 | 307 | elseif ($object->fetch($id, $ref) >= 0) |
| 308 | 308 | { |
| 309 | - $result=$projectstatic->fetch($object->fk_project); |
|
| 310 | - if (! empty($projectstatic->socid)) $projectstatic->fetch_thirdparty(); |
|
| 311 | - $res=$projectstatic->fetch_optionals(); |
|
| 309 | + $result = $projectstatic->fetch($object->fk_project); |
|
| 310 | + if (!empty($projectstatic->socid)) $projectstatic->fetch_thirdparty(); |
|
| 311 | + $res = $projectstatic->fetch_optionals(); |
|
| 312 | 312 | |
| 313 | 313 | $object->project = clone $projectstatic; |
| 314 | 314 | } |
| 315 | 315 | |
| 316 | - $userWrite = $projectstatic->restrictedProjectArea($user,'write'); |
|
| 316 | + $userWrite = $projectstatic->restrictedProjectArea($user, 'write'); |
|
| 317 | 317 | |
| 318 | 318 | if ($projectstatic->id > 0) |
| 319 | 319 | { |
| 320 | 320 | if ($withproject) |
| 321 | 321 | { |
| 322 | 322 | // Tabs for project |
| 323 | - if (empty($id)) $tab='timespent'; |
|
| 324 | - else $tab='tasks'; |
|
| 325 | - $head=project_prepare_head($projectstatic); |
|
| 326 | - dol_fiche_head($head, $tab, $langs->trans("Project"), -1, ($projectstatic->public?'projectpub':'project')); |
|
| 323 | + if (empty($id)) $tab = 'timespent'; |
|
| 324 | + else $tab = 'tasks'; |
|
| 325 | + $head = project_prepare_head($projectstatic); |
|
| 326 | + dol_fiche_head($head, $tab, $langs->trans("Project"), -1, ($projectstatic->public ? 'projectpub' : 'project')); |
|
| 327 | 327 | |
| 328 | - $param=($mode=='mine'?'&mode=mine':''); |
|
| 328 | + $param = ($mode == 'mine' ? '&mode=mine' : ''); |
|
| 329 | 329 | |
| 330 | 330 | // Project card |
| 331 | 331 | |
| 332 | 332 | $linkback = '<a href="'.DOL_URL_ROOT.'/projet/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>'; |
| 333 | 333 | |
| 334 | - $morehtmlref='<div class="refidno">'; |
|
| 334 | + $morehtmlref = '<div class="refidno">'; |
|
| 335 | 335 | // Title |
| 336 | - $morehtmlref.=$projectstatic->title; |
|
| 336 | + $morehtmlref .= $projectstatic->title; |
|
| 337 | 337 | // Thirdparty |
| 338 | 338 | if ($projectstatic->thirdparty->id > 0) |
| 339 | 339 | { |
| 340 | - $morehtmlref.='<br>'.$langs->trans('ThirdParty') . ' : ' . $projectstatic->thirdparty->getNomUrl(1, 'project'); |
|
| 340 | + $morehtmlref .= '<br>'.$langs->trans('ThirdParty').' : '.$projectstatic->thirdparty->getNomUrl(1, 'project'); |
|
| 341 | 341 | } |
| 342 | - $morehtmlref.='</div>'; |
|
| 342 | + $morehtmlref .= '</div>'; |
|
| 343 | 343 | |
| 344 | 344 | // Define a complementary filter for search of next/prev ref. |
| 345 | - if (! $user->rights->projet->all->lire) |
|
| 345 | + if (!$user->rights->projet->all->lire) |
|
| 346 | 346 | { |
| 347 | - $objectsListId = $projectstatic->getProjectsAuthorizedForUser($user,0,0); |
|
| 348 | - $projectstatic->next_prev_filter=" rowid in (".(count($objectsListId)?join(',',array_keys($objectsListId)):'0').")"; |
|
| 347 | + $objectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 0); |
|
| 348 | + $projectstatic->next_prev_filter = " rowid in (".(count($objectsListId) ?join(',', array_keys($objectsListId)) : '0').")"; |
|
| 349 | 349 | } |
| 350 | 350 | |
| 351 | 351 | dol_banner_tab($projectstatic, 'project_ref', $linkback, 1, 'ref', 'ref', $morehtmlref); |
@@ -364,17 +364,17 @@ discard block |
||
| 364 | 364 | |
| 365 | 365 | // Date start - end |
| 366 | 366 | print '<tr><td>'.$langs->trans("DateStart").' - '.$langs->trans("DateEnd").'</td><td>'; |
| 367 | - $start = dol_print_date($projectstatic->date_start,'day'); |
|
| 368 | - print ($start?$start:'?'); |
|
| 369 | - $end = dol_print_date($projectstatic->date_end,'day'); |
|
| 367 | + $start = dol_print_date($projectstatic->date_start, 'day'); |
|
| 368 | + print ($start ? $start : '?'); |
|
| 369 | + $end = dol_print_date($projectstatic->date_end, 'day'); |
|
| 370 | 370 | print ' - '; |
| 371 | - print ($end?$end:'?'); |
|
| 371 | + print ($end ? $end : '?'); |
|
| 372 | 372 | if ($projectstatic->hasDelay()) print img_warning("Late"); |
| 373 | 373 | print '</td></tr>'; |
| 374 | 374 | |
| 375 | 375 | // Budget |
| 376 | 376 | print '<tr><td>'.$langs->trans("Budget").'</td><td>'; |
| 377 | - if (strcmp($projectstatic->budget_amount, '')) print price($projectstatic->budget_amount,'',$langs,1,0,0,$conf->currency); |
|
| 377 | + if (strcmp($projectstatic->budget_amount, '')) print price($projectstatic->budget_amount, '', $langs, 1, 0, 0, $conf->currency); |
|
| 378 | 378 | print '</td></tr>'; |
| 379 | 379 | |
| 380 | 380 | // Other attributes |
@@ -396,9 +396,9 @@ discard block |
||
| 396 | 396 | print '</td></tr>'; |
| 397 | 397 | |
| 398 | 398 | // Categories |
| 399 | - if($conf->categorie->enabled) { |
|
| 399 | + if ($conf->categorie->enabled) { |
|
| 400 | 400 | print '<tr><td valign="middle">'.$langs->trans("Categories").'</td><td>'; |
| 401 | - print $form->showCategories($projectstatic->id,'project',1); |
|
| 401 | + print $form->showCategories($projectstatic->id, 'project', 1); |
|
| 402 | 402 | print "</td></tr>"; |
| 403 | 403 | } |
| 404 | 404 | |
@@ -438,40 +438,40 @@ discard block |
||
| 438 | 438 | |
| 439 | 439 | if (empty($projectidforalltimes)) |
| 440 | 440 | { |
| 441 | - $head=task_prepare_head($object); |
|
| 441 | + $head = task_prepare_head($object); |
|
| 442 | 442 | dol_fiche_head($head, 'task_time', $langs->trans("Task"), -1, 'projecttask', 0, '', 'reposition'); |
| 443 | 443 | |
| 444 | 444 | if ($action == 'deleteline') |
| 445 | 445 | { |
| 446 | - print $form->formconfirm($_SERVER["PHP_SELF"]."?".($object->id>0?"id=".$object->id:'projectid='.$projectstatic->id).'&lineid='.GETPOST("lineid",'int').($withproject?'&withproject=1':''),$langs->trans("DeleteATimeSpent"),$langs->trans("ConfirmDeleteATimeSpent"),"confirm_delete",'','',1); |
|
| 446 | + print $form->formconfirm($_SERVER["PHP_SELF"]."?".($object->id > 0 ? "id=".$object->id : 'projectid='.$projectstatic->id).'&lineid='.GETPOST("lineid", 'int').($withproject ? '&withproject=1' : ''), $langs->trans("DeleteATimeSpent"), $langs->trans("ConfirmDeleteATimeSpent"), "confirm_delete", '', '', 1); |
|
| 447 | 447 | } |
| 448 | 448 | |
| 449 | - $param=($withproject?'&withproject=1':''); |
|
| 450 | - $linkback=$withproject?'<a href="'.DOL_URL_ROOT.'/projet/tasks.php?id='.$projectstatic->id.'">'.$langs->trans("BackToList").'</a>':''; |
|
| 449 | + $param = ($withproject ? '&withproject=1' : ''); |
|
| 450 | + $linkback = $withproject ? '<a href="'.DOL_URL_ROOT.'/projet/tasks.php?id='.$projectstatic->id.'">'.$langs->trans("BackToList").'</a>' : ''; |
|
| 451 | 451 | |
| 452 | - if (! GETPOST('withproject') || empty($projectstatic->id)) |
|
| 452 | + if (!GETPOST('withproject') || empty($projectstatic->id)) |
|
| 453 | 453 | { |
| 454 | - $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user,0,1); |
|
| 455 | - $object->next_prev_filter=" fk_projet in (".$projectsListId.")"; |
|
| 454 | + $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1); |
|
| 455 | + $object->next_prev_filter = " fk_projet in (".$projectsListId.")"; |
|
| 456 | 456 | } |
| 457 | - else $object->next_prev_filter=" fk_projet = ".$projectstatic->id; |
|
| 457 | + else $object->next_prev_filter = " fk_projet = ".$projectstatic->id; |
|
| 458 | 458 | |
| 459 | - $morehtmlref=''; |
|
| 459 | + $morehtmlref = ''; |
|
| 460 | 460 | |
| 461 | 461 | // Project |
| 462 | 462 | if (empty($withproject)) |
| 463 | 463 | { |
| 464 | - $morehtmlref.='<div class="refidno">'; |
|
| 465 | - $morehtmlref.=$langs->trans("Project").': '; |
|
| 466 | - $morehtmlref.=$projectstatic->getNomUrl(1); |
|
| 467 | - $morehtmlref.='<br>'; |
|
| 464 | + $morehtmlref .= '<div class="refidno">'; |
|
| 465 | + $morehtmlref .= $langs->trans("Project").': '; |
|
| 466 | + $morehtmlref .= $projectstatic->getNomUrl(1); |
|
| 467 | + $morehtmlref .= '<br>'; |
|
| 468 | 468 | |
| 469 | 469 | // Third party |
| 470 | - $morehtmlref.=$langs->trans("ThirdParty").': '; |
|
| 470 | + $morehtmlref .= $langs->trans("ThirdParty").': '; |
|
| 471 | 471 | if (is_object($projectstatic->thirdparty)) { |
| 472 | - $morehtmlref.=$projectstatic->thirdparty->getNomUrl(1); |
|
| 472 | + $morehtmlref .= $projectstatic->thirdparty->getNomUrl(1); |
|
| 473 | 473 | } |
| 474 | - $morehtmlref.='</div>'; |
|
| 474 | + $morehtmlref .= '</div>'; |
|
| 475 | 475 | } |
| 476 | 476 | |
| 477 | 477 | dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref, $param); |
@@ -484,17 +484,17 @@ discard block |
||
| 484 | 484 | |
| 485 | 485 | // Date start - Date end |
| 486 | 486 | print '<tr><td class="titlefield">'.$langs->trans("DateStart").' - '.$langs->trans("DateEnd").'</td><td>'; |
| 487 | - $start = dol_print_date($object->date_start,'dayhour'); |
|
| 488 | - print ($start?$start:'?'); |
|
| 489 | - $end = dol_print_date($object->date_end,'dayhour'); |
|
| 487 | + $start = dol_print_date($object->date_start, 'dayhour'); |
|
| 488 | + print ($start ? $start : '?'); |
|
| 489 | + $end = dol_print_date($object->date_end, 'dayhour'); |
|
| 490 | 490 | print ' - '; |
| 491 | - print ($end?$end:'?'); |
|
| 491 | + print ($end ? $end : '?'); |
|
| 492 | 492 | if ($object->hasDelay()) print img_warning("Late"); |
| 493 | 493 | print '</td></tr>'; |
| 494 | 494 | |
| 495 | 495 | // Planned workload |
| 496 | 496 | print '<tr><td>'.$langs->trans("PlannedWorkload").'</td><td>'; |
| 497 | - print convertSecondToTime($object->planned_workload,'allhourmin'); |
|
| 497 | + print convertSecondToTime($object->planned_workload, 'allhourmin'); |
|
| 498 | 498 | print '</td></tr>'; |
| 499 | 499 | |
| 500 | 500 | print '</table>'; |
@@ -514,8 +514,8 @@ discard block |
||
| 514 | 514 | print '<tr><td>'.$langs->trans("ProgressCalculated").'</td><td>'; |
| 515 | 515 | if ($object->planned_workload) |
| 516 | 516 | { |
| 517 | - $tmparray=$object->getSummaryOfTimeSpent(); |
|
| 518 | - if ($tmparray['total_duration'] > 0) print round($tmparray['total_duration']/$object->planned_workload*100, 2).' %'; |
|
| 517 | + $tmparray = $object->getSummaryOfTimeSpent(); |
|
| 518 | + if ($tmparray['total_duration'] > 0) print round($tmparray['total_duration'] / $object->planned_workload * 100, 2).' %'; |
|
| 519 | 519 | else print '0 %'; |
| 520 | 520 | } |
| 521 | 521 | else print '<span class="opacitymedium">'.$langs->trans("WorkloadNotDefined").'</span>'; |
@@ -533,7 +533,7 @@ discard block |
||
| 533 | 533 | |
| 534 | 534 | print '<!-- List of time spent for task -->'."\n"; |
| 535 | 535 | |
| 536 | - $title=$langs->trans("ListTaskTimeForTask"); |
|
| 536 | + $title = $langs->trans("ListTaskTimeForTask"); |
|
| 537 | 537 | //print_barre_liste($title, 0, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, $linktotasks, $num, $totalnboflines, 'title_generic.png', 0, '', '', 0, 1); |
| 538 | 538 | print load_fiche_titre($title, $linktocreatetime, 'title_generic.png'); |
| 539 | 539 | |
@@ -567,18 +567,18 @@ discard block |
||
| 567 | 567 | // Date |
| 568 | 568 | print '<td class="maxwidthonsmartphone">'; |
| 569 | 569 | //$newdate=dol_mktime(12,0,0,$_POST["timemonth"],$_POST["timeday"],$_POST["timeyear"]); |
| 570 | - $newdate=''; |
|
| 571 | - print $form->select_date($newdate, 'time', ($conf->browser->layout == 'phone'?2:1), 1, 2, "timespent_date", 1, 0, 1); |
|
| 570 | + $newdate = ''; |
|
| 571 | + print $form->select_date($newdate, 'time', ($conf->browser->layout == 'phone' ? 2 : 1), 1, 2, "timespent_date", 1, 0, 1); |
|
| 572 | 572 | print '</td>'; |
| 573 | 573 | |
| 574 | 574 | // Contributor |
| 575 | 575 | print '<td class="maxwidthonsmartphone">'; |
| 576 | - print img_object('','user','class="hideonsmartphone"'); |
|
| 577 | - $contactsoftask=$object->getListContactId('internal'); |
|
| 578 | - if (count($contactsoftask)>0) |
|
| 576 | + print img_object('', 'user', 'class="hideonsmartphone"'); |
|
| 577 | + $contactsoftask = $object->getListContactId('internal'); |
|
| 578 | + if (count($contactsoftask) > 0) |
|
| 579 | 579 | { |
| 580 | - $userid=$contactsoftask[0]; |
|
| 581 | - print $form->select_dolusers((GETPOST('userid')?GETPOST('userid'):$userid), 'userid', 0, '', 0, '', $contactsoftask, 0, 0, 0, '', 0, $langs->trans("ResourceNotAssignedToTheTask"), 'maxwidth200'); |
|
| 580 | + $userid = $contactsoftask[0]; |
|
| 581 | + print $form->select_dolusers((GETPOST('userid') ?GETPOST('userid') : $userid), 'userid', 0, '', 0, '', $contactsoftask, 0, 0, 0, '', 0, $langs->trans("ResourceNotAssignedToTheTask"), 'maxwidth200'); |
|
| 582 | 582 | } |
| 583 | 583 | else |
| 584 | 584 | { |
@@ -588,17 +588,17 @@ discard block |
||
| 588 | 588 | |
| 589 | 589 | // Note |
| 590 | 590 | print '<td>'; |
| 591 | - print '<textarea name="timespent_note" class="maxwidth100onsmartphone" rows="'.ROWS_2.'">'.($_POST['timespent_note']?$_POST['timespent_note']:'').'</textarea>'; |
|
| 591 | + print '<textarea name="timespent_note" class="maxwidth100onsmartphone" rows="'.ROWS_2.'">'.($_POST['timespent_note'] ? $_POST['timespent_note'] : '').'</textarea>'; |
|
| 592 | 592 | print '</td>'; |
| 593 | 593 | |
| 594 | 594 | // Duration - Time spent |
| 595 | 595 | print '<td>'; |
| 596 | - print $form->select_duration('timespent_duration', ($_POST['timespent_duration']?$_POST['timespent_duration']:''), 0, 'text'); |
|
| 596 | + print $form->select_duration('timespent_duration', ($_POST['timespent_duration'] ? $_POST['timespent_duration'] : ''), 0, 'text'); |
|
| 597 | 597 | print '</td>'; |
| 598 | 598 | |
| 599 | 599 | // Progress declared |
| 600 | 600 | print '<td class="nowrap">'; |
| 601 | - print $formother->select_percent(GETPOST('progress')?GETPOST('progress'):$object->progress,'progress'); |
|
| 601 | + print $formother->select_percent(GETPOST('progress') ?GETPOST('progress') : $object->progress, 'progress'); |
|
| 602 | 602 | print '</td>'; |
| 603 | 603 | |
| 604 | 604 | print '<td align="center">'; |
@@ -618,9 +618,9 @@ discard block |
||
| 618 | 618 | |
| 619 | 619 | if ($projectstatic->id > 0) |
| 620 | 620 | { |
| 621 | - if ($action == 'deleteline' && ! empty($projectidforalltimes)) |
|
| 621 | + if ($action == 'deleteline' && !empty($projectidforalltimes)) |
|
| 622 | 622 | { |
| 623 | - print $form->formconfirm($_SERVER["PHP_SELF"]."?".($object->id>0?"id=".$object->id:'projectid='.$projectstatic->id).'&lineid='.GETPOST('lineid','int').($withproject?'&withproject=1':''),$langs->trans("DeleteATimeSpent"),$langs->trans("ConfirmDeleteATimeSpent"),"confirm_delete",'','',1); |
|
| 623 | + print $form->formconfirm($_SERVER["PHP_SELF"]."?".($object->id > 0 ? "id=".$object->id : 'projectid='.$projectstatic->id).'&lineid='.GETPOST('lineid', 'int').($withproject ? '&withproject=1' : ''), $langs->trans("DeleteATimeSpent"), $langs->trans("ConfirmDeleteATimeSpent"), "confirm_delete", '', '', 1); |
|
| 624 | 624 | } |
| 625 | 625 | |
| 626 | 626 | // Initialize technical object to manage hooks. Note that conf->hooks_modules contains array |
@@ -628,24 +628,24 @@ discard block |
||
| 628 | 628 | $extrafields = new ExtraFields($db); |
| 629 | 629 | |
| 630 | 630 | // Definition of fields for list |
| 631 | - $arrayfields=array(); |
|
| 632 | - $arrayfields['t.task_date']=array('label'=>$langs->trans("Date"), 'checked'=>1); |
|
| 633 | - if ((empty($id) && empty($ref)) || ! empty($projectidforalltimes)) // Not a dedicated task |
|
| 631 | + $arrayfields = array(); |
|
| 632 | + $arrayfields['t.task_date'] = array('label'=>$langs->trans("Date"), 'checked'=>1); |
|
| 633 | + if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) // Not a dedicated task |
|
| 634 | 634 | { |
| 635 | - $arrayfields['t.task_ref']=array('label'=>$langs->trans("RefTask"), 'checked'=>1); |
|
| 636 | - $arrayfields['t.task_label']=array('label'=>$langs->trans("LabelTask"), 'checked'=>1); |
|
| 635 | + $arrayfields['t.task_ref'] = array('label'=>$langs->trans("RefTask"), 'checked'=>1); |
|
| 636 | + $arrayfields['t.task_label'] = array('label'=>$langs->trans("LabelTask"), 'checked'=>1); |
|
| 637 | 637 | } |
| 638 | - $arrayfields['author']=array('label'=>$langs->trans("By"), 'checked'=>1); |
|
| 639 | - $arrayfields['t.note']=array('label'=>$langs->trans("Note"), 'checked'=>1); |
|
| 640 | - $arrayfields['t.task_duration']=array('label'=>$langs->trans("Duration"), 'checked'=>1); |
|
| 641 | - $arrayfields['value'] =array('label'=>$langs->trans("Value"), 'checked'=>1, 'enabled'=>(empty($conf->salaries->enabled)?0:1)); |
|
| 642 | - $arrayfields['valuebilled'] =array('label'=>$langs->trans("AmountInvoiced"), 'checked'=>1, 'enabled'=>(empty($conf->global->PROJECT_BILL_TIME_SPENT)?0:1)); |
|
| 638 | + $arrayfields['author'] = array('label'=>$langs->trans("By"), 'checked'=>1); |
|
| 639 | + $arrayfields['t.note'] = array('label'=>$langs->trans("Note"), 'checked'=>1); |
|
| 640 | + $arrayfields['t.task_duration'] = array('label'=>$langs->trans("Duration"), 'checked'=>1); |
|
| 641 | + $arrayfields['value'] = array('label'=>$langs->trans("Value"), 'checked'=>1, 'enabled'=>(empty($conf->salaries->enabled) ? 0 : 1)); |
|
| 642 | + $arrayfields['valuebilled'] = array('label'=>$langs->trans("AmountInvoiced"), 'checked'=>1, 'enabled'=>(empty($conf->global->PROJECT_BILL_TIME_SPENT) ? 0 : 1)); |
|
| 643 | 643 | // Extra fields |
| 644 | 644 | if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) |
| 645 | 645 | { |
| 646 | - foreach($extrafields->attribute_label as $key => $val) |
|
| 646 | + foreach ($extrafields->attribute_label as $key => $val) |
|
| 647 | 647 | { |
| 648 | - if (! empty($extrafields->attribute_list[$key])) $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>(($extrafields->attribute_list[$key]<0)?0:1), 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>(abs($extrafields->attribute_list[$key])!=3 && $extrafields->attribute_perms[$key])); |
|
| 648 | + if (!empty($extrafields->attribute_list[$key])) $arrayfields["ef.".$key] = array('label'=>$extrafields->attribute_label[$key], 'checked'=>(($extrafields->attribute_list[$key] < 0) ? 0 : 1), 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>(abs($extrafields->attribute_list[$key]) != 3 && $extrafields->attribute_perms[$key])); |
|
| 649 | 649 | } |
| 650 | 650 | } |
| 651 | 651 | |
@@ -663,7 +663,7 @@ discard block |
||
| 663 | 663 | $sql .= ", ".MAIN_DB_PREFIX."projet_task as pt, ".MAIN_DB_PREFIX."user as u"; |
| 664 | 664 | $sql .= " WHERE t.fk_user = u.rowid AND t.fk_task = pt.rowid"; |
| 665 | 665 | if (empty($projectidforalltimes)) $sql .= " AND t.fk_task =".$object->id; |
| 666 | - else $sql.= " AND pt.fk_projet IN (".$projectidforalltimes.")"; |
|
| 666 | + else $sql .= " AND pt.fk_projet IN (".$projectidforalltimes.")"; |
|
| 667 | 667 | if ($search_ref) $sql .= natural_search('c.ref', $search_ref); |
| 668 | 668 | if ($search_note) $sql .= natural_search('t.note', $search_note); |
| 669 | 669 | if ($search_task_ref) $sql .= natural_search('pt.ref', $search_task_ref); |
@@ -672,15 +672,15 @@ discard block |
||
| 672 | 672 | if ($search_month > 0) |
| 673 | 673 | { |
| 674 | 674 | if ($search_year > 0 && empty($search_day)) |
| 675 | - $sql.= " AND t.task_datehour BETWEEN '".$db->idate(dol_get_first_day($search_year,$search_month,false))."' AND '".$db->idate(dol_get_last_day($search_year,$search_month,false))."'"; |
|
| 676 | - else if ($search_year > 0 && ! empty($search_day)) |
|
| 677 | - $sql.= " AND t.task_datehour BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $search_month, $search_day, $search_year))."' AND '".$db->idate(dol_mktime(23, 59, 59, $search_month, $search_day, $search_year))."'"; |
|
| 675 | + $sql .= " AND t.task_datehour BETWEEN '".$db->idate(dol_get_first_day($search_year, $search_month, false))."' AND '".$db->idate(dol_get_last_day($search_year, $search_month, false))."'"; |
|
| 676 | + else if ($search_year > 0 && !empty($search_day)) |
|
| 677 | + $sql .= " AND t.task_datehour BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $search_month, $search_day, $search_year))."' AND '".$db->idate(dol_mktime(23, 59, 59, $search_month, $search_day, $search_year))."'"; |
|
| 678 | 678 | else |
| 679 | - $sql.= " AND date_format(t.task_datehour, '%m') = '".$db->escape($search_month)."'"; |
|
| 679 | + $sql .= " AND date_format(t.task_datehour, '%m') = '".$db->escape($search_month)."'"; |
|
| 680 | 680 | } |
| 681 | 681 | else if ($search_year > 0) |
| 682 | 682 | { |
| 683 | - $sql.= " AND t.task_datehour BETWEEN '".$db->idate(dol_get_first_day($search_year,1,false))."' AND '".$db->idate(dol_get_last_day($search_year,12,false))."'"; |
|
| 683 | + $sql .= " AND t.task_datehour BETWEEN '".$db->idate(dol_get_first_day($search_year, 1, false))."' AND '".$db->idate(dol_get_last_day($search_year, 12, false))."'"; |
|
| 684 | 684 | } |
| 685 | 685 | |
| 686 | 686 | $sql .= $db->order($sortfield, $sortorder); |
@@ -689,13 +689,13 @@ discard block |
||
| 689 | 689 | if ($resql) |
| 690 | 690 | { |
| 691 | 691 | $num = $db->num_rows($resql); |
| 692 | - $totalnboflines=$num; |
|
| 692 | + $totalnboflines = $num; |
|
| 693 | 693 | |
| 694 | - if (! empty($projectidforalltimes)) |
|
| 694 | + if (!empty($projectidforalltimes)) |
|
| 695 | 695 | { |
| 696 | 696 | print '<!-- List of time spent for project -->'."\n"; |
| 697 | 697 | |
| 698 | - $title=$langs->trans("ListTaskTimeUserProject"); |
|
| 698 | + $title = $langs->trans("ListTaskTimeUserProject"); |
|
| 699 | 699 | //$linktotasks='<a href="'.DOL_URL_ROOT.'/projet/tasks.php?id='.$projectstatic->id.'">'.$langs->trans("GoToListOfTasks").'</a>'; |
| 700 | 700 | //print_barre_liste($title, 0, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, $linktotasks, $num, $totalnboflines, 'title_generic.png', 0, '', '', 0, 1); |
| 701 | 701 | print load_fiche_titre($title, $linktocreatetime, 'title_generic.png'); |
@@ -745,25 +745,25 @@ discard block |
||
| 745 | 745 | // Date |
| 746 | 746 | print '<td class="maxwidthonsmartphone">'; |
| 747 | 747 | //$newdate=dol_mktime(12,0,0,$_POST["timemonth"],$_POST["timeday"],$_POST["timeyear"]); |
| 748 | - $newdate=''; |
|
| 749 | - print $form->select_date($newdate, 'time', ($conf->browser->layout == 'phone'?2:1), 1, 2, "timespent_date", 1, 0, 1); |
|
| 748 | + $newdate = ''; |
|
| 749 | + print $form->select_date($newdate, 'time', ($conf->browser->layout == 'phone' ? 2 : 1), 1, 2, "timespent_date", 1, 0, 1); |
|
| 750 | 750 | print '</td>'; |
| 751 | 751 | |
| 752 | 752 | // Task |
| 753 | 753 | print '<td class="maxwidthonsmartphone">'; |
| 754 | - $formproject->selectTasks(-1, GETPOST('taskid','int'), 'taskid', 0, 0, 1, 1, 0, 0, 'maxwidth300', $projectstatic->id, ''); |
|
| 754 | + $formproject->selectTasks(-1, GETPOST('taskid', 'int'), 'taskid', 0, 0, 1, 1, 0, 0, 'maxwidth300', $projectstatic->id, ''); |
|
| 755 | 755 | print '</td>'; |
| 756 | 756 | |
| 757 | 757 | // Contributor |
| 758 | 758 | print '<td class="maxwidthonsmartphone">'; |
| 759 | - print img_object('','user','class="hideonsmartphone"'); |
|
| 760 | - $contactsofproject=$projectstatic->getListContactId('internal'); |
|
| 761 | - if (count($contactsofproject)>0) |
|
| 759 | + print img_object('', 'user', 'class="hideonsmartphone"'); |
|
| 760 | + $contactsofproject = $projectstatic->getListContactId('internal'); |
|
| 761 | + if (count($contactsofproject) > 0) |
|
| 762 | 762 | { |
| 763 | - if (in_array($user->id, $userid=$contactsofproject)) $userid = $user->id; |
|
| 764 | - else $userid=$contactsofproject[0]; |
|
| 763 | + if (in_array($user->id, $userid = $contactsofproject)) $userid = $user->id; |
|
| 764 | + else $userid = $contactsofproject[0]; |
|
| 765 | 765 | if ($projectstatic->public) $contactsofproject = array(); |
| 766 | - print $form->select_dolusers((GETPOST('userid')?GETPOST('userid'):$userid), 'userid', 0, '', 0, '', $contactsofproject, 0, 0, 0, '', 0, $langs->trans("ResourceNotAssignedToProject"), 'maxwidth200'); |
|
| 766 | + print $form->select_dolusers((GETPOST('userid') ?GETPOST('userid') : $userid), 'userid', 0, '', 0, '', $contactsofproject, 0, 0, 0, '', 0, $langs->trans("ResourceNotAssignedToProject"), 'maxwidth200'); |
|
| 767 | 767 | } |
| 768 | 768 | else |
| 769 | 769 | { |
@@ -773,17 +773,17 @@ discard block |
||
| 773 | 773 | |
| 774 | 774 | // Note |
| 775 | 775 | print '<td>'; |
| 776 | - print '<textarea name="timespent_note" class="maxwidth100onsmartphone" rows="'.ROWS_2.'">'.($_POST['timespent_note']?$_POST['timespent_note']:'').'</textarea>'; |
|
| 776 | + print '<textarea name="timespent_note" class="maxwidth100onsmartphone" rows="'.ROWS_2.'">'.($_POST['timespent_note'] ? $_POST['timespent_note'] : '').'</textarea>'; |
|
| 777 | 777 | print '</td>'; |
| 778 | 778 | |
| 779 | 779 | // Duration - Time spent |
| 780 | 780 | print '<td>'; |
| 781 | - print $form->select_duration('timespent_duration', ($_POST['timespent_duration']?$_POST['timespent_duration']:''), 0, 'text'); |
|
| 781 | + print $form->select_duration('timespent_duration', ($_POST['timespent_duration'] ? $_POST['timespent_duration'] : ''), 0, 'text'); |
|
| 782 | 782 | print '</td>'; |
| 783 | 783 | |
| 784 | 784 | // Progress declared |
| 785 | 785 | print '<td class="nowrap">'; |
| 786 | - print $formother->select_percent(GETPOST('progress')?GETPOST('progress'):$object->progress,'progress'); |
|
| 786 | + print $formother->select_percent(GETPOST('progress') ?GETPOST('progress') : $object->progress, 'progress'); |
|
| 787 | 787 | print '</td>'; |
| 788 | 788 | |
| 789 | 789 | print '<td align="center">'; |
@@ -798,35 +798,35 @@ discard block |
||
| 798 | 798 | } |
| 799 | 799 | |
| 800 | 800 | |
| 801 | - $arrayofselected=is_array($toselect)?$toselect:array(); |
|
| 801 | + $arrayofselected = is_array($toselect) ? $toselect : array(); |
|
| 802 | 802 | |
| 803 | - $param=''; |
|
| 804 | - if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; |
|
| 805 | - if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; |
|
| 806 | - if ($search_month > 0) $param.= '&search_month='.urlencode($search_month); |
|
| 807 | - if ($search_year > 0) $param.= '&search_year='.urlencode($search_year); |
|
| 808 | - if ($search_user > 0) $param.= '&search_user='.urlencode($search_user); |
|
| 809 | - if ($search_task_ref != '') $param.= '&search_task_ref='.urlencode($search_task_ref); |
|
| 810 | - if ($search_task_label != '') $param.= '&search_task_label='.urlencode($search_task_label); |
|
| 811 | - if ($search_note != '') $param.= '&search_note='.urlencode($search_note); |
|
| 812 | - if ($search_duration != '') $param.= '&search_field2='.urlencode($search_duration); |
|
| 813 | - if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss); |
|
| 803 | + $param = ''; |
|
| 804 | + if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.$contextpage; |
|
| 805 | + if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.$limit; |
|
| 806 | + if ($search_month > 0) $param .= '&search_month='.urlencode($search_month); |
|
| 807 | + if ($search_year > 0) $param .= '&search_year='.urlencode($search_year); |
|
| 808 | + if ($search_user > 0) $param .= '&search_user='.urlencode($search_user); |
|
| 809 | + if ($search_task_ref != '') $param .= '&search_task_ref='.urlencode($search_task_ref); |
|
| 810 | + if ($search_task_label != '') $param .= '&search_task_label='.urlencode($search_task_label); |
|
| 811 | + if ($search_note != '') $param .= '&search_note='.urlencode($search_note); |
|
| 812 | + if ($search_duration != '') $param .= '&search_field2='.urlencode($search_duration); |
|
| 813 | + if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss); |
|
| 814 | 814 | /* |
| 815 | 815 | // Add $param from extra fields |
| 816 | 816 | include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; |
| 817 | 817 | */ |
| 818 | - if ($id) $param.='&id='.urlencode($id); |
|
| 819 | - if ($projectid) $param.='&projectid='.urlencode($projectid); |
|
| 820 | - if ($withproject) $param.='&withproject='.urlencode($withproject); |
|
| 818 | + if ($id) $param .= '&id='.urlencode($id); |
|
| 819 | + if ($projectid) $param .= '&projectid='.urlencode($projectid); |
|
| 820 | + if ($withproject) $param .= '&withproject='.urlencode($withproject); |
|
| 821 | 821 | |
| 822 | 822 | |
| 823 | - $arrayofmassactions = array( |
|
| 823 | + $arrayofmassactions = array( |
|
| 824 | 824 | //'presend'=>$langs->trans("SendByMail"), |
| 825 | 825 | //'builddoc'=>$langs->trans("PDFMerge"), |
| 826 | 826 | ); |
| 827 | 827 | //if ($user->rights->projet->creer) $arrayofmassactions['predelete']=$langs->trans("Delete"); |
| 828 | - if (in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array(); |
|
| 829 | - $massactionbutton=$form->selectMassAction('', $arrayofmassactions); |
|
| 828 | + if (in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array(); |
|
| 829 | + $massactionbutton = $form->selectMassAction('', $arrayofmassactions); |
|
| 830 | 830 | |
| 831 | 831 | |
| 832 | 832 | print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'?id='.$id.'">'; |
@@ -845,86 +845,86 @@ discard block |
||
| 845 | 845 | |
| 846 | 846 | $moreforfilter = ''; |
| 847 | 847 | |
| 848 | - $parameters=array(); |
|
| 849 | - $reshook=$hookmanager->executeHooks('printFieldPreListTitle',$parameters); // Note that $action and $object may have been modified by hook |
|
| 848 | + $parameters = array(); |
|
| 849 | + $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook |
|
| 850 | 850 | if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint; |
| 851 | 851 | else $moreforfilter = $hookmanager->resPrint; |
| 852 | 852 | |
| 853 | - if (! empty($moreforfilter)) |
|
| 853 | + if (!empty($moreforfilter)) |
|
| 854 | 854 | { |
| 855 | 855 | print '<div class="liste_titre liste_titre_bydiv centpercent">'; |
| 856 | 856 | print $moreforfilter; |
| 857 | 857 | print '</div>'; |
| 858 | 858 | } |
| 859 | 859 | |
| 860 | - $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; |
|
| 861 | - $selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields |
|
| 860 | + $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; |
|
| 861 | + $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields |
|
| 862 | 862 | |
| 863 | 863 | print '<div class="div-table-responsive">'; |
| 864 | - print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n"; |
|
| 864 | + print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n"; |
|
| 865 | 865 | |
| 866 | 866 | // Fields title search |
| 867 | 867 | print '<tr class="liste_titre_filter">'; |
| 868 | 868 | // Date |
| 869 | - if (! empty($arrayfields['t.task_date']['checked'])) |
|
| 869 | + if (!empty($arrayfields['t.task_date']['checked'])) |
|
| 870 | 870 | { |
| 871 | 871 | print '<td class="liste_titre">'; |
| 872 | - if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print '<input class="flat valignmiddle" type="text" size="1" maxlength="2" name="search_day" value="'.$search_day.'">'; |
|
| 872 | + if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print '<input class="flat valignmiddle" type="text" size="1" maxlength="2" name="search_day" value="'.$search_day.'">'; |
|
| 873 | 873 | print '<input class="flat valignmiddle" type="text" size="1" maxlength="2" name="search_month" value="'.$search_month.'">'; |
| 874 | - $formother->select_year($search_year,'search_year',1, 20, 5); |
|
| 874 | + $formother->select_year($search_year, 'search_year', 1, 20, 5); |
|
| 875 | 875 | print '</td>'; |
| 876 | 876 | } |
| 877 | - if ((empty($id) && empty($ref)) || ! empty($projectidforalltimes)) // Not a dedicated task |
|
| 877 | + if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) // Not a dedicated task |
|
| 878 | 878 | { |
| 879 | - if (! empty($arrayfields['t.task_ref']['checked'])) print '<td class="liste_titre"><input type="text" class="flat maxwidth100" name="search_task_ref" value="'.dol_escape_htmltag($search_task_ref).'"></td>'; |
|
| 880 | - if (! empty($arrayfields['t.task_label']['checked'])) print '<td class="liste_titre"><input type="text" class="flat maxwidth100" name="search_task_label" value="'.dol_escape_htmltag($search_task_label).'"></td>'; |
|
| 879 | + if (!empty($arrayfields['t.task_ref']['checked'])) print '<td class="liste_titre"><input type="text" class="flat maxwidth100" name="search_task_ref" value="'.dol_escape_htmltag($search_task_ref).'"></td>'; |
|
| 880 | + if (!empty($arrayfields['t.task_label']['checked'])) print '<td class="liste_titre"><input type="text" class="flat maxwidth100" name="search_task_label" value="'.dol_escape_htmltag($search_task_label).'"></td>'; |
|
| 881 | 881 | } |
| 882 | 882 | // Author |
| 883 | - if (! empty($arrayfields['author']['checked'])) print '<td class="liste_titre">'.$form->select_dolusers(($search_user > 0 ? $search_user : -1), 'search_user', 1, null, 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth200').'</td>'; |
|
| 883 | + if (!empty($arrayfields['author']['checked'])) print '<td class="liste_titre">'.$form->select_dolusers(($search_user > 0 ? $search_user : -1), 'search_user', 1, null, 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth200').'</td>'; |
|
| 884 | 884 | // Note |
| 885 | - if (! empty($arrayfields['t.note']['checked'])) print '<td class="liste_titre"><input type="text" class="flat maxwidth100" name="search_note" value="'.dol_escape_htmltag($search_note).'"></td>'; |
|
| 885 | + if (!empty($arrayfields['t.note']['checked'])) print '<td class="liste_titre"><input type="text" class="flat maxwidth100" name="search_note" value="'.dol_escape_htmltag($search_note).'"></td>'; |
|
| 886 | 886 | // Duration |
| 887 | - if (! empty($arrayfields['t.task_duration']['checked'])) print '<td class="liste_titre right"></td>'; |
|
| 887 | + if (!empty($arrayfields['t.task_duration']['checked'])) print '<td class="liste_titre right"></td>'; |
|
| 888 | 888 | // Value in main currency |
| 889 | - if (! empty($arrayfields['value']['checked'])) print '<td class="liste_titre"></td>'; |
|
| 889 | + if (!empty($arrayfields['value']['checked'])) print '<td class="liste_titre"></td>'; |
|
| 890 | 890 | // Value billed |
| 891 | - if (! empty($arrayfields['valuebilled']['checked'])) print '<td class="liste_titre"></td>'; |
|
| 891 | + if (!empty($arrayfields['valuebilled']['checked'])) print '<td class="liste_titre"></td>'; |
|
| 892 | 892 | /* |
| 893 | 893 | // Extra fields |
| 894 | 894 | include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; |
| 895 | 895 | */ |
| 896 | 896 | // Fields from hook |
| 897 | - $parameters=array('arrayfields'=>$arrayfields); |
|
| 898 | - $reshook=$hookmanager->executeHooks('printFieldListOption',$parameters); // Note that $action and $object may have been modified by hook |
|
| 897 | + $parameters = array('arrayfields'=>$arrayfields); |
|
| 898 | + $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook |
|
| 899 | 899 | print $hookmanager->resPrint; |
| 900 | 900 | // Action column |
| 901 | 901 | print '<td class="liste_titre center">'; |
| 902 | - $searchpicto=$form->showFilterAndCheckAddButtons($massactionbutton?1:0, 'checkforselect', 1); |
|
| 902 | + $searchpicto = $form->showFilterAndCheckAddButtons($massactionbutton ? 1 : 0, 'checkforselect', 1); |
|
| 903 | 903 | print $searchpicto; |
| 904 | 904 | print '</td>'; |
| 905 | 905 | print '</tr>'."\n"; |
| 906 | 906 | |
| 907 | 907 | print '<tr class="liste_titre">'; |
| 908 | - if (! empty($arrayfields['t.task_date']['checked'])) print_liste_field_titre($arrayfields['t.task_date']['label'],$_SERVER['PHP_SELF'],'t.task_date,t.task_datehour,t.rowid','',$param,'',$sortfield,$sortorder); |
|
| 909 | - if ((empty($id) && empty($ref)) || ! empty($projectidforalltimes)) // Not a dedicated task |
|
| 908 | + if (!empty($arrayfields['t.task_date']['checked'])) print_liste_field_titre($arrayfields['t.task_date']['label'], $_SERVER['PHP_SELF'], 't.task_date,t.task_datehour,t.rowid', '', $param, '', $sortfield, $sortorder); |
|
| 909 | + if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) // Not a dedicated task |
|
| 910 | 910 | { |
| 911 | - if (! empty($arrayfields['t.task_ref']['checked'])) print_liste_field_titre($arrayfields['t.task_ref']['label'],$_SERVER['PHP_SELF'],'pt.ref','',$param,'',$sortfield,$sortorder); |
|
| 912 | - if (! empty($arrayfields['t.task_label']['checked'])) print_liste_field_titre($arrayfields['t.task_label']['label'],$_SERVER['PHP_SELF'],'pt.label','',$param,'',$sortfield,$sortorder); |
|
| 911 | + if (!empty($arrayfields['t.task_ref']['checked'])) print_liste_field_titre($arrayfields['t.task_ref']['label'], $_SERVER['PHP_SELF'], 'pt.ref', '', $param, '', $sortfield, $sortorder); |
|
| 912 | + if (!empty($arrayfields['t.task_label']['checked'])) print_liste_field_titre($arrayfields['t.task_label']['label'], $_SERVER['PHP_SELF'], 'pt.label', '', $param, '', $sortfield, $sortorder); |
|
| 913 | 913 | } |
| 914 | - if (! empty($arrayfields['author']['checked'])) print_liste_field_titre($arrayfields['author']['label'],$_SERVER['PHP_SELF'],'','',$param,'',$sortfield,$sortorder); |
|
| 915 | - if (! empty($arrayfields['t.note']['checked'])) print_liste_field_titre($arrayfields['t.note']['label'],$_SERVER['PHP_SELF'],'t.note','',$param,'',$sortfield,$sortorder); |
|
| 916 | - if (! empty($arrayfields['t.task_duration']['checked'])) print_liste_field_titre($arrayfields['t.task_duration']['label'],$_SERVER['PHP_SELF'],'t.task_duration','',$param,'align="right"',$sortfield,$sortorder); |
|
| 917 | - if (! empty($arrayfields['value']['checked'])) print_liste_field_titre($arrayfields['value']['label'],$_SERVER['PHP_SELF'],'','',$param,'align="right"',$sortfield,$sortorder); |
|
| 918 | - if (! empty($arrayfields['valuebilled']['checked'])) print_liste_field_titre($arrayfields['valuebilled']['label'],$_SERVER['PHP_SELF'],'il.total_ht','',$param,'align="right"',$sortfield,$sortorder); |
|
| 914 | + if (!empty($arrayfields['author']['checked'])) print_liste_field_titre($arrayfields['author']['label'], $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder); |
|
| 915 | + if (!empty($arrayfields['t.note']['checked'])) print_liste_field_titre($arrayfields['t.note']['label'], $_SERVER['PHP_SELF'], 't.note', '', $param, '', $sortfield, $sortorder); |
|
| 916 | + if (!empty($arrayfields['t.task_duration']['checked'])) print_liste_field_titre($arrayfields['t.task_duration']['label'], $_SERVER['PHP_SELF'], 't.task_duration', '', $param, 'align="right"', $sortfield, $sortorder); |
|
| 917 | + if (!empty($arrayfields['value']['checked'])) print_liste_field_titre($arrayfields['value']['label'], $_SERVER['PHP_SELF'], '', '', $param, 'align="right"', $sortfield, $sortorder); |
|
| 918 | + if (!empty($arrayfields['valuebilled']['checked'])) print_liste_field_titre($arrayfields['valuebilled']['label'], $_SERVER['PHP_SELF'], 'il.total_ht', '', $param, 'align="right"', $sortfield, $sortorder); |
|
| 919 | 919 | /* |
| 920 | 920 | // Extra fields |
| 921 | 921 | include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; |
| 922 | 922 | */ |
| 923 | 923 | // Hook fields |
| 924 | - $parameters=array('arrayfields'=>$arrayfields,'param'=>$param,'sortfield'=>$sortfield,'sortorder'=>$sortorder); |
|
| 925 | - $reshook=$hookmanager->executeHooks('printFieldListTitle',$parameters); // Note that $action and $object may have been modified by hook |
|
| 924 | + $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder); |
|
| 925 | + $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook |
|
| 926 | 926 | print $hookmanager->resPrint; |
| 927 | - print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"],"",'','','align="center" width="80"',$sortfield,$sortorder,'maxwidthsearch '); |
|
| 927 | + print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', 'align="center" width="80"', $sortfield, $sortorder, 'maxwidthsearch '); |
|
| 928 | 928 | print "</tr>\n"; |
| 929 | 929 | |
| 930 | 930 | $tasktmp = new Task($db); |
@@ -935,39 +935,39 @@ discard block |
||
| 935 | 935 | |
| 936 | 936 | $total = 0; |
| 937 | 937 | $totalvalue = 0; |
| 938 | - $totalarray=array(); |
|
| 938 | + $totalarray = array(); |
|
| 939 | 939 | foreach ($tasks as $task_time) |
| 940 | 940 | { |
| 941 | 941 | |
| 942 | 942 | print '<tr class="oddeven">'; |
| 943 | 943 | |
| 944 | - $date1=$db->jdate($task_time->task_date); |
|
| 945 | - $date2=$db->jdate($task_time->task_datehour); |
|
| 944 | + $date1 = $db->jdate($task_time->task_date); |
|
| 945 | + $date2 = $db->jdate($task_time->task_datehour); |
|
| 946 | 946 | |
| 947 | 947 | // Date |
| 948 | - if (! empty($arrayfields['t.task_date']['checked'])) |
|
| 948 | + if (!empty($arrayfields['t.task_date']['checked'])) |
|
| 949 | 949 | { |
| 950 | 950 | print '<td class="nowrap">'; |
| 951 | 951 | if ($_GET['action'] == 'editline' && $_GET['lineid'] == $task_time->rowid) |
| 952 | 952 | { |
| 953 | 953 | if (empty($task_time->task_date_withhour)) |
| 954 | 954 | { |
| 955 | - print $form->select_date(($date2?$date2:$date1),'timeline',3,3,2,"timespent_date",1,0,1); |
|
| 955 | + print $form->select_date(($date2 ? $date2 : $date1), 'timeline', 3, 3, 2, "timespent_date", 1, 0, 1); |
|
| 956 | 956 | } |
| 957 | - else print $form->select_date(($date2?$date2:$date1),'timeline',1,1,2,"timespent_date",1,0,1); |
|
| 957 | + else print $form->select_date(($date2 ? $date2 : $date1), 'timeline', 1, 1, 2, "timespent_date", 1, 0, 1); |
|
| 958 | 958 | } |
| 959 | 959 | else |
| 960 | 960 | { |
| 961 | - print dol_print_date(($date2?$date2:$date1),($task_time->task_date_withhour?'dayhour':'day')); |
|
| 961 | + print dol_print_date(($date2 ? $date2 : $date1), ($task_time->task_date_withhour ? 'dayhour' : 'day')); |
|
| 962 | 962 | } |
| 963 | 963 | print '</td>'; |
| 964 | - if (! $i) $totalarray['nbfield']++; |
|
| 964 | + if (!$i) $totalarray['nbfield']++; |
|
| 965 | 965 | } |
| 966 | 966 | |
| 967 | 967 | // Task ref |
| 968 | - if (! empty($arrayfields['t.task_ref']['checked'])) |
|
| 968 | + if (!empty($arrayfields['t.task_ref']['checked'])) |
|
| 969 | 969 | { |
| 970 | - if ((empty($id) && empty($ref)) || ! empty($projectidforalltimes)) // Not a dedicated task |
|
| 970 | + if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) // Not a dedicated task |
|
| 971 | 971 | { |
| 972 | 972 | print '<td class="nowrap">'; |
| 973 | 973 | $tasktmp->id = $task_time->fk_task; |
@@ -975,54 +975,54 @@ discard block |
||
| 975 | 975 | $tasktmp->label = $task_time->label; |
| 976 | 976 | print $tasktmp->getNomUrl(1, 'withproject', 'time'); |
| 977 | 977 | print '</td>'; |
| 978 | - if (! $i) $totalarray['nbfield']++; |
|
| 978 | + if (!$i) $totalarray['nbfield']++; |
|
| 979 | 979 | } |
| 980 | 980 | } |
| 981 | 981 | |
| 982 | 982 | // Task label |
| 983 | - if (! empty($arrayfields['t.task_label']['checked'])) |
|
| 983 | + if (!empty($arrayfields['t.task_label']['checked'])) |
|
| 984 | 984 | { |
| 985 | - if ((empty($id) && empty($ref)) || ! empty($projectidforalltimes)) // Not a dedicated task |
|
| 985 | + if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) // Not a dedicated task |
|
| 986 | 986 | { |
| 987 | 987 | print '<td class="nowrap">'; |
| 988 | 988 | print $task_time->label; |
| 989 | 989 | print '</td>'; |
| 990 | - if (! $i) $totalarray['nbfield']++; |
|
| 990 | + if (!$i) $totalarray['nbfield']++; |
|
| 991 | 991 | } |
| 992 | 992 | } |
| 993 | 993 | |
| 994 | 994 | // User |
| 995 | - if (! empty($arrayfields['author']['checked'])) |
|
| 995 | + if (!empty($arrayfields['author']['checked'])) |
|
| 996 | 996 | { |
| 997 | 997 | print '<td>'; |
| 998 | 998 | if ($_GET['action'] == 'editline' && $_GET['lineid'] == $task_time->rowid) |
| 999 | 999 | { |
| 1000 | 1000 | if (empty($object->id)) $object->fetch($id); |
| 1001 | - $contactsoftask=$object->getListContactId('internal'); |
|
| 1002 | - if (!in_array($task_time->fk_user,$contactsoftask)) { |
|
| 1003 | - $contactsoftask[]=$task_time->fk_user; |
|
| 1001 | + $contactsoftask = $object->getListContactId('internal'); |
|
| 1002 | + if (!in_array($task_time->fk_user, $contactsoftask)) { |
|
| 1003 | + $contactsoftask[] = $task_time->fk_user; |
|
| 1004 | 1004 | } |
| 1005 | - if (count($contactsoftask)>0) { |
|
| 1006 | - print img_object('','user','class="hideonsmartphone"'); |
|
| 1007 | - print $form->select_dolusers($task_time->fk_user,'userid_line',0,'',0,'',$contactsoftask); |
|
| 1008 | - }else { |
|
| 1005 | + if (count($contactsoftask) > 0) { |
|
| 1006 | + print img_object('', 'user', 'class="hideonsmartphone"'); |
|
| 1007 | + print $form->select_dolusers($task_time->fk_user, 'userid_line', 0, '', 0, '', $contactsoftask); |
|
| 1008 | + } else { |
|
| 1009 | 1009 | print img_error($langs->trans('FirstAddRessourceToAllocateTime')).$langs->trans('FirstAddRessourceToAllocateTime'); |
| 1010 | 1010 | } |
| 1011 | 1011 | } |
| 1012 | 1012 | else |
| 1013 | 1013 | { |
| 1014 | 1014 | $userstatic->id = $task_time->fk_user; |
| 1015 | - $userstatic->lastname = $task_time->lastname; |
|
| 1015 | + $userstatic->lastname = $task_time->lastname; |
|
| 1016 | 1016 | $userstatic->firstname = $task_time->firstname; |
| 1017 | 1017 | $userstatic->photo = $task_time->photo; |
| 1018 | 1018 | print $userstatic->getNomUrl(-1); |
| 1019 | 1019 | } |
| 1020 | 1020 | print '</td>'; |
| 1021 | - if (! $i) $totalarray['nbfield']++; |
|
| 1021 | + if (!$i) $totalarray['nbfield']++; |
|
| 1022 | 1022 | } |
| 1023 | 1023 | |
| 1024 | 1024 | // Note |
| 1025 | - if (! empty($arrayfields['t.note']['checked'])) |
|
| 1025 | + if (!empty($arrayfields['t.note']['checked'])) |
|
| 1026 | 1026 | { |
| 1027 | 1027 | print '<td align="left">'; |
| 1028 | 1028 | if ($_GET['action'] == 'editline' && $_GET['lineid'] == $task_time->rowid) |
@@ -1034,49 +1034,49 @@ discard block |
||
| 1034 | 1034 | print dol_nl2br($task_time->note); |
| 1035 | 1035 | } |
| 1036 | 1036 | print '</td>'; |
| 1037 | - if (! $i) $totalarray['nbfield']++; |
|
| 1037 | + if (!$i) $totalarray['nbfield']++; |
|
| 1038 | 1038 | } |
| 1039 | 1039 | |
| 1040 | 1040 | // Time spent |
| 1041 | - if (! empty($arrayfields['t.task_duration']['checked'])) |
|
| 1041 | + if (!empty($arrayfields['t.task_duration']['checked'])) |
|
| 1042 | 1042 | { |
| 1043 | 1043 | print '<td align="right">'; |
| 1044 | 1044 | if ($_GET['action'] == 'editline' && $_GET['lineid'] == $task_time->rowid) |
| 1045 | 1045 | { |
| 1046 | 1046 | print '<input type="hidden" name="old_duration" value="'.$task_time->task_duration.'">'; |
| 1047 | - print $form->select_duration('new_duration',$task_time->task_duration,0,'text'); |
|
| 1047 | + print $form->select_duration('new_duration', $task_time->task_duration, 0, 'text'); |
|
| 1048 | 1048 | } |
| 1049 | 1049 | else |
| 1050 | 1050 | { |
| 1051 | - print convertSecondToTime($task_time->task_duration,'allhourmin'); |
|
| 1051 | + print convertSecondToTime($task_time->task_duration, 'allhourmin'); |
|
| 1052 | 1052 | } |
| 1053 | 1053 | print '</td>'; |
| 1054 | - if (! $i) $totalarray['nbfield']++; |
|
| 1055 | - if (! $i) $totalarray['totaldurationfield']=$totalarray['nbfield']; |
|
| 1054 | + if (!$i) $totalarray['nbfield']++; |
|
| 1055 | + if (!$i) $totalarray['totaldurationfield'] = $totalarray['nbfield']; |
|
| 1056 | 1056 | $totalarray['totalduration'] += $task_time->task_duration; |
| 1057 | 1057 | } |
| 1058 | 1058 | |
| 1059 | 1059 | // Value spent |
| 1060 | - if (! empty($arrayfields['value']['checked'])) |
|
| 1060 | + if (!empty($arrayfields['value']['checked'])) |
|
| 1061 | 1061 | { |
| 1062 | 1062 | print '<td align="right">'; |
| 1063 | 1063 | $value = price2num($task_time->thm * $task_time->task_duration / 3600); |
| 1064 | 1064 | print price($value, 1, $langs, 1, -1, -1, $conf->currency); |
| 1065 | 1065 | print '</td>'; |
| 1066 | - if (! $i) $totalarray['nbfield']++; |
|
| 1067 | - if (! $i) $totalarray['totalvaluefield']=$totalarray['nbfield']; |
|
| 1066 | + if (!$i) $totalarray['nbfield']++; |
|
| 1067 | + if (!$i) $totalarray['totalvaluefield'] = $totalarray['nbfield']; |
|
| 1068 | 1068 | $totalarray['totalvalue'] += $value; |
| 1069 | 1069 | } |
| 1070 | 1070 | |
| 1071 | 1071 | // Value billed |
| 1072 | - if (! empty($arrayfields['valuebilled']['checked'])) |
|
| 1072 | + if (!empty($arrayfields['valuebilled']['checked'])) |
|
| 1073 | 1073 | { |
| 1074 | 1074 | print '<td align="right">'; |
| 1075 | 1075 | $valuebilled = price2num($task_time->total_ht); |
| 1076 | 1076 | if (isset($task_time->total_ht)) print price($valuebilled, 1, $langs, 1, -1, -1, $conf->currency); |
| 1077 | 1077 | print '</td>'; |
| 1078 | - if (! $i) $totalarray['nbfield']++; |
|
| 1079 | - if (! $i) $totalarray['totalvaluefield']=$totalarray['nbfield']; |
|
| 1078 | + if (!$i) $totalarray['nbfield']++; |
|
| 1079 | + if (!$i) $totalarray['totalvaluefield'] = $totalarray['nbfield']; |
|
| 1080 | 1080 | $totalarray['totalvaluebilled'] += $valuebilled; |
| 1081 | 1081 | } |
| 1082 | 1082 | |
@@ -1086,8 +1086,8 @@ discard block |
||
| 1086 | 1086 | */ |
| 1087 | 1087 | |
| 1088 | 1088 | // Fields from hook |
| 1089 | - $parameters=array('arrayfields'=>$arrayfields, 'obj'=>$task_time); |
|
| 1090 | - $reshook=$hookmanager->executeHooks('printFieldListValue',$parameters); // Note that $action and $object may have been modified by hook |
|
| 1089 | + $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$task_time); |
|
| 1090 | + $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook |
|
| 1091 | 1091 | print $hookmanager->resPrint; |
| 1092 | 1092 | |
| 1093 | 1093 | // Action column |
@@ -1116,7 +1116,7 @@ discard block |
||
| 1116 | 1116 | } |
| 1117 | 1117 | } |
| 1118 | 1118 | print '</td>'; |
| 1119 | - if (! $i) $totalarray['nbfield']++; |
|
| 1119 | + if (!$i) $totalarray['nbfield']++; |
|
| 1120 | 1120 | |
| 1121 | 1121 | print "</tr>\n"; |
| 1122 | 1122 | |
@@ -1127,7 +1127,7 @@ discard block |
||
| 1127 | 1127 | if (isset($totalarray['totaldurationfield']) || isset($totalarray['totalvaluefield'])) |
| 1128 | 1128 | { |
| 1129 | 1129 | print '<tr class="liste_total">'; |
| 1130 | - $i=0; |
|
| 1130 | + $i = 0; |
|
| 1131 | 1131 | while ($i < $totalarray['nbfield']) |
| 1132 | 1132 | { |
| 1133 | 1133 | $i++; |
@@ -1136,7 +1136,7 @@ discard block |
||
| 1136 | 1136 | if ($num < $limit && empty($offset)) print '<td align="left">'.$langs->trans("Total").'</td>'; |
| 1137 | 1137 | else print '<td align="left">'.$langs->trans("Totalforthispage").'</td>'; |
| 1138 | 1138 | } |
| 1139 | - elseif ($totalarray['totaldurationfield'] == $i) print '<td align="right">'.convertSecondToTime($totalarray['totalduration'],'allhourmin').'</td>'; |
|
| 1139 | + elseif ($totalarray['totaldurationfield'] == $i) print '<td align="right">'.convertSecondToTime($totalarray['totalduration'], 'allhourmin').'</td>'; |
|
| 1140 | 1140 | elseif ($totalarray['totalvaluefield'] == $i) print '<td align="right">'.price($totalarray['totalvalue']).'</td>'; |
| 1141 | 1141 | else print '<td></td>'; |
| 1142 | 1142 | } |
@@ -59,7 +59,9 @@ discard block |
||
| 59 | 59 | // Security check |
| 60 | 60 | $socid=0; |
| 61 | 61 | //if ($user->societe_id > 0) $socid = $user->societe_id; // For external user, no check is done on company because readability is managed by public status of project and assignement. |
| 62 | -if (!$user->rights->projet->lire) accessforbidden(); |
|
| 62 | +if (!$user->rights->projet->lire) { |
|
| 63 | + accessforbidden(); |
|
| 64 | +} |
|
| 63 | 65 | |
| 64 | 66 | $limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; |
| 65 | 67 | $sortfield = GETPOST("sortfield",'alpha'); |
@@ -69,8 +71,12 @@ discard block |
||
| 69 | 71 | $offset = $limit * $page; |
| 70 | 72 | $pageprev = $page - 1; |
| 71 | 73 | $pagenext = $page + 1; |
| 72 | -if (! $sortfield) $sortfield='t.task_date,t.task_datehour,t.rowid'; |
|
| 73 | -if (! $sortorder) $sortorder='DESC'; |
|
| 74 | +if (! $sortfield) { |
|
| 75 | + $sortfield='t.task_date,t.task_datehour,t.rowid'; |
|
| 76 | +} |
|
| 77 | +if (! $sortorder) { |
|
| 78 | + $sortorder='DESC'; |
|
| 79 | +} |
|
| 74 | 80 | |
| 75 | 81 | // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context |
| 76 | 82 | //$object = new TaskTime($db); |
@@ -93,14 +99,18 @@ discard block |
||
| 93 | 99 | |
| 94 | 100 | $parameters=array('socid'=>$socid, 'projectid'=>$projectid); |
| 95 | 101 | $reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks |
| 96 | -if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); |
|
| 102 | +if ($reshook < 0) { |
|
| 103 | + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); |
|
| 104 | +} |
|
| 97 | 105 | |
| 98 | 106 | include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; |
| 99 | 107 | |
| 100 | 108 | // Purge search criteria |
| 101 | -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 |
|
| 109 | +if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') ||GETPOST('button_removefilter','alpha')) { |
|
| 110 | + // All tests are required to be compatible with all browsers |
|
| 102 | 111 | { |
| 103 | 112 | $search_day=''; |
| 113 | +} |
|
| 104 | 114 | $search_month=''; |
| 105 | 115 | $search_year=''; |
| 106 | 116 | $search_date=''; |
@@ -142,8 +152,7 @@ discard block |
||
| 142 | 152 | if ($id || $ref) |
| 143 | 153 | { |
| 144 | 154 | $object->fetch($id, $ref); |
| 145 | - } |
|
| 146 | - else |
|
| 155 | + } else |
|
| 147 | 156 | { |
| 148 | 157 | $object->fetch(GETPOST('taskid','int')); |
| 149 | 158 | } |
@@ -153,19 +162,19 @@ discard block |
||
| 153 | 162 | { |
| 154 | 163 | setEventMessages($langs->trans("ProjectMustBeValidatedFirst"), null, 'errors'); |
| 155 | 164 | $error++; |
| 156 | - } |
|
| 157 | - else |
|
| 165 | + } else |
|
| 158 | 166 | { |
| 159 | 167 | $object->timespent_note = $_POST["timespent_note"]; |
| 160 | 168 | $object->progress = GETPOST('progress', 'int'); |
| 161 | 169 | $object->timespent_duration = $_POST["timespent_durationhour"]*60*60; // We store duration in seconds |
| 162 | 170 | $object->timespent_duration+= $_POST["timespent_durationmin"]*60; // We store duration in seconds |
| 163 | - if (GETPOST("timehour") != '' && GETPOST("timehour") >= 0) // If hour was entered |
|
| 171 | + if (GETPOST("timehour") != '' && GETPOST("timehour") >= 0) { |
|
| 172 | + // If hour was entered |
|
| 164 | 173 | { |
| 165 | 174 | $object->timespent_date = dol_mktime(GETPOST("timehour"),GETPOST("timemin"),0,GETPOST("timemonth"),GETPOST("timeday"),GETPOST("timeyear")); |
| 166 | - $object->timespent_withhour = 1; |
|
| 167 | 175 | } |
| 168 | - else |
|
| 176 | + $object->timespent_withhour = 1; |
|
| 177 | + } else |
|
| 169 | 178 | { |
| 170 | 179 | $object->timespent_date = dol_mktime(12,0,0,GETPOST("timemonth"),GETPOST("timeday"),GETPOST("timeyear")); |
| 171 | 180 | } |
@@ -174,18 +183,19 @@ discard block |
||
| 174 | 183 | if ($result >= 0) |
| 175 | 184 | { |
| 176 | 185 | setEventMessages($langs->trans("RecordSaved"), null, 'mesgs'); |
| 177 | - } |
|
| 178 | - else |
|
| 186 | + } else |
|
| 179 | 187 | { |
| 180 | 188 | setEventMessages($langs->trans($object->error), null, 'errors'); |
| 181 | 189 | $error++; |
| 182 | 190 | } |
| 183 | 191 | } |
| 184 | - } |
|
| 185 | - else |
|
| 192 | + } else |
|
| 186 | 193 | { |
| 187 | - if (empty($id)) $action='createtime'; |
|
| 188 | - else $action='createtime'; |
|
| 194 | + if (empty($id)) { |
|
| 195 | + $action='createtime'; |
|
| 196 | + } else { |
|
| 197 | + $action='createtime'; |
|
| 198 | + } |
|
| 189 | 199 | } |
| 190 | 200 | } |
| 191 | 201 | |
@@ -209,12 +219,13 @@ discard block |
||
| 209 | 219 | $object->timespent_old_duration = $_POST["old_duration"]; |
| 210 | 220 | $object->timespent_duration = $_POST["new_durationhour"]*60*60; // We store duration in seconds |
| 211 | 221 | $object->timespent_duration+= $_POST["new_durationmin"]*60; // We store duration in seconds |
| 212 | - if (GETPOST("timelinehour") != '' && GETPOST("timelinehour") >= 0) // If hour was entered |
|
| 222 | + if (GETPOST("timelinehour") != '' && GETPOST("timelinehour") >= 0) { |
|
| 223 | + // If hour was entered |
|
| 213 | 224 | { |
| 214 | 225 | $object->timespent_date = dol_mktime(GETPOST("timelinehour"),GETPOST("timelinemin"),0,GETPOST("timelinemonth"),GETPOST("timelineday"),GETPOST("timelineyear")); |
| 215 | - $object->timespent_withhour = 1; |
|
| 216 | 226 | } |
| 217 | - else |
|
| 227 | + $object->timespent_withhour = 1; |
|
| 228 | + } else |
|
| 218 | 229 | { |
| 219 | 230 | $object->timespent_date = dol_mktime(12,0,0,GETPOST("timelinemonth"),GETPOST("timelineday"),GETPOST("timelineyear")); |
| 220 | 231 | } |
@@ -224,14 +235,12 @@ discard block |
||
| 224 | 235 | if ($result >= 0) |
| 225 | 236 | { |
| 226 | 237 | setEventMessages($langs->trans("RecordSaved"), null, 'mesgs'); |
| 227 | - } |
|
| 228 | - else |
|
| 238 | + } else |
|
| 229 | 239 | { |
| 230 | 240 | setEventMessages($langs->trans($object->error), null, 'errors'); |
| 231 | 241 | $error++; |
| 232 | 242 | } |
| 233 | - } |
|
| 234 | - else |
|
| 243 | + } else |
|
| 235 | 244 | { |
| 236 | 245 | $action=''; |
| 237 | 246 | } |
@@ -249,8 +258,7 @@ discard block |
||
| 249 | 258 | setEventMessages($langs->trans($object->error), null, 'errors'); |
| 250 | 259 | $error++; |
| 251 | 260 | $action=''; |
| 252 | - } |
|
| 253 | - else |
|
| 261 | + } else |
|
| 254 | 262 | { |
| 255 | 263 | setEventMessages($langs->trans("RecordDeleted"), null, 'mesgs'); |
| 256 | 264 | } |
@@ -265,8 +273,7 @@ discard block |
||
| 265 | 273 | if (count($tasksarray) > 0) |
| 266 | 274 | { |
| 267 | 275 | $id=$tasksarray[0]->id; |
| 268 | - } |
|
| 269 | - else |
|
| 276 | + } else |
|
| 270 | 277 | { |
| 271 | 278 | header("Location: ".DOL_URL_ROOT.'/projet/tasks.php?id='.$projectstatic->id.($withproject?'&withproject=1':'').(empty($mode)?'':'&mode='.$mode)); |
| 272 | 279 | exit; |
@@ -301,13 +308,16 @@ discard block |
||
| 301 | 308 | if ($projectidforalltimes) |
| 302 | 309 | { |
| 303 | 310 | $result=$projectstatic->fetch($projectidforalltimes); |
| 304 | - if (! empty($projectstatic->socid)) $projectstatic->fetch_thirdparty(); |
|
| 311 | + if (! empty($projectstatic->socid)) { |
|
| 312 | + $projectstatic->fetch_thirdparty(); |
|
| 313 | + } |
|
| 305 | 314 | $res=$projectstatic->fetch_optionals(); |
| 306 | - } |
|
| 307 | - elseif ($object->fetch($id, $ref) >= 0) |
|
| 315 | + } elseif ($object->fetch($id, $ref) >= 0) |
|
| 308 | 316 | { |
| 309 | 317 | $result=$projectstatic->fetch($object->fk_project); |
| 310 | - if (! empty($projectstatic->socid)) $projectstatic->fetch_thirdparty(); |
|
| 318 | + if (! empty($projectstatic->socid)) { |
|
| 319 | + $projectstatic->fetch_thirdparty(); |
|
| 320 | + } |
|
| 311 | 321 | $res=$projectstatic->fetch_optionals(); |
| 312 | 322 | |
| 313 | 323 | $object->project = clone $projectstatic; |
@@ -320,8 +330,11 @@ discard block |
||
| 320 | 330 | if ($withproject) |
| 321 | 331 | { |
| 322 | 332 | // Tabs for project |
| 323 | - if (empty($id)) $tab='timespent'; |
|
| 324 | - else $tab='tasks'; |
|
| 333 | + if (empty($id)) { |
|
| 334 | + $tab='timespent'; |
|
| 335 | + } else { |
|
| 336 | + $tab='tasks'; |
|
| 337 | + } |
|
| 325 | 338 | $head=project_prepare_head($projectstatic); |
| 326 | 339 | dol_fiche_head($head, $tab, $langs->trans("Project"), -1, ($projectstatic->public?'projectpub':'project')); |
| 327 | 340 | |
@@ -358,8 +371,11 @@ discard block |
||
| 358 | 371 | |
| 359 | 372 | // Visibility |
| 360 | 373 | print '<tr><td class="titlefield">'.$langs->trans("Visibility").'</td><td>'; |
| 361 | - if ($projectstatic->public) print $langs->trans('SharedProject'); |
|
| 362 | - else print $langs->trans('PrivateProject'); |
|
| 374 | + if ($projectstatic->public) { |
|
| 375 | + print $langs->trans('SharedProject'); |
|
| 376 | + } else { |
|
| 377 | + print $langs->trans('PrivateProject'); |
|
| 378 | + } |
|
| 363 | 379 | print '</td></tr>'; |
| 364 | 380 | |
| 365 | 381 | // Date start - end |
@@ -369,12 +385,16 @@ discard block |
||
| 369 | 385 | $end = dol_print_date($projectstatic->date_end,'day'); |
| 370 | 386 | print ' - '; |
| 371 | 387 | print ($end?$end:'?'); |
| 372 | - if ($projectstatic->hasDelay()) print img_warning("Late"); |
|
| 388 | + if ($projectstatic->hasDelay()) { |
|
| 389 | + print img_warning("Late"); |
|
| 390 | + } |
|
| 373 | 391 | print '</td></tr>'; |
| 374 | 392 | |
| 375 | 393 | // Budget |
| 376 | 394 | print '<tr><td>'.$langs->trans("Budget").'</td><td>'; |
| 377 | - if (strcmp($projectstatic->budget_amount, '')) print price($projectstatic->budget_amount,'',$langs,1,0,0,$conf->currency); |
|
| 395 | + if (strcmp($projectstatic->budget_amount, '')) { |
|
| 396 | + print price($projectstatic->budget_amount,'',$langs,1,0,0,$conf->currency); |
|
| 397 | + } |
|
| 378 | 398 | print '</td></tr>'; |
| 379 | 399 | |
| 380 | 400 | // Other attributes |
@@ -422,13 +442,11 @@ discard block |
||
| 422 | 442 | if ($projectstatic->public || $userWrite > 0) |
| 423 | 443 | { |
| 424 | 444 | $linktocreatetime = '<a class="butActionNew" href="'.$_SERVER['PHP_SELF'].'?withproject=1'.($object->id > 0 ? '&id='.$object->id : '&projectid='.$projectstatic->id).'&action=createtime'.$param.'&backtopage='.urlencode($_SERVER['PHP_SELF'].'?id='.$object->id).'">'.$langs->trans('AddTimeSpent').'<span class="fa fa-plus-circle valignmiddle"></span></a>'; |
| 425 | - } |
|
| 426 | - else |
|
| 445 | + } else |
|
| 427 | 446 | { |
| 428 | 447 | $linktocreatetime = '<a class="butActionNewRefused" href="#" title="'.$langs->trans("NotOwnerOfProject").'">'.$langs->trans('AddTime').'<span class="fa fa-plus-circle valignmiddle"></span></a>'; |
| 429 | 448 | } |
| 430 | - } |
|
| 431 | - else |
|
| 449 | + } else |
|
| 432 | 450 | { |
| 433 | 451 | $linktocreatetime = '<a class="butActionNewRefused" href="#" title="'.$langs->trans("NotEnoughPermissions").'">'.$langs->trans('AddTime').'<span class="fa fa-plus-circle valignmiddle"></span></a>'; |
| 434 | 452 | } |
@@ -453,8 +471,9 @@ discard block |
||
| 453 | 471 | { |
| 454 | 472 | $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user,0,1); |
| 455 | 473 | $object->next_prev_filter=" fk_projet in (".$projectsListId.")"; |
| 474 | + } else { |
|
| 475 | + $object->next_prev_filter=" fk_projet = ".$projectstatic->id; |
|
| 456 | 476 | } |
| 457 | - else $object->next_prev_filter=" fk_projet = ".$projectstatic->id; |
|
| 458 | 477 | |
| 459 | 478 | $morehtmlref=''; |
| 460 | 479 | |
@@ -489,7 +508,9 @@ discard block |
||
| 489 | 508 | $end = dol_print_date($object->date_end,'dayhour'); |
| 490 | 509 | print ' - '; |
| 491 | 510 | print ($end?$end:'?'); |
| 492 | - if ($object->hasDelay()) print img_warning("Late"); |
|
| 511 | + if ($object->hasDelay()) { |
|
| 512 | + print img_warning("Late"); |
|
| 513 | + } |
|
| 493 | 514 | print '</td></tr>'; |
| 494 | 515 | |
| 495 | 516 | // Planned workload |
@@ -515,10 +536,14 @@ discard block |
||
| 515 | 536 | if ($object->planned_workload) |
| 516 | 537 | { |
| 517 | 538 | $tmparray=$object->getSummaryOfTimeSpent(); |
| 518 | - if ($tmparray['total_duration'] > 0) print round($tmparray['total_duration']/$object->planned_workload*100, 2).' %'; |
|
| 519 | - else print '0 %'; |
|
| 539 | + if ($tmparray['total_duration'] > 0) { |
|
| 540 | + print round($tmparray['total_duration']/$object->planned_workload*100, 2).' %'; |
|
| 541 | + } else { |
|
| 542 | + print '0 %'; |
|
| 543 | + } |
|
| 544 | + } else { |
|
| 545 | + print '<span class="opacitymedium">'.$langs->trans("WorkloadNotDefined").'</span>'; |
|
| 520 | 546 | } |
| 521 | - else print '<span class="opacitymedium">'.$langs->trans("WorkloadNotDefined").'</span>'; |
|
| 522 | 547 | print '</td></tr>'; |
| 523 | 548 | |
| 524 | 549 | print '</table>'; |
@@ -579,8 +604,7 @@ discard block |
||
| 579 | 604 | { |
| 580 | 605 | $userid=$contactsoftask[0]; |
| 581 | 606 | print $form->select_dolusers((GETPOST('userid')?GETPOST('userid'):$userid), 'userid', 0, '', 0, '', $contactsoftask, 0, 0, 0, '', 0, $langs->trans("ResourceNotAssignedToTheTask"), 'maxwidth200'); |
| 582 | - } |
|
| 583 | - else |
|
| 607 | + } else |
|
| 584 | 608 | { |
| 585 | 609 | print img_error($langs->trans('FirstAddRessourceToAllocateTime')).$langs->trans('FirstAddRessourceToAllocateTime'); |
| 586 | 610 | } |
@@ -630,9 +654,11 @@ discard block |
||
| 630 | 654 | // Definition of fields for list |
| 631 | 655 | $arrayfields=array(); |
| 632 | 656 | $arrayfields['t.task_date']=array('label'=>$langs->trans("Date"), 'checked'=>1); |
| 633 | - if ((empty($id) && empty($ref)) || ! empty($projectidforalltimes)) // Not a dedicated task |
|
| 657 | + if ((empty($id) && empty($ref)) || ! empty($projectidforalltimes)) { |
|
| 658 | + // Not a dedicated task |
|
| 634 | 659 | { |
| 635 | 660 | $arrayfields['t.task_ref']=array('label'=>$langs->trans("RefTask"), 'checked'=>1); |
| 661 | + } |
|
| 636 | 662 | $arrayfields['t.task_label']=array('label'=>$langs->trans("LabelTask"), 'checked'=>1); |
| 637 | 663 | } |
| 638 | 664 | $arrayfields['author']=array('label'=>$langs->trans("By"), 'checked'=>1); |
@@ -645,7 +671,9 @@ discard block |
||
| 645 | 671 | { |
| 646 | 672 | foreach($extrafields->attribute_label as $key => $val) |
| 647 | 673 | { |
| 648 | - if (! empty($extrafields->attribute_list[$key])) $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>(($extrafields->attribute_list[$key]<0)?0:1), 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>(abs($extrafields->attribute_list[$key])!=3 && $extrafields->attribute_perms[$key])); |
|
| 674 | + if (! empty($extrafields->attribute_list[$key])) { |
|
| 675 | + $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>(($extrafields->attribute_list[$key]<0)?0:1), 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>(abs($extrafields->attribute_list[$key])!=3 && $extrafields->attribute_perms[$key])); |
|
| 676 | + } |
|
| 649 | 677 | } |
| 650 | 678 | } |
| 651 | 679 | |
@@ -662,23 +690,36 @@ discard block |
||
| 662 | 690 | $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."facturedet as il ON il.rowid = t.invoice_line_id"; |
| 663 | 691 | $sql .= ", ".MAIN_DB_PREFIX."projet_task as pt, ".MAIN_DB_PREFIX."user as u"; |
| 664 | 692 | $sql .= " WHERE t.fk_user = u.rowid AND t.fk_task = pt.rowid"; |
| 665 | - if (empty($projectidforalltimes)) $sql .= " AND t.fk_task =".$object->id; |
|
| 666 | - else $sql.= " AND pt.fk_projet IN (".$projectidforalltimes.")"; |
|
| 667 | - if ($search_ref) $sql .= natural_search('c.ref', $search_ref); |
|
| 668 | - if ($search_note) $sql .= natural_search('t.note', $search_note); |
|
| 669 | - if ($search_task_ref) $sql .= natural_search('pt.ref', $search_task_ref); |
|
| 670 | - if ($search_task_label) $sql .= natural_search('pt.label', $search_task_label); |
|
| 671 | - if ($search_user > 0) $sql .= natural_search('t.fk_user', $search_user); |
|
| 693 | + if (empty($projectidforalltimes)) { |
|
| 694 | + $sql .= " AND t.fk_task =".$object->id; |
|
| 695 | + } else { |
|
| 696 | + $sql.= " AND pt.fk_projet IN (".$projectidforalltimes.")"; |
|
| 697 | + } |
|
| 698 | + if ($search_ref) { |
|
| 699 | + $sql .= natural_search('c.ref', $search_ref); |
|
| 700 | + } |
|
| 701 | + if ($search_note) { |
|
| 702 | + $sql .= natural_search('t.note', $search_note); |
|
| 703 | + } |
|
| 704 | + if ($search_task_ref) { |
|
| 705 | + $sql .= natural_search('pt.ref', $search_task_ref); |
|
| 706 | + } |
|
| 707 | + if ($search_task_label) { |
|
| 708 | + $sql .= natural_search('pt.label', $search_task_label); |
|
| 709 | + } |
|
| 710 | + if ($search_user > 0) { |
|
| 711 | + $sql .= natural_search('t.fk_user', $search_user); |
|
| 712 | + } |
|
| 672 | 713 | if ($search_month > 0) |
| 673 | 714 | { |
| 674 | - if ($search_year > 0 && empty($search_day)) |
|
| 675 | - $sql.= " AND t.task_datehour BETWEEN '".$db->idate(dol_get_first_day($search_year,$search_month,false))."' AND '".$db->idate(dol_get_last_day($search_year,$search_month,false))."'"; |
|
| 676 | - else if ($search_year > 0 && ! empty($search_day)) |
|
| 677 | - $sql.= " AND t.task_datehour BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $search_month, $search_day, $search_year))."' AND '".$db->idate(dol_mktime(23, 59, 59, $search_month, $search_day, $search_year))."'"; |
|
| 678 | - else |
|
| 679 | - $sql.= " AND date_format(t.task_datehour, '%m') = '".$db->escape($search_month)."'"; |
|
| 680 | - } |
|
| 681 | - else if ($search_year > 0) |
|
| 715 | + if ($search_year > 0 && empty($search_day)) { |
|
| 716 | + $sql.= " AND t.task_datehour BETWEEN '".$db->idate(dol_get_first_day($search_year,$search_month,false))."' AND '".$db->idate(dol_get_last_day($search_year,$search_month,false))."'"; |
|
| 717 | + } else if ($search_year > 0 && ! empty($search_day)) { |
|
| 718 | + $sql.= " AND t.task_datehour BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $search_month, $search_day, $search_year))."' AND '".$db->idate(dol_mktime(23, 59, 59, $search_month, $search_day, $search_year))."'"; |
|
| 719 | + } else { |
|
| 720 | + $sql.= " AND date_format(t.task_datehour, '%m') = '".$db->escape($search_month)."'"; |
|
| 721 | + } |
|
| 722 | + } else if ($search_year > 0) |
|
| 682 | 723 | { |
| 683 | 724 | $sql.= " AND t.task_datehour BETWEEN '".$db->idate(dol_get_first_day($search_year,1,false))."' AND '".$db->idate(dol_get_last_day($search_year,12,false))."'"; |
| 684 | 725 | } |
@@ -709,8 +750,7 @@ discard block |
||
| 709 | 750 | $i++; |
| 710 | 751 | } |
| 711 | 752 | $db->free($resql); |
| 712 | - } |
|
| 713 | - else |
|
| 753 | + } else |
|
| 714 | 754 | { |
| 715 | 755 | dol_print_error($db); |
| 716 | 756 | } |
@@ -760,12 +800,16 @@ discard block |
||
| 760 | 800 | $contactsofproject=$projectstatic->getListContactId('internal'); |
| 761 | 801 | if (count($contactsofproject)>0) |
| 762 | 802 | { |
| 763 | - if (in_array($user->id, $userid=$contactsofproject)) $userid = $user->id; |
|
| 764 | - else $userid=$contactsofproject[0]; |
|
| 765 | - if ($projectstatic->public) $contactsofproject = array(); |
|
| 803 | + if (in_array($user->id, $userid=$contactsofproject)) { |
|
| 804 | + $userid = $user->id; |
|
| 805 | + } else { |
|
| 806 | + $userid=$contactsofproject[0]; |
|
| 807 | + } |
|
| 808 | + if ($projectstatic->public) { |
|
| 809 | + $contactsofproject = array(); |
|
| 810 | + } |
|
| 766 | 811 | print $form->select_dolusers((GETPOST('userid')?GETPOST('userid'):$userid), 'userid', 0, '', 0, '', $contactsofproject, 0, 0, 0, '', 0, $langs->trans("ResourceNotAssignedToProject"), 'maxwidth200'); |
| 767 | - } |
|
| 768 | - else |
|
| 812 | + } else |
|
| 769 | 813 | { |
| 770 | 814 | print img_error($langs->trans('FirstAddRessourceToAllocateTime')).$langs->trans('FirstAddRessourceToAllocateTime'); |
| 771 | 815 | } |
@@ -801,23 +845,49 @@ discard block |
||
| 801 | 845 | $arrayofselected=is_array($toselect)?$toselect:array(); |
| 802 | 846 | |
| 803 | 847 | $param=''; |
| 804 | - if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; |
|
| 805 | - if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; |
|
| 806 | - if ($search_month > 0) $param.= '&search_month='.urlencode($search_month); |
|
| 807 | - if ($search_year > 0) $param.= '&search_year='.urlencode($search_year); |
|
| 808 | - if ($search_user > 0) $param.= '&search_user='.urlencode($search_user); |
|
| 809 | - if ($search_task_ref != '') $param.= '&search_task_ref='.urlencode($search_task_ref); |
|
| 810 | - if ($search_task_label != '') $param.= '&search_task_label='.urlencode($search_task_label); |
|
| 811 | - if ($search_note != '') $param.= '&search_note='.urlencode($search_note); |
|
| 812 | - if ($search_duration != '') $param.= '&search_field2='.urlencode($search_duration); |
|
| 813 | - if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss); |
|
| 848 | + if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { |
|
| 849 | + $param.='&contextpage='.$contextpage; |
|
| 850 | + } |
|
| 851 | + if ($limit > 0 && $limit != $conf->liste_limit) { |
|
| 852 | + $param.='&limit='.$limit; |
|
| 853 | + } |
|
| 854 | + if ($search_month > 0) { |
|
| 855 | + $param.= '&search_month='.urlencode($search_month); |
|
| 856 | + } |
|
| 857 | + if ($search_year > 0) { |
|
| 858 | + $param.= '&search_year='.urlencode($search_year); |
|
| 859 | + } |
|
| 860 | + if ($search_user > 0) { |
|
| 861 | + $param.= '&search_user='.urlencode($search_user); |
|
| 862 | + } |
|
| 863 | + if ($search_task_ref != '') { |
|
| 864 | + $param.= '&search_task_ref='.urlencode($search_task_ref); |
|
| 865 | + } |
|
| 866 | + if ($search_task_label != '') { |
|
| 867 | + $param.= '&search_task_label='.urlencode($search_task_label); |
|
| 868 | + } |
|
| 869 | + if ($search_note != '') { |
|
| 870 | + $param.= '&search_note='.urlencode($search_note); |
|
| 871 | + } |
|
| 872 | + if ($search_duration != '') { |
|
| 873 | + $param.= '&search_field2='.urlencode($search_duration); |
|
| 874 | + } |
|
| 875 | + if ($optioncss != '') { |
|
| 876 | + $param.='&optioncss='.urlencode($optioncss); |
|
| 877 | + } |
|
| 814 | 878 | /* |
| 815 | 879 | // Add $param from extra fields |
| 816 | 880 | include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; |
| 817 | 881 | */ |
| 818 | - if ($id) $param.='&id='.urlencode($id); |
|
| 819 | - if ($projectid) $param.='&projectid='.urlencode($projectid); |
|
| 820 | - if ($withproject) $param.='&withproject='.urlencode($withproject); |
|
| 882 | + if ($id) { |
|
| 883 | + $param.='&id='.urlencode($id); |
|
| 884 | + } |
|
| 885 | + if ($projectid) { |
|
| 886 | + $param.='&projectid='.urlencode($projectid); |
|
| 887 | + } |
|
| 888 | + if ($withproject) { |
|
| 889 | + $param.='&withproject='.urlencode($withproject); |
|
| 890 | + } |
|
| 821 | 891 | |
| 822 | 892 | |
| 823 | 893 | $arrayofmassactions = array( |
@@ -825,16 +895,23 @@ discard block |
||
| 825 | 895 | //'builddoc'=>$langs->trans("PDFMerge"), |
| 826 | 896 | ); |
| 827 | 897 | //if ($user->rights->projet->creer) $arrayofmassactions['predelete']=$langs->trans("Delete"); |
| 828 | - if (in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array(); |
|
| 898 | + if (in_array($massaction, array('presend','predelete'))) { |
|
| 899 | + $arrayofmassactions=array(); |
|
| 900 | + } |
|
| 829 | 901 | $massactionbutton=$form->selectMassAction('', $arrayofmassactions); |
| 830 | 902 | |
| 831 | 903 | |
| 832 | 904 | print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'?id='.$id.'">'; |
| 833 | - if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">'; |
|
| 905 | + if ($optioncss != '') { |
|
| 906 | + print '<input type="hidden" name="optioncss" value="'.$optioncss.'">'; |
|
| 907 | + } |
|
| 834 | 908 | print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
| 835 | 909 | print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">'; |
| 836 | - if ($action == 'editline') print '<input type="hidden" name="action" value="updateline">'; |
|
| 837 | - else print '<input type="hidden" name="action" value="list">'; |
|
| 910 | + if ($action == 'editline') { |
|
| 911 | + print '<input type="hidden" name="action" value="updateline">'; |
|
| 912 | + } else { |
|
| 913 | + print '<input type="hidden" name="action" value="list">'; |
|
| 914 | + } |
|
| 838 | 915 | print '<input type="hidden" name="sortfield" value="'.$sortfield.'">'; |
| 839 | 916 | print '<input type="hidden" name="sortorder" value="'.$sortorder.'">'; |
| 840 | 917 | print '<input type="hidden" name="page" value="'.$page.'">'; |
@@ -847,8 +924,11 @@ discard block |
||
| 847 | 924 | |
| 848 | 925 | $parameters=array(); |
| 849 | 926 | $reshook=$hookmanager->executeHooks('printFieldPreListTitle',$parameters); // Note that $action and $object may have been modified by hook |
| 850 | - if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint; |
|
| 851 | - else $moreforfilter = $hookmanager->resPrint; |
|
| 927 | + if (empty($reshook)) { |
|
| 928 | + $moreforfilter .= $hookmanager->resPrint; |
|
| 929 | + } else { |
|
| 930 | + $moreforfilter = $hookmanager->resPrint; |
|
| 931 | + } |
|
| 852 | 932 | |
| 853 | 933 | if (! empty($moreforfilter)) |
| 854 | 934 | { |
@@ -869,26 +949,42 @@ discard block |
||
| 869 | 949 | if (! empty($arrayfields['t.task_date']['checked'])) |
| 870 | 950 | { |
| 871 | 951 | print '<td class="liste_titre">'; |
| 872 | - if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print '<input class="flat valignmiddle" type="text" size="1" maxlength="2" name="search_day" value="'.$search_day.'">'; |
|
| 952 | + if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) { |
|
| 953 | + print '<input class="flat valignmiddle" type="text" size="1" maxlength="2" name="search_day" value="'.$search_day.'">'; |
|
| 954 | + } |
|
| 873 | 955 | print '<input class="flat valignmiddle" type="text" size="1" maxlength="2" name="search_month" value="'.$search_month.'">'; |
| 874 | 956 | $formother->select_year($search_year,'search_year',1, 20, 5); |
| 875 | 957 | print '</td>'; |
| 876 | 958 | } |
| 877 | - if ((empty($id) && empty($ref)) || ! empty($projectidforalltimes)) // Not a dedicated task |
|
| 959 | + if ((empty($id) && empty($ref)) || ! empty($projectidforalltimes)) { |
|
| 960 | + // Not a dedicated task |
|
| 878 | 961 | { |
| 879 | 962 | if (! empty($arrayfields['t.task_ref']['checked'])) print '<td class="liste_titre"><input type="text" class="flat maxwidth100" name="search_task_ref" value="'.dol_escape_htmltag($search_task_ref).'"></td>'; |
| 880 | - if (! empty($arrayfields['t.task_label']['checked'])) print '<td class="liste_titre"><input type="text" class="flat maxwidth100" name="search_task_label" value="'.dol_escape_htmltag($search_task_label).'"></td>'; |
|
| 963 | + } |
|
| 964 | + if (! empty($arrayfields['t.task_label']['checked'])) { |
|
| 965 | + print '<td class="liste_titre"><input type="text" class="flat maxwidth100" name="search_task_label" value="'.dol_escape_htmltag($search_task_label).'"></td>'; |
|
| 966 | + } |
|
| 881 | 967 | } |
| 882 | 968 | // Author |
| 883 | - if (! empty($arrayfields['author']['checked'])) print '<td class="liste_titre">'.$form->select_dolusers(($search_user > 0 ? $search_user : -1), 'search_user', 1, null, 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth200').'</td>'; |
|
| 969 | + if (! empty($arrayfields['author']['checked'])) { |
|
| 970 | + print '<td class="liste_titre">'.$form->select_dolusers(($search_user > 0 ? $search_user : -1), 'search_user', 1, null, 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth200').'</td>'; |
|
| 971 | + } |
|
| 884 | 972 | // Note |
| 885 | - if (! empty($arrayfields['t.note']['checked'])) print '<td class="liste_titre"><input type="text" class="flat maxwidth100" name="search_note" value="'.dol_escape_htmltag($search_note).'"></td>'; |
|
| 973 | + if (! empty($arrayfields['t.note']['checked'])) { |
|
| 974 | + print '<td class="liste_titre"><input type="text" class="flat maxwidth100" name="search_note" value="'.dol_escape_htmltag($search_note).'"></td>'; |
|
| 975 | + } |
|
| 886 | 976 | // Duration |
| 887 | - if (! empty($arrayfields['t.task_duration']['checked'])) print '<td class="liste_titre right"></td>'; |
|
| 977 | + if (! empty($arrayfields['t.task_duration']['checked'])) { |
|
| 978 | + print '<td class="liste_titre right"></td>'; |
|
| 979 | + } |
|
| 888 | 980 | // Value in main currency |
| 889 | - if (! empty($arrayfields['value']['checked'])) print '<td class="liste_titre"></td>'; |
|
| 981 | + if (! empty($arrayfields['value']['checked'])) { |
|
| 982 | + print '<td class="liste_titre"></td>'; |
|
| 983 | + } |
|
| 890 | 984 | // Value billed |
| 891 | - if (! empty($arrayfields['valuebilled']['checked'])) print '<td class="liste_titre"></td>'; |
|
| 985 | + if (! empty($arrayfields['valuebilled']['checked'])) { |
|
| 986 | + print '<td class="liste_titre"></td>'; |
|
| 987 | + } |
|
| 892 | 988 | /* |
| 893 | 989 | // Extra fields |
| 894 | 990 | include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; |
@@ -905,17 +1001,33 @@ discard block |
||
| 905 | 1001 | print '</tr>'."\n"; |
| 906 | 1002 | |
| 907 | 1003 | print '<tr class="liste_titre">'; |
| 908 | - if (! empty($arrayfields['t.task_date']['checked'])) print_liste_field_titre($arrayfields['t.task_date']['label'],$_SERVER['PHP_SELF'],'t.task_date,t.task_datehour,t.rowid','',$param,'',$sortfield,$sortorder); |
|
| 909 | - if ((empty($id) && empty($ref)) || ! empty($projectidforalltimes)) // Not a dedicated task |
|
| 1004 | + if (! empty($arrayfields['t.task_date']['checked'])) { |
|
| 1005 | + print_liste_field_titre($arrayfields['t.task_date']['label'],$_SERVER['PHP_SELF'],'t.task_date,t.task_datehour,t.rowid','',$param,'',$sortfield,$sortorder); |
|
| 1006 | + } |
|
| 1007 | + if ((empty($id) && empty($ref)) || ! empty($projectidforalltimes)) { |
|
| 1008 | + // Not a dedicated task |
|
| 910 | 1009 | { |
| 911 | 1010 | if (! empty($arrayfields['t.task_ref']['checked'])) print_liste_field_titre($arrayfields['t.task_ref']['label'],$_SERVER['PHP_SELF'],'pt.ref','',$param,'',$sortfield,$sortorder); |
| 912 | - if (! empty($arrayfields['t.task_label']['checked'])) print_liste_field_titre($arrayfields['t.task_label']['label'],$_SERVER['PHP_SELF'],'pt.label','',$param,'',$sortfield,$sortorder); |
|
| 1011 | + } |
|
| 1012 | + if (! empty($arrayfields['t.task_label']['checked'])) { |
|
| 1013 | + print_liste_field_titre($arrayfields['t.task_label']['label'],$_SERVER['PHP_SELF'],'pt.label','',$param,'',$sortfield,$sortorder); |
|
| 1014 | + } |
|
| 1015 | + } |
|
| 1016 | + if (! empty($arrayfields['author']['checked'])) { |
|
| 1017 | + print_liste_field_titre($arrayfields['author']['label'],$_SERVER['PHP_SELF'],'','',$param,'',$sortfield,$sortorder); |
|
| 913 | 1018 | } |
| 914 | - if (! empty($arrayfields['author']['checked'])) print_liste_field_titre($arrayfields['author']['label'],$_SERVER['PHP_SELF'],'','',$param,'',$sortfield,$sortorder); |
|
| 915 | - if (! empty($arrayfields['t.note']['checked'])) print_liste_field_titre($arrayfields['t.note']['label'],$_SERVER['PHP_SELF'],'t.note','',$param,'',$sortfield,$sortorder); |
|
| 916 | - if (! empty($arrayfields['t.task_duration']['checked'])) print_liste_field_titre($arrayfields['t.task_duration']['label'],$_SERVER['PHP_SELF'],'t.task_duration','',$param,'align="right"',$sortfield,$sortorder); |
|
| 917 | - if (! empty($arrayfields['value']['checked'])) print_liste_field_titre($arrayfields['value']['label'],$_SERVER['PHP_SELF'],'','',$param,'align="right"',$sortfield,$sortorder); |
|
| 918 | - if (! empty($arrayfields['valuebilled']['checked'])) print_liste_field_titre($arrayfields['valuebilled']['label'],$_SERVER['PHP_SELF'],'il.total_ht','',$param,'align="right"',$sortfield,$sortorder); |
|
| 1019 | + if (! empty($arrayfields['t.note']['checked'])) { |
|
| 1020 | + print_liste_field_titre($arrayfields['t.note']['label'],$_SERVER['PHP_SELF'],'t.note','',$param,'',$sortfield,$sortorder); |
|
| 1021 | + } |
|
| 1022 | + if (! empty($arrayfields['t.task_duration']['checked'])) { |
|
| 1023 | + print_liste_field_titre($arrayfields['t.task_duration']['label'],$_SERVER['PHP_SELF'],'t.task_duration','',$param,'align="right"',$sortfield,$sortorder); |
|
| 1024 | + } |
|
| 1025 | + if (! empty($arrayfields['value']['checked'])) { |
|
| 1026 | + print_liste_field_titre($arrayfields['value']['label'],$_SERVER['PHP_SELF'],'','',$param,'align="right"',$sortfield,$sortorder); |
|
| 1027 | + } |
|
| 1028 | + if (! empty($arrayfields['valuebilled']['checked'])) { |
|
| 1029 | + print_liste_field_titre($arrayfields['valuebilled']['label'],$_SERVER['PHP_SELF'],'il.total_ht','',$param,'align="right"',$sortfield,$sortorder); |
|
| 1030 | + } |
|
| 919 | 1031 | /* |
| 920 | 1032 | // Extra fields |
| 921 | 1033 | include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; |
@@ -953,41 +1065,51 @@ discard block |
||
| 953 | 1065 | if (empty($task_time->task_date_withhour)) |
| 954 | 1066 | { |
| 955 | 1067 | print $form->select_date(($date2?$date2:$date1),'timeline',3,3,2,"timespent_date",1,0,1); |
| 1068 | + } else { |
|
| 1069 | + print $form->select_date(($date2?$date2:$date1),'timeline',1,1,2,"timespent_date",1,0,1); |
|
| 956 | 1070 | } |
| 957 | - else print $form->select_date(($date2?$date2:$date1),'timeline',1,1,2,"timespent_date",1,0,1); |
|
| 958 | - } |
|
| 959 | - else |
|
| 1071 | + } else |
|
| 960 | 1072 | { |
| 961 | 1073 | print dol_print_date(($date2?$date2:$date1),($task_time->task_date_withhour?'dayhour':'day')); |
| 962 | 1074 | } |
| 963 | 1075 | print '</td>'; |
| 964 | - if (! $i) $totalarray['nbfield']++; |
|
| 1076 | + if (! $i) { |
|
| 1077 | + $totalarray['nbfield']++; |
|
| 1078 | + } |
|
| 965 | 1079 | } |
| 966 | 1080 | |
| 967 | 1081 | // Task ref |
| 968 | 1082 | if (! empty($arrayfields['t.task_ref']['checked'])) |
| 969 | 1083 | { |
| 970 | - if ((empty($id) && empty($ref)) || ! empty($projectidforalltimes)) // Not a dedicated task |
|
| 1084 | + if ((empty($id) && empty($ref)) || ! empty($projectidforalltimes)) { |
|
| 1085 | + // Not a dedicated task |
|
| 971 | 1086 | { |
| 972 | 1087 | print '<td class="nowrap">'; |
| 1088 | + } |
|
| 973 | 1089 | $tasktmp->id = $task_time->fk_task; |
| 974 | 1090 | $tasktmp->ref = $task_time->ref; |
| 975 | 1091 | $tasktmp->label = $task_time->label; |
| 976 | 1092 | print $tasktmp->getNomUrl(1, 'withproject', 'time'); |
| 977 | 1093 | print '</td>'; |
| 978 | - if (! $i) $totalarray['nbfield']++; |
|
| 1094 | + if (! $i) { |
|
| 1095 | + $totalarray['nbfield']++; |
|
| 1096 | + } |
|
| 979 | 1097 | } |
| 980 | 1098 | } |
| 981 | 1099 | |
| 982 | 1100 | // Task label |
| 983 | 1101 | if (! empty($arrayfields['t.task_label']['checked'])) |
| 984 | 1102 | { |
| 985 | - if ((empty($id) && empty($ref)) || ! empty($projectidforalltimes)) // Not a dedicated task |
|
| 1103 | + if ((empty($id) && empty($ref)) || ! empty($projectidforalltimes)) { |
|
| 1104 | + // Not a dedicated task |
|
| 986 | 1105 | { |
| 987 | 1106 | print '<td class="nowrap">'; |
| 1107 | + } |
|
| 988 | 1108 | print $task_time->label; |
| 989 | 1109 | print '</td>'; |
| 990 | - if (! $i) $totalarray['nbfield']++; |
|
| 1110 | + if (! $i) { |
|
| 1111 | + $totalarray['nbfield']++; |
|
| 1112 | + } |
|
| 991 | 1113 | } |
| 992 | 1114 | } |
| 993 | 1115 | |
@@ -997,7 +1119,9 @@ discard block |
||
| 997 | 1119 | print '<td>'; |
| 998 | 1120 | if ($_GET['action'] == 'editline' && $_GET['lineid'] == $task_time->rowid) |
| 999 | 1121 | { |
| 1000 | - if (empty($object->id)) $object->fetch($id); |
|
| 1122 | + if (empty($object->id)) { |
|
| 1123 | + $object->fetch($id); |
|
| 1124 | + } |
|
| 1001 | 1125 | $contactsoftask=$object->getListContactId('internal'); |
| 1002 | 1126 | if (!in_array($task_time->fk_user,$contactsoftask)) { |
| 1003 | 1127 | $contactsoftask[]=$task_time->fk_user; |
@@ -1005,11 +1129,10 @@ discard block |
||
| 1005 | 1129 | if (count($contactsoftask)>0) { |
| 1006 | 1130 | print img_object('','user','class="hideonsmartphone"'); |
| 1007 | 1131 | print $form->select_dolusers($task_time->fk_user,'userid_line',0,'',0,'',$contactsoftask); |
| 1008 | - }else { |
|
| 1132 | + } else { |
|
| 1009 | 1133 | print img_error($langs->trans('FirstAddRessourceToAllocateTime')).$langs->trans('FirstAddRessourceToAllocateTime'); |
| 1010 | 1134 | } |
| 1011 | - } |
|
| 1012 | - else |
|
| 1135 | + } else |
|
| 1013 | 1136 | { |
| 1014 | 1137 | $userstatic->id = $task_time->fk_user; |
| 1015 | 1138 | $userstatic->lastname = $task_time->lastname; |
@@ -1018,7 +1141,9 @@ discard block |
||
| 1018 | 1141 | print $userstatic->getNomUrl(-1); |
| 1019 | 1142 | } |
| 1020 | 1143 | print '</td>'; |
| 1021 | - if (! $i) $totalarray['nbfield']++; |
|
| 1144 | + if (! $i) { |
|
| 1145 | + $totalarray['nbfield']++; |
|
| 1146 | + } |
|
| 1022 | 1147 | } |
| 1023 | 1148 | |
| 1024 | 1149 | // Note |
@@ -1028,13 +1153,14 @@ discard block |
||
| 1028 | 1153 | if ($_GET['action'] == 'editline' && $_GET['lineid'] == $task_time->rowid) |
| 1029 | 1154 | { |
| 1030 | 1155 | print '<textarea name="timespent_note_line" width="95%" rows="'.ROWS_2.'">'.$task_time->note.'</textarea>'; |
| 1031 | - } |
|
| 1032 | - else |
|
| 1156 | + } else |
|
| 1033 | 1157 | { |
| 1034 | 1158 | print dol_nl2br($task_time->note); |
| 1035 | 1159 | } |
| 1036 | 1160 | print '</td>'; |
| 1037 | - if (! $i) $totalarray['nbfield']++; |
|
| 1161 | + if (! $i) { |
|
| 1162 | + $totalarray['nbfield']++; |
|
| 1163 | + } |
|
| 1038 | 1164 | } |
| 1039 | 1165 | |
| 1040 | 1166 | // Time spent |
@@ -1045,14 +1171,17 @@ discard block |
||
| 1045 | 1171 | { |
| 1046 | 1172 | print '<input type="hidden" name="old_duration" value="'.$task_time->task_duration.'">'; |
| 1047 | 1173 | print $form->select_duration('new_duration',$task_time->task_duration,0,'text'); |
| 1048 | - } |
|
| 1049 | - else |
|
| 1174 | + } else |
|
| 1050 | 1175 | { |
| 1051 | 1176 | print convertSecondToTime($task_time->task_duration,'allhourmin'); |
| 1052 | 1177 | } |
| 1053 | 1178 | print '</td>'; |
| 1054 | - if (! $i) $totalarray['nbfield']++; |
|
| 1055 | - if (! $i) $totalarray['totaldurationfield']=$totalarray['nbfield']; |
|
| 1179 | + if (! $i) { |
|
| 1180 | + $totalarray['nbfield']++; |
|
| 1181 | + } |
|
| 1182 | + if (! $i) { |
|
| 1183 | + $totalarray['totaldurationfield']=$totalarray['nbfield']; |
|
| 1184 | + } |
|
| 1056 | 1185 | $totalarray['totalduration'] += $task_time->task_duration; |
| 1057 | 1186 | } |
| 1058 | 1187 | |
@@ -1063,8 +1192,12 @@ discard block |
||
| 1063 | 1192 | $value = price2num($task_time->thm * $task_time->task_duration / 3600); |
| 1064 | 1193 | print price($value, 1, $langs, 1, -1, -1, $conf->currency); |
| 1065 | 1194 | print '</td>'; |
| 1066 | - if (! $i) $totalarray['nbfield']++; |
|
| 1067 | - if (! $i) $totalarray['totalvaluefield']=$totalarray['nbfield']; |
|
| 1195 | + if (! $i) { |
|
| 1196 | + $totalarray['nbfield']++; |
|
| 1197 | + } |
|
| 1198 | + if (! $i) { |
|
| 1199 | + $totalarray['totalvaluefield']=$totalarray['nbfield']; |
|
| 1200 | + } |
|
| 1068 | 1201 | $totalarray['totalvalue'] += $value; |
| 1069 | 1202 | } |
| 1070 | 1203 | |
@@ -1073,10 +1206,16 @@ discard block |
||
| 1073 | 1206 | { |
| 1074 | 1207 | print '<td align="right">'; |
| 1075 | 1208 | $valuebilled = price2num($task_time->total_ht); |
| 1076 | - if (isset($task_time->total_ht)) print price($valuebilled, 1, $langs, 1, -1, -1, $conf->currency); |
|
| 1209 | + if (isset($task_time->total_ht)) { |
|
| 1210 | + print price($valuebilled, 1, $langs, 1, -1, -1, $conf->currency); |
|
| 1211 | + } |
|
| 1077 | 1212 | print '</td>'; |
| 1078 | - if (! $i) $totalarray['nbfield']++; |
|
| 1079 | - if (! $i) $totalarray['totalvaluefield']=$totalarray['nbfield']; |
|
| 1213 | + if (! $i) { |
|
| 1214 | + $totalarray['nbfield']++; |
|
| 1215 | + } |
|
| 1216 | + if (! $i) { |
|
| 1217 | + $totalarray['totalvaluefield']=$totalarray['nbfield']; |
|
| 1218 | + } |
|
| 1080 | 1219 | $totalarray['totalvaluebilled'] += $valuebilled; |
| 1081 | 1220 | } |
| 1082 | 1221 | |
@@ -1098,13 +1237,14 @@ discard block |
||
| 1098 | 1237 | print '<input type="submit" class="button" name="save" value="'.$langs->trans("Save").'">'; |
| 1099 | 1238 | print '<br>'; |
| 1100 | 1239 | print '<input type="submit" class="button" name="cancel" value="'.$langs->trans('Cancel').'">'; |
| 1101 | - } |
|
| 1102 | - else if ($user->rights->projet->lire || $user->rights->projet->all->creer) // Read project and enter time consumed on assigned tasks |
|
| 1240 | + } else if ($user->rights->projet->lire || $user->rights->projet->all->creer) { |
|
| 1241 | + // Read project and enter time consumed on assigned tasks |
|
| 1103 | 1242 | { |
| 1104 | 1243 | if ($task_time->fk_user == $user->id || in_array($task_time->fk_user, $childids) || $user->rights->projet->all->creer) |
| 1105 | 1244 | { |
| 1106 | 1245 | //$param = ($projectidforalltimes?'projectid='.$projectidforalltimes.'&':'').'.($withproject?'&withproject=1':''); |
| 1107 | 1246 | print ' '; |
| 1247 | + } |
|
| 1108 | 1248 | print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?id='.$task_time->fk_task.'&action=editline&lineid='.$task_time->rowid.$param.'">'; |
| 1109 | 1249 | print img_edit(); |
| 1110 | 1250 | print '</a>'; |
@@ -1116,7 +1256,9 @@ discard block |
||
| 1116 | 1256 | } |
| 1117 | 1257 | } |
| 1118 | 1258 | print '</td>'; |
| 1119 | - if (! $i) $totalarray['nbfield']++; |
|
| 1259 | + if (! $i) { |
|
| 1260 | + $totalarray['nbfield']++; |
|
| 1261 | + } |
|
| 1120 | 1262 | |
| 1121 | 1263 | print "</tr>\n"; |
| 1122 | 1264 | |
@@ -1133,12 +1275,18 @@ discard block |
||
| 1133 | 1275 | $i++; |
| 1134 | 1276 | if ($i == 1) |
| 1135 | 1277 | { |
| 1136 | - if ($num < $limit && empty($offset)) print '<td align="left">'.$langs->trans("Total").'</td>'; |
|
| 1137 | - else print '<td align="left">'.$langs->trans("Totalforthispage").'</td>'; |
|
| 1278 | + if ($num < $limit && empty($offset)) { |
|
| 1279 | + print '<td align="left">'.$langs->trans("Total").'</td>'; |
|
| 1280 | + } else { |
|
| 1281 | + print '<td align="left">'.$langs->trans("Totalforthispage").'</td>'; |
|
| 1282 | + } |
|
| 1283 | + } elseif ($totalarray['totaldurationfield'] == $i) { |
|
| 1284 | + print '<td align="right">'.convertSecondToTime($totalarray['totalduration'],'allhourmin').'</td>'; |
|
| 1285 | + } elseif ($totalarray['totalvaluefield'] == $i) { |
|
| 1286 | + print '<td align="right">'.price($totalarray['totalvalue']).'</td>'; |
|
| 1287 | + } else { |
|
| 1288 | + print '<td></td>'; |
|
| 1138 | 1289 | } |
| 1139 | - elseif ($totalarray['totaldurationfield'] == $i) print '<td align="right">'.convertSecondToTime($totalarray['totalduration'],'allhourmin').'</td>'; |
|
| 1140 | - elseif ($totalarray['totalvaluefield'] == $i) print '<td align="right">'.price($totalarray['totalvalue']).'</td>'; |
|
| 1141 | - else print '<td></td>'; |
|
| 1142 | 1290 | } |
| 1143 | 1291 | print '</tr>'; |
| 1144 | 1292 | } |
@@ -27,7 +27,7 @@ discard block |
||
| 27 | 27 | require_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'; |
| 28 | 28 | |
| 29 | 29 | if (!$user->admin) |
| 30 | - accessforbidden(); |
|
| 30 | + accessforbidden(); |
|
| 31 | 31 | |
| 32 | 32 | $langs->loadLangs(array("admin","other","agenda")); |
| 33 | 33 | |
@@ -76,54 +76,54 @@ discard block |
||
| 76 | 76 | if ($action == 'set') |
| 77 | 77 | { |
| 78 | 78 | dolibarr_set_const($db, 'AGENDA_USE_EVENT_TYPE_DEFAULT', GETPOST('AGENDA_USE_EVENT_TYPE_DEFAULT'), 'chaine', 0, '', $conf->entity); |
| 79 | - dolibarr_set_const($db, 'AGENDA_DEFAULT_FILTER_TYPE', GETPOST('AGENDA_DEFAULT_FILTER_TYPE'), 'chaine', 0, '', $conf->entity); |
|
| 80 | - dolibarr_set_const($db, 'AGENDA_DEFAULT_FILTER_STATUS', GETPOST('AGENDA_DEFAULT_FILTER_STATUS'), 'chaine', 0, '', $conf->entity); |
|
| 79 | + dolibarr_set_const($db, 'AGENDA_DEFAULT_FILTER_TYPE', GETPOST('AGENDA_DEFAULT_FILTER_TYPE'), 'chaine', 0, '', $conf->entity); |
|
| 80 | + dolibarr_set_const($db, 'AGENDA_DEFAULT_FILTER_STATUS', GETPOST('AGENDA_DEFAULT_FILTER_STATUS'), 'chaine', 0, '', $conf->entity); |
|
| 81 | 81 | dolibarr_set_const($db, 'AGENDA_DEFAULT_VIEW', GETPOST('AGENDA_DEFAULT_VIEW'), 'chaine', 0, '', $conf->entity); |
| 82 | 82 | } |
| 83 | 83 | else if ($action == 'specimen') // For orders |
| 84 | 84 | { |
| 85 | - $modele=GETPOST('module','alpha'); |
|
| 86 | - |
|
| 87 | - $commande = new CommandeFournisseur($db); |
|
| 88 | - $commande->initAsSpecimen(); |
|
| 89 | - $commande->thirdparty=$specimenthirdparty; |
|
| 90 | - |
|
| 91 | - // Search template files |
|
| 92 | - $file=''; $classname=''; $filefound=0; |
|
| 93 | - $dirmodels=array_merge(array('/'),(array) $conf->modules_parts['models']); |
|
| 94 | - foreach($dirmodels as $reldir) |
|
| 95 | - { |
|
| 96 | - $file=dol_buildpath($reldir."core/modules/action/doc/pdf_".$modele.".modules.php",0); |
|
| 97 | - if (file_exists($file)) |
|
| 98 | - { |
|
| 99 | - $filefound=1; |
|
| 100 | - $classname = "pdf_".$modele; |
|
| 101 | - break; |
|
| 102 | - } |
|
| 103 | - } |
|
| 104 | - |
|
| 105 | - if ($filefound) |
|
| 106 | - { |
|
| 107 | - require_once $file; |
|
| 108 | - |
|
| 109 | - $module = new $classname($db,$commande); |
|
| 110 | - |
|
| 111 | - if ($module->write_file($commande,$langs) > 0) |
|
| 112 | - { |
|
| 113 | - header("Location: ".DOL_URL_ROOT."/document.php?modulepart=action&file=SPECIMEN.pdf"); |
|
| 114 | - return; |
|
| 115 | - } |
|
| 116 | - else |
|
| 117 | - { |
|
| 118 | - setEventMessages($module->error, $module->errors, 'errors'); |
|
| 119 | - dol_syslog($module->error, LOG_ERR); |
|
| 120 | - } |
|
| 121 | - } |
|
| 122 | - else |
|
| 123 | - { |
|
| 124 | - setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors'); |
|
| 125 | - dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR); |
|
| 126 | - } |
|
| 85 | + $modele=GETPOST('module','alpha'); |
|
| 86 | + |
|
| 87 | + $commande = new CommandeFournisseur($db); |
|
| 88 | + $commande->initAsSpecimen(); |
|
| 89 | + $commande->thirdparty=$specimenthirdparty; |
|
| 90 | + |
|
| 91 | + // Search template files |
|
| 92 | + $file=''; $classname=''; $filefound=0; |
|
| 93 | + $dirmodels=array_merge(array('/'),(array) $conf->modules_parts['models']); |
|
| 94 | + foreach($dirmodels as $reldir) |
|
| 95 | + { |
|
| 96 | + $file=dol_buildpath($reldir."core/modules/action/doc/pdf_".$modele.".modules.php",0); |
|
| 97 | + if (file_exists($file)) |
|
| 98 | + { |
|
| 99 | + $filefound=1; |
|
| 100 | + $classname = "pdf_".$modele; |
|
| 101 | + break; |
|
| 102 | + } |
|
| 103 | + } |
|
| 104 | + |
|
| 105 | + if ($filefound) |
|
| 106 | + { |
|
| 107 | + require_once $file; |
|
| 108 | + |
|
| 109 | + $module = new $classname($db,$commande); |
|
| 110 | + |
|
| 111 | + if ($module->write_file($commande,$langs) > 0) |
|
| 112 | + { |
|
| 113 | + header("Location: ".DOL_URL_ROOT."/document.php?modulepart=action&file=SPECIMEN.pdf"); |
|
| 114 | + return; |
|
| 115 | + } |
|
| 116 | + else |
|
| 117 | + { |
|
| 118 | + setEventMessages($module->error, $module->errors, 'errors'); |
|
| 119 | + dol_syslog($module->error, LOG_ERR); |
|
| 120 | + } |
|
| 121 | + } |
|
| 122 | + else |
|
| 123 | + { |
|
| 124 | + setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors'); |
|
| 125 | + dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR); |
|
| 126 | + } |
|
| 127 | 127 | } |
| 128 | 128 | |
| 129 | 129 | // Activate a model |
@@ -138,7 +138,7 @@ discard block |
||
| 138 | 138 | $ret = delDocumentModel($value, $type); |
| 139 | 139 | if ($ret > 0) |
| 140 | 140 | { |
| 141 | - if ($conf->global->ACTION_EVENT_ADDON_PDF == "$value") dolibarr_del_const($db, 'ACTION_EVENT_ADDON_PDF',$conf->entity); |
|
| 141 | + if ($conf->global->ACTION_EVENT_ADDON_PDF == "$value") dolibarr_del_const($db, 'ACTION_EVENT_ADDON_PDF',$conf->entity); |
|
| 142 | 142 | } |
| 143 | 143 | } |
| 144 | 144 | |
@@ -209,31 +209,31 @@ discard block |
||
| 209 | 209 | // AGENDA REMINDER BROWSER |
| 210 | 210 | if ($conf->global->MAIN_FEATURES_LEVEL > 0) |
| 211 | 211 | { |
| 212 | - print '<tr class="oddeven">'."\n"; |
|
| 213 | - print '<td>'.$langs->trans('AGENDA_REMINDER_BROWSER').'</td>'."\n"; |
|
| 214 | - print '<td align="center"> </td>'."\n"; |
|
| 215 | - print '<td align="right">'."\n"; |
|
| 216 | - |
|
| 217 | - if (empty($conf->global->AGENDA_REMINDER_BROWSER)) { |
|
| 218 | - print '<a href="'.$_SERVER['PHP_SELF'].'?action=set_AGENDA_REMINDER_BROWSER">'.img_picto($langs->trans('Disabled'),'switch_off').'</a>'; |
|
| 219 | - print '</td></tr>'."\n"; |
|
| 220 | - } else { |
|
| 221 | - print '<a href="'.$_SERVER['PHP_SELF'].'?action=del_AGENDA_REMINDER_BROWSER">'.img_picto($langs->trans('Enabled'),'switch_on').'</a>'; |
|
| 222 | - print '</td></tr>'."\n"; |
|
| 223 | - |
|
| 224 | - print '<tr class="oddeven">'."\n"; |
|
| 225 | - print '<td>'.$langs->trans('AGENDA_REMINDER_BROWSER_SOUND').'</td>'."\n"; |
|
| 226 | - print '<td align="center"> </td>'."\n"; |
|
| 227 | - print '<td align="right">'."\n"; |
|
| 228 | - |
|
| 229 | - if (empty($conf->global->AGENDA_REMINDER_BROWSER_SOUND)) { |
|
| 230 | - print '<a href="'.$_SERVER['PHP_SELF'].'?action=set_AGENDA_REMINDER_BROWSER_SOUND">'.img_picto($langs->trans('Disabled'),'switch_off').'</a>'; |
|
| 231 | - } else { |
|
| 232 | - print '<a href="'.$_SERVER['PHP_SELF'].'?action=del_AGENDA_REMINDER_BROWSER_SOUND">'.img_picto($langs->trans('Enabled'),'switch_on').'</a>'; |
|
| 233 | - } |
|
| 234 | - |
|
| 235 | - print '</td></tr>'."\n"; |
|
| 236 | - } |
|
| 212 | + print '<tr class="oddeven">'."\n"; |
|
| 213 | + print '<td>'.$langs->trans('AGENDA_REMINDER_BROWSER').'</td>'."\n"; |
|
| 214 | + print '<td align="center"> </td>'."\n"; |
|
| 215 | + print '<td align="right">'."\n"; |
|
| 216 | + |
|
| 217 | + if (empty($conf->global->AGENDA_REMINDER_BROWSER)) { |
|
| 218 | + print '<a href="'.$_SERVER['PHP_SELF'].'?action=set_AGENDA_REMINDER_BROWSER">'.img_picto($langs->trans('Disabled'),'switch_off').'</a>'; |
|
| 219 | + print '</td></tr>'."\n"; |
|
| 220 | + } else { |
|
| 221 | + print '<a href="'.$_SERVER['PHP_SELF'].'?action=del_AGENDA_REMINDER_BROWSER">'.img_picto($langs->trans('Enabled'),'switch_on').'</a>'; |
|
| 222 | + print '</td></tr>'."\n"; |
|
| 223 | + |
|
| 224 | + print '<tr class="oddeven">'."\n"; |
|
| 225 | + print '<td>'.$langs->trans('AGENDA_REMINDER_BROWSER_SOUND').'</td>'."\n"; |
|
| 226 | + print '<td align="center"> </td>'."\n"; |
|
| 227 | + print '<td align="right">'."\n"; |
|
| 228 | + |
|
| 229 | + if (empty($conf->global->AGENDA_REMINDER_BROWSER_SOUND)) { |
|
| 230 | + print '<a href="'.$_SERVER['PHP_SELF'].'?action=set_AGENDA_REMINDER_BROWSER_SOUND">'.img_picto($langs->trans('Disabled'),'switch_off').'</a>'; |
|
| 231 | + } else { |
|
| 232 | + print '<a href="'.$_SERVER['PHP_SELF'].'?action=del_AGENDA_REMINDER_BROWSER_SOUND">'.img_picto($langs->trans('Enabled'),'switch_on').'</a>'; |
|
| 233 | + } |
|
| 234 | + |
|
| 235 | + print '</td></tr>'."\n"; |
|
| 236 | + } |
|
| 237 | 237 | } |
| 238 | 238 | |
| 239 | 239 | print '</table>'; |
@@ -29,13 +29,13 @@ discard block |
||
| 29 | 29 | if (!$user->admin) |
| 30 | 30 | accessforbidden(); |
| 31 | 31 | |
| 32 | -$langs->loadLangs(array("admin","other","agenda")); |
|
| 32 | +$langs->loadLangs(array("admin", "other", "agenda")); |
|
| 33 | 33 | |
| 34 | -$action = GETPOST('action','alpha'); |
|
| 35 | -$value = GETPOST('value','alpha'); |
|
| 36 | -$param = GETPOST('param','alpha'); |
|
| 37 | -$cancel = GETPOST('cancel','alpha'); |
|
| 38 | -$scandir = GETPOST('scandir','alpha'); |
|
| 34 | +$action = GETPOST('action', 'alpha'); |
|
| 35 | +$value = GETPOST('value', 'alpha'); |
|
| 36 | +$param = GETPOST('param', 'alpha'); |
|
| 37 | +$cancel = GETPOST('cancel', 'alpha'); |
|
| 38 | +$scandir = GETPOST('scandir', 'alpha'); |
|
| 39 | 39 | $type = 'action'; |
| 40 | 40 | |
| 41 | 41 | |
@@ -45,10 +45,10 @@ discard block |
||
| 45 | 45 | |
| 46 | 46 | include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; |
| 47 | 47 | |
| 48 | -if (preg_match('/set_([a-z0-9_\-]+)/i',$action,$reg)) |
|
| 48 | +if (preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg)) |
|
| 49 | 49 | { |
| 50 | - $code=$reg[1]; |
|
| 51 | - $value=(GETPOST($code, 'alpha') ? GETPOST($code, 'alpha') : 1); |
|
| 50 | + $code = $reg[1]; |
|
| 51 | + $value = (GETPOST($code, 'alpha') ? GETPOST($code, 'alpha') : 1); |
|
| 52 | 52 | if (dolibarr_set_const($db, $code, $value, 'chaine', 0, '', $conf->entity) > 0) |
| 53 | 53 | { |
| 54 | 54 | Header("Location: ".$_SERVER["PHP_SELF"]); |
@@ -60,9 +60,9 @@ discard block |
||
| 60 | 60 | } |
| 61 | 61 | } |
| 62 | 62 | |
| 63 | -if (preg_match('/del_([a-z0-9_\-]+)/i',$action,$reg)) |
|
| 63 | +if (preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg)) |
|
| 64 | 64 | { |
| 65 | - $code=$reg[1]; |
|
| 65 | + $code = $reg[1]; |
|
| 66 | 66 | if (dolibarr_del_const($db, $code, $conf->entity) > 0) |
| 67 | 67 | { |
| 68 | 68 | Header("Location: ".$_SERVER["PHP_SELF"]); |
@@ -82,21 +82,21 @@ discard block |
||
| 82 | 82 | } |
| 83 | 83 | else if ($action == 'specimen') // For orders |
| 84 | 84 | { |
| 85 | - $modele=GETPOST('module','alpha'); |
|
| 85 | + $modele = GETPOST('module', 'alpha'); |
|
| 86 | 86 | |
| 87 | 87 | $commande = new CommandeFournisseur($db); |
| 88 | 88 | $commande->initAsSpecimen(); |
| 89 | - $commande->thirdparty=$specimenthirdparty; |
|
| 89 | + $commande->thirdparty = $specimenthirdparty; |
|
| 90 | 90 | |
| 91 | 91 | // Search template files |
| 92 | - $file=''; $classname=''; $filefound=0; |
|
| 93 | - $dirmodels=array_merge(array('/'),(array) $conf->modules_parts['models']); |
|
| 94 | - foreach($dirmodels as $reldir) |
|
| 92 | + $file = ''; $classname = ''; $filefound = 0; |
|
| 93 | + $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); |
|
| 94 | + foreach ($dirmodels as $reldir) |
|
| 95 | 95 | { |
| 96 | - $file=dol_buildpath($reldir."core/modules/action/doc/pdf_".$modele.".modules.php",0); |
|
| 96 | + $file = dol_buildpath($reldir."core/modules/action/doc/pdf_".$modele.".modules.php", 0); |
|
| 97 | 97 | if (file_exists($file)) |
| 98 | 98 | { |
| 99 | - $filefound=1; |
|
| 99 | + $filefound = 1; |
|
| 100 | 100 | $classname = "pdf_".$modele; |
| 101 | 101 | break; |
| 102 | 102 | } |
@@ -106,9 +106,9 @@ discard block |
||
| 106 | 106 | { |
| 107 | 107 | require_once $file; |
| 108 | 108 | |
| 109 | - $module = new $classname($db,$commande); |
|
| 109 | + $module = new $classname($db, $commande); |
|
| 110 | 110 | |
| 111 | - if ($module->write_file($commande,$langs) > 0) |
|
| 111 | + if ($module->write_file($commande, $langs) > 0) |
|
| 112 | 112 | { |
| 113 | 113 | header("Location: ".DOL_URL_ROOT."/document.php?modulepart=action&file=SPECIMEN.pdf"); |
| 114 | 114 | return; |
@@ -138,14 +138,14 @@ discard block |
||
| 138 | 138 | $ret = delDocumentModel($value, $type); |
| 139 | 139 | if ($ret > 0) |
| 140 | 140 | { |
| 141 | - if ($conf->global->ACTION_EVENT_ADDON_PDF == "$value") dolibarr_del_const($db, 'ACTION_EVENT_ADDON_PDF',$conf->entity); |
|
| 141 | + if ($conf->global->ACTION_EVENT_ADDON_PDF == "$value") dolibarr_del_const($db, 'ACTION_EVENT_ADDON_PDF', $conf->entity); |
|
| 142 | 142 | } |
| 143 | 143 | } |
| 144 | 144 | |
| 145 | 145 | // Set default model |
| 146 | 146 | else if ($action == 'setdoc') |
| 147 | 147 | { |
| 148 | - if (dolibarr_set_const($db, "ACTION_EVENT_ADDON_PDF",$value,'chaine',0,'',$conf->entity)) |
|
| 148 | + if (dolibarr_set_const($db, "ACTION_EVENT_ADDON_PDF", $value, 'chaine', 0, '', $conf->entity)) |
|
| 149 | 149 | { |
| 150 | 150 | // La constante qui a ete lue en avant du nouveau set |
| 151 | 151 | // on passe donc par une variable pour avoir un affichage coherent |
@@ -165,16 +165,16 @@ discard block |
||
| 165 | 165 | * View |
| 166 | 166 | */ |
| 167 | 167 | |
| 168 | -$formactions=new FormActions($db); |
|
| 169 | -$dirmodels=array_merge(array('/'),(array) $conf->modules_parts['models']); |
|
| 168 | +$formactions = new FormActions($db); |
|
| 169 | +$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); |
|
| 170 | 170 | llxHeader(); |
| 171 | 171 | |
| 172 | -$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>'; |
|
| 173 | -print load_fiche_titre($langs->trans("AgendaSetup"),$linkback,'title_setup'); |
|
| 172 | +$linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>'; |
|
| 173 | +print load_fiche_titre($langs->trans("AgendaSetup"), $linkback, 'title_setup'); |
|
| 174 | 174 | |
| 175 | 175 | |
| 176 | 176 | |
| 177 | -$head=agenda_prepare_head(); |
|
| 177 | +$head = agenda_prepare_head(); |
|
| 178 | 178 | |
| 179 | 179 | dol_fiche_head($head, 'reminders', $langs->trans("Agenda"), -1, 'action'); |
| 180 | 180 | |
@@ -198,10 +198,10 @@ discard block |
||
| 198 | 198 | print '<td align="right">'."\n"; |
| 199 | 199 | |
| 200 | 200 | if (empty($conf->global->AGENDA_REMINDER_EMAIL)) { |
| 201 | - print '<a href="'.$_SERVER['PHP_SELF'].'?action=set_AGENDA_REMINDER_EMAIL">'.img_picto($langs->trans('Disabled'),'switch_off').'</a>'; |
|
| 201 | + print '<a href="'.$_SERVER['PHP_SELF'].'?action=set_AGENDA_REMINDER_EMAIL">'.img_picto($langs->trans('Disabled'), 'switch_off').'</a>'; |
|
| 202 | 202 | print '</td></tr>'."\n"; |
| 203 | 203 | } else { |
| 204 | - print '<a href="'.$_SERVER['PHP_SELF'].'?action=del_AGENDA_REMINDER_EMAIL">'.img_picto($langs->trans('Enabled'),'switch_on').'</a>'; |
|
| 204 | + print '<a href="'.$_SERVER['PHP_SELF'].'?action=del_AGENDA_REMINDER_EMAIL">'.img_picto($langs->trans('Enabled'), 'switch_on').'</a>'; |
|
| 205 | 205 | print '</td></tr>'."\n"; |
| 206 | 206 | } |
| 207 | 207 | } |
@@ -215,10 +215,10 @@ discard block |
||
| 215 | 215 | print '<td align="right">'."\n"; |
| 216 | 216 | |
| 217 | 217 | if (empty($conf->global->AGENDA_REMINDER_BROWSER)) { |
| 218 | - print '<a href="'.$_SERVER['PHP_SELF'].'?action=set_AGENDA_REMINDER_BROWSER">'.img_picto($langs->trans('Disabled'),'switch_off').'</a>'; |
|
| 218 | + print '<a href="'.$_SERVER['PHP_SELF'].'?action=set_AGENDA_REMINDER_BROWSER">'.img_picto($langs->trans('Disabled'), 'switch_off').'</a>'; |
|
| 219 | 219 | print '</td></tr>'."\n"; |
| 220 | 220 | } else { |
| 221 | - print '<a href="'.$_SERVER['PHP_SELF'].'?action=del_AGENDA_REMINDER_BROWSER">'.img_picto($langs->trans('Enabled'),'switch_on').'</a>'; |
|
| 221 | + print '<a href="'.$_SERVER['PHP_SELF'].'?action=del_AGENDA_REMINDER_BROWSER">'.img_picto($langs->trans('Enabled'), 'switch_on').'</a>'; |
|
| 222 | 222 | print '</td></tr>'."\n"; |
| 223 | 223 | |
| 224 | 224 | print '<tr class="oddeven">'."\n"; |
@@ -227,9 +227,9 @@ discard block |
||
| 227 | 227 | print '<td align="right">'."\n"; |
| 228 | 228 | |
| 229 | 229 | if (empty($conf->global->AGENDA_REMINDER_BROWSER_SOUND)) { |
| 230 | - print '<a href="'.$_SERVER['PHP_SELF'].'?action=set_AGENDA_REMINDER_BROWSER_SOUND">'.img_picto($langs->trans('Disabled'),'switch_off').'</a>'; |
|
| 230 | + print '<a href="'.$_SERVER['PHP_SELF'].'?action=set_AGENDA_REMINDER_BROWSER_SOUND">'.img_picto($langs->trans('Disabled'), 'switch_off').'</a>'; |
|
| 231 | 231 | } else { |
| 232 | - print '<a href="'.$_SERVER['PHP_SELF'].'?action=del_AGENDA_REMINDER_BROWSER_SOUND">'.img_picto($langs->trans('Enabled'),'switch_on').'</a>'; |
|
| 232 | + print '<a href="'.$_SERVER['PHP_SELF'].'?action=del_AGENDA_REMINDER_BROWSER_SOUND">'.img_picto($langs->trans('Enabled'), 'switch_on').'</a>'; |
|
| 233 | 233 | } |
| 234 | 234 | |
| 235 | 235 | print '</td></tr>'."\n"; |
@@ -26,8 +26,9 @@ discard block |
||
| 26 | 26 | require_once DOL_DOCUMENT_ROOT.'/core/lib/agenda.lib.php'; |
| 27 | 27 | require_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'; |
| 28 | 28 | |
| 29 | -if (!$user->admin) |
|
| 29 | +if (!$user->admin) { |
|
| 30 | 30 | accessforbidden(); |
| 31 | +} |
|
| 31 | 32 | |
| 32 | 33 | $langs->loadLangs(array("admin","other","agenda")); |
| 33 | 34 | |
@@ -53,8 +54,7 @@ discard block |
||
| 53 | 54 | { |
| 54 | 55 | Header("Location: ".$_SERVER["PHP_SELF"]); |
| 55 | 56 | exit; |
| 56 | - } |
|
| 57 | - else |
|
| 57 | + } else |
|
| 58 | 58 | { |
| 59 | 59 | dol_print_error($db); |
| 60 | 60 | } |
@@ -67,8 +67,7 @@ discard block |
||
| 67 | 67 | { |
| 68 | 68 | Header("Location: ".$_SERVER["PHP_SELF"]); |
| 69 | 69 | exit; |
| 70 | - } |
|
| 71 | - else |
|
| 70 | + } else |
|
| 72 | 71 | { |
| 73 | 72 | dol_print_error($db); |
| 74 | 73 | } |
@@ -79,10 +78,11 @@ discard block |
||
| 79 | 78 | dolibarr_set_const($db, 'AGENDA_DEFAULT_FILTER_TYPE', GETPOST('AGENDA_DEFAULT_FILTER_TYPE'), 'chaine', 0, '', $conf->entity); |
| 80 | 79 | dolibarr_set_const($db, 'AGENDA_DEFAULT_FILTER_STATUS', GETPOST('AGENDA_DEFAULT_FILTER_STATUS'), 'chaine', 0, '', $conf->entity); |
| 81 | 80 | dolibarr_set_const($db, 'AGENDA_DEFAULT_VIEW', GETPOST('AGENDA_DEFAULT_VIEW'), 'chaine', 0, '', $conf->entity); |
| 82 | -} |
|
| 83 | -else if ($action == 'specimen') // For orders |
|
| 81 | +} else if ($action == 'specimen') { |
|
| 82 | + // For orders |
|
| 84 | 83 | { |
| 85 | 84 | $modele=GETPOST('module','alpha'); |
| 85 | +} |
|
| 86 | 86 | |
| 87 | 87 | $commande = new CommandeFournisseur($db); |
| 88 | 88 | $commande->initAsSpecimen(); |
@@ -112,14 +112,12 @@ discard block |
||
| 112 | 112 | { |
| 113 | 113 | header("Location: ".DOL_URL_ROOT."/document.php?modulepart=action&file=SPECIMEN.pdf"); |
| 114 | 114 | return; |
| 115 | - } |
|
| 116 | - else |
|
| 115 | + } else |
|
| 117 | 116 | { |
| 118 | 117 | setEventMessages($module->error, $module->errors, 'errors'); |
| 119 | 118 | dol_syslog($module->error, LOG_ERR); |
| 120 | 119 | } |
| 121 | - } |
|
| 122 | - else |
|
| 120 | + } else |
|
| 123 | 121 | { |
| 124 | 122 | setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors'); |
| 125 | 123 | dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR); |
@@ -131,14 +129,14 @@ discard block |
||
| 131 | 129 | { |
| 132 | 130 | //print "sssd".$value; |
| 133 | 131 | $ret = addDocumentModel($value, $type, $label, $scandir); |
| 134 | -} |
|
| 135 | - |
|
| 136 | -else if ($action == 'del') |
|
| 132 | +} else if ($action == 'del') |
|
| 137 | 133 | { |
| 138 | 134 | $ret = delDocumentModel($value, $type); |
| 139 | 135 | if ($ret > 0) |
| 140 | 136 | { |
| 141 | - if ($conf->global->ACTION_EVENT_ADDON_PDF == "$value") dolibarr_del_const($db, 'ACTION_EVENT_ADDON_PDF',$conf->entity); |
|
| 137 | + if ($conf->global->ACTION_EVENT_ADDON_PDF == "$value") { |
|
| 138 | + dolibarr_del_const($db, 'ACTION_EVENT_ADDON_PDF',$conf->entity); |
|
| 139 | + } |
|
| 142 | 140 | } |
| 143 | 141 | } |
| 144 | 142 | |