@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | $h = 0; |
36 | 36 | $head = array(); |
37 | 37 | |
38 | - $head[$h][0] = DOL_URL_ROOT . '/asset/admin/setup.php'; |
|
38 | + $head[$h][0] = DOL_URL_ROOT.'/asset/admin/setup.php'; |
|
39 | 39 | $head[$h][1] = $langs->trans("Settings"); |
40 | 40 | $head[$h][2] = 'settings'; |
41 | 41 | $h++; |
@@ -50,12 +50,12 @@ discard block |
||
50 | 50 | //); // to remove a tab |
51 | 51 | complete_head_from_modules($conf, $langs, $object, $head, $h, 'assets_admin'); |
52 | 52 | |
53 | - $head[$h][0] = DOL_URL_ROOT . '/asset/admin/assets_extrafields.php'; |
|
53 | + $head[$h][0] = DOL_URL_ROOT.'/asset/admin/assets_extrafields.php'; |
|
54 | 54 | $head[$h][1] = $langs->trans("ExtraFields"); |
55 | 55 | $head[$h][2] = 'attributes'; |
56 | 56 | $h++; |
57 | 57 | |
58 | - $head[$h][0] = DOL_URL_ROOT . '/asset/admin/assets_type_extrafields.php'; |
|
58 | + $head[$h][0] = DOL_URL_ROOT.'/asset/admin/assets_type_extrafields.php'; |
|
59 | 59 | $head[$h][1] = $langs->trans("ExtraFieldsAssetsType"); |
60 | 60 | $head[$h][2] = 'attributes_type'; |
61 | 61 | $h++; |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | $h = 0; |
80 | 80 | $head = array(); |
81 | 81 | |
82 | - $head[$h][0] = DOL_URL_ROOT . '/asset/card.php'; |
|
82 | + $head[$h][0] = DOL_URL_ROOT.'/asset/card.php'; |
|
83 | 83 | $head[$h][1] = $langs->trans("Card"); |
84 | 84 | $head[$h][2] = 'card'; |
85 | 85 | $h++; |
@@ -96,25 +96,25 @@ discard block |
||
96 | 96 | |
97 | 97 | require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; |
98 | 98 | require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php'; |
99 | - $upload_dir = $conf->assets->dir_output . '/' . get_exdir($filename,2,0,1,$object,'assets'). '/'. dol_sanitizeFileName($object->ref); |
|
100 | - $nbFiles = count(dol_dir_list($upload_dir,'files',0,'','(\.meta|_preview.*\.png)$')); |
|
101 | - $nbLinks=Link::count($db, $object->element, $object->id); |
|
99 | + $upload_dir = $conf->assets->dir_output.'/'.get_exdir($filename, 2, 0, 1, $object, 'assets').'/'.dol_sanitizeFileName($object->ref); |
|
100 | + $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$')); |
|
101 | + $nbLinks = Link::count($db, $object->element, $object->id); |
|
102 | 102 | $head[$h][0] = DOL_URL_ROOT.'/asset/document.php?id='.$object->id; |
103 | 103 | $head[$h][1] = $langs->trans('Documents'); |
104 | - if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>'; |
|
104 | + if (($nbFiles + $nbLinks) > 0) $head[$h][1] .= ' <span class="badge">'.($nbFiles + $nbLinks).'</span>'; |
|
105 | 105 | $head[$h][2] = 'documents'; |
106 | 106 | $h++; |
107 | 107 | |
108 | 108 | $nbNote = 0; |
109 | - if(!empty($object->note_private)) $nbNote++; |
|
110 | - if(!empty($object->note_public)) $nbNote++; |
|
109 | + if (!empty($object->note_private)) $nbNote++; |
|
110 | + if (!empty($object->note_public)) $nbNote++; |
|
111 | 111 | $head[$h][0] = DOL_URL_ROOT.'/asset/note.php?id='.$object->id; |
112 | 112 | $head[$h][1] = $langs->trans("Notes"); |
113 | - if ($nbNote > 0) $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>'; |
|
113 | + if ($nbNote > 0) $head[$h][1] .= ' <span class="badge">'.$nbNote.'</span>'; |
|
114 | 114 | $head[$h][2] = 'note'; |
115 | 115 | $h++; |
116 | 116 | |
117 | - $head[$h][0] = DOL_URL_ROOT . '/asset/info.php?id=' . $object->id; |
|
117 | + $head[$h][0] = DOL_URL_ROOT.'/asset/info.php?id='.$object->id; |
|
118 | 118 | $head[$h][1] = $langs->trans("Info"); |
119 | 119 | $head[$h][2] = 'info'; |
120 | 120 | $h++; |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | { |
135 | 135 | global $langs, $conf, $user; |
136 | 136 | |
137 | - $h=0; |
|
137 | + $h = 0; |
|
138 | 138 | $head = array(); |
139 | 139 | |
140 | 140 | $head[$h][0] = DOL_URL_ROOT.'/asset/type.php?rowid='.$object->id; |
@@ -146,9 +146,9 @@ discard block |
||
146 | 146 | // Entries must be declared in modules descriptor with line |
147 | 147 | // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab |
148 | 148 | // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab |
149 | - complete_head_from_modules($conf,$langs,$object,$head,$h,'assettype'); |
|
149 | + complete_head_from_modules($conf, $langs, $object, $head, $h, 'assettype'); |
|
150 | 150 | |
151 | - complete_head_from_modules($conf,$langs,$object,$head,$h,'assettype','remove'); |
|
151 | + complete_head_from_modules($conf, $langs, $object, $head, $h, 'assettype', 'remove'); |
|
152 | 152 | |
153 | 153 | return $head; |
154 | 154 | } |
@@ -45,16 +45,16 @@ discard block |
||
45 | 45 | // Entries must be declared in modules descriptor with line |
46 | 46 | // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab |
47 | 47 | // $this->tabs = array('entity:-tabname); to remove a tab |
48 | - complete_head_from_modules($conf, $langs, $object, $head, $tab,'vat'); |
|
48 | + complete_head_from_modules($conf, $langs, $object, $head, $tab, 'vat'); |
|
49 | 49 | |
50 | 50 | require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; |
51 | 51 | require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php'; |
52 | - $upload_dir = $conf->tax->dir_output . "/" . dol_sanitizeFileName($object->ref); |
|
53 | - $nbFiles = count(dol_dir_list($upload_dir,'files',0,'','(\.meta|_preview.*\.png)$')); |
|
54 | - $nbLinks=Link::count($db, $object->element, $object->id); |
|
52 | + $upload_dir = $conf->tax->dir_output."/".dol_sanitizeFileName($object->ref); |
|
53 | + $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$')); |
|
54 | + $nbLinks = Link::count($db, $object->element, $object->id); |
|
55 | 55 | $head[$tab][0] = DOL_URL_ROOT.'/compta/tva/document.php?id='.$object->id; |
56 | 56 | $head[$tab][1] = $langs->trans("Documents"); |
57 | - if (($nbFiles+$nbLinks) > 0) $head[$tab][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>'; |
|
57 | + if (($nbFiles + $nbLinks) > 0) $head[$tab][1] .= ' <span class="badge">'.($nbFiles + $nbLinks).'</span>'; |
|
58 | 58 | $head[$tab][2] = 'documents'; |
59 | 59 | $tab++; |
60 | 60 | |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | $head[$tab][2] = 'info'; |
64 | 64 | $tab++; |
65 | 65 | |
66 | - complete_head_from_modules($conf,$langs,$object,$head,$tab,'vat','remove'); |
|
66 | + complete_head_from_modules($conf, $langs, $object, $head, $tab, 'vat', 'remove'); |
|
67 | 67 | |
68 | 68 | return $head; |
69 | 69 | } |
@@ -33,10 +33,10 @@ discard block |
||
33 | 33 | $h = 0; |
34 | 34 | $head = array(); |
35 | 35 | |
36 | - $head[$h][0] = DOL_URL_ROOT . '/don/admin/donation.php'; |
|
36 | + $head[$h][0] = DOL_URL_ROOT.'/don/admin/donation.php'; |
|
37 | 37 | $head[$h][1] = $langs->trans("Miscellaneous"); |
38 | 38 | $head[$h][2] = 'general'; |
39 | - $h ++; |
|
39 | + $h++; |
|
40 | 40 | |
41 | 41 | // Show more tabs from modules |
42 | 42 | // Entries must be declared in modules descriptor with line |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | // $this->tabs = array('entity:-tabname); to remove a tab |
45 | 45 | complete_head_from_modules($conf, $langs, null, $head, $h, 'donation_admin'); |
46 | 46 | |
47 | - $head[$h][0] = DOL_URL_ROOT . '/don/admin/donation_extrafields.php'; |
|
47 | + $head[$h][0] = DOL_URL_ROOT.'/don/admin/donation_extrafields.php'; |
|
48 | 48 | $head[$h][1] = $langs->trans("ExtraFields"); |
49 | 49 | $head[$h][2] = 'attributes'; |
50 | 50 | $h++; |
@@ -67,10 +67,10 @@ discard block |
||
67 | 67 | $h = 0; |
68 | 68 | $head = array(); |
69 | 69 | |
70 | - $head[$h][0] = DOL_URL_ROOT . '/don/card.php?id=' . $object->id; |
|
70 | + $head[$h][0] = DOL_URL_ROOT.'/don/card.php?id='.$object->id; |
|
71 | 71 | $head[$h][1] = $langs->trans("Card"); |
72 | 72 | $head[$h][2] = 'card'; |
73 | - $h ++; |
|
73 | + $h++; |
|
74 | 74 | |
75 | 75 | // Show more tabs from modules |
76 | 76 | // Entries must be declared in modules descriptor with line |
@@ -80,25 +80,25 @@ discard block |
||
80 | 80 | |
81 | 81 | require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; |
82 | 82 | require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php'; |
83 | - $upload_dir = $conf->don->dir_output . '/' . get_exdir($filename,2,0,1,$object,'donation'). '/'. dol_sanitizeFileName($object->ref); |
|
84 | - $nbFiles = count(dol_dir_list($upload_dir,'files',0,'','(\.meta|_preview.*\.png)$')); |
|
85 | - $nbLinks=Link::count($db, $object->element, $object->id); |
|
83 | + $upload_dir = $conf->don->dir_output.'/'.get_exdir($filename, 2, 0, 1, $object, 'donation').'/'.dol_sanitizeFileName($object->ref); |
|
84 | + $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$')); |
|
85 | + $nbLinks = Link::count($db, $object->element, $object->id); |
|
86 | 86 | $head[$h][0] = DOL_URL_ROOT.'/don/document.php?id='.$object->id; |
87 | 87 | $head[$h][1] = $langs->trans('Documents'); |
88 | - if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>'; |
|
88 | + if (($nbFiles + $nbLinks) > 0) $head[$h][1] .= ' <span class="badge">'.($nbFiles + $nbLinks).'</span>'; |
|
89 | 89 | $head[$h][2] = 'documents'; |
90 | 90 | $h++; |
91 | 91 | |
92 | 92 | $nbNote = 0; |
93 | - if(!empty($object->note_private)) $nbNote++; |
|
94 | - if(!empty($object->note_public)) $nbNote++; |
|
93 | + if (!empty($object->note_private)) $nbNote++; |
|
94 | + if (!empty($object->note_public)) $nbNote++; |
|
95 | 95 | $head[$h][0] = DOL_URL_ROOT.'/don/note.php?id='.$object->id; |
96 | 96 | $head[$h][1] = $langs->trans("Notes"); |
97 | - if ($nbNote > 0) $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>'; |
|
97 | + if ($nbNote > 0) $head[$h][1] .= ' <span class="badge">'.$nbNote.'</span>'; |
|
98 | 98 | $head[$h][2] = 'note'; |
99 | 99 | $h++; |
100 | 100 | |
101 | - $head[$h][0] = DOL_URL_ROOT . '/don/info.php?id=' . $object->id; |
|
101 | + $head[$h][0] = DOL_URL_ROOT.'/don/info.php?id='.$object->id; |
|
102 | 102 | $head[$h][1] = $langs->trans("Info"); |
103 | 103 | $head[$h][2] = 'info'; |
104 | 104 | $h++; |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | $h = 0; |
35 | 35 | $head = array(); |
36 | 36 | |
37 | - $head[$h][0] = DOL_URL_ROOT . '/compta/deplacement/card.php?id=' . $object->id; |
|
37 | + $head[$h][0] = DOL_URL_ROOT.'/compta/deplacement/card.php?id='.$object->id; |
|
38 | 38 | $head[$h][1] = $langs->trans("Card"); |
39 | 39 | $head[$h][2] = 'card'; |
40 | 40 | $h++; |
@@ -43,19 +43,19 @@ discard block |
||
43 | 43 | // Entries must be declared in modules descriptor with line |
44 | 44 | // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab |
45 | 45 | // $this->tabs = array('entity:-tabname); to remove a tab |
46 | - complete_head_from_modules($conf,$langs,$object,$head,$h,'trip'); |
|
46 | + complete_head_from_modules($conf, $langs, $object, $head, $h, 'trip'); |
|
47 | 47 | |
48 | 48 | $head[$h][0] = DOL_URL_ROOT.'/compta/deplacement/document.php?id='.$object->id; |
49 | 49 | $head[$h][1] = $langs->trans("Documents"); |
50 | 50 | $head[$h][2] = 'documents'; |
51 | 51 | $h++; |
52 | 52 | |
53 | - $head[$h][0] = DOL_URL_ROOT . '/compta/deplacement/info.php?id=' . $object->id; |
|
53 | + $head[$h][0] = DOL_URL_ROOT.'/compta/deplacement/info.php?id='.$object->id; |
|
54 | 54 | $head[$h][1] = $langs->trans("Info"); |
55 | 55 | $head[$h][2] = 'info'; |
56 | 56 | $h++; |
57 | 57 | |
58 | - complete_head_from_modules($conf,$langs,$object,$head,$h,'trip','remove'); |
|
58 | + complete_head_from_modules($conf, $langs, $object, $head, $h, 'trip', 'remove'); |
|
59 | 59 | |
60 | 60 | return $head; |
61 | 61 | } |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | * @param string $type Type of category |
30 | 30 | * @return array Array of tabs to show |
31 | 31 | */ |
32 | -function categories_prepare_head($object,$type) |
|
32 | +function categories_prepare_head($object, $type) |
|
33 | 33 | { |
34 | 34 | global $langs, $conf, $user; |
35 | 35 | |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | $head[$h][2] = 'photos'; |
50 | 50 | $h++; |
51 | 51 | |
52 | - if (! empty($conf->global->MAIN_MULTILANGS)) |
|
52 | + if (!empty($conf->global->MAIN_MULTILANGS)) |
|
53 | 53 | { |
54 | 54 | $head[$h][0] = DOL_URL_ROOT.'/categories/traduction.php?id='.$object->id.'&type='.$type; |
55 | 55 | $head[$h][1] = $langs->trans("Translation"); |
@@ -61,9 +61,9 @@ discard block |
||
61 | 61 | // Entries must be declared in modules descriptor with line |
62 | 62 | // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab |
63 | 63 | // $this->tabs = array('entity:-tabname); to remove a tab |
64 | - complete_head_from_modules($conf,$langs,$object,$head,$h,'categories_'.$type); |
|
64 | + complete_head_from_modules($conf, $langs, $object, $head, $h, 'categories_'.$type); |
|
65 | 65 | |
66 | - complete_head_from_modules($conf,$langs,$object,$head,$h,'categories_'.$type,'remove'); |
|
66 | + complete_head_from_modules($conf, $langs, $object, $head, $h, 'categories_'.$type, 'remove'); |
|
67 | 67 | |
68 | 68 | return $head; |
69 | 69 | } |
@@ -97,9 +97,9 @@ discard block |
||
97 | 97 | // Entries must be declared in modules descriptor with line |
98 | 98 | // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab |
99 | 99 | // $this->tabs = array('entity:-tabname); to remove a tab |
100 | - complete_head_from_modules($conf,$langs,null,$head,$h,'categoriesadmin'); |
|
100 | + complete_head_from_modules($conf, $langs, null, $head, $h, 'categoriesadmin'); |
|
101 | 101 | |
102 | - complete_head_from_modules($conf,$langs,null,$head,$h,'categoriesadmin','remove'); |
|
102 | + complete_head_from_modules($conf, $langs, null, $head, $h, 'categoriesadmin', 'remove'); |
|
103 | 103 | |
104 | 104 | return $head; |
105 | 105 | } |
@@ -45,10 +45,10 @@ discard block |
||
45 | 45 | $head[$h][2] = 'project'; |
46 | 46 | $h++; |
47 | 47 | |
48 | - $nbContact = count($object->liste_contact(-1,'internal')) + count($object->liste_contact(-1,'external')); |
|
48 | + $nbContact = count($object->liste_contact(-1, 'internal')) + count($object->liste_contact(-1, 'external')); |
|
49 | 49 | $head[$h][0] = DOL_URL_ROOT.'/projet/contact.php?id='.$object->id; |
50 | 50 | $head[$h][1] = $langs->trans("ProjectContact"); |
51 | - if ($nbContact > 0) $head[$h][1].= ' <span class="badge">'.$nbContact.'</span>'; |
|
51 | + if ($nbContact > 0) $head[$h][1] .= ' <span class="badge">'.$nbContact.'</span>'; |
|
52 | 52 | $head[$h][2] = 'contact'; |
53 | 53 | $h++; |
54 | 54 | |
@@ -59,13 +59,13 @@ discard block |
||
59 | 59 | $head[$h][1] = $langs->trans("Tasks"); |
60 | 60 | |
61 | 61 | require_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php'; |
62 | - $taskstatic=new Task($db); |
|
63 | - $nbTasks=count($taskstatic->getTasksArray(0, 0, $object->id, 0, 0)); |
|
64 | - if ($nbTasks > 0) $head[$h][1].= ' <span class="badge">'.($nbTasks).'</span>'; |
|
62 | + $taskstatic = new Task($db); |
|
63 | + $nbTasks = count($taskstatic->getTasksArray(0, 0, $object->id, 0, 0)); |
|
64 | + if ($nbTasks > 0) $head[$h][1] .= ' <span class="badge">'.($nbTasks).'</span>'; |
|
65 | 65 | $head[$h][2] = 'tasks'; |
66 | 66 | $h++; |
67 | 67 | |
68 | - $nbTimeSpent=0; |
|
68 | + $nbTimeSpent = 0; |
|
69 | 69 | $sql = "SELECT t.rowid"; |
70 | 70 | //$sql .= " FROM ".MAIN_DB_PREFIX."projet_task_time as t, ".MAIN_DB_PREFIX."projet_task as pt, ".MAIN_DB_PREFIX."user as u"; |
71 | 71 | //$sql .= " WHERE t.fk_user = u.rowid AND t.fk_task = pt.rowid"; |
@@ -76,20 +76,20 @@ discard block |
||
76 | 76 | if ($resql) |
77 | 77 | { |
78 | 78 | $obj = $db->fetch_object($resql); |
79 | - if ($obj) $nbTimeSpent=1; |
|
79 | + if ($obj) $nbTimeSpent = 1; |
|
80 | 80 | } |
81 | 81 | else dol_print_error($db); |
82 | 82 | |
83 | 83 | $head[$h][0] = DOL_URL_ROOT.'/projet/tasks/time.php?withproject=1&projectid='.$object->id; |
84 | 84 | $head[$h][1] = $langs->trans("TimeSpent"); |
85 | - if ($nbTimeSpent > 0) $head[$h][1].= ' <span class="badge">...</span>'; |
|
85 | + if ($nbTimeSpent > 0) $head[$h][1] .= ' <span class="badge">...</span>'; |
|
86 | 86 | $head[$h][2] = 'timespent'; |
87 | 87 | $h++; |
88 | 88 | } |
89 | 89 | |
90 | - if (! empty($conf->fournisseur->enabled) || ! empty($conf->propal->enabled) || ! empty($conf->commande->enabled) |
|
91 | - || ! empty($conf->facture->enabled) || ! empty($conf->contrat->enabled) |
|
92 | - || ! empty($conf->ficheinter->enabled) || ! empty($conf->agenda->enabled) || ! empty($conf->deplacement->enabled)) |
|
90 | + if (!empty($conf->fournisseur->enabled) || !empty($conf->propal->enabled) || !empty($conf->commande->enabled) |
|
91 | + || !empty($conf->facture->enabled) || !empty($conf->contrat->enabled) |
|
92 | + || !empty($conf->ficheinter->enabled) || !empty($conf->agenda->enabled) || !empty($conf->deplacement->enabled)) |
|
93 | 93 | { |
94 | 94 | $head[$h][0] = DOL_URL_ROOT.'/projet/element.php?id='.$object->id; |
95 | 95 | $head[$h][1] = $langs->trans("ProjectOverview"); |
@@ -101,29 +101,29 @@ discard block |
||
101 | 101 | // Entries must be declared in modules descriptor with line |
102 | 102 | // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab |
103 | 103 | // $this->tabs = array('entity:-tabname); to remove a tab |
104 | - complete_head_from_modules($conf,$langs,$object,$head,$h,'project'); |
|
104 | + complete_head_from_modules($conf, $langs, $object, $head, $h, 'project'); |
|
105 | 105 | |
106 | 106 | |
107 | 107 | if (empty($conf->global->MAIN_DISABLE_NOTES_TAB)) |
108 | 108 | { |
109 | 109 | $nbNote = 0; |
110 | - if(!empty($object->note_private)) $nbNote++; |
|
111 | - if(!empty($object->note_public)) $nbNote++; |
|
110 | + if (!empty($object->note_private)) $nbNote++; |
|
111 | + if (!empty($object->note_public)) $nbNote++; |
|
112 | 112 | $head[$h][0] = DOL_URL_ROOT.'/projet/note.php?id='.$object->id; |
113 | 113 | $head[$h][1] = $langs->trans('Notes'); |
114 | - if ($nbNote > 0) $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>'; |
|
114 | + if ($nbNote > 0) $head[$h][1] .= ' <span class="badge">'.$nbNote.'</span>'; |
|
115 | 115 | $head[$h][2] = 'notes'; |
116 | 116 | $h++; |
117 | 117 | } |
118 | 118 | |
119 | 119 | require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; |
120 | 120 | require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php'; |
121 | - $upload_dir = $conf->projet->dir_output . "/" . dol_sanitizeFileName($object->ref); |
|
122 | - $nbFiles = count(dol_dir_list($upload_dir,'files',0,'','(\.meta|_preview.*\.png)$')); |
|
123 | - $nbLinks=Link::count($db, $object->element, $object->id); |
|
121 | + $upload_dir = $conf->projet->dir_output."/".dol_sanitizeFileName($object->ref); |
|
122 | + $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$')); |
|
123 | + $nbLinks = Link::count($db, $object->element, $object->id); |
|
124 | 124 | $head[$h][0] = DOL_URL_ROOT.'/projet/document.php?id='.$object->id; |
125 | 125 | $head[$h][1] = $langs->trans('Documents'); |
126 | - if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>'; |
|
126 | + if (($nbFiles + $nbLinks) > 0) $head[$h][1] .= ' <span class="badge">'.($nbFiles + $nbLinks).'</span>'; |
|
127 | 127 | $head[$h][2] = 'document'; |
128 | 128 | $h++; |
129 | 129 | |
@@ -133,22 +133,22 @@ discard block |
||
133 | 133 | $nbComments = $object->getNbComments(); |
134 | 134 | $head[$h][0] = DOL_URL_ROOT.'/projet/comment.php?id='.$object->id; |
135 | 135 | $head[$h][1] = $langs->trans("CommentLink"); |
136 | - if ($nbComments > 0) $head[$h][1].= ' <span class="badge">'.$nbComments.'</span>'; |
|
136 | + if ($nbComments > 0) $head[$h][1] .= ' <span class="badge">'.$nbComments.'</span>'; |
|
137 | 137 | $head[$h][2] = 'project_comment'; |
138 | 138 | $h++; |
139 | 139 | } |
140 | 140 | |
141 | 141 | $head[$h][0] = DOL_URL_ROOT.'/projet/info.php?id='.$object->id; |
142 | - $head[$h][1].= $langs->trans("Events"); |
|
143 | - if (! empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read) )) |
|
142 | + $head[$h][1] .= $langs->trans("Events"); |
|
143 | + if (!empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read))) |
|
144 | 144 | { |
145 | - $head[$h][1].= '/'; |
|
146 | - $head[$h][1].= $langs->trans("Agenda"); |
|
145 | + $head[$h][1] .= '/'; |
|
146 | + $head[$h][1] .= $langs->trans("Agenda"); |
|
147 | 147 | } |
148 | 148 | $head[$h][2] = 'agenda'; |
149 | 149 | $h++; |
150 | 150 | |
151 | - complete_head_from_modules($conf,$langs,$object,$head,$h,'project','remove'); |
|
151 | + complete_head_from_modules($conf, $langs, $object, $head, $h, 'project', 'remove'); |
|
152 | 152 | |
153 | 153 | return $head; |
154 | 154 | } |
@@ -166,20 +166,20 @@ discard block |
||
166 | 166 | $h = 0; |
167 | 167 | $head = array(); |
168 | 168 | |
169 | - $head[$h][0] = DOL_URL_ROOT.'/projet/tasks/task.php?id='.$object->id.(GETPOST('withproject')?'&withproject=1':''); |
|
169 | + $head[$h][0] = DOL_URL_ROOT.'/projet/tasks/task.php?id='.$object->id.(GETPOST('withproject') ? '&withproject=1' : ''); |
|
170 | 170 | $head[$h][1] = $langs->trans("Card"); |
171 | 171 | $head[$h][2] = 'task_task'; |
172 | 172 | $h++; |
173 | 173 | |
174 | - $nbContact = count($object->liste_contact(-1,'internal')) + count($object->liste_contact(-1,'external')); |
|
175 | - $head[$h][0] = DOL_URL_ROOT.'/projet/tasks/contact.php?id='.$object->id.(GETPOST('withproject')?'&withproject=1':''); |
|
174 | + $nbContact = count($object->liste_contact(-1, 'internal')) + count($object->liste_contact(-1, 'external')); |
|
175 | + $head[$h][0] = DOL_URL_ROOT.'/projet/tasks/contact.php?id='.$object->id.(GETPOST('withproject') ? '&withproject=1' : ''); |
|
176 | 176 | $head[$h][1] = $langs->trans("TaskRessourceLinks"); |
177 | - if ($nbContact > 0) $head[$h][1].= ' <span class="badge">'.$nbContact.'</span>'; |
|
177 | + if ($nbContact > 0) $head[$h][1] .= ' <span class="badge">'.$nbContact.'</span>'; |
|
178 | 178 | $head[$h][2] = 'task_contact'; |
179 | 179 | $h++; |
180 | 180 | |
181 | 181 | // Is there timespent ? |
182 | - $nbTimeSpent=0; |
|
182 | + $nbTimeSpent = 0; |
|
183 | 183 | $sql = "SELECT t.rowid"; |
184 | 184 | //$sql .= " FROM ".MAIN_DB_PREFIX."projet_task_time as t, ".MAIN_DB_PREFIX."projet_task as pt, ".MAIN_DB_PREFIX."user as u"; |
185 | 185 | //$sql .= " WHERE t.fk_user = u.rowid AND t.fk_task = pt.rowid"; |
@@ -189,13 +189,13 @@ discard block |
||
189 | 189 | if ($resql) |
190 | 190 | { |
191 | 191 | $obj = $db->fetch_object($resql); |
192 | - if ($obj) $nbTimeSpent=1; |
|
192 | + if ($obj) $nbTimeSpent = 1; |
|
193 | 193 | } |
194 | 194 | else dol_print_error($db); |
195 | 195 | |
196 | - $head[$h][0] = DOL_URL_ROOT.'/projet/tasks/time.php?id='.$object->id.(GETPOST('withproject')?'&withproject=1':''); |
|
196 | + $head[$h][0] = DOL_URL_ROOT.'/projet/tasks/time.php?id='.$object->id.(GETPOST('withproject') ? '&withproject=1' : ''); |
|
197 | 197 | $head[$h][1] = $langs->trans("TimeSpent"); |
198 | - if ($nbTimeSpent > 0) $head[$h][1].= ' <span class="badge">...</span>'; |
|
198 | + if ($nbTimeSpent > 0) $head[$h][1] .= ' <span class="badge">...</span>'; |
|
199 | 199 | $head[$h][2] = 'task_time'; |
200 | 200 | $h++; |
201 | 201 | |
@@ -203,28 +203,28 @@ discard block |
||
203 | 203 | // Entries must be declared in modules descriptor with line |
204 | 204 | // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab |
205 | 205 | // $this->tabs = array('entity:-tabname); to remove a tab |
206 | - complete_head_from_modules($conf,$langs,$object,$head,$h,'task'); |
|
206 | + complete_head_from_modules($conf, $langs, $object, $head, $h, 'task'); |
|
207 | 207 | |
208 | 208 | if (empty($conf->global->MAIN_DISABLE_NOTES_TAB)) |
209 | 209 | { |
210 | 210 | $nbNote = 0; |
211 | - if(!empty($object->note_private)) $nbNote++; |
|
212 | - if(!empty($object->note_public)) $nbNote++; |
|
213 | - $head[$h][0] = DOL_URL_ROOT.'/projet/tasks/note.php?id='.$object->id.(GETPOST('withproject')?'&withproject=1':''); |
|
211 | + if (!empty($object->note_private)) $nbNote++; |
|
212 | + if (!empty($object->note_public)) $nbNote++; |
|
213 | + $head[$h][0] = DOL_URL_ROOT.'/projet/tasks/note.php?id='.$object->id.(GETPOST('withproject') ? '&withproject=1' : ''); |
|
214 | 214 | $head[$h][1] = $langs->trans('Notes'); |
215 | - if ($nbNote > 0) $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>'; |
|
215 | + if ($nbNote > 0) $head[$h][1] .= ' <span class="badge">'.$nbNote.'</span>'; |
|
216 | 216 | $head[$h][2] = 'task_notes'; |
217 | 217 | $h++; |
218 | 218 | } |
219 | 219 | |
220 | - $head[$h][0] = DOL_URL_ROOT.'/projet/tasks/document.php?id='.$object->id.(GETPOST('withproject')?'&withproject=1':''); |
|
221 | - $filesdir = $conf->projet->dir_output . "/" . dol_sanitizeFileName($object->project->ref) . '/' .dol_sanitizeFileName($object->ref); |
|
220 | + $head[$h][0] = DOL_URL_ROOT.'/projet/tasks/document.php?id='.$object->id.(GETPOST('withproject') ? '&withproject=1' : ''); |
|
221 | + $filesdir = $conf->projet->dir_output."/".dol_sanitizeFileName($object->project->ref).'/'.dol_sanitizeFileName($object->ref); |
|
222 | 222 | include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; |
223 | 223 | include_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php'; |
224 | - $nbFiles = count(dol_dir_list($filesdir,'files',0,'','(\.meta|_preview.*\.png)$')); |
|
225 | - $nbLinks=Link::count($db, $object->element, $object->id); |
|
224 | + $nbFiles = count(dol_dir_list($filesdir, 'files', 0, '', '(\.meta|_preview.*\.png)$')); |
|
225 | + $nbLinks = Link::count($db, $object->element, $object->id); |
|
226 | 226 | $head[$h][1] = $langs->trans('Documents'); |
227 | - if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>'; |
|
227 | + if (($nbFiles + $nbLinks) > 0) $head[$h][1] .= ' <span class="badge">'.($nbFiles + $nbLinks).'</span>'; |
|
228 | 228 | $head[$h][2] = 'task_document'; |
229 | 229 | $h++; |
230 | 230 | |
@@ -232,14 +232,14 @@ discard block |
||
232 | 232 | if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_TASK)) |
233 | 233 | { |
234 | 234 | $nbComments = $object->getNbComments(); |
235 | - $head[$h][0] = DOL_URL_ROOT.'/projet/tasks/comment.php?id='.$object->id.(GETPOST('withproject')?'&withproject=1':''); |
|
235 | + $head[$h][0] = DOL_URL_ROOT.'/projet/tasks/comment.php?id='.$object->id.(GETPOST('withproject') ? '&withproject=1' : ''); |
|
236 | 236 | $head[$h][1] = $langs->trans("CommentLink"); |
237 | - if ($nbComments > 0) $head[$h][1].= ' <span class="badge">'.$nbComments.'</span>'; |
|
237 | + if ($nbComments > 0) $head[$h][1] .= ' <span class="badge">'.$nbComments.'</span>'; |
|
238 | 238 | $head[$h][2] = 'task_comment'; |
239 | 239 | $h++; |
240 | 240 | } |
241 | 241 | |
242 | - complete_head_from_modules($conf,$langs,$object,$head,$h,'task','remove'); |
|
242 | + complete_head_from_modules($conf, $langs, $object, $head, $h, 'task', 'remove'); |
|
243 | 243 | |
244 | 244 | return $head; |
245 | 245 | } |
@@ -251,7 +251,7 @@ discard block |
||
251 | 251 | * @param string $fuser Filter on user |
252 | 252 | * @return array Array of tabs to show |
253 | 253 | */ |
254 | -function project_timesheet_prepare_head($mode, $fuser=null) |
|
254 | +function project_timesheet_prepare_head($mode, $fuser = null) |
|
255 | 255 | { |
256 | 256 | global $langs, $conf, $user; |
257 | 257 | $h = 0; |
@@ -259,13 +259,13 @@ discard block |
||
259 | 259 | |
260 | 260 | $h = 0; |
261 | 261 | |
262 | - $param=''; |
|
263 | - $param.=($mode?'&mode='.$mode:''); |
|
264 | - if (is_object($fuser) && $fuser->id > 0 && $fuser->id != $user->id) $param.='&search_usertoprocessid='.$fuser->id; |
|
262 | + $param = ''; |
|
263 | + $param .= ($mode ? '&mode='.$mode : ''); |
|
264 | + if (is_object($fuser) && $fuser->id > 0 && $fuser->id != $user->id) $param .= '&search_usertoprocessid='.$fuser->id; |
|
265 | 265 | |
266 | 266 | if (empty($conf->global->PROJECT_DISABLE_TIMESHEET_PERWEEK)) |
267 | 267 | { |
268 | - $head[$h][0] = DOL_URL_ROOT."/projet/activity/perweek.php".($param?'?'.$param:''); |
|
268 | + $head[$h][0] = DOL_URL_ROOT."/projet/activity/perweek.php".($param ? '?'.$param : ''); |
|
269 | 269 | $head[$h][1] = $langs->trans("InputPerWeek"); |
270 | 270 | $head[$h][2] = 'inputperweek'; |
271 | 271 | $h++; |
@@ -273,7 +273,7 @@ discard block |
||
273 | 273 | |
274 | 274 | if (empty($conf->global->PROJECT_DISABLE_TIMESHEET_PERTIME)) |
275 | 275 | { |
276 | - $head[$h][0] = DOL_URL_ROOT."/projet/activity/perday.php".($param?'?'.$param:''); |
|
276 | + $head[$h][0] = DOL_URL_ROOT."/projet/activity/perday.php".($param ? '?'.$param : ''); |
|
277 | 277 | $head[$h][1] = $langs->trans("InputPerDay"); |
278 | 278 | $head[$h][2] = 'inputperday'; |
279 | 279 | $h++; |
@@ -287,9 +287,9 @@ discard block |
||
287 | 287 | $h++; |
288 | 288 | }*/ |
289 | 289 | |
290 | - complete_head_from_modules($conf,$langs,null,$head,$h,'project_timesheet'); |
|
290 | + complete_head_from_modules($conf, $langs, null, $head, $h, 'project_timesheet'); |
|
291 | 291 | |
292 | - complete_head_from_modules($conf,$langs,null,$head,$h,'project_timesheet','remove'); |
|
292 | + complete_head_from_modules($conf, $langs, null, $head, $h, 'project_timesheet', 'remove'); |
|
293 | 293 | |
294 | 294 | return $head; |
295 | 295 | } |
@@ -313,7 +313,7 @@ discard block |
||
313 | 313 | $head[$h][2] = 'project'; |
314 | 314 | $h++; |
315 | 315 | |
316 | - complete_head_from_modules($conf,$langs,null,$head,$h,'project_admin'); |
|
316 | + complete_head_from_modules($conf, $langs, null, $head, $h, 'project_admin'); |
|
317 | 317 | |
318 | 318 | $head[$h][0] = DOL_URL_ROOT."/projet/admin/project_extrafields.php"; |
319 | 319 | $head[$h][1] = $langs->trans("ExtraFieldsProject"); |
@@ -325,7 +325,7 @@ discard block |
||
325 | 325 | $head[$h][2] = 'attributes_task'; |
326 | 326 | $h++; |
327 | 327 | |
328 | - complete_head_from_modules($conf,$langs,null,$head,$h,'project_admin','remove'); |
|
328 | + complete_head_from_modules($conf, $langs, null, $head, $h, 'project_admin', 'remove'); |
|
329 | 329 | |
330 | 330 | return $head; |
331 | 331 | } |
@@ -347,15 +347,15 @@ discard block |
||
347 | 347 | * @param string $filterprogresscalc filter text |
348 | 348 | * @return void |
349 | 349 | */ |
350 | -function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$taskrole, $projectsListId='', $addordertick=0, $projectidfortotallink=0, $filterprogresscalc='') |
|
350 | +function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$taskrole, $projectsListId = '', $addordertick = 0, $projectidfortotallink = 0, $filterprogresscalc = '') |
|
351 | 351 | { |
352 | 352 | global $user, $bc, $langs, $conf, $db; |
353 | 353 | global $projectstatic, $taskstatic; |
354 | 354 | |
355 | - $lastprojectid=0; |
|
355 | + $lastprojectid = 0; |
|
356 | 356 | |
357 | - $projectsArrayId=explode(',',$projectsListId); |
|
358 | - if ($filterprogresscalc!=='') { |
|
357 | + $projectsArrayId = explode(',', $projectsListId); |
|
358 | + if ($filterprogresscalc !== '') { |
|
359 | 359 | foreach ($lines as $key=>$line) { |
360 | 360 | if (!empty($line->planned_workload) && !empty($line->duration)) { |
361 | 361 | $filterprogresscalc = str_replace(' = ', ' == ', $filterprogresscalc); |
@@ -364,23 +364,23 @@ discard block |
||
364 | 364 | } |
365 | 365 | } |
366 | 366 | } |
367 | - $lines=array_values($lines); |
|
367 | + $lines = array_values($lines); |
|
368 | 368 | } |
369 | 369 | |
370 | - $numlines=count($lines); |
|
370 | + $numlines = count($lines); |
|
371 | 371 | |
372 | 372 | // We declare counter as global because we want to edit them into recursive call |
373 | - global $total_projectlinesa_spent,$total_projectlinesa_planned,$total_projectlinesa_spent_if_planned; |
|
373 | + global $total_projectlinesa_spent, $total_projectlinesa_planned, $total_projectlinesa_spent_if_planned; |
|
374 | 374 | if ($level == 0) |
375 | 375 | { |
376 | - $total_projectlinesa_spent=0; |
|
377 | - $total_projectlinesa_planned=0; |
|
378 | - $total_projectlinesa_spent_if_planned=0; |
|
376 | + $total_projectlinesa_spent = 0; |
|
377 | + $total_projectlinesa_planned = 0; |
|
378 | + $total_projectlinesa_spent_if_planned = 0; |
|
379 | 379 | } |
380 | 380 | |
381 | - for ($i = 0 ; $i < $numlines ; $i++) |
|
381 | + for ($i = 0; $i < $numlines; $i++) |
|
382 | 382 | { |
383 | - if ($parent == 0 && $level >= 0) $level = 0; // if $level = -1, we dont' use sublevel recursion, we show all lines |
|
383 | + if ($parent == 0 && $level >= 0) $level = 0; // if $level = -1, we dont' use sublevel recursion, we show all lines |
|
384 | 384 | |
385 | 385 | // Process line |
386 | 386 | // print "i:".$i."-".$lines[$i]->fk_project.'<br>'; |
@@ -388,26 +388,26 @@ discard block |
||
388 | 388 | if ($lines[$i]->fk_parent == $parent || $level < 0) // if $level = -1, we dont' use sublevel recursion, we show all lines |
389 | 389 | { |
390 | 390 | // Show task line. |
391 | - $showline=1; |
|
392 | - $showlineingray=0; |
|
391 | + $showline = 1; |
|
392 | + $showlineingray = 0; |
|
393 | 393 | |
394 | 394 | // If there is filters to use |
395 | 395 | if (is_array($taskrole)) |
396 | 396 | { |
397 | 397 | // If task not legitimate to show, search if a legitimate task exists later in tree |
398 | - if (! isset($taskrole[$lines[$i]->id]) && $lines[$i]->id != $lines[$i]->fk_parent) |
|
398 | + if (!isset($taskrole[$lines[$i]->id]) && $lines[$i]->id != $lines[$i]->fk_parent) |
|
399 | 399 | { |
400 | 400 | // So search if task has a subtask legitimate to show |
401 | - $foundtaskforuserdeeper=0; |
|
402 | - searchTaskInChild($foundtaskforuserdeeper,$lines[$i]->id,$lines,$taskrole); |
|
401 | + $foundtaskforuserdeeper = 0; |
|
402 | + searchTaskInChild($foundtaskforuserdeeper, $lines[$i]->id, $lines, $taskrole); |
|
403 | 403 | //print '$foundtaskforuserpeeper='.$foundtaskforuserdeeper.'<br>'; |
404 | 404 | if ($foundtaskforuserdeeper > 0) |
405 | 405 | { |
406 | - $showlineingray=1; // We will show line but in gray |
|
406 | + $showlineingray = 1; // We will show line but in gray |
|
407 | 407 | } |
408 | 408 | else |
409 | 409 | { |
410 | - $showline=0; // No reason to show line |
|
410 | + $showline = 0; // No reason to show line |
|
411 | 411 | } |
412 | 412 | } |
413 | 413 | } |
@@ -418,12 +418,12 @@ discard block |
||
418 | 418 | if (empty($user->rights->projet->all->lire)) |
419 | 419 | { |
420 | 420 | // User is not allowed on this project and project is not public, so we hide line |
421 | - if (! in_array($lines[$i]->fk_project, $projectsArrayId)) |
|
421 | + if (!in_array($lines[$i]->fk_project, $projectsArrayId)) |
|
422 | 422 | { |
423 | 423 | // Note that having a user assigned to a task into a project user has no permission on, should not be possible |
424 | 424 | // because assignement on task can be done only on contact of project. |
425 | 425 | // If assignement was done and after, was removed from contact of project, then we can hide the line. |
426 | - $showline=0; |
|
426 | + $showline = 0; |
|
427 | 427 | } |
428 | 428 | } |
429 | 429 | } |
@@ -434,7 +434,7 @@ discard block |
||
434 | 434 | if ($parent == 0 && $lines[$i]->fk_project != $lastprojectid) |
435 | 435 | { |
436 | 436 | $var = !$var; |
437 | - $lastprojectid=$lines[$i]->fk_project; |
|
437 | + $lastprojectid = $lines[$i]->fk_project; |
|
438 | 438 | } |
439 | 439 | |
440 | 440 | print '<tr '.$bc[$var].' id="row-'.$lines[$i]->id.'">'."\n"; |
@@ -444,18 +444,18 @@ discard block |
||
444 | 444 | // Project ref |
445 | 445 | print "<td>"; |
446 | 446 | //if ($showlineingray) print '<i>'; |
447 | - $projectstatic->id=$lines[$i]->fk_project; |
|
448 | - $projectstatic->ref=$lines[$i]->projectref; |
|
449 | - $projectstatic->public=$lines[$i]->public; |
|
450 | - $projectstatic->title=$lines[$i]->projectlabel; |
|
451 | - if ($lines[$i]->public || in_array($lines[$i]->fk_project,$projectsArrayId) || ! empty($user->rights->projet->all->lire)) print $projectstatic->getNomUrl(1); |
|
452 | - else print $projectstatic->getNomUrl(1,'nolink'); |
|
447 | + $projectstatic->id = $lines[$i]->fk_project; |
|
448 | + $projectstatic->ref = $lines[$i]->projectref; |
|
449 | + $projectstatic->public = $lines[$i]->public; |
|
450 | + $projectstatic->title = $lines[$i]->projectlabel; |
|
451 | + if ($lines[$i]->public || in_array($lines[$i]->fk_project, $projectsArrayId) || !empty($user->rights->projet->all->lire)) print $projectstatic->getNomUrl(1); |
|
452 | + else print $projectstatic->getNomUrl(1, 'nolink'); |
|
453 | 453 | //if ($showlineingray) print '</i>'; |
454 | 454 | print "</td>"; |
455 | 455 | |
456 | 456 | // Project status |
457 | 457 | print '<td>'; |
458 | - $projectstatic->statut=$lines[$i]->projectstatus; |
|
458 | + $projectstatic->statut = $lines[$i]->projectstatus; |
|
459 | 459 | print $projectstatic->getLibStatut(2); |
460 | 460 | print "</td>"; |
461 | 461 | } |
@@ -464,14 +464,14 @@ discard block |
||
464 | 464 | print '<td>'; |
465 | 465 | if ($showlineingray) |
466 | 466 | { |
467 | - print '<i>'.img_object('','projecttask').' '.$lines[$i]->ref.'</i>'; |
|
467 | + print '<i>'.img_object('', 'projecttask').' '.$lines[$i]->ref.'</i>'; |
|
468 | 468 | } |
469 | 469 | else |
470 | 470 | { |
471 | - $taskstatic->id=$lines[$i]->id; |
|
472 | - $taskstatic->ref=$lines[$i]->ref; |
|
473 | - $taskstatic->label=($taskrole[$lines[$i]->id]?$langs->trans("YourRole").': '.$taskrole[$lines[$i]->id]:''); |
|
474 | - print $taskstatic->getNomUrl(1,'withproject'); |
|
471 | + $taskstatic->id = $lines[$i]->id; |
|
472 | + $taskstatic->ref = $lines[$i]->ref; |
|
473 | + $taskstatic->label = ($taskrole[$lines[$i]->id] ? $langs->trans("YourRole").': '.$taskrole[$lines[$i]->id] : ''); |
|
474 | + print $taskstatic->getNomUrl(1, 'withproject'); |
|
475 | 475 | } |
476 | 476 | print '</td>'; |
477 | 477 | |
@@ -479,7 +479,7 @@ discard block |
||
479 | 479 | print "<td>"; |
480 | 480 | if ($showlineingray) print '<i>'; |
481 | 481 | //else print '<a href="'.DOL_URL_ROOT.'/projet/tasks/task.php?id='.$lines[$i]->id.'&withproject=1">'; |
482 | - for ($k = 0 ; $k < $level ; $k++) |
|
482 | + for ($k = 0; $k < $level; $k++) |
|
483 | 483 | { |
484 | 484 | print " "; |
485 | 485 | } |
@@ -490,7 +490,7 @@ discard block |
||
490 | 490 | |
491 | 491 | // Date start |
492 | 492 | print '<td align="center">'; |
493 | - print dol_print_date($lines[$i]->date_start,'dayhour'); |
|
493 | + print dol_print_date($lines[$i]->date_start, 'dayhour'); |
|
494 | 494 | print '</td>'; |
495 | 495 | |
496 | 496 | // Date end |
@@ -499,19 +499,19 @@ discard block |
||
499 | 499 | $taskstatic->progress = $lines[$i]->progress; |
500 | 500 | $taskstatic->fk_statut = $lines[$i]->status; |
501 | 501 | $taskstatic->datee = $lines[$i]->date_end; |
502 | - print dol_print_date($lines[$i]->date_end,'dayhour'); |
|
502 | + print dol_print_date($lines[$i]->date_end, 'dayhour'); |
|
503 | 503 | if ($taskstatic->hasDelay()) print img_warning($langs->trans("Late")); |
504 | 504 | print '</td>'; |
505 | 505 | |
506 | - $plannedworkloadoutputformat='allhourmin'; |
|
507 | - $timespentoutputformat='allhourmin'; |
|
508 | - if (! empty($conf->global->PROJECT_PLANNED_WORKLOAD_FORMAT)) $plannedworkloadoutputformat=$conf->global->PROJECT_PLANNED_WORKLOAD_FORMAT; |
|
509 | - if (! empty($conf->global->PROJECT_TIMES_SPENT_FORMAT)) $timespentoutputformat=$conf->global->PROJECT_TIME_SPENT_FORMAT; |
|
506 | + $plannedworkloadoutputformat = 'allhourmin'; |
|
507 | + $timespentoutputformat = 'allhourmin'; |
|
508 | + if (!empty($conf->global->PROJECT_PLANNED_WORKLOAD_FORMAT)) $plannedworkloadoutputformat = $conf->global->PROJECT_PLANNED_WORKLOAD_FORMAT; |
|
509 | + if (!empty($conf->global->PROJECT_TIMES_SPENT_FORMAT)) $timespentoutputformat = $conf->global->PROJECT_TIME_SPENT_FORMAT; |
|
510 | 510 | |
511 | 511 | // Planned Workload (in working hours) |
512 | 512 | print '<td align="right">'; |
513 | - $fullhour=convertSecondToTime($lines[$i]->planned_workload,$plannedworkloadoutputformat); |
|
514 | - $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 |
|
513 | + $fullhour = convertSecondToTime($lines[$i]->planned_workload, $plannedworkloadoutputformat); |
|
514 | + $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 |
|
515 | 515 | if ($lines[$i]->planned_workload != '') |
516 | 516 | { |
517 | 517 | print $fullhour; |
@@ -524,8 +524,8 @@ discard block |
||
524 | 524 | // Time spent |
525 | 525 | print '<td align="right">'; |
526 | 526 | if ($showlineingray) print '<i>'; |
527 | - else print '<a href="'.DOL_URL_ROOT.'/projet/tasks/time.php?id='.$lines[$i]->id.($showproject?'':'&withproject=1').'">'; |
|
528 | - if ($lines[$i]->duration) print convertSecondToTime($lines[$i]->duration,$timespentoutputformat); |
|
527 | + else print '<a href="'.DOL_URL_ROOT.'/projet/tasks/time.php?id='.$lines[$i]->id.($showproject ? '' : '&withproject=1').'">'; |
|
528 | + if ($lines[$i]->duration) print convertSecondToTime($lines[$i]->duration, $timespentoutputformat); |
|
529 | 529 | else print '--:--'; |
530 | 530 | if ($showlineingray) print '</i>'; |
531 | 531 | else print '</a>'; |
@@ -535,7 +535,7 @@ discard block |
||
535 | 535 | print '<td align="right">'; |
536 | 536 | if ($lines[$i]->planned_workload || $lines[$i]->duration) |
537 | 537 | { |
538 | - if ($lines[$i]->planned_workload) print round(100 * $lines[$i]->duration / $lines[$i]->planned_workload,2).' %'; |
|
538 | + if ($lines[$i]->planned_workload) print round(100 * $lines[$i]->duration / $lines[$i]->planned_workload, 2).' %'; |
|
539 | 539 | else print '<span class="opacitymedium">'.$langs->trans('WorkloadNotDefined').'</span>'; |
540 | 540 | } |
541 | 541 | print '</td>'; |
@@ -549,20 +549,20 @@ discard block |
||
549 | 549 | print '</td>'; |
550 | 550 | |
551 | 551 | // Contacts of task |
552 | - if (! empty($conf->global->PROJECT_SHOW_CONTACTS_IN_LIST)) |
|
552 | + if (!empty($conf->global->PROJECT_SHOW_CONTACTS_IN_LIST)) |
|
553 | 553 | { |
554 | 554 | print '<td>'; |
555 | - foreach(array('internal','external') as $source) |
|
555 | + foreach (array('internal', 'external') as $source) |
|
556 | 556 | { |
557 | - $tab = $lines[$i]->liste_contact(-1,$source); |
|
558 | - $num=count($tab); |
|
559 | - if (!empty($num)){ |
|
560 | - foreach ($tab as $contacttask){ |
|
557 | + $tab = $lines[$i]->liste_contact(-1, $source); |
|
558 | + $num = count($tab); |
|
559 | + if (!empty($num)) { |
|
560 | + foreach ($tab as $contacttask) { |
|
561 | 561 | //var_dump($contacttask); |
562 | 562 | if ($source == 'internal') $c = new User($db); |
563 | 563 | else $c = new Contact($db); |
564 | 564 | $c->fetch($contacttask['id']); |
565 | - print $c->getNomUrl(1) . ' (' . $contacttask['libelle'] . ')' . '<br>'; |
|
565 | + print $c->getNomUrl(1).' ('.$contacttask['libelle'].')'.'<br>'; |
|
566 | 566 | } |
567 | 567 | } |
568 | 568 | } |
@@ -577,7 +577,7 @@ discard block |
||
577 | 577 | |
578 | 578 | print "</tr>\n"; |
579 | 579 | |
580 | - if (! $showlineingray) $inc++; |
|
580 | + if (!$showlineingray) $inc++; |
|
581 | 581 | |
582 | 582 | if ($level >= 0) // Call sublevels |
583 | 583 | { |
@@ -609,16 +609,16 @@ discard block |
||
609 | 609 | print convertSecondToTime($total_projectlinesa_planned, 'allhourmin'); |
610 | 610 | print '</td>'; |
611 | 611 | print '<td align="right" class="nowrap liste_total">'; |
612 | - if ($projectidfortotallink > 0) print '<a href="'.DOL_URL_ROOT.'/projet/tasks/time.php?projectid='.$projectidfortotallink.($showproject?'':'&withproject=1').'">'; |
|
612 | + if ($projectidfortotallink > 0) print '<a href="'.DOL_URL_ROOT.'/projet/tasks/time.php?projectid='.$projectidfortotallink.($showproject ? '' : '&withproject=1').'">'; |
|
613 | 613 | print convertSecondToTime($total_projectlinesa_spent, 'allhourmin'); |
614 | 614 | if ($projectidfortotallink > 0) print '</a>'; |
615 | 615 | print '</td>'; |
616 | 616 | print '<td align="right" class="nowrap liste_total">'; |
617 | - if ($total_projectlinesa_planned) print round(100 * $total_projectlinesa_spent / $total_projectlinesa_planned,2).' %'; |
|
617 | + if ($total_projectlinesa_planned) print round(100 * $total_projectlinesa_spent / $total_projectlinesa_planned, 2).' %'; |
|
618 | 618 | print '</td>'; |
619 | 619 | print '<td></td>'; |
620 | 620 | // Contacts of task |
621 | - if (! empty($conf->global->PROJECT_SHOW_CONTACTS_IN_LIST)) |
|
621 | + if (!empty($conf->global->PROJECT_SHOW_CONTACTS_IN_LIST)) |
|
622 | 622 | { |
623 | 623 | print '<td></td>'; |
624 | 624 | } |
@@ -647,48 +647,48 @@ discard block |
||
647 | 647 | * @param int $oldprojectforbreak Old project id of last project break |
648 | 648 | * @return array Array with time spent for $fuser for each day of week on tasks in $lines and substasks |
649 | 649 | */ |
650 | -function projectLinesPerAction(&$inc, $parent, $fuser, $lines, &$level, &$projectsrole, &$tasksrole, $mine, $restricteditformytask, $preselectedday, &$isavailable, $oldprojectforbreak=0) |
|
650 | +function projectLinesPerAction(&$inc, $parent, $fuser, $lines, &$level, &$projectsrole, &$tasksrole, $mine, $restricteditformytask, $preselectedday, &$isavailable, $oldprojectforbreak = 0) |
|
651 | 651 | { |
652 | 652 | global $conf, $db, $user, $bc, $langs; |
653 | 653 | global $form, $formother, $projectstatic, $taskstatic, $thirdpartystatic; |
654 | 654 | |
655 | - $lastprojectid=0; |
|
656 | - $totalforeachline=array(); |
|
657 | - $workloadforid=array(); |
|
658 | - $lineswithoutlevel0=array(); |
|
655 | + $lastprojectid = 0; |
|
656 | + $totalforeachline = array(); |
|
657 | + $workloadforid = array(); |
|
658 | + $lineswithoutlevel0 = array(); |
|
659 | 659 | |
660 | - $numlines=count($lines); |
|
660 | + $numlines = count($lines); |
|
661 | 661 | |
662 | 662 | // Create a smaller array with sublevels only to be used later. This increase dramatically performances. |
663 | 663 | if ($parent == 0) // Always and only if at first level |
664 | 664 | { |
665 | - for ($i = 0 ; $i < $numlines ; $i++) |
|
665 | + for ($i = 0; $i < $numlines; $i++) |
|
666 | 666 | { |
667 | - if ($lines[$i]->fk_task_parent) $lineswithoutlevel0[]=$lines[$i]; |
|
667 | + if ($lines[$i]->fk_task_parent) $lineswithoutlevel0[] = $lines[$i]; |
|
668 | 668 | } |
669 | 669 | } |
670 | 670 | |
671 | 671 | if (empty($oldprojectforbreak)) |
672 | 672 | { |
673 | - $oldprojectforbreak = (empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)?0:-1); // 0 to start break , -1 no break |
|
673 | + $oldprojectforbreak = (empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT) ? 0 : -1); // 0 to start break , -1 no break |
|
674 | 674 | } |
675 | 675 | |
676 | 676 | //dol_syslog('projectLinesPerDay inc='.$inc.' preselectedday='.$preselectedday.' task parent id='.$parent.' level='.$level." count(lines)=".$numlines." count(lineswithoutlevel0)=".count($lineswithoutlevel0)); |
677 | - for ($i = 0 ; $i < $numlines ; $i++) |
|
677 | + for ($i = 0; $i < $numlines; $i++) |
|
678 | 678 | { |
679 | 679 | if ($parent == 0) $level = 0; |
680 | 680 | |
681 | 681 | //if ($lines[$i]->fk_task_parent == $parent) |
682 | 682 | //{ |
683 | 683 | // If we want all or we have a role on task, we show it |
684 | - if (empty($mine) || ! empty($tasksrole[$lines[$i]->id])) |
|
684 | + if (empty($mine) || !empty($tasksrole[$lines[$i]->id])) |
|
685 | 685 | { |
686 | 686 | //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); |
687 | 687 | |
688 | 688 | // Break on a new project |
689 | 689 | if ($parent == 0 && $lines[$i]->fk_project != $lastprojectid) |
690 | 690 | { |
691 | - $lastprojectid=$lines[$i]->fk_project; |
|
691 | + $lastprojectid = $lines[$i]->fk_project; |
|
692 | 692 | if ($preselectedday) |
693 | 693 | { |
694 | 694 | $projectstatic->id = $lines[$i]->fk_project; |
@@ -699,31 +699,31 @@ discard block |
||
699 | 699 | { |
700 | 700 | if ($preselectedday) |
701 | 701 | { |
702 | - $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 |
|
703 | - $workloadforid[$projectstatic->id]=1; |
|
702 | + $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 |
|
703 | + $workloadforid[$projectstatic->id] = 1; |
|
704 | 704 | } |
705 | 705 | } |
706 | 706 | |
707 | - $projectstatic->id=$lines[$i]->fk_project; |
|
708 | - $projectstatic->ref=$lines[$i]->project_ref; |
|
709 | - $projectstatic->title=$lines[$i]->project_label; |
|
710 | - $projectstatic->public=$lines[$i]->public; |
|
707 | + $projectstatic->id = $lines[$i]->fk_project; |
|
708 | + $projectstatic->ref = $lines[$i]->project_ref; |
|
709 | + $projectstatic->title = $lines[$i]->project_label; |
|
710 | + $projectstatic->public = $lines[$i]->public; |
|
711 | 711 | |
712 | - $taskstatic->id=$lines[$i]->task_id; |
|
713 | - $taskstatic->ref=($lines[$i]->task_ref?$lines[$i]->task_ref:$lines[$i]->task_id); |
|
714 | - $taskstatic->label=$lines[$i]->task_label; |
|
715 | - $taskstatic->date_start=$lines[$i]->date_start; |
|
716 | - $taskstatic->date_end=$lines[$i]->date_end; |
|
712 | + $taskstatic->id = $lines[$i]->task_id; |
|
713 | + $taskstatic->ref = ($lines[$i]->task_ref ? $lines[$i]->task_ref : $lines[$i]->task_id); |
|
714 | + $taskstatic->label = $lines[$i]->task_label; |
|
715 | + $taskstatic->date_start = $lines[$i]->date_start; |
|
716 | + $taskstatic->date_end = $lines[$i]->date_end; |
|
717 | 717 | |
718 | - $thirdpartystatic->id=$lines[$i]->socid; |
|
719 | - $thirdpartystatic->name=$lines[$i]->thirdparty_name; |
|
720 | - $thirdpartystatic->email=$lines[$i]->thirdparty_email; |
|
718 | + $thirdpartystatic->id = $lines[$i]->socid; |
|
719 | + $thirdpartystatic->name = $lines[$i]->thirdparty_name; |
|
720 | + $thirdpartystatic->email = $lines[$i]->thirdparty_email; |
|
721 | 721 | |
722 | 722 | if (empty($oldprojectforbreak) || ($oldprojectforbreak != -1 && $oldprojectforbreak != $projectstatic->id)) |
723 | 723 | { |
724 | 724 | print '<tr class="oddeven trforbreak">'."\n"; |
725 | 725 | print '<td colspan="11">'; |
726 | - print $projectstatic->getNomUrl(1,'',0,$langs->transnoentitiesnoconv("YourRole").': '.$projectsrole[$lines[$i]->fk_project]); |
|
726 | + print $projectstatic->getNomUrl(1, '', 0, $langs->transnoentitiesnoconv("YourRole").': '.$projectsrole[$lines[$i]->fk_project]); |
|
727 | 727 | if ($projectstatic->title) |
728 | 728 | { |
729 | 729 | print ' - '; |
@@ -748,7 +748,7 @@ discard block |
||
748 | 748 | print "<td>"; |
749 | 749 | if ($oldprojectforbreak == -1) |
750 | 750 | { |
751 | - print $projectstatic->getNomUrl(1,'',0,$langs->transnoentitiesnoconv("YourRole").': '.$projectsrole[$lines[$i]->fk_project]); |
|
751 | + print $projectstatic->getNomUrl(1, '', 0, $langs->transnoentitiesnoconv("YourRole").': '.$projectsrole[$lines[$i]->fk_project]); |
|
752 | 752 | print '<br>'.$projectstatic->title; |
753 | 753 | } |
754 | 754 | print "</td>"; |
@@ -761,11 +761,11 @@ discard block |
||
761 | 761 | // Ref |
762 | 762 | print '<td>'; |
763 | 763 | print '<!-- Task id = '.$lines[$i]->id.' -->'; |
764 | - for ($k = 0 ; $k < $level ; $k++) print " "; |
|
764 | + for ($k = 0; $k < $level; $k++) print " "; |
|
765 | 765 | print $taskstatic->getNomUrl(1, 'withproject', 'time'); |
766 | 766 | // Label task |
767 | 767 | print '<br>'; |
768 | - for ($k = 0 ; $k < $level ; $k++) print " "; |
|
768 | + for ($k = 0; $k < $level; $k++) print " "; |
|
769 | 769 | print $taskstatic->label; |
770 | 770 | //print "<br>"; |
771 | 771 | //for ($k = 0 ; $k < $level ; $k++) print " "; |
@@ -774,47 +774,47 @@ discard block |
||
774 | 774 | |
775 | 775 | // Date |
776 | 776 | print '<td align="center">'; |
777 | - print dol_print_date($lines[$i]->timespent_datehour,'day'); |
|
777 | + print dol_print_date($lines[$i]->timespent_datehour, 'day'); |
|
778 | 778 | print '</td>'; |
779 | 779 | |
780 | - $disabledproject=1;$disabledtask=1; |
|
780 | + $disabledproject = 1; $disabledtask = 1; |
|
781 | 781 | //print "x".$lines[$i]->fk_project; |
782 | 782 | //var_dump($lines[$i]); |
783 | 783 | //var_dump($projectsrole[$lines[$i]->fk_project]); |
784 | 784 | // If at least one role for project |
785 | - if ($lines[$i]->public || ! empty($projectsrole[$lines[$i]->fk_project]) || $user->rights->projet->all->creer) |
|
785 | + if ($lines[$i]->public || !empty($projectsrole[$lines[$i]->fk_project]) || $user->rights->projet->all->creer) |
|
786 | 786 | { |
787 | - $disabledproject=0; |
|
788 | - $disabledtask=0; |
|
787 | + $disabledproject = 0; |
|
788 | + $disabledtask = 0; |
|
789 | 789 | } |
790 | 790 | // If $restricteditformytask is on and I have no role on task, i disable edit |
791 | 791 | if ($restricteditformytask && empty($tasksrole[$lines[$i]->id])) |
792 | 792 | { |
793 | - $disabledtask=1; |
|
793 | + $disabledtask = 1; |
|
794 | 794 | } |
795 | 795 | |
796 | 796 | // Hour |
797 | 797 | print '<td class="nowrap" align="center">'; |
798 | - print dol_print_date($lines[$i]->timespent_datehour,'hour'); |
|
798 | + print dol_print_date($lines[$i]->timespent_datehour, 'hour'); |
|
799 | 799 | print '</td>'; |
800 | 800 | |
801 | - $cssonholiday=''; |
|
802 | - if (! $isavailable[$preselectedday]['morning'] && ! $isavailable[$preselectedday]['afternoon']) $cssonholiday.='onholidayallday '; |
|
803 | - elseif (! $isavailable[$preselectedday]['morning']) $cssonholiday.='onholidaymorning '; |
|
804 | - elseif (! $isavailable[$preselectedday]['afternoon']) $cssonholiday.='onholidayafternoon '; |
|
801 | + $cssonholiday = ''; |
|
802 | + if (!$isavailable[$preselectedday]['morning'] && !$isavailable[$preselectedday]['afternoon']) $cssonholiday .= 'onholidayallday '; |
|
803 | + elseif (!$isavailable[$preselectedday]['morning']) $cssonholiday .= 'onholidaymorning '; |
|
804 | + elseif (!$isavailable[$preselectedday]['afternoon']) $cssonholiday .= 'onholidayafternoon '; |
|
805 | 805 | |
806 | 806 | // Duration |
807 | - print '<td align="center" class="duration'.($cssonholiday?' '.$cssonholiday:'').'">'; |
|
807 | + print '<td align="center" class="duration'.($cssonholiday ? ' '.$cssonholiday : '').'">'; |
|
808 | 808 | |
809 | 809 | $dayWorkLoad = $lines[$i]->timespent_duration; |
810 | - $totalforeachline[$preselectedday]+=$lines[$i]->timespent_duration; |
|
810 | + $totalforeachline[$preselectedday] += $lines[$i]->timespent_duration; |
|
811 | 811 | |
812 | - $alreadyspent=''; |
|
813 | - if ($dayWorkLoad > 0) $alreadyspent=convertSecondToTime($lines[$i]->timespent_duration,'allhourmin'); |
|
812 | + $alreadyspent = ''; |
|
813 | + if ($dayWorkLoad > 0) $alreadyspent = convertSecondToTime($lines[$i]->timespent_duration, 'allhourmin'); |
|
814 | 814 | |
815 | - print convertSecondToTime($lines[$i]->timespent_duration,'allhourmin'); |
|
815 | + print convertSecondToTime($lines[$i]->timespent_duration, 'allhourmin'); |
|
816 | 816 | |
817 | - $modeinput='hours'; |
|
817 | + $modeinput = 'hours'; |
|
818 | 818 | |
819 | 819 | print '<script type="text/javascript">'; |
820 | 820 | print "jQuery(document).ready(function () {\n"; |
@@ -826,7 +826,7 @@ discard block |
||
826 | 826 | |
827 | 827 | // Note |
828 | 828 | print '<td align="center">'; |
829 | - print '<textarea name="'.$lines[$i]->id.'note" rows="'.ROWS_2.'" id="'.$lines[$i]->id.'note"'.($disabledtask?' disabled="disabled"':'').'>'; |
|
829 | + print '<textarea name="'.$lines[$i]->id.'note" rows="'.ROWS_2.'" id="'.$lines[$i]->id.'note"'.($disabledtask ? ' disabled="disabled"' : '').'>'; |
|
830 | 830 | print $lines[$i]->timespent_note; |
831 | 831 | print '</textarea>'; |
832 | 832 | print '</td>'; |
@@ -873,41 +873,41 @@ discard block |
||
873 | 873 | * @param int $oldprojectforbreak Old project id of last project break |
874 | 874 | * @return array Array with time spent for $fuser for each day of week on tasks in $lines and substasks |
875 | 875 | */ |
876 | -function projectLinesPerDay(&$inc, $parent, $fuser, $lines, &$level, &$projectsrole, &$tasksrole, $mine, $restricteditformytask, $preselectedday, &$isavailable, $oldprojectforbreak=0) |
|
876 | +function projectLinesPerDay(&$inc, $parent, $fuser, $lines, &$level, &$projectsrole, &$tasksrole, $mine, $restricteditformytask, $preselectedday, &$isavailable, $oldprojectforbreak = 0) |
|
877 | 877 | { |
878 | 878 | global $conf, $db, $user, $bc, $langs; |
879 | 879 | global $form, $formother, $projectstatic, $taskstatic, $thirdpartystatic; |
880 | 880 | |
881 | - $lastprojectid=0; |
|
882 | - $totalforeachday=array(); |
|
883 | - $workloadforid=array(); |
|
884 | - $lineswithoutlevel0=array(); |
|
881 | + $lastprojectid = 0; |
|
882 | + $totalforeachday = array(); |
|
883 | + $workloadforid = array(); |
|
884 | + $lineswithoutlevel0 = array(); |
|
885 | 885 | |
886 | - $numlines=count($lines); |
|
886 | + $numlines = count($lines); |
|
887 | 887 | |
888 | 888 | // Create a smaller array with sublevels only to be used later. This increase dramatically performances. |
889 | 889 | if ($parent == 0) // Always and only if at first level |
890 | 890 | { |
891 | - for ($i = 0 ; $i < $numlines ; $i++) |
|
891 | + for ($i = 0; $i < $numlines; $i++) |
|
892 | 892 | { |
893 | - if ($lines[$i]->fk_task_parent) $lineswithoutlevel0[]=$lines[$i]; |
|
893 | + if ($lines[$i]->fk_task_parent) $lineswithoutlevel0[] = $lines[$i]; |
|
894 | 894 | } |
895 | 895 | } |
896 | 896 | |
897 | 897 | if (empty($oldprojectforbreak)) |
898 | 898 | { |
899 | - $oldprojectforbreak = (empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)?0:-1); // 0 to start break , -1 no break |
|
899 | + $oldprojectforbreak = (empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT) ? 0 : -1); // 0 to start break , -1 no break |
|
900 | 900 | } |
901 | 901 | |
902 | 902 | //dol_syslog('projectLinesPerDay inc='.$inc.' preselectedday='.$preselectedday.' task parent id='.$parent.' level='.$level." count(lines)=".$numlines." count(lineswithoutlevel0)=".count($lineswithoutlevel0)); |
903 | - for ($i = 0 ; $i < $numlines ; $i++) |
|
903 | + for ($i = 0; $i < $numlines; $i++) |
|
904 | 904 | { |
905 | 905 | if ($parent == 0) $level = 0; |
906 | 906 | |
907 | 907 | if ($lines[$i]->fk_task_parent == $parent) |
908 | 908 | { |
909 | 909 | // If we want all or we have a role on task, we show it |
910 | - if (empty($mine) || ! empty($tasksrole[$lines[$i]->id])) |
|
910 | + if (empty($mine) || !empty($tasksrole[$lines[$i]->id])) |
|
911 | 911 | { |
912 | 912 | //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); |
913 | 913 | |
@@ -919,7 +919,7 @@ discard block |
||
919 | 919 | // Break on a new project |
920 | 920 | if ($parent == 0 && $lines[$i]->fk_project != $lastprojectid) |
921 | 921 | { |
922 | - $lastprojectid=$lines[$i]->fk_project; |
|
922 | + $lastprojectid = $lines[$i]->fk_project; |
|
923 | 923 | if ($preselectedday) |
924 | 924 | { |
925 | 925 | $projectstatic->id = $lines[$i]->fk_project; |
@@ -930,31 +930,31 @@ discard block |
||
930 | 930 | { |
931 | 931 | if ($preselectedday) |
932 | 932 | { |
933 | - $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 |
|
934 | - $workloadforid[$projectstatic->id]=1; |
|
933 | + $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 |
|
934 | + $workloadforid[$projectstatic->id] = 1; |
|
935 | 935 | } |
936 | 936 | } |
937 | 937 | |
938 | - $projectstatic->id=$lines[$i]->fk_project; |
|
939 | - $projectstatic->ref=$lines[$i]->projectref; |
|
940 | - $projectstatic->title=$lines[$i]->projectlabel; |
|
941 | - $projectstatic->public=$lines[$i]->public; |
|
938 | + $projectstatic->id = $lines[$i]->fk_project; |
|
939 | + $projectstatic->ref = $lines[$i]->projectref; |
|
940 | + $projectstatic->title = $lines[$i]->projectlabel; |
|
941 | + $projectstatic->public = $lines[$i]->public; |
|
942 | 942 | |
943 | - $taskstatic->id=$lines[$i]->id; |
|
944 | - $taskstatic->ref=($lines[$i]->ref?$lines[$i]->ref:$lines[$i]->id); |
|
945 | - $taskstatic->label=$lines[$i]->label; |
|
946 | - $taskstatic->date_start=$lines[$i]->date_start; |
|
947 | - $taskstatic->date_end=$lines[$i]->date_end; |
|
943 | + $taskstatic->id = $lines[$i]->id; |
|
944 | + $taskstatic->ref = ($lines[$i]->ref ? $lines[$i]->ref : $lines[$i]->id); |
|
945 | + $taskstatic->label = $lines[$i]->label; |
|
946 | + $taskstatic->date_start = $lines[$i]->date_start; |
|
947 | + $taskstatic->date_end = $lines[$i]->date_end; |
|
948 | 948 | |
949 | - $thirdpartystatic->id=$lines[$i]->socid; |
|
950 | - $thirdpartystatic->name=$lines[$i]->thirdparty_name; |
|
951 | - $thirdpartystatic->email=$lines[$i]->thirdparty_email; |
|
949 | + $thirdpartystatic->id = $lines[$i]->socid; |
|
950 | + $thirdpartystatic->name = $lines[$i]->thirdparty_name; |
|
951 | + $thirdpartystatic->email = $lines[$i]->thirdparty_email; |
|
952 | 952 | |
953 | 953 | if (empty($oldprojectforbreak) || ($oldprojectforbreak != -1 && $oldprojectforbreak != $projectstatic->id)) |
954 | 954 | { |
955 | 955 | print '<tr class="oddeven trforbreak">'."\n"; |
956 | 956 | print '<td colspan="9">'; |
957 | - print $projectstatic->getNomUrl(1,'',0,'<strong>'.$langs->transnoentitiesnoconv("YourRole").':</strong> '.$projectsrole[$lines[$i]->fk_project]); |
|
957 | + print $projectstatic->getNomUrl(1, '', 0, '<strong>'.$langs->transnoentitiesnoconv("YourRole").':</strong> '.$projectsrole[$lines[$i]->fk_project]); |
|
958 | 958 | if ($thirdpartystatic->id > 0) print ' - '.$thirdpartystatic->getNomUrl(1); |
959 | 959 | if ($projectstatic->title) |
960 | 960 | { |
@@ -989,11 +989,11 @@ discard block |
||
989 | 989 | // Ref |
990 | 990 | print '<td>'; |
991 | 991 | print '<!-- Task id = '.$lines[$i]->id.' -->'; |
992 | - for ($k = 0 ; $k < $level ; $k++) print " "; |
|
992 | + for ($k = 0; $k < $level; $k++) print " "; |
|
993 | 993 | print $taskstatic->getNomUrl(1, 'withproject', 'time'); |
994 | 994 | // Label task |
995 | 995 | print '<br>'; |
996 | - for ($k = 0 ; $k < $level ; $k++) print " "; |
|
996 | + for ($k = 0; $k < $level; $k++) print " "; |
|
997 | 997 | print $taskstatic->label; |
998 | 998 | //print "<br>"; |
999 | 999 | //for ($k = 0 ; $k < $level ; $k++) print " "; |
@@ -1002,13 +1002,13 @@ discard block |
||
1002 | 1002 | |
1003 | 1003 | // Planned Workload |
1004 | 1004 | print '<td align="right" class="leftborder plannedworkload">'; |
1005 | - if ($lines[$i]->planned_workload) print convertSecondToTime($lines[$i]->planned_workload,'allhourmin'); |
|
1005 | + if ($lines[$i]->planned_workload) print convertSecondToTime($lines[$i]->planned_workload, 'allhourmin'); |
|
1006 | 1006 | else print '--:--'; |
1007 | 1007 | print '</td>'; |
1008 | 1008 | |
1009 | 1009 | // Progress declared % |
1010 | 1010 | print '<td align="right">'; |
1011 | - print $formother->select_percent($lines[$i]->progress, $lines[$i]->id . 'progress'); |
|
1011 | + print $formother->select_percent($lines[$i]->progress, $lines[$i]->id.'progress'); |
|
1012 | 1012 | print '</td>'; |
1013 | 1013 | |
1014 | 1014 | // Time spent by everybody |
@@ -1017,7 +1017,7 @@ discard block |
||
1017 | 1017 | if ($lines[$i]->duration) |
1018 | 1018 | { |
1019 | 1019 | print '<a href="'.DOL_URL_ROOT.'/projet/tasks/time.php?id='.$lines[$i]->id.'">'; |
1020 | - print convertSecondToTime($lines[$i]->duration,'allhourmin'); |
|
1020 | + print convertSecondToTime($lines[$i]->duration, 'allhourmin'); |
|
1021 | 1021 | print '</a>'; |
1022 | 1022 | } |
1023 | 1023 | else print '--:--'; |
@@ -1025,25 +1025,25 @@ discard block |
||
1025 | 1025 | |
1026 | 1026 | // Time spent by user |
1027 | 1027 | print '<td align="right">'; |
1028 | - $tmptimespent=$taskstatic->getSummaryOfTimeSpent($fuser->id); |
|
1029 | - if ($tmptimespent['total_duration']) print convertSecondToTime($tmptimespent['total_duration'],'allhourmin'); |
|
1028 | + $tmptimespent = $taskstatic->getSummaryOfTimeSpent($fuser->id); |
|
1029 | + if ($tmptimespent['total_duration']) print convertSecondToTime($tmptimespent['total_duration'], 'allhourmin'); |
|
1030 | 1030 | else print '--:--'; |
1031 | 1031 | print "</td>\n"; |
1032 | 1032 | |
1033 | - $disabledproject=1;$disabledtask=1; |
|
1033 | + $disabledproject = 1; $disabledtask = 1; |
|
1034 | 1034 | //print "x".$lines[$i]->fk_project; |
1035 | 1035 | //var_dump($lines[$i]); |
1036 | 1036 | //var_dump($projectsrole[$lines[$i]->fk_project]); |
1037 | 1037 | // If at least one role for project |
1038 | - if ($lines[$i]->public || ! empty($projectsrole[$lines[$i]->fk_project]) || $user->rights->projet->all->creer) |
|
1038 | + if ($lines[$i]->public || !empty($projectsrole[$lines[$i]->fk_project]) || $user->rights->projet->all->creer) |
|
1039 | 1039 | { |
1040 | - $disabledproject=0; |
|
1041 | - $disabledtask=0; |
|
1040 | + $disabledproject = 0; |
|
1041 | + $disabledtask = 0; |
|
1042 | 1042 | } |
1043 | 1043 | // If $restricteditformytask is on and I have no role on task, i disable edit |
1044 | 1044 | if ($restricteditformytask && empty($tasksrole[$lines[$i]->id])) |
1045 | 1045 | { |
1046 | - $disabledtask=1; |
|
1046 | + $disabledtask = 1; |
|
1047 | 1047 | } |
1048 | 1048 | |
1049 | 1049 | // Form to add new time |
@@ -1052,41 +1052,41 @@ discard block |
||
1052 | 1052 | print $tableCell; |
1053 | 1053 | print '</td>'; |
1054 | 1054 | |
1055 | - $cssonholiday=''; |
|
1056 | - if (! $isavailable[$preselectedday]['morning'] && ! $isavailable[$preselectedday]['afternoon']) $cssonholiday.='onholidayallday '; |
|
1057 | - elseif (! $isavailable[$preselectedday]['morning']) $cssonholiday.='onholidaymorning '; |
|
1058 | - elseif (! $isavailable[$preselectedday]['afternoon']) $cssonholiday.='onholidayafternoon '; |
|
1055 | + $cssonholiday = ''; |
|
1056 | + if (!$isavailable[$preselectedday]['morning'] && !$isavailable[$preselectedday]['afternoon']) $cssonholiday .= 'onholidayallday '; |
|
1057 | + elseif (!$isavailable[$preselectedday]['morning']) $cssonholiday .= 'onholidaymorning '; |
|
1058 | + elseif (!$isavailable[$preselectedday]['afternoon']) $cssonholiday .= 'onholidayafternoon '; |
|
1059 | 1059 | |
1060 | 1060 | global $daytoparse; |
1061 | - $tmparray = dol_getdate($daytoparse,true); // detail of current day |
|
1061 | + $tmparray = dol_getdate($daytoparse, true); // detail of current day |
|
1062 | 1062 | $idw = $tmparray['wday']; |
1063 | 1063 | |
1064 | 1064 | global $numstartworkingday, $numendworkingday; |
1065 | - $cssweekend=''; |
|
1065 | + $cssweekend = ''; |
|
1066 | 1066 | 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. |
1067 | 1067 | { |
1068 | - $cssweekend='weekend'; |
|
1068 | + $cssweekend = 'weekend'; |
|
1069 | 1069 | } |
1070 | 1070 | |
1071 | 1071 | // Duration |
1072 | - print '<td class="center duration'.($cssonholiday?' '.$cssonholiday:'').($cssweekend?' '.$cssweekend:'').'">'; |
|
1072 | + print '<td class="center duration'.($cssonholiday ? ' '.$cssonholiday : '').($cssweekend ? ' '.$cssweekend : '').'">'; |
|
1073 | 1073 | $dayWorkLoad = $projectstatic->weekWorkLoadPerTask[$preselectedday][$lines[$i]->id]; |
1074 | - $totalforeachday[$preselectedday]+=$dayWorkLoad; |
|
1074 | + $totalforeachday[$preselectedday] += $dayWorkLoad; |
|
1075 | 1075 | |
1076 | - $alreadyspent=''; |
|
1077 | - if ($dayWorkLoad > 0) $alreadyspent=convertSecondToTime($dayWorkLoad,'allhourmin'); |
|
1076 | + $alreadyspent = ''; |
|
1077 | + if ($dayWorkLoad > 0) $alreadyspent = convertSecondToTime($dayWorkLoad, 'allhourmin'); |
|
1078 | 1078 | |
1079 | 1079 | $idw = 0; |
1080 | 1080 | |
1081 | - $tableCell=''; |
|
1082 | - $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>'; |
|
1083 | - $tableCell.='<span class="hideonsmartphone"> + </span>'; |
|
1081 | + $tableCell = ''; |
|
1082 | + $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>'; |
|
1083 | + $tableCell .= '<span class="hideonsmartphone"> + </span>'; |
|
1084 | 1084 | //$tableCell.=' '; |
1085 | - $tableCell.=$form->select_duration($lines[$i]->id.'duration','',$disabledtask,'text',0,1); |
|
1085 | + $tableCell .= $form->select_duration($lines[$i]->id.'duration', '', $disabledtask, 'text', 0, 1); |
|
1086 | 1086 | //$tableCell.=' <input type="submit" class="button"'.($disabledtask?' disabled':'').' value="'.$langs->trans("Add").'">'; |
1087 | 1087 | print $tableCell; |
1088 | 1088 | |
1089 | - $modeinput='hours'; |
|
1089 | + $modeinput = 'hours'; |
|
1090 | 1090 | |
1091 | 1091 | print '<script type="text/javascript">'; |
1092 | 1092 | print "jQuery(document).ready(function () {\n"; |
@@ -1098,19 +1098,19 @@ discard block |
||
1098 | 1098 | |
1099 | 1099 | // Note |
1100 | 1100 | print '<td align="center">'; |
1101 | - print '<textarea name="'.$lines[$i]->id.'note" rows="'.ROWS_2.'" id="'.$lines[$i]->id.'note"'.($disabledtask?' disabled="disabled"':'').'>'; |
|
1101 | + print '<textarea name="'.$lines[$i]->id.'note" rows="'.ROWS_2.'" id="'.$lines[$i]->id.'note"'.($disabledtask ? ' disabled="disabled"' : '').'>'; |
|
1102 | 1102 | print '</textarea>'; |
1103 | 1103 | print '</td>'; |
1104 | 1104 | |
1105 | 1105 | // Warning |
1106 | 1106 | print '<td align="right">'; |
1107 | - if ((! $lines[$i]->public) && $disabledproject) print $form->textwithpicto('',$langs->trans("UserIsNotContactOfProject")); |
|
1107 | + if ((!$lines[$i]->public) && $disabledproject) print $form->textwithpicto('', $langs->trans("UserIsNotContactOfProject")); |
|
1108 | 1108 | else if ($disabledtask) |
1109 | 1109 | { |
1110 | 1110 | $titleassigntask = $langs->trans("AssignTaskToMe"); |
1111 | 1111 | if ($fuser->id != $user->id) $titleassigntask = $langs->trans("AssignTaskToUser", '...'); |
1112 | 1112 | |
1113 | - print $form->textwithpicto('',$langs->trans("TaskIsNotAssignedToUser", $titleassigntask)); |
|
1113 | + print $form->textwithpicto('', $langs->trans("TaskIsNotAssignedToUser", $titleassigntask)); |
|
1114 | 1114 | } |
1115 | 1115 | print '</td>'; |
1116 | 1116 | |
@@ -1126,9 +1126,9 @@ discard block |
||
1126 | 1126 | $ret = projectLinesPerDay($inc, $lines[$i]->id, $fuser, ($parent == 0 ? $lineswithoutlevel0 : $lines), $level, $projectsrole, $tasksrole, $mine, $restricteditformytask, $preselectedday, $isavailable, $oldprojectforbreak); |
1127 | 1127 | //var_dump('ret with parent='.$lines[$i]->id.' level='.$level); |
1128 | 1128 | //var_dump($ret); |
1129 | - foreach($ret as $key => $val) |
|
1129 | + foreach ($ret as $key => $val) |
|
1130 | 1130 | { |
1131 | - $totalforeachday[$key]+=$val; |
|
1131 | + $totalforeachday[$key] += $val; |
|
1132 | 1132 | } |
1133 | 1133 | //var_dump('totalforeachday after taskid='.$lines[$i]->id.' and previous one on level '.$level.' + subtasks'); |
1134 | 1134 | //var_dump($totalforeachday); |
@@ -1162,24 +1162,24 @@ discard block |
||
1162 | 1162 | * @param int $oldprojectforbreak Old project id of last project break |
1163 | 1163 | * @return array Array with time spent for $fuser for each day of week on tasks in $lines and substasks |
1164 | 1164 | */ |
1165 | -function projectLinesPerWeek(&$inc, $firstdaytoshow, $fuser, $parent, $lines, &$level, &$projectsrole, &$tasksrole, $mine, $restricteditformytask, &$isavailable, $oldprojectforbreak=0) |
|
1165 | +function projectLinesPerWeek(&$inc, $firstdaytoshow, $fuser, $parent, $lines, &$level, &$projectsrole, &$tasksrole, $mine, $restricteditformytask, &$isavailable, $oldprojectforbreak = 0) |
|
1166 | 1166 | { |
1167 | 1167 | global $conf, $db, $user, $bc, $langs; |
1168 | 1168 | global $form, $formother, $projectstatic, $taskstatic, $thirdpartystatic; |
1169 | 1169 | |
1170 | - $numlines=count($lines); |
|
1170 | + $numlines = count($lines); |
|
1171 | 1171 | |
1172 | - $lastprojectid=0; |
|
1173 | - $workloadforid=array(); |
|
1174 | - $totalforeachday=array(); |
|
1175 | - $lineswithoutlevel0=array(); |
|
1172 | + $lastprojectid = 0; |
|
1173 | + $workloadforid = array(); |
|
1174 | + $totalforeachday = array(); |
|
1175 | + $lineswithoutlevel0 = array(); |
|
1176 | 1176 | |
1177 | 1177 | // Create a smaller array with sublevels only to be used later. This increase dramatically performances. |
1178 | 1178 | if ($parent == 0) // Always and only if at first level |
1179 | 1179 | { |
1180 | - for ($i = 0 ; $i < $numlines ; $i++) |
|
1180 | + for ($i = 0; $i < $numlines; $i++) |
|
1181 | 1181 | { |
1182 | - if ($lines[$i]->fk_task_parent) $lineswithoutlevel0[]=$lines[$i]; |
|
1182 | + if ($lines[$i]->fk_task_parent) $lineswithoutlevel0[] = $lines[$i]; |
|
1183 | 1183 | } |
1184 | 1184 | } |
1185 | 1185 | |
@@ -1187,17 +1187,17 @@ discard block |
||
1187 | 1187 | |
1188 | 1188 | if (empty($oldprojectforbreak)) |
1189 | 1189 | { |
1190 | - $oldprojectforbreak = (empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)?0:-1); // 0 = start break, -1 = never break |
|
1190 | + $oldprojectforbreak = (empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT) ? 0 : -1); // 0 = start break, -1 = never break |
|
1191 | 1191 | } |
1192 | 1192 | |
1193 | - for ($i = 0 ; $i < $numlines ; $i++) |
|
1193 | + for ($i = 0; $i < $numlines; $i++) |
|
1194 | 1194 | { |
1195 | 1195 | if ($parent == 0) $level = 0; |
1196 | 1196 | |
1197 | 1197 | if ($lines[$i]->fk_task_parent == $parent) |
1198 | 1198 | { |
1199 | 1199 | // If we want all or we have a role on task, we show it |
1200 | - if (empty($mine) || ! empty($tasksrole[$lines[$i]->id])) |
|
1200 | + if (empty($mine) || !empty($tasksrole[$lines[$i]->id])) |
|
1201 | 1201 | { |
1202 | 1202 | //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); |
1203 | 1203 | |
@@ -1209,7 +1209,7 @@ discard block |
||
1209 | 1209 | // Break on a new project |
1210 | 1210 | if ($parent == 0 && $lines[$i]->fk_project != $lastprojectid) |
1211 | 1211 | { |
1212 | - $lastprojectid=$lines[$i]->fk_project; |
|
1212 | + $lastprojectid = $lines[$i]->fk_project; |
|
1213 | 1213 | $projectstatic->id = $lines[$i]->fk_project; |
1214 | 1214 | } |
1215 | 1215 | |
@@ -1217,33 +1217,33 @@ discard block |
||
1217 | 1217 | //var_dump($projectstatic->weekWorkLoadPerTask); |
1218 | 1218 | if (empty($workloadforid[$projectstatic->id])) |
1219 | 1219 | { |
1220 | - $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 |
|
1221 | - $workloadforid[$projectstatic->id]=1; |
|
1220 | + $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 |
|
1221 | + $workloadforid[$projectstatic->id] = 1; |
|
1222 | 1222 | } |
1223 | 1223 | //var_dump($projectstatic->weekWorkLoadPerTask); |
1224 | 1224 | //var_dump('--- '.$projectstatic->id.' '.$workloadforid[$projectstatic->id]); |
1225 | 1225 | |
1226 | - $projectstatic->id=$lines[$i]->fk_project; |
|
1227 | - $projectstatic->ref=$lines[$i]->projectref; |
|
1228 | - $projectstatic->title=$lines[$i]->projectlabel; |
|
1229 | - $projectstatic->public=$lines[$i]->public; |
|
1230 | - $projectstatic->thirdparty_name=$lines[$i]->thirdparty_name; |
|
1226 | + $projectstatic->id = $lines[$i]->fk_project; |
|
1227 | + $projectstatic->ref = $lines[$i]->projectref; |
|
1228 | + $projectstatic->title = $lines[$i]->projectlabel; |
|
1229 | + $projectstatic->public = $lines[$i]->public; |
|
1230 | + $projectstatic->thirdparty_name = $lines[$i]->thirdparty_name; |
|
1231 | 1231 | |
1232 | - $taskstatic->id=$lines[$i]->id; |
|
1233 | - $taskstatic->ref=($lines[$i]->ref?$lines[$i]->ref:$lines[$i]->id); |
|
1234 | - $taskstatic->label=$lines[$i]->label; |
|
1235 | - $taskstatic->date_start=$lines[$i]->date_start; |
|
1236 | - $taskstatic->date_end=$lines[$i]->date_end; |
|
1232 | + $taskstatic->id = $lines[$i]->id; |
|
1233 | + $taskstatic->ref = ($lines[$i]->ref ? $lines[$i]->ref : $lines[$i]->id); |
|
1234 | + $taskstatic->label = $lines[$i]->label; |
|
1235 | + $taskstatic->date_start = $lines[$i]->date_start; |
|
1236 | + $taskstatic->date_end = $lines[$i]->date_end; |
|
1237 | 1237 | |
1238 | - $thirdpartystatic->id=$lines[$i]->thirdparty_id; |
|
1239 | - $thirdpartystatic->name=$lines[$i]->thirdparty_name; |
|
1240 | - $thirdpartystatic->email=$lines[$i]->thirdparty_email; |
|
1238 | + $thirdpartystatic->id = $lines[$i]->thirdparty_id; |
|
1239 | + $thirdpartystatic->name = $lines[$i]->thirdparty_name; |
|
1240 | + $thirdpartystatic->email = $lines[$i]->thirdparty_email; |
|
1241 | 1241 | |
1242 | 1242 | if (empty($oldprojectforbreak) || ($oldprojectforbreak != -1 && $oldprojectforbreak != $projectstatic->id)) |
1243 | 1243 | { |
1244 | 1244 | print '<tr class="oddeven trforbreak">'."\n"; |
1245 | 1245 | print '<td colspan="13">'; |
1246 | - print $projectstatic->getNomUrl(1,'',0,'<strong>'.$langs->transnoentitiesnoconv("YourRole").':</strong> '.$projectsrole[$lines[$i]->fk_project]); |
|
1246 | + print $projectstatic->getNomUrl(1, '', 0, '<strong>'.$langs->transnoentitiesnoconv("YourRole").':</strong> '.$projectsrole[$lines[$i]->fk_project]); |
|
1247 | 1247 | if ($thirdpartystatic->id > 0) print ' - '.$thirdpartystatic->getNomUrl(1); |
1248 | 1248 | if ($projectstatic->title) |
1249 | 1249 | { |
@@ -1278,11 +1278,11 @@ discard block |
||
1278 | 1278 | // Ref |
1279 | 1279 | print '<td class="nowrap">'; |
1280 | 1280 | print '<!-- Task id = '.$lines[$i]->id.' -->'; |
1281 | - for ($k = 0 ; $k < $level ; $k++) print " "; |
|
1281 | + for ($k = 0; $k < $level; $k++) print " "; |
|
1282 | 1282 | print $taskstatic->getNomUrl(1, 'withproject', 'time'); |
1283 | 1283 | // Label task |
1284 | 1284 | print '<br>'; |
1285 | - for ($k = 0 ; $k < $level ; $k++) print " "; |
|
1285 | + for ($k = 0; $k < $level; $k++) print " "; |
|
1286 | 1286 | //print $taskstatic->getNomUrl(0, 'withproject', 'time'); |
1287 | 1287 | print $taskstatic->label; |
1288 | 1288 | //print "<br>"; |
@@ -1292,13 +1292,13 @@ discard block |
||
1292 | 1292 | |
1293 | 1293 | // Planned Workload |
1294 | 1294 | print '<td align="right" class="leftborder plannedworkload">'; |
1295 | - if ($lines[$i]->planned_workload) print convertSecondToTime($lines[$i]->planned_workload,'allhourmin'); |
|
1295 | + if ($lines[$i]->planned_workload) print convertSecondToTime($lines[$i]->planned_workload, 'allhourmin'); |
|
1296 | 1296 | else print '--:--'; |
1297 | 1297 | print '</td>'; |
1298 | 1298 | |
1299 | 1299 | // Progress declared % |
1300 | 1300 | print '<td align="right">'; |
1301 | - print $formother->select_percent($lines[$i]->progress, $lines[$i]->id . 'progress'); |
|
1301 | + print $formother->select_percent($lines[$i]->progress, $lines[$i]->id.'progress'); |
|
1302 | 1302 | print '</td>'; |
1303 | 1303 | |
1304 | 1304 | // Time spent by everybody |
@@ -1307,7 +1307,7 @@ discard block |
||
1307 | 1307 | if ($lines[$i]->duration) |
1308 | 1308 | { |
1309 | 1309 | print '<a href="'.DOL_URL_ROOT.'/projet/tasks/time.php?id='.$lines[$i]->id.'">'; |
1310 | - print convertSecondToTime($lines[$i]->duration,'allhourmin'); |
|
1310 | + print convertSecondToTime($lines[$i]->duration, 'allhourmin'); |
|
1311 | 1311 | print '</a>'; |
1312 | 1312 | } |
1313 | 1313 | else print '--:--'; |
@@ -1315,80 +1315,80 @@ discard block |
||
1315 | 1315 | |
1316 | 1316 | // Time spent by user |
1317 | 1317 | print '<td align="right">'; |
1318 | - $tmptimespent=$taskstatic->getSummaryOfTimeSpent($fuser->id); |
|
1319 | - if ($tmptimespent['total_duration']) print convertSecondToTime($tmptimespent['total_duration'],'allhourmin'); |
|
1318 | + $tmptimespent = $taskstatic->getSummaryOfTimeSpent($fuser->id); |
|
1319 | + if ($tmptimespent['total_duration']) print convertSecondToTime($tmptimespent['total_duration'], 'allhourmin'); |
|
1320 | 1320 | else print '--:--'; |
1321 | 1321 | print "</td>\n"; |
1322 | 1322 | |
1323 | - $disabledproject=1;$disabledtask=1; |
|
1323 | + $disabledproject = 1; $disabledtask = 1; |
|
1324 | 1324 | //print "x".$lines[$i]->fk_project; |
1325 | 1325 | //var_dump($lines[$i]); |
1326 | 1326 | //var_dump($projectsrole[$lines[$i]->fk_project]); |
1327 | 1327 | // If at least one role for project |
1328 | - if ($lines[$i]->public || ! empty($projectsrole[$lines[$i]->fk_project]) || $user->rights->projet->all->creer) |
|
1328 | + if ($lines[$i]->public || !empty($projectsrole[$lines[$i]->fk_project]) || $user->rights->projet->all->creer) |
|
1329 | 1329 | { |
1330 | - $disabledproject=0; |
|
1331 | - $disabledtask=0; |
|
1330 | + $disabledproject = 0; |
|
1331 | + $disabledtask = 0; |
|
1332 | 1332 | } |
1333 | 1333 | // If $restricteditformytask is on and I have no role on task, i disable edit |
1334 | 1334 | if ($restricteditformytask && empty($tasksrole[$lines[$i]->id])) |
1335 | 1335 | { |
1336 | - $disabledtask=1; |
|
1336 | + $disabledtask = 1; |
|
1337 | 1337 | } |
1338 | 1338 | |
1339 | 1339 | //var_dump($projectstatic->weekWorkLoadPerTask); |
1340 | 1340 | |
1341 | 1341 | // Fields to show current time |
1342 | - $tableCell=''; $modeinput='hours'; |
|
1342 | + $tableCell = ''; $modeinput = 'hours'; |
|
1343 | 1343 | for ($idw = 0; $idw < 7; $idw++) |
1344 | 1344 | { |
1345 | - $tmpday=dol_time_plus_duree($firstdaytoshow, $idw, 'd'); |
|
1345 | + $tmpday = dol_time_plus_duree($firstdaytoshow, $idw, 'd'); |
|
1346 | 1346 | |
1347 | - $cssonholiday=''; |
|
1348 | - if (! $isavailable[$tmpday]['morning'] && ! $isavailable[$tmpday]['afternoon']) $cssonholiday.='onholidayallday '; |
|
1349 | - elseif (! $isavailable[$tmpday]['morning']) $cssonholiday.='onholidaymorning '; |
|
1350 | - elseif (! $isavailable[$tmpday]['afternoon']) $cssonholiday.='onholidayafternoon '; |
|
1347 | + $cssonholiday = ''; |
|
1348 | + if (!$isavailable[$tmpday]['morning'] && !$isavailable[$tmpday]['afternoon']) $cssonholiday .= 'onholidayallday '; |
|
1349 | + elseif (!$isavailable[$tmpday]['morning']) $cssonholiday .= 'onholidaymorning '; |
|
1350 | + elseif (!$isavailable[$tmpday]['afternoon']) $cssonholiday .= 'onholidayafternoon '; |
|
1351 | 1351 | |
1352 | - $tmparray=dol_getdate($tmpday); |
|
1352 | + $tmparray = dol_getdate($tmpday); |
|
1353 | 1353 | $dayWorkLoad = $projectstatic->weekWorkLoadPerTask[$tmpday][$lines[$i]->id]; |
1354 | - $totalforeachday[$tmpday]+=$dayWorkLoad; |
|
1354 | + $totalforeachday[$tmpday] += $dayWorkLoad; |
|
1355 | 1355 | |
1356 | - $alreadyspent=''; |
|
1357 | - if ($dayWorkLoad > 0) $alreadyspent=convertSecondToTime($dayWorkLoad,'allhourmin'); |
|
1358 | - $alttitle=$langs->trans("AddHereTimeSpentForDay",$tmparray['day'],$tmparray['mon']); |
|
1356 | + $alreadyspent = ''; |
|
1357 | + if ($dayWorkLoad > 0) $alreadyspent = convertSecondToTime($dayWorkLoad, 'allhourmin'); |
|
1358 | + $alttitle = $langs->trans("AddHereTimeSpentForDay", $tmparray['day'], $tmparray['mon']); |
|
1359 | 1359 | |
1360 | 1360 | global $numstartworkingday, $numendworkingday; |
1361 | - $cssweekend=''; |
|
1361 | + $cssweekend = ''; |
|
1362 | 1362 | 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. |
1363 | 1363 | { |
1364 | - $cssweekend='weekend'; |
|
1364 | + $cssweekend = 'weekend'; |
|
1365 | 1365 | } |
1366 | 1366 | |
1367 | - $tableCell ='<td align="center" class="hide'.$idw.($cssonholiday?' '.$cssonholiday:'').($cssweekend?' '.$cssweekend:'').'">'; |
|
1368 | - $placeholder=''; |
|
1367 | + $tableCell = '<td align="center" class="hide'.$idw.($cssonholiday ? ' '.$cssonholiday : '').($cssweekend ? ' '.$cssweekend : '').'">'; |
|
1368 | + $placeholder = ''; |
|
1369 | 1369 | if ($alreadyspent) |
1370 | 1370 | { |
1371 | - $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>'; |
|
1371 | + $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>'; |
|
1372 | 1372 | //$placeholder=' placeholder="00:00"'; |
1373 | 1373 | //$tableCell.='+'; |
1374 | 1374 | } |
1375 | - $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"'; |
|
1376 | - $tableCell.=' onkeypress="return regexEvent(this,event,\'timeChar\')"'; |
|
1377 | - $tableCell.=' onkeyup="updateTotal('.$idw.',\''.$modeinput.'\')"'; |
|
1378 | - $tableCell.=' onblur="regexEvent(this,event,\''.$modeinput.'\'); updateTotal('.$idw.',\''.$modeinput.'\')" />'; |
|
1379 | - $tableCell.='</td>'; |
|
1375 | + $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"'; |
|
1376 | + $tableCell .= ' onkeypress="return regexEvent(this,event,\'timeChar\')"'; |
|
1377 | + $tableCell .= ' onkeyup="updateTotal('.$idw.',\''.$modeinput.'\')"'; |
|
1378 | + $tableCell .= ' onblur="regexEvent(this,event,\''.$modeinput.'\'); updateTotal('.$idw.',\''.$modeinput.'\')" />'; |
|
1379 | + $tableCell .= '</td>'; |
|
1380 | 1380 | print $tableCell; |
1381 | 1381 | } |
1382 | 1382 | |
1383 | 1383 | // Warning |
1384 | 1384 | print '<td align="right">'; |
1385 | - if ((! $lines[$i]->public) && $disabledproject) print $form->textwithpicto('',$langs->trans("UserIsNotContactOfProject")); |
|
1385 | + if ((!$lines[$i]->public) && $disabledproject) print $form->textwithpicto('', $langs->trans("UserIsNotContactOfProject")); |
|
1386 | 1386 | else if ($disabledtask) |
1387 | 1387 | { |
1388 | 1388 | $titleassigntask = $langs->trans("AssignTaskToMe"); |
1389 | 1389 | if ($fuser->id != $user->id) $titleassigntask = $langs->trans("AssignTaskToUser", '...'); |
1390 | 1390 | |
1391 | - print $form->textwithpicto('',$langs->trans("TaskIsNotAssignedToUser", $titleassigntask)); |
|
1391 | + print $form->textwithpicto('', $langs->trans("TaskIsNotAssignedToUser", $titleassigntask)); |
|
1392 | 1392 | } |
1393 | 1393 | print '</td>'; |
1394 | 1394 | |
@@ -1405,9 +1405,9 @@ discard block |
||
1405 | 1405 | $ret = projectLinesPerWeek($inc, $firstdaytoshow, $fuser, $lines[$i]->id, ($parent == 0 ? $lineswithoutlevel0 : $lines), $level, $projectsrole, $tasksrole, $mine, $restricteditformytask, $isavailable, $oldprojectforbreak); |
1406 | 1406 | //var_dump('ret with parent='.$lines[$i]->id.' level='.$level); |
1407 | 1407 | //var_dump($ret); |
1408 | - foreach($ret as $key => $val) |
|
1408 | + foreach ($ret as $key => $val) |
|
1409 | 1409 | { |
1410 | - $totalforeachday[$key]+=$val; |
|
1410 | + $totalforeachday[$key] += $val; |
|
1411 | 1411 | } |
1412 | 1412 | //var_dump('totalforeachday after taskid='.$lines[$i]->id.' and previous one on level '.$level.' + subtasks'); |
1413 | 1413 | //var_dump($totalforeachday); |
@@ -1436,8 +1436,8 @@ discard block |
||
1436 | 1436 | function searchTaskInChild(&$inc, $parent, &$lines, &$taskrole) |
1437 | 1437 | { |
1438 | 1438 | //print 'Search in line with parent id = '.$parent.'<br>'; |
1439 | - $numlines=count($lines); |
|
1440 | - for ($i = 0 ; $i < $numlines ; $i++) |
|
1439 | + $numlines = count($lines); |
|
1440 | + for ($i = 0; $i < $numlines; $i++) |
|
1441 | 1441 | { |
1442 | 1442 | // Process line $lines[$i] |
1443 | 1443 | if ($lines[$i]->fk_parent == $parent && $lines[$i]->id != $lines[$i]->fk_parent) |
@@ -1473,52 +1473,52 @@ discard block |
||
1473 | 1473 | * @param array $hiddenfields List of info to not show ('projectlabel', 'declaredprogress', '...', ) |
1474 | 1474 | * @return void |
1475 | 1475 | */ |
1476 | -function print_projecttasks_array($db, $form, $socid, $projectsListId, $mytasks=0, $statut=-1, $listofoppstatus=array(),$hiddenfields=array()) |
|
1476 | +function print_projecttasks_array($db, $form, $socid, $projectsListId, $mytasks = 0, $statut = -1, $listofoppstatus = array(), $hiddenfields = array()) |
|
1477 | 1477 | { |
1478 | - global $langs,$conf,$user,$bc; |
|
1478 | + global $langs, $conf, $user, $bc; |
|
1479 | 1479 | |
1480 | 1480 | require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; |
1481 | 1481 | |
1482 | - $projectstatic=new Project($db); |
|
1483 | - $thirdpartystatic=new Societe($db); |
|
1482 | + $projectstatic = new Project($db); |
|
1483 | + $thirdpartystatic = new Societe($db); |
|
1484 | 1484 | |
1485 | - $sortfield=''; |
|
1486 | - $sortorder=''; |
|
1487 | - $project_year_filter=0; |
|
1485 | + $sortfield = ''; |
|
1486 | + $sortorder = ''; |
|
1487 | + $project_year_filter = 0; |
|
1488 | 1488 | |
1489 | - $title=$langs->trans("Projects"); |
|
1490 | - if (strcmp($statut, '') && $statut >= 0) $title=$langs->trans("Projects").' '.$langs->trans($projectstatic->statuts_long[$statut]); |
|
1489 | + $title = $langs->trans("Projects"); |
|
1490 | + if (strcmp($statut, '') && $statut >= 0) $title = $langs->trans("Projects").' '.$langs->trans($projectstatic->statuts_long[$statut]); |
|
1491 | 1491 | |
1492 | - $arrayidtypeofcontact=array(); |
|
1492 | + $arrayidtypeofcontact = array(); |
|
1493 | 1493 | |
1494 | 1494 | print '<div class="div-table-responsive-no-min">'; |
1495 | 1495 | print '<table class="noborder" width="100%">'; |
1496 | 1496 | |
1497 | - $sql= " FROM ".MAIN_DB_PREFIX."projet as p"; |
|
1497 | + $sql = " FROM ".MAIN_DB_PREFIX."projet as p"; |
|
1498 | 1498 | if ($mytasks) |
1499 | 1499 | { |
1500 | - $sql.= ", ".MAIN_DB_PREFIX."projet_task as t"; |
|
1501 | - $sql.= ", ".MAIN_DB_PREFIX."element_contact as ec"; |
|
1502 | - $sql.= ", ".MAIN_DB_PREFIX."c_type_contact as ctc"; |
|
1500 | + $sql .= ", ".MAIN_DB_PREFIX."projet_task as t"; |
|
1501 | + $sql .= ", ".MAIN_DB_PREFIX."element_contact as ec"; |
|
1502 | + $sql .= ", ".MAIN_DB_PREFIX."c_type_contact as ctc"; |
|
1503 | 1503 | } |
1504 | 1504 | else |
1505 | 1505 | { |
1506 | - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."projet_task as t ON p.rowid = t.fk_projet"; |
|
1506 | + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."projet_task as t ON p.rowid = t.fk_projet"; |
|
1507 | 1507 | } |
1508 | - $sql.= " WHERE p.entity IN (".getEntity('project').")"; |
|
1509 | - $sql.= " AND p.rowid IN (".$projectsListId.")"; |
|
1510 | - if ($socid) $sql.= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")"; |
|
1508 | + $sql .= " WHERE p.entity IN (".getEntity('project').")"; |
|
1509 | + $sql .= " AND p.rowid IN (".$projectsListId.")"; |
|
1510 | + if ($socid) $sql .= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")"; |
|
1511 | 1511 | if ($mytasks) |
1512 | 1512 | { |
1513 | - $sql.= " AND p.rowid = t.fk_projet"; |
|
1514 | - $sql.= " AND ec.element_id = t.rowid"; |
|
1515 | - $sql.= " AND ec.fk_socpeople = ".$user->id; |
|
1516 | - $sql.= " AND ec.fk_c_type_contact = ctc.rowid"; // Replace the 2 lines with ec.fk_c_type_contact in $arrayidtypeofcontact |
|
1517 | - $sql.= " AND ctc.element = 'project_task'"; |
|
1513 | + $sql .= " AND p.rowid = t.fk_projet"; |
|
1514 | + $sql .= " AND ec.element_id = t.rowid"; |
|
1515 | + $sql .= " AND ec.fk_socpeople = ".$user->id; |
|
1516 | + $sql .= " AND ec.fk_c_type_contact = ctc.rowid"; // Replace the 2 lines with ec.fk_c_type_contact in $arrayidtypeofcontact |
|
1517 | + $sql .= " AND ctc.element = 'project_task'"; |
|
1518 | 1518 | } |
1519 | 1519 | if ($statut >= 0) |
1520 | 1520 | { |
1521 | - $sql.= " AND p.fk_statut = ".$statut; |
|
1521 | + $sql .= " AND p.fk_statut = ".$statut; |
|
1522 | 1522 | } |
1523 | 1523 | if (!empty($conf->global->PROJECT_LIMIT_YEAR_RANGE)) |
1524 | 1524 | { |
@@ -1530,40 +1530,40 @@ discard block |
||
1530 | 1530 | { |
1531 | 1531 | $project_year_filter = date("Y"); |
1532 | 1532 | } |
1533 | - $sql.= " AND (p.dateo IS NULL OR p.dateo <= ".$db->idate(dol_get_last_day($project_year_filter,12,false)).")"; |
|
1534 | - $sql.= " AND (p.datee IS NULL OR p.datee >= ".$db->idate(dol_get_first_day($project_year_filter,1,false)).")"; |
|
1533 | + $sql .= " AND (p.dateo IS NULL OR p.dateo <= ".$db->idate(dol_get_last_day($project_year_filter, 12, false)).")"; |
|
1534 | + $sql .= " AND (p.datee IS NULL OR p.datee >= ".$db->idate(dol_get_first_day($project_year_filter, 1, false)).")"; |
|
1535 | 1535 | } |
1536 | 1536 | } |
1537 | 1537 | |
1538 | 1538 | // Get id of project we must show tasks |
1539 | - $arrayidofprojects=array(); |
|
1539 | + $arrayidofprojects = array(); |
|
1540 | 1540 | $sql1 = "SELECT p.rowid as projectid"; |
1541 | - $sql1.= $sql; |
|
1541 | + $sql1 .= $sql; |
|
1542 | 1542 | $resql = $db->query($sql1); |
1543 | 1543 | if ($resql) |
1544 | 1544 | { |
1545 | - $i=0; |
|
1545 | + $i = 0; |
|
1546 | 1546 | $num = $db->num_rows($resql); |
1547 | 1547 | while ($i < $num) |
1548 | 1548 | { |
1549 | 1549 | $objp = $db->fetch_object($resql); |
1550 | - $arrayidofprojects[$objp->projectid]=$objp->projectid; |
|
1550 | + $arrayidofprojects[$objp->projectid] = $objp->projectid; |
|
1551 | 1551 | $i++; |
1552 | 1552 | } |
1553 | 1553 | } |
1554 | 1554 | else dol_print_error($db); |
1555 | - if (empty($arrayidofprojects)) $arrayidofprojects[0]=-1; |
|
1555 | + if (empty($arrayidofprojects)) $arrayidofprojects[0] = -1; |
|
1556 | 1556 | |
1557 | 1557 | // Get list of project with calculation on tasks |
1558 | 1558 | $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,"; |
1559 | - $sql2.= " p.dateo, p.datee,"; |
|
1560 | - $sql2.= " COUNT(t.rowid) as nb, SUM(t.planned_workload) as planned_workload, SUM(t.planned_workload * t.progress / 100) as declared_progess_workload"; |
|
1561 | - $sql2.= " FROM ".MAIN_DB_PREFIX."projet as p"; |
|
1562 | - $sql2.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = p.fk_soc"; |
|
1563 | - $sql2.= " LEFT JOIN ".MAIN_DB_PREFIX."projet_task as t ON p.rowid = t.fk_projet"; |
|
1564 | - $sql2.= " WHERE p.rowid IN (".join(',',$arrayidofprojects).")"; |
|
1565 | - $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"; |
|
1566 | - $sql2.= " ORDER BY p.title, p.ref"; |
|
1559 | + $sql2 .= " p.dateo, p.datee,"; |
|
1560 | + $sql2 .= " COUNT(t.rowid) as nb, SUM(t.planned_workload) as planned_workload, SUM(t.planned_workload * t.progress / 100) as declared_progess_workload"; |
|
1561 | + $sql2 .= " FROM ".MAIN_DB_PREFIX."projet as p"; |
|
1562 | + $sql2 .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = p.fk_soc"; |
|
1563 | + $sql2 .= " LEFT JOIN ".MAIN_DB_PREFIX."projet_task as t ON p.rowid = t.fk_projet"; |
|
1564 | + $sql2 .= " WHERE p.rowid IN (".join(',', $arrayidofprojects).")"; |
|
1565 | + $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"; |
|
1566 | + $sql2 .= " ORDER BY p.title, p.ref"; |
|
1567 | 1567 | |
1568 | 1568 | $resql = $db->query($sql2); |
1569 | 1569 | if ($resql) |
@@ -1576,24 +1576,24 @@ discard block |
||
1576 | 1576 | $i = 0; |
1577 | 1577 | |
1578 | 1578 | print '<tr class="liste_titre">'; |
1579 | - print_liste_field_titre($title.' <span class="badge">'.$num.'</span>',$_SERVER["PHP_SELF"],"","","","",$sortfield,$sortorder); |
|
1580 | - print_liste_field_titre("ThirdParty",$_SERVER["PHP_SELF"],"","","","",$sortfield,$sortorder); |
|
1581 | - if (! empty($conf->global->PROJECT_USE_OPPORTUNITIES)) |
|
1579 | + print_liste_field_titre($title.' <span class="badge">'.$num.'</span>', $_SERVER["PHP_SELF"], "", "", "", "", $sortfield, $sortorder); |
|
1580 | + print_liste_field_titre("ThirdParty", $_SERVER["PHP_SELF"], "", "", "", "", $sortfield, $sortorder); |
|
1581 | + if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) |
|
1582 | 1582 | { |
1583 | - print_liste_field_titre("OpportunityAmount","","","","",'align="right"',$sortfield,$sortorder); |
|
1584 | - print_liste_field_titre("OpportunityStatus","","","","",'align="right"',$sortfield,$sortorder); |
|
1583 | + print_liste_field_titre("OpportunityAmount", "", "", "", "", 'align="right"', $sortfield, $sortorder); |
|
1584 | + print_liste_field_titre("OpportunityStatus", "", "", "", "", 'align="right"', $sortfield, $sortorder); |
|
1585 | 1585 | } |
1586 | 1586 | if (empty($conf->global->PROJECT_HIDE_TASKS)) |
1587 | 1587 | { |
1588 | - print_liste_field_titre("Tasks","","","","",'align="right"',$sortfield,$sortorder); |
|
1589 | - if (! in_array('plannedworkload', $hiddenfields)) print_liste_field_titre("PlannedWorkload","","","","",'align="right"',$sortfield,$sortorder); |
|
1590 | - if (! in_array('declaredprogress', $hiddenfields)) print_liste_field_titre("ProgressDeclared","","","","",'align="right"',$sortfield,$sortorder); |
|
1588 | + print_liste_field_titre("Tasks", "", "", "", "", 'align="right"', $sortfield, $sortorder); |
|
1589 | + if (!in_array('plannedworkload', $hiddenfields)) print_liste_field_titre("PlannedWorkload", "", "", "", "", 'align="right"', $sortfield, $sortorder); |
|
1590 | + if (!in_array('declaredprogress', $hiddenfields)) print_liste_field_titre("ProgressDeclared", "", "", "", "", 'align="right"', $sortfield, $sortorder); |
|
1591 | 1591 | } |
1592 | - print_liste_field_titre("Status","","","","",'align="right"',$sortfield,$sortorder); |
|
1592 | + print_liste_field_titre("Status", "", "", "", "", 'align="right"', $sortfield, $sortorder); |
|
1593 | 1593 | print "</tr>\n"; |
1594 | 1594 | |
1595 | - $total_plannedworkload=0; |
|
1596 | - $total_declaredprogressworkload=0; |
|
1595 | + $total_plannedworkload = 0; |
|
1596 | + $total_declaredprogressworkload = 0; |
|
1597 | 1597 | while ($i < $num) |
1598 | 1598 | { |
1599 | 1599 | $objp = $db->fetch_object($resql); |
@@ -1606,7 +1606,7 @@ discard block |
||
1606 | 1606 | $userAccess = $projectstatic->restrictedProjectArea($user); |
1607 | 1607 | if ($userAccess >= 0) |
1608 | 1608 | { |
1609 | - $projectstatic->ref=$objp->ref; |
|
1609 | + $projectstatic->ref = $objp->ref; |
|
1610 | 1610 | $projectstatic->statut = $objp->status; |
1611 | 1611 | $projectstatic->title = $objp->title; |
1612 | 1612 | $projectstatic->datee = $db->jdate($objp->datee); |
@@ -1616,18 +1616,18 @@ discard block |
||
1616 | 1616 | print '<tr class="oddeven">'; |
1617 | 1617 | print '<td>'; |
1618 | 1618 | print $projectstatic->getNomUrl(1); |
1619 | - if (! in_array('projectlabel', $hiddenfields)) print '<br>'.dol_trunc($objp->title,24); |
|
1619 | + if (!in_array('projectlabel', $hiddenfields)) print '<br>'.dol_trunc($objp->title, 24); |
|
1620 | 1620 | print '</td>'; |
1621 | 1621 | print '<td>'; |
1622 | 1622 | if ($objp->fk_soc > 0) |
1623 | 1623 | { |
1624 | - $thirdpartystatic->id=$objp->fk_soc; |
|
1625 | - $thirdpartystatic->ref=$objp->socname; |
|
1626 | - $thirdpartystatic->name=$objp->socname; |
|
1624 | + $thirdpartystatic->id = $objp->fk_soc; |
|
1625 | + $thirdpartystatic->ref = $objp->socname; |
|
1626 | + $thirdpartystatic->name = $objp->socname; |
|
1627 | 1627 | print $thirdpartystatic->getNomUrl(1); |
1628 | 1628 | } |
1629 | 1629 | print '</td>'; |
1630 | - if (! empty($conf->global->PROJECT_USE_OPPORTUNITIES)) |
|
1630 | + if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) |
|
1631 | 1631 | { |
1632 | 1632 | print '<td align="right">'; |
1633 | 1633 | if ($objp->opp_amount) print price($objp->opp_amount, 0, '', 1, -1, -1, $conf->currency); |
@@ -1641,19 +1641,19 @@ discard block |
||
1641 | 1641 | { |
1642 | 1642 | print '<td align="right">'.$objp->nb.'</td>'; |
1643 | 1643 | |
1644 | - $plannedworkload=$objp->planned_workload; |
|
1645 | - $total_plannedworkload+=$plannedworkload; |
|
1646 | - if (! in_array('plannedworkload', $hiddenfields)) |
|
1644 | + $plannedworkload = $objp->planned_workload; |
|
1645 | + $total_plannedworkload += $plannedworkload; |
|
1646 | + if (!in_array('plannedworkload', $hiddenfields)) |
|
1647 | 1647 | { |
1648 | - print '<td align="right">'.($plannedworkload?convertSecondToTime($plannedworkload):'').'</td>'; |
|
1648 | + print '<td align="right">'.($plannedworkload ?convertSecondToTime($plannedworkload) : '').'</td>'; |
|
1649 | 1649 | } |
1650 | - if (! in_array('declaredprogress', $hiddenfields)) |
|
1650 | + if (!in_array('declaredprogress', $hiddenfields)) |
|
1651 | 1651 | { |
1652 | - $declaredprogressworkload=$objp->declared_progess_workload; |
|
1653 | - $total_declaredprogressworkload+=$declaredprogressworkload; |
|
1652 | + $declaredprogressworkload = $objp->declared_progess_workload; |
|
1653 | + $total_declaredprogressworkload += $declaredprogressworkload; |
|
1654 | 1654 | print '<td align="right">'; |
1655 | 1655 | //print $objp->planned_workload.'-'.$objp->declared_progess_workload."<br>"; |
1656 | - print ($plannedworkload?round(100*$declaredprogressworkload/$plannedworkload,0).'%':''); |
|
1656 | + print ($plannedworkload ?round(100 * $declaredprogressworkload / $plannedworkload, 0).'%' : ''); |
|
1657 | 1657 | print '</td>'; |
1658 | 1658 | } |
1659 | 1659 | } |
@@ -1671,7 +1671,7 @@ discard block |
||
1671 | 1671 | |
1672 | 1672 | print '<tr class="liste_total">'; |
1673 | 1673 | print '<td colspan="2">'.$langs->trans("Total")."</td>"; |
1674 | - if (! empty($conf->global->PROJECT_USE_OPPORTUNITIES)) |
|
1674 | + if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) |
|
1675 | 1675 | { |
1676 | 1676 | print '<td class="liste_total" align="right">'.price($total_opp_amount, 0, '', 1, -1, -1, $conf->currency).'</td>'; |
1677 | 1677 | print '<td class="liste_total" align="right">'.$form->textwithpicto(price($ponderated_opp_amount, 0, '', 1, -1, -1, $conf->currency), $langs->trans("OpportunityPonderatedAmountDesc"), 1).'</td>'; |
@@ -1679,8 +1679,8 @@ discard block |
||
1679 | 1679 | if (empty($conf->global->PROJECT_HIDE_TASKS)) |
1680 | 1680 | { |
1681 | 1681 | print '<td class="liste_total" align="right">'.$total_task.'</td>'; |
1682 | - if (! in_array('plannedworkload', $hiddenfields)) print '<td class="liste_total" align="right">'.($total_plannedworkload?convertSecondToTime($total_plannedworkload):'').'</td>'; |
|
1683 | - if (! in_array('declaredprogress', $hiddenfields)) print '<td class="liste_total" align="right">'.($total_plannedworkload?round(100*$total_declaredprogressworkload/$total_plannedworkload,0).'%':'').'</td>'; |
|
1682 | + if (!in_array('plannedworkload', $hiddenfields)) print '<td class="liste_total" align="right">'.($total_plannedworkload ?convertSecondToTime($total_plannedworkload) : '').'</td>'; |
|
1683 | + if (!in_array('declaredprogress', $hiddenfields)) print '<td class="liste_total" align="right">'.($total_plannedworkload ?round(100 * $total_declaredprogressworkload / $total_plannedworkload, 0).'%' : '').'</td>'; |
|
1684 | 1684 | } |
1685 | 1685 | print '<td class="liste_total"></td>'; |
1686 | 1686 | print '</tr>'; |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | * \ingroup core |
24 | 24 | */ |
25 | 25 | |
26 | -if (! function_exists('json_encode')) |
|
26 | +if (!function_exists('json_encode')) |
|
27 | 27 | { |
28 | 28 | /** |
29 | 29 | * Implement json_encode for PHP that does not have module enabled. |
@@ -49,14 +49,14 @@ discard block |
||
49 | 49 | { |
50 | 50 | dol_syslog("For better performance, enable the native json in your PHP", LOG_WARNING); |
51 | 51 | |
52 | - $num=0; |
|
52 | + $num = 0; |
|
53 | 53 | if (is_object($elements)) // Count number of properties for an object |
54 | 54 | { |
55 | - foreach($elements as $key => $value) $num++; |
|
55 | + foreach ($elements as $key => $value) $num++; |
|
56 | 56 | } |
57 | 57 | else |
58 | 58 | { |
59 | - $num=count($elements); |
|
59 | + $num = count($elements); |
|
60 | 60 | } |
61 | 61 | //var_dump($num); |
62 | 62 | |
@@ -64,16 +64,16 @@ discard block |
||
64 | 64 | if (is_numeric(key($elements)) && key($elements) == 0) |
65 | 65 | { |
66 | 66 | // indexed (list) |
67 | - $keysofelements=array_keys($elements); // Elements array mus have key that does not start with 0 and end with num-1, so we will use this later. |
|
67 | + $keysofelements = array_keys($elements); // Elements array mus have key that does not start with 0 and end with num-1, so we will use this later. |
|
68 | 68 | $output = '['; |
69 | 69 | for ($i = 0, $last = ($num - 1); $i < $num; $i++) |
70 | 70 | { |
71 | - if (! isset($elements[$keysofelements[$i]])) continue; |
|
72 | - if (is_array($elements[$keysofelements[$i]]) || is_object($elements[$keysofelements[$i]])) $output.= json_encode($elements[$keysofelements[$i]]); |
|
71 | + if (!isset($elements[$keysofelements[$i]])) continue; |
|
72 | + if (is_array($elements[$keysofelements[$i]]) || is_object($elements[$keysofelements[$i]])) $output .= json_encode($elements[$keysofelements[$i]]); |
|
73 | 73 | else $output .= _val($elements[$keysofelements[$i]]); |
74 | - if ($i !== $last) $output.= ','; |
|
74 | + if ($i !== $last) $output .= ','; |
|
75 | 75 | } |
76 | - $output.= ']'; |
|
76 | + $output .= ']'; |
|
77 | 77 | } |
78 | 78 | else |
79 | 79 | { |
@@ -81,18 +81,18 @@ discard block |
||
81 | 81 | $output = '{'; |
82 | 82 | $last = $num - 1; |
83 | 83 | $i = 0; |
84 | - $tmpelements=array(); |
|
85 | - if (is_array($elements)) $tmpelements=$elements; |
|
86 | - if (is_object($elements)) $tmpelements=get_object_vars($elements); |
|
87 | - foreach($tmpelements as $key => $value) |
|
84 | + $tmpelements = array(); |
|
85 | + if (is_array($elements)) $tmpelements = $elements; |
|
86 | + if (is_object($elements)) $tmpelements = get_object_vars($elements); |
|
87 | + foreach ($tmpelements as $key => $value) |
|
88 | 88 | { |
89 | 89 | $output .= '"'.$key.'":'; |
90 | - if (is_array($value)) $output.= json_encode($value); |
|
90 | + if (is_array($value)) $output .= json_encode($value); |
|
91 | 91 | else $output .= _val($value); |
92 | - if ($i !== $last) $output.= ','; |
|
92 | + if ($i !== $last) $output .= ','; |
|
93 | 93 | ++$i; |
94 | 94 | } |
95 | - $output.= '}'; |
|
95 | + $output .= '}'; |
|
96 | 96 | } |
97 | 97 | |
98 | 98 | // return |
@@ -205,7 +205,7 @@ discard block |
||
205 | 205 | else return 'null'; |
206 | 206 | } |
207 | 207 | |
208 | -if (! function_exists('json_decode')) |
|
208 | +if (!function_exists('json_decode')) |
|
209 | 209 | { |
210 | 210 | /** |
211 | 211 | * Implement json_decode for PHP that does not support it |
@@ -214,7 +214,7 @@ discard block |
||
214 | 214 | * @param bool $assoc False return an object, true return an array |
215 | 215 | * @return mixed Object or Array |
216 | 216 | */ |
217 | - function json_decode($json, $assoc=false) |
|
217 | + function json_decode($json, $assoc = false) |
|
218 | 218 | { |
219 | 219 | return dol_json_decode($json, $assoc); |
220 | 220 | } |
@@ -229,40 +229,40 @@ discard block |
||
229 | 229 | * @return mixed Object or Array or false on error |
230 | 230 | * @see json_decode() |
231 | 231 | */ |
232 | -function dol_json_decode($json, $assoc=false) |
|
232 | +function dol_json_decode($json, $assoc = false) |
|
233 | 233 | { |
234 | 234 | dol_syslog("For better performance, enable the native json in your PHP", LOG_WARNING); |
235 | 235 | |
236 | 236 | $comment = false; |
237 | 237 | |
238 | - $out=''; |
|
239 | - $strLength = strlen($json); // Must stay strlen and not dol_strlen because we want technical length, not visible length |
|
240 | - for ($i=0; $i<$strLength; $i++) |
|
238 | + $out = ''; |
|
239 | + $strLength = strlen($json); // Must stay strlen and not dol_strlen because we want technical length, not visible length |
|
240 | + for ($i = 0; $i < $strLength; $i++) |
|
241 | 241 | { |
242 | - if (! $comment) |
|
242 | + if (!$comment) |
|
243 | 243 | { |
244 | - if (($json[$i] == '{') || ($json[$i] == '[')) $out.= 'array('; |
|
245 | - else if (($json[$i] == '}') || ($json[$i] == ']')) $out.= ')'; |
|
246 | - else if ($json[$i] == ':') $out.= ' => '; |
|
247 | - else $out.=$json[$i]; |
|
244 | + if (($json[$i] == '{') || ($json[$i] == '[')) $out .= 'array('; |
|
245 | + else if (($json[$i] == '}') || ($json[$i] == ']')) $out .= ')'; |
|
246 | + else if ($json[$i] == ':') $out .= ' => '; |
|
247 | + else $out .= $json[$i]; |
|
248 | 248 | } |
249 | - else $out.= $json[$i]; |
|
250 | - if ($json[$i] == '"' && $json[($i-1)]!="\\") $comment = !$comment; |
|
249 | + else $out .= $json[$i]; |
|
250 | + if ($json[$i] == '"' && $json[($i - 1)] != "\\") $comment = !$comment; |
|
251 | 251 | } |
252 | 252 | |
253 | - $out=_unval($out); |
|
253 | + $out = _unval($out); |
|
254 | 254 | |
255 | 255 | // Return an array |
256 | 256 | if ($out != '') eval('$array = '.$out.';'); |
257 | - else $array=array(); |
|
257 | + else $array = array(); |
|
258 | 258 | |
259 | 259 | // Return an object |
260 | - if (! $assoc) |
|
260 | + if (!$assoc) |
|
261 | 261 | { |
262 | - if (! empty($array)) |
|
262 | + if (!empty($array)) |
|
263 | 263 | { |
264 | 264 | $object = false; |
265 | - if (count($array)>0) { |
|
265 | + if (count($array) > 0) { |
|
266 | 266 | $object = (object) array(); |
267 | 267 | } |
268 | 268 | foreach ($array as $key => $value) |
@@ -290,9 +290,9 @@ discard block |
||
290 | 290 | while (preg_match('/\\\u([0-9A-F]{2})([0-9A-F]{2})/i', $val, $reg)) |
291 | 291 | { |
292 | 292 | // single, escaped unicode character |
293 | - $utf16 = chr(hexdec($reg[1])) . chr(hexdec($reg[2])); |
|
293 | + $utf16 = chr(hexdec($reg[1])).chr(hexdec($reg[2])); |
|
294 | 294 | $utf8 = utf162utf8($utf16); |
295 | - $val=preg_replace('/\\\u'.$reg[1].$reg[2].'/i',$utf8,$val); |
|
295 | + $val = preg_replace('/\\\u'.$reg[1].$reg[2].'/i', $utf8, $val); |
|
296 | 296 | } |
297 | 297 | return $val; |
298 | 298 | } |
@@ -310,13 +310,13 @@ discard block |
||
310 | 310 | function utf162utf8($utf16) |
311 | 311 | { |
312 | 312 | // oh please oh please oh please oh please oh please |
313 | - if(function_exists('mb_convert_encoding')) { |
|
313 | + if (function_exists('mb_convert_encoding')) { |
|
314 | 314 | return mb_convert_encoding($utf16, 'UTF-8', 'UTF-16'); |
315 | 315 | } |
316 | 316 | |
317 | 317 | $bytes = (ord($utf16{0}) << 8) | ord($utf16{1}); |
318 | 318 | |
319 | - switch(true) { |
|
319 | + switch (true) { |
|
320 | 320 | case ((0x7F & $bytes) == $bytes): |
321 | 321 | // this case should never be reached, because we are in ASCII range |
322 | 322 | // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 |
@@ -353,11 +353,11 @@ discard block |
||
353 | 353 | function utf82utf16($utf8) |
354 | 354 | { |
355 | 355 | // oh please oh please oh please oh please oh please |
356 | - if(function_exists('mb_convert_encoding')) { |
|
356 | + if (function_exists('mb_convert_encoding')) { |
|
357 | 357 | return mb_convert_encoding($utf8, 'UTF-16', 'UTF-8'); |
358 | 358 | } |
359 | 359 | |
360 | - switch(strlen($utf8)) { |
|
360 | + switch (strlen($utf8)) { |
|
361 | 361 | case 1: |
362 | 362 | // this case should never be reached, because we are in ASCII range |
363 | 363 | // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 |
@@ -366,12 +366,12 @@ discard block |
||
366 | 366 | case 2: |
367 | 367 | // return a UTF-16 character from a 2-byte UTF-8 char |
368 | 368 | // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 |
369 | - return chr(0x07 & (ord($utf8{0}) >> 2)) . chr((0xC0 & (ord($utf8{0}) << 6)) | (0x3F & ord($utf8{1}))); |
|
369 | + return chr(0x07 & (ord($utf8{0}) >> 2)).chr((0xC0 & (ord($utf8{0}) << 6)) | (0x3F & ord($utf8{1}))); |
|
370 | 370 | |
371 | 371 | case 3: |
372 | 372 | // return a UTF-16 character from a 3-byte UTF-8 char |
373 | 373 | // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 |
374 | - return chr((0xF0 & (ord($utf8{0}) << 4)) | (0x0F & (ord($utf8{1}) >> 2))) . chr((0xC0 & (ord($utf8{1}) << 6)) | (0x7F & ord($utf8{2}))); |
|
374 | + return chr((0xF0 & (ord($utf8{0}) << 4)) | (0x0F & (ord($utf8{1}) >> 2))).chr((0xC0 & (ord($utf8{1}) << 6)) | (0x7F & ord($utf8{2}))); |
|
375 | 375 | } |
376 | 376 | |
377 | 377 | // ignoring UTF-32 for now, sorry |
@@ -38,15 +38,15 @@ discard block |
||
38 | 38 | * @param int $issupplierline Is it a line for a supplier object ? |
39 | 39 | * @return string String with line |
40 | 40 | */ |
41 | -function doc_getlinedesc($line,$outputlangs,$hideref=0,$hidedesc=0,$issupplierline=0) |
|
41 | +function doc_getlinedesc($line, $outputlangs, $hideref = 0, $hidedesc = 0, $issupplierline = 0) |
|
42 | 42 | { |
43 | 43 | global $db, $conf, $langs; |
44 | 44 | |
45 | - $idprod=$line->fk_product; |
|
46 | - $label=(! empty($line->label)?$line->label:(! empty($line->libelle)?$line->libelle:'')); |
|
47 | - $desc=(! empty($line->desc)?$line->desc:(! empty($line->description)?$line->description:'')); |
|
48 | - $ref_supplier=(! empty($line->ref_supplier)?$line->ref_supplier:(! empty($line->ref_fourn)?$line->ref_fourn:'')); // TODO Not yet saved for supplier invoices, only supplier orders |
|
49 | - $note=(! empty($line->note)?$line->note:''); |
|
45 | + $idprod = $line->fk_product; |
|
46 | + $label = (!empty($line->label) ? $line->label : (!empty($line->libelle) ? $line->libelle : '')); |
|
47 | + $desc = (!empty($line->desc) ? $line->desc : (!empty($line->description) ? $line->description : '')); |
|
48 | + $ref_supplier = (!empty($line->ref_supplier) ? $line->ref_supplier : (!empty($line->ref_fourn) ? $line->ref_fourn : '')); // TODO Not yet saved for supplier invoices, only supplier orders |
|
49 | + $note = (!empty($line->note) ? $line->note : ''); |
|
50 | 50 | |
51 | 51 | if ($issupplierline) $prodser = new ProductFournisseur($db); |
52 | 52 | else $prodser = new Product($db); |
@@ -55,57 +55,57 @@ discard block |
||
55 | 55 | { |
56 | 56 | $prodser->fetch($idprod); |
57 | 57 | // If a predefined product and multilang and on other lang, we renamed label with label translated |
58 | - if (! empty($conf->global->MAIN_MULTILANGS) && ($outputlangs->defaultlang != $langs->defaultlang)) |
|
58 | + if (!empty($conf->global->MAIN_MULTILANGS) && ($outputlangs->defaultlang != $langs->defaultlang)) |
|
59 | 59 | { |
60 | - if (! empty($prodser->multilangs[$outputlangs->defaultlang]["label"]) && $label == $prodser->label) $label=$prodser->multilangs[$outputlangs->defaultlang]["label"]; |
|
61 | - if (! empty($prodser->multilangs[$outputlangs->defaultlang]["description"]) && $desc == $prodser->description) $desc=$prodser->multilangs[$outputlangs->defaultlang]["description"]; |
|
62 | - if (! empty($prodser->multilangs[$outputlangs->defaultlang]["note"]) && $note == $prodser->note) $note=$prodser->multilangs[$outputlangs->defaultlang]["note"]; |
|
60 | + if (!empty($prodser->multilangs[$outputlangs->defaultlang]["label"]) && $label == $prodser->label) $label = $prodser->multilangs[$outputlangs->defaultlang]["label"]; |
|
61 | + if (!empty($prodser->multilangs[$outputlangs->defaultlang]["description"]) && $desc == $prodser->description) $desc = $prodser->multilangs[$outputlangs->defaultlang]["description"]; |
|
62 | + if (!empty($prodser->multilangs[$outputlangs->defaultlang]["note"]) && $note == $prodser->note) $note = $prodser->multilangs[$outputlangs->defaultlang]["note"]; |
|
63 | 63 | } |
64 | 64 | } |
65 | 65 | |
66 | 66 | // Description short of product line |
67 | - $libelleproduitservice=$label; |
|
67 | + $libelleproduitservice = $label; |
|
68 | 68 | |
69 | 69 | // Description long of product line |
70 | 70 | if ($desc && ($desc != $label)) |
71 | 71 | { |
72 | 72 | if ($desc == '(CREDIT_NOTE)' && $line->fk_remise_except) |
73 | 73 | { |
74 | - $discount=new DiscountAbsolute($db); |
|
74 | + $discount = new DiscountAbsolute($db); |
|
75 | 75 | $discount->fetch($line->fk_remise_except); |
76 | - $sourceref=!empty($discount->discount_type)?$discount->ref_invoive_supplier_source:$discount->ref_facture_source; |
|
77 | - $libelleproduitservice=$outputlangs->transnoentitiesnoconv("DiscountFromCreditNote",$sourceref); |
|
76 | + $sourceref = !empty($discount->discount_type) ? $discount->ref_invoive_supplier_source : $discount->ref_facture_source; |
|
77 | + $libelleproduitservice = $outputlangs->transnoentitiesnoconv("DiscountFromCreditNote", $sourceref); |
|
78 | 78 | } |
79 | 79 | elseif ($desc == '(DEPOSIT)' && $line->fk_remise_except) |
80 | 80 | { |
81 | - $discount=new DiscountAbsolute($db); |
|
81 | + $discount = new DiscountAbsolute($db); |
|
82 | 82 | $discount->fetch($line->fk_remise_except); |
83 | - $sourceref=!empty($discount->discount_type)?$discount->ref_invoive_supplier_source:$discount->ref_facture_source; |
|
84 | - $libelleproduitservice=$outputlangs->transnoentitiesnoconv("DiscountFromDeposit",$sourceref); |
|
83 | + $sourceref = !empty($discount->discount_type) ? $discount->ref_invoive_supplier_source : $discount->ref_facture_source; |
|
84 | + $libelleproduitservice = $outputlangs->transnoentitiesnoconv("DiscountFromDeposit", $sourceref); |
|
85 | 85 | // Add date of deposit |
86 | - if (! empty($conf->global->INVOICE_ADD_DEPOSIT_DATE)) $libelleproduitservice.=' ('.dol_print_date($discount->datec,'day','',$outputlangs).')'; |
|
86 | + if (!empty($conf->global->INVOICE_ADD_DEPOSIT_DATE)) $libelleproduitservice .= ' ('.dol_print_date($discount->datec, 'day', '', $outputlangs).')'; |
|
87 | 87 | } |
88 | 88 | elseif ($desc == '(EXCESS RECEIVED)' && $line->fk_remise_except) |
89 | 89 | { |
90 | - $discount=new DiscountAbsolute($db); |
|
90 | + $discount = new DiscountAbsolute($db); |
|
91 | 91 | $discount->fetch($line->fk_remise_except); |
92 | - $libelleproduitservice=$outputlangs->transnoentitiesnoconv("DiscountFromExcessReceived",$discount->ref_facture_source); |
|
92 | + $libelleproduitservice = $outputlangs->transnoentitiesnoconv("DiscountFromExcessReceived", $discount->ref_facture_source); |
|
93 | 93 | } |
94 | 94 | elseif ($desc == '(EXCESS PAID)' && $line->fk_remise_except) |
95 | 95 | { |
96 | - $discount=new DiscountAbsolute($db); |
|
96 | + $discount = new DiscountAbsolute($db); |
|
97 | 97 | $discount->fetch($line->fk_remise_except); |
98 | - $libelleproduitservice=$outputlangs->transnoentitiesnoconv("DiscountFromExcessPaid",$discount->ref_invoice_supplier_source); |
|
98 | + $libelleproduitservice = $outputlangs->transnoentitiesnoconv("DiscountFromExcessPaid", $discount->ref_invoice_supplier_source); |
|
99 | 99 | } |
100 | 100 | else |
101 | 101 | { |
102 | 102 | if ($idprod) |
103 | 103 | { |
104 | - if (empty($hidedesc)) $libelleproduitservice=dol_concatdesc($libelleproduitservice, $desc); |
|
104 | + if (empty($hidedesc)) $libelleproduitservice = dol_concatdesc($libelleproduitservice, $desc); |
|
105 | 105 | } |
106 | 106 | else |
107 | 107 | { |
108 | - $libelleproduitservice=dol_concatdesc($libelleproduitservice, $desc); |
|
108 | + $libelleproduitservice = dol_concatdesc($libelleproduitservice, $desc); |
|
109 | 109 | } |
110 | 110 | } |
111 | 111 | } |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | { |
119 | 119 | $prefix_prodserv = ""; |
120 | 120 | $ref_prodserv = ""; |
121 | - if (! empty($conf->global->PRODUCT_ADD_TYPE_IN_DOCUMENTS)) // In standard mode, we do not show this |
|
121 | + if (!empty($conf->global->PRODUCT_ADD_TYPE_IN_DOCUMENTS)) // In standard mode, we do not show this |
|
122 | 122 | { |
123 | 123 | if ($prodser->isService()) |
124 | 124 | { |
@@ -132,34 +132,34 @@ discard block |
||
132 | 132 | |
133 | 133 | if (empty($hideref)) |
134 | 134 | { |
135 | - if ($issupplierline) $ref_prodserv = $prodser->ref.' ('.$outputlangs->trans("SupplierRef").' '.$ref_supplier.')'; // Show local ref and supplier ref |
|
135 | + if ($issupplierline) $ref_prodserv = $prodser->ref.' ('.$outputlangs->trans("SupplierRef").' '.$ref_supplier.')'; // Show local ref and supplier ref |
|
136 | 136 | else $ref_prodserv = $prodser->ref; // Show local ref only |
137 | 137 | |
138 | 138 | $ref_prodserv .= " - "; |
139 | 139 | } |
140 | 140 | |
141 | - $libelleproduitservice=$prefix_prodserv.$ref_prodserv.$libelleproduitservice; |
|
141 | + $libelleproduitservice = $prefix_prodserv.$ref_prodserv.$libelleproduitservice; |
|
142 | 142 | } |
143 | 143 | } |
144 | 144 | |
145 | - if (! empty($line->date_start) || ! empty($line->date_end)) |
|
145 | + if (!empty($line->date_start) || !empty($line->date_end)) |
|
146 | 146 | { |
147 | - $format='day'; |
|
147 | + $format = 'day'; |
|
148 | 148 | // Show duration if exists |
149 | 149 | if ($line->date_start && $line->date_end) |
150 | 150 | { |
151 | - $period='('.$outputlangs->transnoentitiesnoconv('DateFromTo',dol_print_date($line->date_start, $format, false, $outputlangs),dol_print_date($line->date_end, $format, false, $outputlangs)).')'; |
|
151 | + $period = '('.$outputlangs->transnoentitiesnoconv('DateFromTo', dol_print_date($line->date_start, $format, false, $outputlangs), dol_print_date($line->date_end, $format, false, $outputlangs)).')'; |
|
152 | 152 | } |
153 | - if ($line->date_start && ! $line->date_end) |
|
153 | + if ($line->date_start && !$line->date_end) |
|
154 | 154 | { |
155 | - $period='('.$outputlangs->transnoentitiesnoconv('DateFrom',dol_print_date($line->date_start, $format, false, $outputlangs)).')'; |
|
155 | + $period = '('.$outputlangs->transnoentitiesnoconv('DateFrom', dol_print_date($line->date_start, $format, false, $outputlangs)).')'; |
|
156 | 156 | } |
157 | - if (! $line->date_start && $line->date_end) |
|
157 | + if (!$line->date_start && $line->date_end) |
|
158 | 158 | { |
159 | - $period='('.$outputlangs->transnoentitiesnoconv('DateUntil',dol_print_date($line->date_end, $format, false, $outputlangs)).')'; |
|
159 | + $period = '('.$outputlangs->transnoentitiesnoconv('DateUntil', dol_print_date($line->date_end, $format, false, $outputlangs)).')'; |
|
160 | 160 | } |
161 | 161 | //print '>'.$outputlangs->charset_output.','.$period; |
162 | - $libelleproduitservice=dol_concatdesc($libelleproduitservice, $period); |
|
162 | + $libelleproduitservice = dol_concatdesc($libelleproduitservice, $period); |
|
163 | 163 | //print $libelleproduitservice; |
164 | 164 | } |
165 | 165 |
@@ -50,16 +50,16 @@ discard block |
||
50 | 50 | // Entries must be declared in modules descriptor with line |
51 | 51 | // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab |
52 | 52 | // $this->tabs = array('entity:-tabname); to remove a tab |
53 | - complete_head_from_modules($conf,$langs,$object,$head,$h,'tax'); |
|
53 | + complete_head_from_modules($conf, $langs, $object, $head, $h, 'tax'); |
|
54 | 54 | |
55 | 55 | require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; |
56 | 56 | require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php'; |
57 | - $upload_dir = $conf->tax->dir_output . "/" . dol_sanitizeFileName($object->ref); |
|
58 | - $nbFiles = count(dol_dir_list($upload_dir,'files',0,'','(\.meta|_preview.*\.png)$')); |
|
59 | - $nbLinks=Link::count($db, $object->element, $object->id); |
|
57 | + $upload_dir = $conf->tax->dir_output."/".dol_sanitizeFileName($object->ref); |
|
58 | + $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$')); |
|
59 | + $nbLinks = Link::count($db, $object->element, $object->id); |
|
60 | 60 | $head[$h][0] = DOL_URL_ROOT.'/compta/sociales/document.php?id='.$object->id; |
61 | 61 | $head[$h][1] = $langs->trans("Documents"); |
62 | - if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>'; |
|
62 | + if (($nbFiles + $nbLinks) > 0) $head[$h][1] .= ' <span class="badge">'.($nbFiles + $nbLinks).'</span>'; |
|
63 | 63 | $head[$h][2] = 'documents'; |
64 | 64 | $h++; |
65 | 65 | |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | $head[$h][2] = 'info'; |
69 | 69 | $h++; |
70 | 70 | |
71 | - complete_head_from_modules($conf,$langs,$object,$head,$h,'tax','remove'); |
|
71 | + complete_head_from_modules($conf, $langs, $object, $head, $h, 'tax', 'remove'); |
|
72 | 72 | |
73 | 73 | return $head; |
74 | 74 | } |
@@ -88,136 +88,136 @@ discard block |
||
88 | 88 | * @param int $q Quarter |
89 | 89 | * @return array Array with details of VATs (per third parties), -1 if no accountancy module, -2 if not yet developped, -3 if error |
90 | 90 | */ |
91 | -function tax_by_thirdparty($type, $db, $y, $date_start, $date_end, $modetax, $direction, $m=0, $q=0) |
|
91 | +function tax_by_thirdparty($type, $db, $y, $date_start, $date_end, $modetax, $direction, $m = 0, $q = 0) |
|
92 | 92 | { |
93 | 93 | global $conf; |
94 | 94 | |
95 | 95 | // If we use date_start and date_end, we must not use $y, $m, $q |
96 | - if (($date_start || $date_end) && (! empty($y) || ! empty($m) || ! empty($q))) |
|
96 | + if (($date_start || $date_end) && (!empty($y) || !empty($m) || !empty($q))) |
|
97 | 97 | { |
98 | 98 | dol_print_error('', 'Bad value of input parameter for tax_by_rate'); |
99 | 99 | } |
100 | 100 | |
101 | - $list=array(); |
|
101 | + $list = array(); |
|
102 | 102 | if ($direction == 'sell') |
103 | 103 | { |
104 | - $invoicetable='facture'; |
|
105 | - $invoicedettable='facturedet'; |
|
106 | - $fk_facture='fk_facture'; |
|
107 | - $fk_facture2='fk_facture'; |
|
108 | - $fk_payment='fk_paiement'; |
|
109 | - $total_tva='total_tva'; |
|
110 | - $paymenttable='paiement'; |
|
111 | - $paymentfacturetable='paiement_facture'; |
|
112 | - $invoicefieldref='ref'; |
|
104 | + $invoicetable = 'facture'; |
|
105 | + $invoicedettable = 'facturedet'; |
|
106 | + $fk_facture = 'fk_facture'; |
|
107 | + $fk_facture2 = 'fk_facture'; |
|
108 | + $fk_payment = 'fk_paiement'; |
|
109 | + $total_tva = 'total_tva'; |
|
110 | + $paymenttable = 'paiement'; |
|
111 | + $paymentfacturetable = 'paiement_facture'; |
|
112 | + $invoicefieldref = 'ref'; |
|
113 | 113 | } |
114 | 114 | if ($direction == 'buy') |
115 | 115 | { |
116 | - $invoicetable='facture_fourn'; |
|
117 | - $invoicedettable='facture_fourn_det'; |
|
118 | - $fk_facture='fk_facture_fourn'; |
|
119 | - $fk_facture2='fk_facturefourn'; |
|
120 | - $fk_payment='fk_paiementfourn'; |
|
121 | - $total_tva='tva'; |
|
122 | - $paymenttable='paiementfourn'; |
|
123 | - $paymentfacturetable='paiementfourn_facturefourn'; |
|
124 | - $invoicefieldref='ref'; |
|
116 | + $invoicetable = 'facture_fourn'; |
|
117 | + $invoicedettable = 'facture_fourn_det'; |
|
118 | + $fk_facture = 'fk_facture_fourn'; |
|
119 | + $fk_facture2 = 'fk_facturefourn'; |
|
120 | + $fk_payment = 'fk_paiementfourn'; |
|
121 | + $total_tva = 'tva'; |
|
122 | + $paymenttable = 'paiementfourn'; |
|
123 | + $paymentfacturetable = 'paiementfourn_facturefourn'; |
|
124 | + $invoicefieldref = 'ref'; |
|
125 | 125 | } |
126 | 126 | |
127 | - if ( strpos( $type, 'localtax' ) === 0 ) { |
|
128 | - $f_rate = $type . '_tx'; |
|
127 | + if (strpos($type, 'localtax') === 0) { |
|
128 | + $f_rate = $type.'_tx'; |
|
129 | 129 | } else { |
130 | 130 | $f_rate = 'tva_tx'; |
131 | 131 | } |
132 | 132 | |
133 | - $total_localtax1='total_localtax1'; |
|
134 | - $total_localtax2='total_localtax2'; |
|
133 | + $total_localtax1 = 'total_localtax1'; |
|
134 | + $total_localtax2 = 'total_localtax2'; |
|
135 | 135 | |
136 | 136 | |
137 | 137 | // CAS DES BIENS/PRODUITS |
138 | 138 | |
139 | 139 | // Define sql request |
140 | - $sql=''; |
|
140 | + $sql = ''; |
|
141 | 141 | if (($direction == 'sell' && $conf->global->TAX_MODE_SELL_PRODUCT == 'invoice') |
142 | 142 | || ($direction == 'buy' && $conf->global->TAX_MODE_BUY_PRODUCT == 'invoice')) |
143 | 143 | { |
144 | 144 | // Count on delivery date (use invoice date as delivery is unknown) |
145 | 145 | $sql = "SELECT d.rowid, d.product_type as dtype, d.".$fk_facture." as facid, d.$f_rate as rate, d.total_ht as total_ht, d.total_ttc as total_ttc, d.".$total_tva." as total_vat, d.description as descr,"; |
146 | - $sql .=" d.".$total_localtax1." as total_localtax1, d.".$total_localtax2." as total_localtax2, "; |
|
147 | - $sql.= " d.date_start as date_start, d.date_end as date_end,"; |
|
148 | - $sql.= " f.".$invoicefieldref." as facnum, f.type, f.total_ttc as ftotal_ttc, f.datef, s.nom as company_name, s.rowid as company_id,"; |
|
149 | - $sql.= " p.rowid as pid, p.ref as pref, p.fk_product_type as ptype,"; |
|
150 | - $sql.= " 0 as payment_id, 0 as payment_amount"; |
|
151 | - $sql.= " FROM ".MAIN_DB_PREFIX.$invoicetable." as f,"; |
|
152 | - $sql.= " ".MAIN_DB_PREFIX."societe as s,"; |
|
153 | - $sql.= " ".MAIN_DB_PREFIX.$invoicedettable." as d" ; |
|
154 | - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p on d.fk_product = p.rowid"; |
|
155 | - $sql.= " WHERE f.entity = " . $conf->entity; |
|
156 | - $sql.= " AND f.fk_statut in (1,2)"; // Validated or paid (partially or completely) |
|
157 | - if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $sql.= " AND f.type IN (0,1,2,5)"; |
|
158 | - else $sql.= " AND f.type IN (0,1,2,3,5)"; |
|
159 | - $sql.= " AND f.rowid = d.".$fk_facture; |
|
160 | - $sql.= " AND s.rowid = f.fk_soc"; |
|
146 | + $sql .= " d.".$total_localtax1." as total_localtax1, d.".$total_localtax2." as total_localtax2, "; |
|
147 | + $sql .= " d.date_start as date_start, d.date_end as date_end,"; |
|
148 | + $sql .= " f.".$invoicefieldref." as facnum, f.type, f.total_ttc as ftotal_ttc, f.datef, s.nom as company_name, s.rowid as company_id,"; |
|
149 | + $sql .= " p.rowid as pid, p.ref as pref, p.fk_product_type as ptype,"; |
|
150 | + $sql .= " 0 as payment_id, 0 as payment_amount"; |
|
151 | + $sql .= " FROM ".MAIN_DB_PREFIX.$invoicetable." as f,"; |
|
152 | + $sql .= " ".MAIN_DB_PREFIX."societe as s,"; |
|
153 | + $sql .= " ".MAIN_DB_PREFIX.$invoicedettable." as d"; |
|
154 | + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p on d.fk_product = p.rowid"; |
|
155 | + $sql .= " WHERE f.entity = ".$conf->entity; |
|
156 | + $sql .= " AND f.fk_statut in (1,2)"; // Validated or paid (partially or completely) |
|
157 | + if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $sql .= " AND f.type IN (0,1,2,5)"; |
|
158 | + else $sql .= " AND f.type IN (0,1,2,3,5)"; |
|
159 | + $sql .= " AND f.rowid = d.".$fk_facture; |
|
160 | + $sql .= " AND s.rowid = f.fk_soc"; |
|
161 | 161 | if ($y && $m) |
162 | 162 | { |
163 | - $sql.= " AND f.datef >= '".$db->idate(dol_get_first_day($y,$m,false))."'"; |
|
164 | - $sql.= " AND f.datef <= '".$db->idate(dol_get_last_day($y,$m,false))."'"; |
|
163 | + $sql .= " AND f.datef >= '".$db->idate(dol_get_first_day($y, $m, false))."'"; |
|
164 | + $sql .= " AND f.datef <= '".$db->idate(dol_get_last_day($y, $m, false))."'"; |
|
165 | 165 | } |
166 | 166 | else if ($y) |
167 | 167 | { |
168 | - $sql.= " AND f.datef >= '".$db->idate(dol_get_first_day($y,1,false))."'"; |
|
169 | - $sql.= " AND f.datef <= '".$db->idate(dol_get_last_day($y,12,false))."'"; |
|
168 | + $sql .= " AND f.datef >= '".$db->idate(dol_get_first_day($y, 1, false))."'"; |
|
169 | + $sql .= " AND f.datef <= '".$db->idate(dol_get_last_day($y, 12, false))."'"; |
|
170 | 170 | } |
171 | - if ($q) $sql.= " AND (date_format(f.datef,'%m') > ".(($q-1)*3)." AND date_format(f.datef,'%m') <= ".($q*3).")"; |
|
172 | - if ($date_start && $date_end) $sql.= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'"; |
|
173 | - $sql.= " AND (d.product_type = 0"; // Limit to products |
|
174 | - $sql.= " AND d.date_start is null AND d.date_end IS NULL)"; // enhance detection of products |
|
175 | - if (empty($conf->global->MAIN_INCLUDE_ZERO_VAT_IN_REPORTS)) $sql.= " AND (d.".$f_rate." <> 0 OR d.".$total_tva." <> 0)"; |
|
176 | - $sql.= " ORDER BY d.rowid, d.".$fk_facture; |
|
171 | + if ($q) $sql .= " AND (date_format(f.datef,'%m') > ".(($q - 1) * 3)." AND date_format(f.datef,'%m') <= ".($q * 3).")"; |
|
172 | + if ($date_start && $date_end) $sql .= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'"; |
|
173 | + $sql .= " AND (d.product_type = 0"; // Limit to products |
|
174 | + $sql .= " AND d.date_start is null AND d.date_end IS NULL)"; // enhance detection of products |
|
175 | + if (empty($conf->global->MAIN_INCLUDE_ZERO_VAT_IN_REPORTS)) $sql .= " AND (d.".$f_rate." <> 0 OR d.".$total_tva." <> 0)"; |
|
176 | + $sql .= " ORDER BY d.rowid, d.".$fk_facture; |
|
177 | 177 | } |
178 | 178 | else |
179 | 179 | { |
180 | 180 | // Count on payments date |
181 | 181 | $sql = "SELECT d.rowid, d.product_type as dtype, d.".$fk_facture." as facid, d.$f_rate as rate, d.total_ht as total_ht, d.total_ttc as total_ttc, d.".$total_tva." as total_vat, d.description as descr,"; |
182 | - $sql .=" d.".$total_localtax1." as total_localtax1, d.".$total_localtax2." as total_localtax2, "; |
|
183 | - $sql.= " d.date_start as date_start, d.date_end as date_end,"; |
|
184 | - $sql.= " f.".$invoicefieldref." as facnum, f.type, f.total_ttc as ftotal_ttc, f.datef, s.nom as company_name, s.rowid as company_id,"; |
|
185 | - $sql.= " p.rowid as pid, p.ref as pref, p.fk_product_type as ptype,"; |
|
186 | - $sql.= " pf.".$fk_payment." as payment_id, pf.amount as payment_amount,"; |
|
187 | - $sql.= " pa.datep as datep"; |
|
188 | - $sql.= " FROM ".MAIN_DB_PREFIX.$invoicetable." as f,"; |
|
189 | - $sql.= " ".MAIN_DB_PREFIX.$paymentfacturetable." as pf,"; |
|
190 | - $sql.= " ".MAIN_DB_PREFIX.$paymenttable." as pa,"; |
|
191 | - $sql.= " ".MAIN_DB_PREFIX."societe as s,"; |
|
192 | - $sql.= " ".MAIN_DB_PREFIX.$invoicedettable." as d"; |
|
193 | - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p on d.fk_product = p.rowid"; |
|
194 | - $sql.= " WHERE f.entity = " . $conf->entity; |
|
195 | - $sql.= " AND f.fk_statut in (1,2)"; // Paid (partially or completely) |
|
196 | - if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $sql.= " AND f.type IN (0,1,2,5)"; |
|
197 | - else $sql.= " AND f.type IN (0,1,2,3,5)"; |
|
198 | - $sql.= " AND f.rowid = d.".$fk_facture; |
|
199 | - $sql.= " AND s.rowid = f.fk_soc"; |
|
200 | - $sql.= " AND pf.".$fk_facture2." = f.rowid"; |
|
201 | - $sql.= " AND pa.rowid = pf.".$fk_payment; |
|
182 | + $sql .= " d.".$total_localtax1." as total_localtax1, d.".$total_localtax2." as total_localtax2, "; |
|
183 | + $sql .= " d.date_start as date_start, d.date_end as date_end,"; |
|
184 | + $sql .= " f.".$invoicefieldref." as facnum, f.type, f.total_ttc as ftotal_ttc, f.datef, s.nom as company_name, s.rowid as company_id,"; |
|
185 | + $sql .= " p.rowid as pid, p.ref as pref, p.fk_product_type as ptype,"; |
|
186 | + $sql .= " pf.".$fk_payment." as payment_id, pf.amount as payment_amount,"; |
|
187 | + $sql .= " pa.datep as datep"; |
|
188 | + $sql .= " FROM ".MAIN_DB_PREFIX.$invoicetable." as f,"; |
|
189 | + $sql .= " ".MAIN_DB_PREFIX.$paymentfacturetable." as pf,"; |
|
190 | + $sql .= " ".MAIN_DB_PREFIX.$paymenttable." as pa,"; |
|
191 | + $sql .= " ".MAIN_DB_PREFIX."societe as s,"; |
|
192 | + $sql .= " ".MAIN_DB_PREFIX.$invoicedettable." as d"; |
|
193 | + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p on d.fk_product = p.rowid"; |
|
194 | + $sql .= " WHERE f.entity = ".$conf->entity; |
|
195 | + $sql .= " AND f.fk_statut in (1,2)"; // Paid (partially or completely) |
|
196 | + if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $sql .= " AND f.type IN (0,1,2,5)"; |
|
197 | + else $sql .= " AND f.type IN (0,1,2,3,5)"; |
|
198 | + $sql .= " AND f.rowid = d.".$fk_facture; |
|
199 | + $sql .= " AND s.rowid = f.fk_soc"; |
|
200 | + $sql .= " AND pf.".$fk_facture2." = f.rowid"; |
|
201 | + $sql .= " AND pa.rowid = pf.".$fk_payment; |
|
202 | 202 | if ($y && $m) |
203 | 203 | { |
204 | - $sql.= " AND pa.datep >= '".$db->idate(dol_get_first_day($y,$m,false))."'"; |
|
205 | - $sql.= " AND pa.datep <= '".$db->idate(dol_get_last_day($y,$m,false))."'"; |
|
204 | + $sql .= " AND pa.datep >= '".$db->idate(dol_get_first_day($y, $m, false))."'"; |
|
205 | + $sql .= " AND pa.datep <= '".$db->idate(dol_get_last_day($y, $m, false))."'"; |
|
206 | 206 | } |
207 | 207 | else if ($y) |
208 | 208 | { |
209 | - $sql.= " AND pa.datep >= '".$db->idate(dol_get_first_day($y,1,false))."'"; |
|
210 | - $sql.= " AND pa.datep <= '".$db->idate(dol_get_last_day($y,12,false))."'"; |
|
209 | + $sql .= " AND pa.datep >= '".$db->idate(dol_get_first_day($y, 1, false))."'"; |
|
210 | + $sql .= " AND pa.datep <= '".$db->idate(dol_get_last_day($y, 12, false))."'"; |
|
211 | 211 | } |
212 | - if ($q) $sql.= " AND (date_format(pa.datep,'%m') > ".(($q-1)*3)." AND date_format(pa.datep,'%m') <= ".($q*3).")"; |
|
213 | - if ($date_start && $date_end) $sql.= " AND pa.datep >= '".$db->idate($date_start)."' AND pa.datep <= '".$db->idate($date_end)."'"; |
|
214 | - $sql.= " AND (d.product_type = 0"; // Limit to products |
|
215 | - $sql.= " AND d.date_start is null AND d.date_end IS NULL)"; // enhance detection of products |
|
216 | - if (empty($conf->global->MAIN_INCLUDE_ZERO_VAT_IN_REPORTS)) $sql.= " AND (d.".$f_rate." <> 0 OR d.".$total_tva." <> 0)"; |
|
217 | - $sql.= " ORDER BY d.rowid, d.".$fk_facture.", pf.rowid"; |
|
212 | + if ($q) $sql .= " AND (date_format(pa.datep,'%m') > ".(($q - 1) * 3)." AND date_format(pa.datep,'%m') <= ".($q * 3).")"; |
|
213 | + if ($date_start && $date_end) $sql .= " AND pa.datep >= '".$db->idate($date_start)."' AND pa.datep <= '".$db->idate($date_end)."'"; |
|
214 | + $sql .= " AND (d.product_type = 0"; // Limit to products |
|
215 | + $sql .= " AND d.date_start is null AND d.date_end IS NULL)"; // enhance detection of products |
|
216 | + if (empty($conf->global->MAIN_INCLUDE_ZERO_VAT_IN_REPORTS)) $sql .= " AND (d.".$f_rate." <> 0 OR d.".$total_tva." <> 0)"; |
|
217 | + $sql .= " ORDER BY d.rowid, d.".$fk_facture.", pf.rowid"; |
|
218 | 218 | } |
219 | 219 | |
220 | - if (! $sql) return -1; |
|
220 | + if (!$sql) return -1; |
|
221 | 221 | if ($sql == 'TODO') return -2; |
222 | 222 | if ($sql != 'TODO') |
223 | 223 | { |
@@ -227,17 +227,17 @@ discard block |
||
227 | 227 | if ($resql) |
228 | 228 | { |
229 | 229 | $company_id = -1; |
230 | - $oldrowid=''; |
|
231 | - while($assoc = $db->fetch_array($resql)) |
|
230 | + $oldrowid = ''; |
|
231 | + while ($assoc = $db->fetch_array($resql)) |
|
232 | 232 | { |
233 | - if (! isset($list[$assoc['company_id']]['totalht'])) $list[$assoc['company_id']]['totalht']=0; |
|
234 | - if (! isset($list[$assoc['company_id']]['vat'])) $list[$assoc['company_id']]['vat']=0; |
|
235 | - if (! isset($list[$assoc['company_id']]['localtax1'])) $list[$assoc['company_id']]['localtax1']=0; |
|
236 | - if (! isset($list[$assoc['company_id']]['localtax2'])) $list[$assoc['company_id']]['localtax2']=0; |
|
233 | + if (!isset($list[$assoc['company_id']]['totalht'])) $list[$assoc['company_id']]['totalht'] = 0; |
|
234 | + if (!isset($list[$assoc['company_id']]['vat'])) $list[$assoc['company_id']]['vat'] = 0; |
|
235 | + if (!isset($list[$assoc['company_id']]['localtax1'])) $list[$assoc['company_id']]['localtax1'] = 0; |
|
236 | + if (!isset($list[$assoc['company_id']]['localtax2'])) $list[$assoc['company_id']]['localtax2'] = 0; |
|
237 | 237 | |
238 | 238 | if ($assoc['rowid'] != $oldrowid) // Si rupture sur d.rowid |
239 | 239 | { |
240 | - $oldrowid=$assoc['rowid']; |
|
240 | + $oldrowid = $assoc['rowid']; |
|
241 | 241 | $list[$assoc['company_id']]['totalht'] += $assoc['total_ht']; |
242 | 242 | $list[$assoc['company_id']]['vat'] += $assoc['total_vat']; |
243 | 243 | $list[$assoc['company_id']]['localtax1'] += $assoc['total_localtax1']; |
@@ -262,7 +262,7 @@ discard block |
||
262 | 262 | $list[$assoc['company_id']]['totalht_list'][] = $assoc['total_ht']; |
263 | 263 | $list[$assoc['company_id']]['vat_list'][] = $assoc['total_vat']; |
264 | 264 | $list[$assoc['company_id']]['localtax1_list'][] = $assoc['total_localtax1']; |
265 | - $list[$assoc['company_id']]['localtax2_list'][] = $assoc['total_localtax2']; |
|
265 | + $list[$assoc['company_id']]['localtax2_list'][] = $assoc['total_localtax2']; |
|
266 | 266 | |
267 | 267 | $list[$assoc['company_id']]['pid'][] = $assoc['pid']; |
268 | 268 | $list[$assoc['company_id']]['pref'][] = $assoc['pref']; |
@@ -285,90 +285,90 @@ discard block |
||
285 | 285 | // CAS DES SERVICES |
286 | 286 | |
287 | 287 | // Define sql request |
288 | - $sql=''; |
|
288 | + $sql = ''; |
|
289 | 289 | if (($direction == 'sell' && $conf->global->TAX_MODE_SELL_SERVICE == 'invoice') |
290 | 290 | || ($direction == 'buy' && $conf->global->TAX_MODE_BUY_SERVICE == 'invoice')) |
291 | 291 | { |
292 | 292 | // Count on invoice date |
293 | 293 | $sql = "SELECT d.rowid, d.product_type as dtype, d.".$fk_facture." as facid, d.$f_rate as rate, d.total_ht as total_ht, d.total_ttc as total_ttc, d.".$total_tva." as total_vat, d.description as descr,"; |
294 | - $sql .=" d.".$total_localtax1." as total_localtax1, d.".$total_localtax2." as total_localtax2, "; |
|
295 | - $sql.= " d.date_start as date_start, d.date_end as date_end,"; |
|
296 | - $sql.= " f.".$invoicefieldref." as facnum, f.type, f.total_ttc as ftotal_ttc, f.datef, s.nom as company_name, s.rowid as company_id,"; |
|
297 | - $sql.= " p.rowid as pid, p.ref as pref, p.fk_product_type as ptype,"; |
|
298 | - $sql.= " 0 as payment_id, 0 as payment_amount"; |
|
299 | - $sql.= " FROM ".MAIN_DB_PREFIX.$invoicetable." as f,"; |
|
300 | - $sql.= " ".MAIN_DB_PREFIX."societe as s,"; |
|
301 | - $sql.= " ".MAIN_DB_PREFIX.$invoicedettable." as d" ; |
|
302 | - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p on d.fk_product = p.rowid"; |
|
303 | - $sql.= " WHERE f.entity = " . $conf->entity; |
|
304 | - $sql.= " AND f.fk_statut in (1,2)"; // Validated or paid (partially or completely) |
|
305 | - if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $sql.= " AND f.type IN (0,1,2,5)"; |
|
306 | - else $sql.= " AND f.type IN (0,1,2,3,5)"; |
|
307 | - $sql.= " AND f.rowid = d.".$fk_facture; |
|
308 | - $sql.= " AND s.rowid = f.fk_soc"; |
|
294 | + $sql .= " d.".$total_localtax1." as total_localtax1, d.".$total_localtax2." as total_localtax2, "; |
|
295 | + $sql .= " d.date_start as date_start, d.date_end as date_end,"; |
|
296 | + $sql .= " f.".$invoicefieldref." as facnum, f.type, f.total_ttc as ftotal_ttc, f.datef, s.nom as company_name, s.rowid as company_id,"; |
|
297 | + $sql .= " p.rowid as pid, p.ref as pref, p.fk_product_type as ptype,"; |
|
298 | + $sql .= " 0 as payment_id, 0 as payment_amount"; |
|
299 | + $sql .= " FROM ".MAIN_DB_PREFIX.$invoicetable." as f,"; |
|
300 | + $sql .= " ".MAIN_DB_PREFIX."societe as s,"; |
|
301 | + $sql .= " ".MAIN_DB_PREFIX.$invoicedettable." as d"; |
|
302 | + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p on d.fk_product = p.rowid"; |
|
303 | + $sql .= " WHERE f.entity = ".$conf->entity; |
|
304 | + $sql .= " AND f.fk_statut in (1,2)"; // Validated or paid (partially or completely) |
|
305 | + if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $sql .= " AND f.type IN (0,1,2,5)"; |
|
306 | + else $sql .= " AND f.type IN (0,1,2,3,5)"; |
|
307 | + $sql .= " AND f.rowid = d.".$fk_facture; |
|
308 | + $sql .= " AND s.rowid = f.fk_soc"; |
|
309 | 309 | if ($y && $m) |
310 | 310 | { |
311 | - $sql.= " AND f.datef >= '".$db->idate(dol_get_first_day($y,$m,false))."'"; |
|
312 | - $sql.= " AND f.datef <= '".$db->idate(dol_get_last_day($y,$m,false))."'"; |
|
311 | + $sql .= " AND f.datef >= '".$db->idate(dol_get_first_day($y, $m, false))."'"; |
|
312 | + $sql .= " AND f.datef <= '".$db->idate(dol_get_last_day($y, $m, false))."'"; |
|
313 | 313 | } |
314 | 314 | else if ($y) |
315 | 315 | { |
316 | - $sql.= " AND f.datef >= '".$db->idate(dol_get_first_day($y,1,false))."'"; |
|
317 | - $sql.= " AND f.datef <= '".$db->idate(dol_get_last_day($y,12,false))."'"; |
|
316 | + $sql .= " AND f.datef >= '".$db->idate(dol_get_first_day($y, 1, false))."'"; |
|
317 | + $sql .= " AND f.datef <= '".$db->idate(dol_get_last_day($y, 12, false))."'"; |
|
318 | 318 | } |
319 | - if ($q) $sql.= " AND (date_format(f.datef,'%m') > ".(($q-1)*3)." AND date_format(f.datef,'%m') <= ".($q*3).")"; |
|
320 | - if ($date_start && $date_end) $sql.= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'"; |
|
321 | - $sql.= " AND (d.product_type = 1"; // Limit to services |
|
322 | - $sql.= " OR d.date_start is NOT null OR d.date_end IS NOT NULL)"; // enhance detection of service |
|
323 | - if (empty($conf->global->MAIN_INCLUDE_ZERO_VAT_IN_REPORTS)) $sql.= " AND (d.".$f_rate." <> 0 OR d.".$total_tva." <> 0)"; |
|
324 | - $sql.= " ORDER BY d.rowid, d.".$fk_facture; |
|
319 | + if ($q) $sql .= " AND (date_format(f.datef,'%m') > ".(($q - 1) * 3)." AND date_format(f.datef,'%m') <= ".($q * 3).")"; |
|
320 | + if ($date_start && $date_end) $sql .= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'"; |
|
321 | + $sql .= " AND (d.product_type = 1"; // Limit to services |
|
322 | + $sql .= " OR d.date_start is NOT null OR d.date_end IS NOT NULL)"; // enhance detection of service |
|
323 | + if (empty($conf->global->MAIN_INCLUDE_ZERO_VAT_IN_REPORTS)) $sql .= " AND (d.".$f_rate." <> 0 OR d.".$total_tva." <> 0)"; |
|
324 | + $sql .= " ORDER BY d.rowid, d.".$fk_facture; |
|
325 | 325 | } |
326 | 326 | else |
327 | 327 | { |
328 | 328 | // Count on payments date |
329 | 329 | $sql = "SELECT d.rowid, d.product_type as dtype, d.".$fk_facture." as facid, d.$f_rate as rate, d.total_ht as total_ht, d.total_ttc as total_ttc, d.".$total_tva." as total_vat, d.description as descr,"; |
330 | - $sql .=" d.".$total_localtax1." as total_localtax1, d.".$total_localtax2." as total_localtax2, "; |
|
331 | - $sql.= " d.date_start as date_start, d.date_end as date_end,"; |
|
332 | - $sql.= " f.".$invoicefieldref." as facnum, f.type, f.total_ttc as ftotal_ttc, f.datef, s.nom as company_name, s.rowid as company_id,"; |
|
333 | - $sql.= " p.rowid as pid, p.ref as pref, p.fk_product_type as ptype,"; |
|
334 | - $sql.= " pf.".$fk_payment." as payment_id, pf.amount as payment_amount,"; |
|
335 | - $sql.= " pa.datep as datep"; |
|
336 | - $sql.= " FROM ".MAIN_DB_PREFIX.$invoicetable." as f,"; |
|
337 | - $sql.= " ".MAIN_DB_PREFIX.$paymentfacturetable." as pf,"; |
|
338 | - $sql.= " ".MAIN_DB_PREFIX.$paymenttable." as pa,"; |
|
339 | - $sql.= " ".MAIN_DB_PREFIX."societe as s,"; |
|
340 | - $sql.= " ".MAIN_DB_PREFIX.$invoicedettable." as d"; |
|
341 | - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p on d.fk_product = p.rowid"; |
|
342 | - $sql.= " WHERE f.entity = " . $conf->entity; |
|
343 | - $sql.= " AND f.fk_statut in (1,2)"; // Paid (partially or completely) |
|
344 | - if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $sql.= " AND f.type IN (0,1,2,5)"; |
|
345 | - else $sql.= " AND f.type IN (0,1,2,3,5)"; |
|
346 | - $sql.= " AND f.rowid = d.".$fk_facture; |
|
347 | - $sql.= " AND s.rowid = f.fk_soc"; |
|
348 | - $sql.= " AND pf.".$fk_facture2." = f.rowid"; |
|
349 | - $sql.= " AND pa.rowid = pf.".$fk_payment; |
|
330 | + $sql .= " d.".$total_localtax1." as total_localtax1, d.".$total_localtax2." as total_localtax2, "; |
|
331 | + $sql .= " d.date_start as date_start, d.date_end as date_end,"; |
|
332 | + $sql .= " f.".$invoicefieldref." as facnum, f.type, f.total_ttc as ftotal_ttc, f.datef, s.nom as company_name, s.rowid as company_id,"; |
|
333 | + $sql .= " p.rowid as pid, p.ref as pref, p.fk_product_type as ptype,"; |
|
334 | + $sql .= " pf.".$fk_payment." as payment_id, pf.amount as payment_amount,"; |
|
335 | + $sql .= " pa.datep as datep"; |
|
336 | + $sql .= " FROM ".MAIN_DB_PREFIX.$invoicetable." as f,"; |
|
337 | + $sql .= " ".MAIN_DB_PREFIX.$paymentfacturetable." as pf,"; |
|
338 | + $sql .= " ".MAIN_DB_PREFIX.$paymenttable." as pa,"; |
|
339 | + $sql .= " ".MAIN_DB_PREFIX."societe as s,"; |
|
340 | + $sql .= " ".MAIN_DB_PREFIX.$invoicedettable." as d"; |
|
341 | + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p on d.fk_product = p.rowid"; |
|
342 | + $sql .= " WHERE f.entity = ".$conf->entity; |
|
343 | + $sql .= " AND f.fk_statut in (1,2)"; // Paid (partially or completely) |
|
344 | + if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $sql .= " AND f.type IN (0,1,2,5)"; |
|
345 | + else $sql .= " AND f.type IN (0,1,2,3,5)"; |
|
346 | + $sql .= " AND f.rowid = d.".$fk_facture; |
|
347 | + $sql .= " AND s.rowid = f.fk_soc"; |
|
348 | + $sql .= " AND pf.".$fk_facture2." = f.rowid"; |
|
349 | + $sql .= " AND pa.rowid = pf.".$fk_payment; |
|
350 | 350 | if ($y && $m) |
351 | 351 | { |
352 | - $sql.= " AND pa.datep >= '".$db->idate(dol_get_first_day($y,$m,false))."'"; |
|
353 | - $sql.= " AND pa.datep <= '".$db->idate(dol_get_last_day($y,$m,false))."'"; |
|
352 | + $sql .= " AND pa.datep >= '".$db->idate(dol_get_first_day($y, $m, false))."'"; |
|
353 | + $sql .= " AND pa.datep <= '".$db->idate(dol_get_last_day($y, $m, false))."'"; |
|
354 | 354 | } |
355 | 355 | else if ($y) |
356 | 356 | { |
357 | - $sql.= " AND pa.datep >= '".$db->idate(dol_get_first_day($y,1,false))."'"; |
|
358 | - $sql.= " AND pa.datep <= '".$db->idate(dol_get_last_day($y,12,false))."'"; |
|
357 | + $sql .= " AND pa.datep >= '".$db->idate(dol_get_first_day($y, 1, false))."'"; |
|
358 | + $sql .= " AND pa.datep <= '".$db->idate(dol_get_last_day($y, 12, false))."'"; |
|
359 | 359 | } |
360 | - if ($q) $sql.= " AND (date_format(pa.datep,'%m') > ".(($q-1)*3)." AND date_format(pa.datep,'%m') <= ".($q*3).")"; |
|
361 | - if ($date_start && $date_end) $sql.= " AND pa.datep >= '".$db->idate($date_start)."' AND pa.datep <= '".$db->idate($date_end)."'"; |
|
362 | - $sql.= " AND (d.product_type = 1"; // Limit to services |
|
363 | - $sql.= " OR d.date_start is NOT null OR d.date_end IS NOT NULL)"; // enhance detection of service |
|
364 | - if (empty($conf->global->MAIN_INCLUDE_ZERO_VAT_IN_REPORTS)) $sql.= " AND (d.".$f_rate." <> 0 OR d.".$total_tva." <> 0)"; |
|
365 | - $sql.= " ORDER BY d.rowid, d.".$fk_facture.", pf.rowid"; |
|
360 | + if ($q) $sql .= " AND (date_format(pa.datep,'%m') > ".(($q - 1) * 3)." AND date_format(pa.datep,'%m') <= ".($q * 3).")"; |
|
361 | + if ($date_start && $date_end) $sql .= " AND pa.datep >= '".$db->idate($date_start)."' AND pa.datep <= '".$db->idate($date_end)."'"; |
|
362 | + $sql .= " AND (d.product_type = 1"; // Limit to services |
|
363 | + $sql .= " OR d.date_start is NOT null OR d.date_end IS NOT NULL)"; // enhance detection of service |
|
364 | + if (empty($conf->global->MAIN_INCLUDE_ZERO_VAT_IN_REPORTS)) $sql .= " AND (d.".$f_rate." <> 0 OR d.".$total_tva." <> 0)"; |
|
365 | + $sql .= " ORDER BY d.rowid, d.".$fk_facture.", pf.rowid"; |
|
366 | 366 | } |
367 | 367 | |
368 | - if (! $sql) |
|
368 | + if (!$sql) |
|
369 | 369 | { |
370 | - dol_syslog("Tax.lib.php::tax_by_rate no accountancy module enabled".$sql,LOG_ERR); |
|
371 | - return -1; // -1 = Not accountancy module enabled |
|
370 | + dol_syslog("Tax.lib.php::tax_by_rate no accountancy module enabled".$sql, LOG_ERR); |
|
371 | + return -1; // -1 = Not accountancy module enabled |
|
372 | 372 | } |
373 | 373 | if ($sql == 'TODO') return -2; // -2 = Feature not yet available |
374 | 374 | if ($sql != 'TODO') |
@@ -378,17 +378,17 @@ discard block |
||
378 | 378 | if ($resql) |
379 | 379 | { |
380 | 380 | $company_id = -1; |
381 | - $oldrowid=''; |
|
382 | - while($assoc = $db->fetch_array($resql)) |
|
381 | + $oldrowid = ''; |
|
382 | + while ($assoc = $db->fetch_array($resql)) |
|
383 | 383 | { |
384 | - if (! isset($list[$assoc['company_id']]['totalht'])) $list[$assoc['company_id']]['totalht']=0; |
|
385 | - if (! isset($list[$assoc['company_id']]['vat'])) $list[$assoc['company_id']]['vat']=0; |
|
386 | - if (! isset($list[$assoc['company_id']]['localtax1'])) $list[$assoc['company_id']]['localtax1']=0; |
|
387 | - if (! isset($list[$assoc['company_id']]['localtax2'])) $list[$assoc['company_id']]['localtax2']=0; |
|
384 | + if (!isset($list[$assoc['company_id']]['totalht'])) $list[$assoc['company_id']]['totalht'] = 0; |
|
385 | + if (!isset($list[$assoc['company_id']]['vat'])) $list[$assoc['company_id']]['vat'] = 0; |
|
386 | + if (!isset($list[$assoc['company_id']]['localtax1'])) $list[$assoc['company_id']]['localtax1'] = 0; |
|
387 | + if (!isset($list[$assoc['company_id']]['localtax2'])) $list[$assoc['company_id']]['localtax2'] = 0; |
|
388 | 388 | |
389 | 389 | if ($assoc['rowid'] != $oldrowid) // Si rupture sur d.rowid |
390 | 390 | { |
391 | - $oldrowid=$assoc['rowid']; |
|
391 | + $oldrowid = $assoc['rowid']; |
|
392 | 392 | $list[$assoc['company_id']]['totalht'] += $assoc['total_ht']; |
393 | 393 | $list[$assoc['company_id']]['vat'] += $assoc['total_vat']; |
394 | 394 | $list[$assoc['company_id']]['localtax1'] += $assoc['total_localtax1']; |
@@ -438,40 +438,40 @@ discard block |
||
438 | 438 | if ($direction == 'buy') // buy only for expense reports |
439 | 439 | { |
440 | 440 | // Define sql request |
441 | - $sql=''; |
|
441 | + $sql = ''; |
|
442 | 442 | |
443 | 443 | // Count on payments date |
444 | 444 | $sql = "SELECT d.rowid, d.product_type as dtype, e.rowid as facid, d.$f_rate as rate, d.total_ht as total_ht, d.total_ttc as total_ttc, d.total_tva as total_vat, e.note_private as descr,"; |
445 | - $sql .=" d.total_localtax1 as total_localtax1, d.total_localtax2 as total_localtax2, "; |
|
446 | - $sql.= " e.date_debut as date_start, e.date_fin as date_end, e.fk_user_author,"; |
|
447 | - $sql.= " e.ref as facnum, e.total_ttc as ftotal_ttc, e.date_create, d.fk_c_type_fees as type,"; |
|
448 | - $sql.= " p.fk_bank as payment_id, p.amount as payment_amount, p.rowid as pid, e.ref as pref"; |
|
449 | - $sql.= " FROM ".MAIN_DB_PREFIX."expensereport as e"; |
|
450 | - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."expensereport_det as d ON d.fk_expensereport = e.rowid "; |
|
451 | - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."payment_expensereport as p ON p.fk_expensereport = e.rowid "; |
|
452 | - $sql.= " WHERE e.entity = " . $conf->entity; |
|
453 | - $sql.= " AND e.fk_statut in (6)"; |
|
445 | + $sql .= " d.total_localtax1 as total_localtax1, d.total_localtax2 as total_localtax2, "; |
|
446 | + $sql .= " e.date_debut as date_start, e.date_fin as date_end, e.fk_user_author,"; |
|
447 | + $sql .= " e.ref as facnum, e.total_ttc as ftotal_ttc, e.date_create, d.fk_c_type_fees as type,"; |
|
448 | + $sql .= " p.fk_bank as payment_id, p.amount as payment_amount, p.rowid as pid, e.ref as pref"; |
|
449 | + $sql .= " FROM ".MAIN_DB_PREFIX."expensereport as e"; |
|
450 | + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."expensereport_det as d ON d.fk_expensereport = e.rowid "; |
|
451 | + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."payment_expensereport as p ON p.fk_expensereport = e.rowid "; |
|
452 | + $sql .= " WHERE e.entity = ".$conf->entity; |
|
453 | + $sql .= " AND e.fk_statut in (6)"; |
|
454 | 454 | if ($y && $m) |
455 | 455 | { |
456 | - $sql.= " AND p.datep >= '".$db->idate(dol_get_first_day($y,$m,false))."'"; |
|
457 | - $sql.= " AND p.datep <= '".$db->idate(dol_get_last_day($y,$m,false))."'"; |
|
456 | + $sql .= " AND p.datep >= '".$db->idate(dol_get_first_day($y, $m, false))."'"; |
|
457 | + $sql .= " AND p.datep <= '".$db->idate(dol_get_last_day($y, $m, false))."'"; |
|
458 | 458 | } |
459 | 459 | else if ($y) |
460 | 460 | { |
461 | - $sql.= " AND p.datep >= '".$db->idate(dol_get_first_day($y,1,false))."'"; |
|
462 | - $sql.= " AND p.datep <= '".$db->idate(dol_get_last_day($y,12,false))."'"; |
|
461 | + $sql .= " AND p.datep >= '".$db->idate(dol_get_first_day($y, 1, false))."'"; |
|
462 | + $sql .= " AND p.datep <= '".$db->idate(dol_get_last_day($y, 12, false))."'"; |
|
463 | 463 | } |
464 | - if ($q) $sql.= " AND (date_format(p.datep,'%m') > ".(($q-1)*3)." AND date_format(p.datep,'%m') <= ".($q*3).")"; |
|
465 | - if ($date_start && $date_end) $sql.= " AND p.datep >= '".$db->idate($date_start)."' AND p.datep <= '".$db->idate($date_end)."'"; |
|
466 | - $sql.= " AND (d.product_type = -1"; |
|
467 | - $sql.= " OR e.date_debut is NOT null OR e.date_fin IS NOT NULL)"; // enhance detection of service |
|
468 | - if (empty($conf->global->MAIN_INCLUDE_ZERO_VAT_IN_REPORTS)) $sql.= " AND (d.".$f_rate." <> 0 OR d.total_tva <> 0)"; |
|
469 | - $sql.= " ORDER BY e.rowid"; |
|
470 | - |
|
471 | - if (! $sql) |
|
464 | + if ($q) $sql .= " AND (date_format(p.datep,'%m') > ".(($q - 1) * 3)." AND date_format(p.datep,'%m') <= ".($q * 3).")"; |
|
465 | + if ($date_start && $date_end) $sql .= " AND p.datep >= '".$db->idate($date_start)."' AND p.datep <= '".$db->idate($date_end)."'"; |
|
466 | + $sql .= " AND (d.product_type = -1"; |
|
467 | + $sql .= " OR e.date_debut is NOT null OR e.date_fin IS NOT NULL)"; // enhance detection of service |
|
468 | + if (empty($conf->global->MAIN_INCLUDE_ZERO_VAT_IN_REPORTS)) $sql .= " AND (d.".$f_rate." <> 0 OR d.total_tva <> 0)"; |
|
469 | + $sql .= " ORDER BY e.rowid"; |
|
470 | + |
|
471 | + if (!$sql) |
|
472 | 472 | { |
473 | - dol_syslog("Tax.lib.php::tax_by_rate no accountancy module enabled".$sql,LOG_ERR); |
|
474 | - return -1; // -1 = Not accountancy module enabled |
|
473 | + dol_syslog("Tax.lib.php::tax_by_rate no accountancy module enabled".$sql, LOG_ERR); |
|
474 | + return -1; // -1 = Not accountancy module enabled |
|
475 | 475 | } |
476 | 476 | if ($sql == 'TODO') return -2; // -2 = Feature not yet available |
477 | 477 | if ($sql != 'TODO') |
@@ -481,18 +481,18 @@ discard block |
||
481 | 481 | if ($resql) |
482 | 482 | { |
483 | 483 | $company_id = -1; |
484 | - $oldrowid=''; |
|
485 | - while($assoc = $db->fetch_array($resql)) |
|
484 | + $oldrowid = ''; |
|
485 | + while ($assoc = $db->fetch_array($resql)) |
|
486 | 486 | { |
487 | - if (! isset($list[$assoc['company_id']]['totalht'])) $list[$assoc['company_id']]['totalht']=0; |
|
488 | - if (! isset($list[$assoc['company_id']]['vat'])) $list[$assoc['company_id']]['vat']=0; |
|
489 | - if (! isset($list[$assoc['company_id']]['localtax1'])) $list[$assoc['company_id']]['localtax1']=0; |
|
490 | - if (! isset($list[$assoc['company_id']]['localtax2'])) $list[$assoc['company_id']]['localtax2']=0; |
|
487 | + if (!isset($list[$assoc['company_id']]['totalht'])) $list[$assoc['company_id']]['totalht'] = 0; |
|
488 | + if (!isset($list[$assoc['company_id']]['vat'])) $list[$assoc['company_id']]['vat'] = 0; |
|
489 | + if (!isset($list[$assoc['company_id']]['localtax1'])) $list[$assoc['company_id']]['localtax1'] = 0; |
|
490 | + if (!isset($list[$assoc['company_id']]['localtax2'])) $list[$assoc['company_id']]['localtax2'] = 0; |
|
491 | 491 | |
492 | 492 | if ($assoc['rowid'] != $oldrowid) // Si rupture sur d.rowid |
493 | 493 | { |
494 | - $oldrowid=$assoc['rowid']; |
|
495 | - $list[$assoc['company_id']]['totalht'] += $assoc['total_ht']; |
|
494 | + $oldrowid = $assoc['rowid']; |
|
495 | + $list[$assoc['company_id']]['totalht'] += $assoc['total_ht']; |
|
496 | 496 | $list[$assoc['company_id']]['vat'] += $assoc['total_vat']; |
497 | 497 | $list[$assoc['company_id']]['localtax1'] += $assoc['total_localtax1']; |
498 | 498 | $list[$assoc['company_id']]['localtax2'] += $assoc['total_localtax2']; |
@@ -556,137 +556,137 @@ discard block |
||
556 | 556 | * @param int $m Month |
557 | 557 | * @return array Array with details of VATs (per rate), -1 if no accountancy module, -2 if not yet developped, -3 if error |
558 | 558 | */ |
559 | -function tax_by_rate($type, $db, $y, $q, $date_start, $date_end, $modetax, $direction, $m=0) |
|
559 | +function tax_by_rate($type, $db, $y, $q, $date_start, $date_end, $modetax, $direction, $m = 0) |
|
560 | 560 | { |
561 | 561 | global $conf; |
562 | 562 | |
563 | 563 | // If we use date_start and date_end, we must not use $y, $m, $q |
564 | - if (($date_start || $date_end) && (! empty($y) || ! empty($m) || ! empty($q))) |
|
564 | + if (($date_start || $date_end) && (!empty($y) || !empty($m) || !empty($q))) |
|
565 | 565 | { |
566 | 566 | dol_print_error('', 'Bad value of input parameter for tax_by_rate'); |
567 | 567 | } |
568 | 568 | |
569 | - $list=array(); |
|
569 | + $list = array(); |
|
570 | 570 | |
571 | 571 | if ($direction == 'sell') |
572 | 572 | { |
573 | - $invoicetable='facture'; |
|
574 | - $invoicedettable='facturedet'; |
|
575 | - $fk_facture='fk_facture'; |
|
576 | - $fk_facture2='fk_facture'; |
|
577 | - $fk_payment='fk_paiement'; |
|
578 | - $total_tva='total_tva'; |
|
579 | - $paymenttable='paiement'; |
|
580 | - $paymentfacturetable='paiement_facture'; |
|
581 | - $invoicefieldref='ref'; |
|
573 | + $invoicetable = 'facture'; |
|
574 | + $invoicedettable = 'facturedet'; |
|
575 | + $fk_facture = 'fk_facture'; |
|
576 | + $fk_facture2 = 'fk_facture'; |
|
577 | + $fk_payment = 'fk_paiement'; |
|
578 | + $total_tva = 'total_tva'; |
|
579 | + $paymenttable = 'paiement'; |
|
580 | + $paymentfacturetable = 'paiement_facture'; |
|
581 | + $invoicefieldref = 'ref'; |
|
582 | 582 | } |
583 | 583 | else |
584 | 584 | { |
585 | - $invoicetable='facture_fourn'; |
|
586 | - $invoicedettable='facture_fourn_det'; |
|
587 | - $fk_facture='fk_facture_fourn'; |
|
588 | - $fk_facture2='fk_facturefourn'; |
|
589 | - $fk_payment='fk_paiementfourn'; |
|
590 | - $total_tva='tva'; |
|
591 | - $paymenttable='paiementfourn'; |
|
592 | - $paymentfacturetable='paiementfourn_facturefourn'; |
|
593 | - $invoicefieldref='ref'; |
|
585 | + $invoicetable = 'facture_fourn'; |
|
586 | + $invoicedettable = 'facture_fourn_det'; |
|
587 | + $fk_facture = 'fk_facture_fourn'; |
|
588 | + $fk_facture2 = 'fk_facturefourn'; |
|
589 | + $fk_payment = 'fk_paiementfourn'; |
|
590 | + $total_tva = 'tva'; |
|
591 | + $paymenttable = 'paiementfourn'; |
|
592 | + $paymentfacturetable = 'paiementfourn_facturefourn'; |
|
593 | + $invoicefieldref = 'ref'; |
|
594 | 594 | } |
595 | 595 | |
596 | - if ( strpos( $type, 'localtax' ) === 0 ) { |
|
597 | - $f_rate = $type . '_tx'; |
|
596 | + if (strpos($type, 'localtax') === 0) { |
|
597 | + $f_rate = $type.'_tx'; |
|
598 | 598 | } else { |
599 | 599 | $f_rate = 'tva_tx'; |
600 | 600 | } |
601 | 601 | |
602 | - $total_localtax1='total_localtax1'; |
|
603 | - $total_localtax2='total_localtax2'; |
|
602 | + $total_localtax1 = 'total_localtax1'; |
|
603 | + $total_localtax2 = 'total_localtax2'; |
|
604 | 604 | |
605 | 605 | |
606 | 606 | // CAS DES BIENS/PRODUITS |
607 | 607 | |
608 | 608 | // Define sql request |
609 | - $sql=''; |
|
609 | + $sql = ''; |
|
610 | 610 | if (($direction == 'sell' && $conf->global->TAX_MODE_SELL_PRODUCT == 'invoice') |
611 | 611 | || ($direction == 'buy' && $conf->global->TAX_MODE_BUY_PRODUCT == 'invoice')) |
612 | 612 | { |
613 | 613 | // Count on delivery date (use invoice date as delivery is unknown) |
614 | 614 | $sql = "SELECT d.rowid, d.product_type as dtype, d.".$fk_facture." as facid, d.$f_rate as rate, d.total_ht as total_ht, d.total_ttc as total_ttc, d.".$total_tva." as total_vat, d.description as descr,"; |
615 | - $sql .=" d.".$total_localtax1." as total_localtax1, d.".$total_localtax2." as total_localtax2, "; |
|
616 | - $sql.= " d.date_start as date_start, d.date_end as date_end,"; |
|
617 | - $sql.= " f.".$invoicefieldref." as facnum, f.type, f.total_ttc as ftotal_ttc, f.datef, s.nom as company_name, s.rowid as company_id,"; |
|
618 | - $sql.= " p.rowid as pid, p.ref as pref, p.fk_product_type as ptype,"; |
|
619 | - $sql.= " 0 as payment_id, 0 as payment_amount"; |
|
620 | - $sql.= " FROM ".MAIN_DB_PREFIX.$invoicetable." as f,"; |
|
621 | - $sql.= " ".MAIN_DB_PREFIX."societe as s,"; |
|
622 | - $sql.= " ".MAIN_DB_PREFIX.$invoicedettable." as d" ; |
|
623 | - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p on d.fk_product = p.rowid"; |
|
624 | - $sql.= " WHERE f.entity = " . $conf->entity; |
|
625 | - $sql.= " AND f.fk_statut in (1,2)"; // Validated or paid (partially or completely) |
|
626 | - if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $sql.= " AND f.type IN (0,1,2,5)"; |
|
627 | - else $sql.= " AND f.type IN (0,1,2,3,5)"; |
|
628 | - $sql.= " AND f.rowid = d.".$fk_facture; |
|
629 | - $sql.= " AND s.rowid = f.fk_soc"; |
|
615 | + $sql .= " d.".$total_localtax1." as total_localtax1, d.".$total_localtax2." as total_localtax2, "; |
|
616 | + $sql .= " d.date_start as date_start, d.date_end as date_end,"; |
|
617 | + $sql .= " f.".$invoicefieldref." as facnum, f.type, f.total_ttc as ftotal_ttc, f.datef, s.nom as company_name, s.rowid as company_id,"; |
|
618 | + $sql .= " p.rowid as pid, p.ref as pref, p.fk_product_type as ptype,"; |
|
619 | + $sql .= " 0 as payment_id, 0 as payment_amount"; |
|
620 | + $sql .= " FROM ".MAIN_DB_PREFIX.$invoicetable." as f,"; |
|
621 | + $sql .= " ".MAIN_DB_PREFIX."societe as s,"; |
|
622 | + $sql .= " ".MAIN_DB_PREFIX.$invoicedettable." as d"; |
|
623 | + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p on d.fk_product = p.rowid"; |
|
624 | + $sql .= " WHERE f.entity = ".$conf->entity; |
|
625 | + $sql .= " AND f.fk_statut in (1,2)"; // Validated or paid (partially or completely) |
|
626 | + if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $sql .= " AND f.type IN (0,1,2,5)"; |
|
627 | + else $sql .= " AND f.type IN (0,1,2,3,5)"; |
|
628 | + $sql .= " AND f.rowid = d.".$fk_facture; |
|
629 | + $sql .= " AND s.rowid = f.fk_soc"; |
|
630 | 630 | if ($y && $m) |
631 | 631 | { |
632 | - $sql.= " AND f.datef >= '".$db->idate(dol_get_first_day($y,$m,false))."'"; |
|
633 | - $sql.= " AND f.datef <= '".$db->idate(dol_get_last_day($y,$m,false))."'"; |
|
632 | + $sql .= " AND f.datef >= '".$db->idate(dol_get_first_day($y, $m, false))."'"; |
|
633 | + $sql .= " AND f.datef <= '".$db->idate(dol_get_last_day($y, $m, false))."'"; |
|
634 | 634 | } |
635 | 635 | else if ($y) |
636 | 636 | { |
637 | - $sql.= " AND f.datef >= '".$db->idate(dol_get_first_day($y,1,false))."'"; |
|
638 | - $sql.= " AND f.datef <= '".$db->idate(dol_get_last_day($y,12,false))."'"; |
|
637 | + $sql .= " AND f.datef >= '".$db->idate(dol_get_first_day($y, 1, false))."'"; |
|
638 | + $sql .= " AND f.datef <= '".$db->idate(dol_get_last_day($y, 12, false))."'"; |
|
639 | 639 | } |
640 | - if ($q) $sql.= " AND (date_format(f.datef,'%m') > ".(($q-1)*3)." AND date_format(f.datef,'%m') <= ".($q*3).")"; |
|
641 | - if ($date_start && $date_end) $sql.= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'"; |
|
642 | - $sql.= " AND (d.product_type = 0"; // Limit to products |
|
643 | - $sql.= " AND d.date_start is null AND d.date_end IS NULL)"; // enhance detection of products |
|
644 | - if (empty($conf->global->MAIN_INCLUDE_ZERO_VAT_IN_REPORTS)) $sql.= " AND (d.".$f_rate." <> 0 OR d.".$total_tva." <> 0)"; |
|
645 | - $sql.= " ORDER BY d.rowid, d.".$fk_facture; |
|
640 | + if ($q) $sql .= " AND (date_format(f.datef,'%m') > ".(($q - 1) * 3)." AND date_format(f.datef,'%m') <= ".($q * 3).")"; |
|
641 | + if ($date_start && $date_end) $sql .= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'"; |
|
642 | + $sql .= " AND (d.product_type = 0"; // Limit to products |
|
643 | + $sql .= " AND d.date_start is null AND d.date_end IS NULL)"; // enhance detection of products |
|
644 | + if (empty($conf->global->MAIN_INCLUDE_ZERO_VAT_IN_REPORTS)) $sql .= " AND (d.".$f_rate." <> 0 OR d.".$total_tva." <> 0)"; |
|
645 | + $sql .= " ORDER BY d.rowid, d.".$fk_facture; |
|
646 | 646 | } |
647 | 647 | else |
648 | 648 | { |
649 | 649 | // Count on payments date |
650 | 650 | $sql = "SELECT d.rowid, d.product_type as dtype, d.".$fk_facture." as facid, d.$f_rate as rate, d.total_ht as total_ht, d.total_ttc as total_ttc, d.".$total_tva." as total_vat, d.description as descr,"; |
651 | - $sql .=" d.".$total_localtax1." as total_localtax1, d.".$total_localtax2." as total_localtax2, "; |
|
652 | - $sql.= " d.date_start as date_start, d.date_end as date_end,"; |
|
653 | - $sql.= " f.".$invoicefieldref." as facnum, f.type, f.total_ttc as ftotal_ttc, f.datef, s.nom as company_name, s.rowid as company_id,"; |
|
654 | - $sql.= " p.rowid as pid, p.ref as pref, p.fk_product_type as ptype,"; |
|
655 | - $sql.= " pf.".$fk_payment." as payment_id, pf.amount as payment_amount,"; |
|
656 | - $sql.= " pa.datep as datep"; |
|
657 | - $sql.= " FROM ".MAIN_DB_PREFIX.$invoicetable." as f,"; |
|
658 | - $sql.= " ".MAIN_DB_PREFIX.$paymentfacturetable." as pf,"; |
|
659 | - $sql.= " ".MAIN_DB_PREFIX.$paymenttable." as pa,"; |
|
660 | - $sql.= " ".MAIN_DB_PREFIX."societe as s,"; |
|
661 | - $sql.= " ".MAIN_DB_PREFIX.$invoicedettable." as d"; |
|
662 | - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p on d.fk_product = p.rowid"; |
|
663 | - $sql.= " WHERE f.entity = " . $conf->entity; |
|
664 | - $sql.= " AND f.fk_statut in (1,2)"; // Paid (partially or completely) |
|
665 | - if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $sql.= " AND f.type IN (0,1,2,5)"; |
|
666 | - else $sql.= " AND f.type IN (0,1,2,3,5)"; |
|
667 | - $sql.= " AND f.rowid = d.".$fk_facture; |
|
668 | - $sql.= " AND s.rowid = f.fk_soc"; |
|
669 | - $sql.= " AND pf.".$fk_facture2." = f.rowid"; |
|
670 | - $sql.= " AND pa.rowid = pf.".$fk_payment; |
|
651 | + $sql .= " d.".$total_localtax1." as total_localtax1, d.".$total_localtax2." as total_localtax2, "; |
|
652 | + $sql .= " d.date_start as date_start, d.date_end as date_end,"; |
|
653 | + $sql .= " f.".$invoicefieldref." as facnum, f.type, f.total_ttc as ftotal_ttc, f.datef, s.nom as company_name, s.rowid as company_id,"; |
|
654 | + $sql .= " p.rowid as pid, p.ref as pref, p.fk_product_type as ptype,"; |
|
655 | + $sql .= " pf.".$fk_payment." as payment_id, pf.amount as payment_amount,"; |
|
656 | + $sql .= " pa.datep as datep"; |
|
657 | + $sql .= " FROM ".MAIN_DB_PREFIX.$invoicetable." as f,"; |
|
658 | + $sql .= " ".MAIN_DB_PREFIX.$paymentfacturetable." as pf,"; |
|
659 | + $sql .= " ".MAIN_DB_PREFIX.$paymenttable." as pa,"; |
|
660 | + $sql .= " ".MAIN_DB_PREFIX."societe as s,"; |
|
661 | + $sql .= " ".MAIN_DB_PREFIX.$invoicedettable." as d"; |
|
662 | + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p on d.fk_product = p.rowid"; |
|
663 | + $sql .= " WHERE f.entity = ".$conf->entity; |
|
664 | + $sql .= " AND f.fk_statut in (1,2)"; // Paid (partially or completely) |
|
665 | + if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $sql .= " AND f.type IN (0,1,2,5)"; |
|
666 | + else $sql .= " AND f.type IN (0,1,2,3,5)"; |
|
667 | + $sql .= " AND f.rowid = d.".$fk_facture; |
|
668 | + $sql .= " AND s.rowid = f.fk_soc"; |
|
669 | + $sql .= " AND pf.".$fk_facture2." = f.rowid"; |
|
670 | + $sql .= " AND pa.rowid = pf.".$fk_payment; |
|
671 | 671 | if ($y && $m) |
672 | 672 | { |
673 | - $sql.= " AND pa.datep >= '".$db->idate(dol_get_first_day($y,$m,false))."'"; |
|
674 | - $sql.= " AND pa.datep <= '".$db->idate(dol_get_last_day($y,$m,false))."'"; |
|
673 | + $sql .= " AND pa.datep >= '".$db->idate(dol_get_first_day($y, $m, false))."'"; |
|
674 | + $sql .= " AND pa.datep <= '".$db->idate(dol_get_last_day($y, $m, false))."'"; |
|
675 | 675 | } |
676 | 676 | else if ($y) |
677 | 677 | { |
678 | - $sql.= " AND pa.datep >= '".$db->idate(dol_get_first_day($y,1,false))."'"; |
|
679 | - $sql.= " AND pa.datep <= '".$db->idate(dol_get_last_day($y,12,false))."'"; |
|
678 | + $sql .= " AND pa.datep >= '".$db->idate(dol_get_first_day($y, 1, false))."'"; |
|
679 | + $sql .= " AND pa.datep <= '".$db->idate(dol_get_last_day($y, 12, false))."'"; |
|
680 | 680 | } |
681 | - if ($q) $sql.= " AND (date_format(pa.datep,'%m') > ".(($q-1)*3)." AND date_format(pa.datep,'%m') <= ".($q*3).")"; |
|
682 | - if ($date_start && $date_end) $sql.= " AND pa.datep >= '".$db->idate($date_start)."' AND pa.datep <= '".$db->idate($date_end)."'"; |
|
683 | - $sql.= " AND (d.product_type = 0"; // Limit to products |
|
684 | - $sql.= " AND d.date_start is null AND d.date_end IS NULL)"; // enhance detection of products |
|
685 | - if (empty($conf->global->MAIN_INCLUDE_ZERO_VAT_IN_REPORTS)) $sql.= " AND (d.".$f_rate." <> 0 OR d.".$total_tva." <> 0)"; |
|
686 | - $sql.= " ORDER BY d.rowid, d.".$fk_facture.", pf.rowid"; |
|
681 | + if ($q) $sql .= " AND (date_format(pa.datep,'%m') > ".(($q - 1) * 3)." AND date_format(pa.datep,'%m') <= ".($q * 3).")"; |
|
682 | + if ($date_start && $date_end) $sql .= " AND pa.datep >= '".$db->idate($date_start)."' AND pa.datep <= '".$db->idate($date_end)."'"; |
|
683 | + $sql .= " AND (d.product_type = 0"; // Limit to products |
|
684 | + $sql .= " AND d.date_start is null AND d.date_end IS NULL)"; // enhance detection of products |
|
685 | + if (empty($conf->global->MAIN_INCLUDE_ZERO_VAT_IN_REPORTS)) $sql .= " AND (d.".$f_rate." <> 0 OR d.".$total_tva." <> 0)"; |
|
686 | + $sql .= " ORDER BY d.rowid, d.".$fk_facture.", pf.rowid"; |
|
687 | 687 | } |
688 | 688 | |
689 | - if (! $sql) return -1; |
|
689 | + if (!$sql) return -1; |
|
690 | 690 | if ($sql == 'TODO') return -2; |
691 | 691 | if ($sql != 'TODO') |
692 | 692 | { |
@@ -696,18 +696,18 @@ discard block |
||
696 | 696 | if ($resql) |
697 | 697 | { |
698 | 698 | $rate = -1; |
699 | - $oldrowid=''; |
|
700 | - while($assoc = $db->fetch_array($resql)) |
|
699 | + $oldrowid = ''; |
|
700 | + while ($assoc = $db->fetch_array($resql)) |
|
701 | 701 | { |
702 | 702 | // Code to avoid warnings when array entry not defined |
703 | - if (! isset($list[$assoc['rate']]['totalht'])) $list[$assoc['rate']]['totalht']=0; |
|
704 | - if (! isset($list[$assoc['rate']]['vat'])) $list[$assoc['rate']]['vat']=0; |
|
705 | - if (! isset($list[$assoc['rate']]['localtax1'])) $list[$assoc['rate']]['localtax1']=0; |
|
706 | - if (! isset($list[$assoc['rate']]['localtax2'])) $list[$assoc['rate']]['localtax2']=0; |
|
703 | + if (!isset($list[$assoc['rate']]['totalht'])) $list[$assoc['rate']]['totalht'] = 0; |
|
704 | + if (!isset($list[$assoc['rate']]['vat'])) $list[$assoc['rate']]['vat'] = 0; |
|
705 | + if (!isset($list[$assoc['rate']]['localtax1'])) $list[$assoc['rate']]['localtax1'] = 0; |
|
706 | + if (!isset($list[$assoc['rate']]['localtax2'])) $list[$assoc['rate']]['localtax2'] = 0; |
|
707 | 707 | |
708 | 708 | if ($assoc['rowid'] != $oldrowid) // Si rupture sur d.rowid |
709 | 709 | { |
710 | - $oldrowid=$assoc['rowid']; |
|
710 | + $oldrowid = $assoc['rowid']; |
|
711 | 711 | $list[$assoc['rate']]['totalht'] += $assoc['total_ht']; |
712 | 712 | $list[$assoc['rate']]['vat'] += $assoc['total_vat']; |
713 | 713 | $list[$assoc['rate']]['localtax1'] += $assoc['total_localtax1']; |
@@ -754,90 +754,90 @@ discard block |
||
754 | 754 | // CAS DES SERVICES |
755 | 755 | |
756 | 756 | // Define sql request |
757 | - $sql=''; |
|
757 | + $sql = ''; |
|
758 | 758 | if (($direction == 'sell' && $conf->global->TAX_MODE_SELL_SERVICE == 'invoice') |
759 | 759 | || ($direction == 'buy' && $conf->global->TAX_MODE_BUY_SERVICE == 'invoice')) |
760 | 760 | { |
761 | 761 | // Count on invoice date |
762 | 762 | $sql = "SELECT d.rowid, d.product_type as dtype, d.".$fk_facture." as facid, d.$f_rate as rate, d.total_ht as total_ht, d.total_ttc as total_ttc, d.".$total_tva." as total_vat, d.description as descr,"; |
763 | - $sql .=" d.".$total_localtax1." as total_localtax1, d.".$total_localtax2." as total_localtax2, "; |
|
764 | - $sql.= " d.date_start as date_start, d.date_end as date_end,"; |
|
765 | - $sql.= " f.".$invoicefieldref." as facnum, f.type, f.total_ttc as ftotal_ttc, f.datef, s.nom as company_name, s.rowid as company_id,"; |
|
766 | - $sql.= " p.rowid as pid, p.ref as pref, p.fk_product_type as ptype,"; |
|
767 | - $sql.= " 0 as payment_id, 0 as payment_amount"; |
|
768 | - $sql.= " FROM ".MAIN_DB_PREFIX.$invoicetable." as f,"; |
|
769 | - $sql.= " ".MAIN_DB_PREFIX."societe as s,"; |
|
770 | - $sql.= " ".MAIN_DB_PREFIX.$invoicedettable." as d" ; |
|
771 | - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p on d.fk_product = p.rowid"; |
|
772 | - $sql.= " WHERE f.entity = " . $conf->entity; |
|
773 | - $sql.= " AND f.fk_statut in (1,2)"; // Validated or paid (partially or completely) |
|
774 | - if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $sql.= " AND f.type IN (0,1,2,5)"; |
|
775 | - else $sql.= " AND f.type IN (0,1,2,3,5)"; |
|
776 | - $sql.= " AND f.rowid = d.".$fk_facture; |
|
777 | - $sql.= " AND s.rowid = f.fk_soc"; |
|
763 | + $sql .= " d.".$total_localtax1." as total_localtax1, d.".$total_localtax2." as total_localtax2, "; |
|
764 | + $sql .= " d.date_start as date_start, d.date_end as date_end,"; |
|
765 | + $sql .= " f.".$invoicefieldref." as facnum, f.type, f.total_ttc as ftotal_ttc, f.datef, s.nom as company_name, s.rowid as company_id,"; |
|
766 | + $sql .= " p.rowid as pid, p.ref as pref, p.fk_product_type as ptype,"; |
|
767 | + $sql .= " 0 as payment_id, 0 as payment_amount"; |
|
768 | + $sql .= " FROM ".MAIN_DB_PREFIX.$invoicetable." as f,"; |
|
769 | + $sql .= " ".MAIN_DB_PREFIX."societe as s,"; |
|
770 | + $sql .= " ".MAIN_DB_PREFIX.$invoicedettable." as d"; |
|
771 | + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p on d.fk_product = p.rowid"; |
|
772 | + $sql .= " WHERE f.entity = ".$conf->entity; |
|
773 | + $sql .= " AND f.fk_statut in (1,2)"; // Validated or paid (partially or completely) |
|
774 | + if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $sql .= " AND f.type IN (0,1,2,5)"; |
|
775 | + else $sql .= " AND f.type IN (0,1,2,3,5)"; |
|
776 | + $sql .= " AND f.rowid = d.".$fk_facture; |
|
777 | + $sql .= " AND s.rowid = f.fk_soc"; |
|
778 | 778 | if ($y && $m) |
779 | 779 | { |
780 | - $sql.= " AND f.datef >= '".$db->idate(dol_get_first_day($y,$m,false))."'"; |
|
781 | - $sql.= " AND f.datef <= '".$db->idate(dol_get_last_day($y,$m,false))."'"; |
|
780 | + $sql .= " AND f.datef >= '".$db->idate(dol_get_first_day($y, $m, false))."'"; |
|
781 | + $sql .= " AND f.datef <= '".$db->idate(dol_get_last_day($y, $m, false))."'"; |
|
782 | 782 | } |
783 | 783 | else if ($y) |
784 | 784 | { |
785 | - $sql.= " AND f.datef >= '".$db->idate(dol_get_first_day($y,1,false))."'"; |
|
786 | - $sql.= " AND f.datef <= '".$db->idate(dol_get_last_day($y,12,false))."'"; |
|
785 | + $sql .= " AND f.datef >= '".$db->idate(dol_get_first_day($y, 1, false))."'"; |
|
786 | + $sql .= " AND f.datef <= '".$db->idate(dol_get_last_day($y, 12, false))."'"; |
|
787 | 787 | } |
788 | - if ($q) $sql.= " AND (date_format(f.datef,'%m') > ".(($q-1)*3)." AND date_format(f.datef,'%m') <= ".($q*3).")"; |
|
789 | - if ($date_start && $date_end) $sql.= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'"; |
|
790 | - $sql.= " AND (d.product_type = 1"; // Limit to services |
|
791 | - $sql.= " OR d.date_start is NOT null OR d.date_end IS NOT NULL)"; // enhance detection of service |
|
792 | - if (empty($conf->global->MAIN_INCLUDE_ZERO_VAT_IN_REPORTS)) $sql.= " AND (d.".$f_rate." <> 0 OR d.".$total_tva." <> 0)"; |
|
793 | - $sql.= " ORDER BY d.rowid, d.".$fk_facture; |
|
788 | + if ($q) $sql .= " AND (date_format(f.datef,'%m') > ".(($q - 1) * 3)." AND date_format(f.datef,'%m') <= ".($q * 3).")"; |
|
789 | + if ($date_start && $date_end) $sql .= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'"; |
|
790 | + $sql .= " AND (d.product_type = 1"; // Limit to services |
|
791 | + $sql .= " OR d.date_start is NOT null OR d.date_end IS NOT NULL)"; // enhance detection of service |
|
792 | + if (empty($conf->global->MAIN_INCLUDE_ZERO_VAT_IN_REPORTS)) $sql .= " AND (d.".$f_rate." <> 0 OR d.".$total_tva." <> 0)"; |
|
793 | + $sql .= " ORDER BY d.rowid, d.".$fk_facture; |
|
794 | 794 | } |
795 | 795 | else |
796 | 796 | { |
797 | 797 | // Count on payments date |
798 | 798 | $sql = "SELECT d.rowid, d.product_type as dtype, d.".$fk_facture." as facid, d.$f_rate as rate, d.total_ht as total_ht, d.total_ttc as total_ttc, d.".$total_tva." as total_vat, d.description as descr,"; |
799 | - $sql .=" d.".$total_localtax1." as total_localtax1, d.".$total_localtax2." as total_localtax2, "; |
|
800 | - $sql.= " d.date_start as date_start, d.date_end as date_end,"; |
|
801 | - $sql.= " f.".$invoicefieldref." as facnum, f.type, f.total_ttc as ftotal_ttc, f.datef, s.nom as company_name, s.rowid as company_id,"; |
|
802 | - $sql.= " p.rowid as pid, p.ref as pref, p.fk_product_type as ptype,"; |
|
803 | - $sql.= " pf.".$fk_payment." as payment_id, pf.amount as payment_amount,"; |
|
804 | - $sql.= " pa.datep as datep"; |
|
805 | - $sql.= " FROM ".MAIN_DB_PREFIX.$invoicetable." as f,"; |
|
806 | - $sql.= " ".MAIN_DB_PREFIX.$paymentfacturetable." as pf,"; |
|
807 | - $sql.= " ".MAIN_DB_PREFIX.$paymenttable." as pa,"; |
|
808 | - $sql.= " ".MAIN_DB_PREFIX."societe as s,"; |
|
809 | - $sql.= " ".MAIN_DB_PREFIX.$invoicedettable." as d"; |
|
810 | - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p on d.fk_product = p.rowid"; |
|
811 | - $sql.= " WHERE f.entity = " . $conf->entity; |
|
812 | - $sql.= " AND f.fk_statut in (1,2)"; // Paid (partially or completely) |
|
813 | - if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $sql.= " AND f.type IN (0,1,2,5)"; |
|
814 | - else $sql.= " AND f.type IN (0,1,2,3,5)"; |
|
815 | - $sql.= " AND f.rowid = d.".$fk_facture; |
|
816 | - $sql.= " AND s.rowid = f.fk_soc"; |
|
817 | - $sql.= " AND pf.".$fk_facture2." = f.rowid"; |
|
818 | - $sql.= " AND pa.rowid = pf.".$fk_payment; |
|
799 | + $sql .= " d.".$total_localtax1." as total_localtax1, d.".$total_localtax2." as total_localtax2, "; |
|
800 | + $sql .= " d.date_start as date_start, d.date_end as date_end,"; |
|
801 | + $sql .= " f.".$invoicefieldref." as facnum, f.type, f.total_ttc as ftotal_ttc, f.datef, s.nom as company_name, s.rowid as company_id,"; |
|
802 | + $sql .= " p.rowid as pid, p.ref as pref, p.fk_product_type as ptype,"; |
|
803 | + $sql .= " pf.".$fk_payment." as payment_id, pf.amount as payment_amount,"; |
|
804 | + $sql .= " pa.datep as datep"; |
|
805 | + $sql .= " FROM ".MAIN_DB_PREFIX.$invoicetable." as f,"; |
|
806 | + $sql .= " ".MAIN_DB_PREFIX.$paymentfacturetable." as pf,"; |
|
807 | + $sql .= " ".MAIN_DB_PREFIX.$paymenttable." as pa,"; |
|
808 | + $sql .= " ".MAIN_DB_PREFIX."societe as s,"; |
|
809 | + $sql .= " ".MAIN_DB_PREFIX.$invoicedettable." as d"; |
|
810 | + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p on d.fk_product = p.rowid"; |
|
811 | + $sql .= " WHERE f.entity = ".$conf->entity; |
|
812 | + $sql .= " AND f.fk_statut in (1,2)"; // Paid (partially or completely) |
|
813 | + if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $sql .= " AND f.type IN (0,1,2,5)"; |
|
814 | + else $sql .= " AND f.type IN (0,1,2,3,5)"; |
|
815 | + $sql .= " AND f.rowid = d.".$fk_facture; |
|
816 | + $sql .= " AND s.rowid = f.fk_soc"; |
|
817 | + $sql .= " AND pf.".$fk_facture2." = f.rowid"; |
|
818 | + $sql .= " AND pa.rowid = pf.".$fk_payment; |
|
819 | 819 | if ($y && $m) |
820 | 820 | { |
821 | - $sql.= " AND pa.datep >= '".$db->idate(dol_get_first_day($y,$m,false))."'"; |
|
822 | - $sql.= " AND pa.datep <= '".$db->idate(dol_get_last_day($y,$m,false))."'"; |
|
821 | + $sql .= " AND pa.datep >= '".$db->idate(dol_get_first_day($y, $m, false))."'"; |
|
822 | + $sql .= " AND pa.datep <= '".$db->idate(dol_get_last_day($y, $m, false))."'"; |
|
823 | 823 | } |
824 | 824 | else if ($y) |
825 | 825 | { |
826 | - $sql.= " AND pa.datep >= '".$db->idate(dol_get_first_day($y,1,false))."'"; |
|
827 | - $sql.= " AND pa.datep <= '".$db->idate(dol_get_last_day($y,12,false))."'"; |
|
826 | + $sql .= " AND pa.datep >= '".$db->idate(dol_get_first_day($y, 1, false))."'"; |
|
827 | + $sql .= " AND pa.datep <= '".$db->idate(dol_get_last_day($y, 12, false))."'"; |
|
828 | 828 | } |
829 | - if ($q) $sql.= " AND (date_format(pa.datep,'%m') > ".(($q-1)*3)." AND date_format(pa.datep,'%m') <= ".($q*3).")"; |
|
830 | - if ($date_start && $date_end) $sql.= " AND pa.datep >= '".$db->idate($date_start)."' AND pa.datep <= '".$db->idate($date_end)."'"; |
|
831 | - $sql.= " AND (d.product_type = 1"; // Limit to services |
|
832 | - $sql.= " OR d.date_start is NOT null OR d.date_end IS NOT NULL)"; // enhance detection of service |
|
833 | - if (empty($conf->global->MAIN_INCLUDE_ZERO_VAT_IN_REPORTS)) $sql.= " AND (d.".$f_rate." <> 0 OR d.".$total_tva." <> 0)"; |
|
834 | - $sql.= " ORDER BY d.rowid, d.".$fk_facture.", pf.rowid"; |
|
829 | + if ($q) $sql .= " AND (date_format(pa.datep,'%m') > ".(($q - 1) * 3)." AND date_format(pa.datep,'%m') <= ".($q * 3).")"; |
|
830 | + if ($date_start && $date_end) $sql .= " AND pa.datep >= '".$db->idate($date_start)."' AND pa.datep <= '".$db->idate($date_end)."'"; |
|
831 | + $sql .= " AND (d.product_type = 1"; // Limit to services |
|
832 | + $sql .= " OR d.date_start is NOT null OR d.date_end IS NOT NULL)"; // enhance detection of service |
|
833 | + if (empty($conf->global->MAIN_INCLUDE_ZERO_VAT_IN_REPORTS)) $sql .= " AND (d.".$f_rate." <> 0 OR d.".$total_tva." <> 0)"; |
|
834 | + $sql .= " ORDER BY d.rowid, d.".$fk_facture.", pf.rowid"; |
|
835 | 835 | } |
836 | 836 | |
837 | - if (! $sql) |
|
837 | + if (!$sql) |
|
838 | 838 | { |
839 | - dol_syslog("Tax.lib.php::tax_by_rate no accountancy module enabled".$sql,LOG_ERR); |
|
840 | - return -1; // -1 = Not accountancy module enabled |
|
839 | + dol_syslog("Tax.lib.php::tax_by_rate no accountancy module enabled".$sql, LOG_ERR); |
|
840 | + return -1; // -1 = Not accountancy module enabled |
|
841 | 841 | } |
842 | 842 | if ($sql == 'TODO') return -2; // -2 = Feature not yet available |
843 | 843 | if ($sql != 'TODO') |
@@ -847,18 +847,18 @@ discard block |
||
847 | 847 | if ($resql) |
848 | 848 | { |
849 | 849 | $rate = -1; |
850 | - $oldrowid=''; |
|
851 | - while($assoc = $db->fetch_array($resql)) |
|
850 | + $oldrowid = ''; |
|
851 | + while ($assoc = $db->fetch_array($resql)) |
|
852 | 852 | { |
853 | 853 | // Code to avoid warnings when array entry not defined |
854 | - if (! isset($list[$assoc['rate']]['totalht'])) $list[$assoc['rate']]['totalht']=0; |
|
855 | - if (! isset($list[$assoc['rate']]['vat'])) $list[$assoc['rate']]['vat']=0; |
|
856 | - if (! isset($list[$assoc['rate']]['localtax1'])) $list[$assoc['rate']]['localtax1']=0; |
|
857 | - if (! isset($list[$assoc['rate']]['localtax2'])) $list[$assoc['rate']]['localtax2']=0; |
|
854 | + if (!isset($list[$assoc['rate']]['totalht'])) $list[$assoc['rate']]['totalht'] = 0; |
|
855 | + if (!isset($list[$assoc['rate']]['vat'])) $list[$assoc['rate']]['vat'] = 0; |
|
856 | + if (!isset($list[$assoc['rate']]['localtax1'])) $list[$assoc['rate']]['localtax1'] = 0; |
|
857 | + if (!isset($list[$assoc['rate']]['localtax2'])) $list[$assoc['rate']]['localtax2'] = 0; |
|
858 | 858 | |
859 | 859 | if ($assoc['rowid'] != $oldrowid) // Si rupture sur d.rowid |
860 | 860 | { |
861 | - $oldrowid=$assoc['rowid']; |
|
861 | + $oldrowid = $assoc['rowid']; |
|
862 | 862 | $list[$assoc['rate']]['totalht'] += $assoc['total_ht']; |
863 | 863 | $list[$assoc['rate']]['vat'] += $assoc['total_vat']; |
864 | 864 | $list[$assoc['rate']]['localtax1'] += $assoc['total_localtax1']; |
@@ -907,40 +907,40 @@ discard block |
||
907 | 907 | if ($direction == 'buy') // buy only for expense reports |
908 | 908 | { |
909 | 909 | // Define sql request |
910 | - $sql=''; |
|
910 | + $sql = ''; |
|
911 | 911 | |
912 | 912 | // Count on payments date |
913 | 913 | $sql = "SELECT d.rowid, d.product_type as dtype, e.rowid as facid, d.$f_rate as rate, d.total_ht as total_ht, d.total_ttc as total_ttc, d.total_tva as total_vat, e.note_private as descr,"; |
914 | - $sql .=" d.total_localtax1 as total_localtax1, d.total_localtax2 as total_localtax2, "; |
|
915 | - $sql.= " e.date_debut as date_start, e.date_fin as date_end, e.fk_user_author,"; |
|
916 | - $sql.= " e.ref as facnum, e.total_ttc as ftotal_ttc, e.date_create, d.fk_c_type_fees as type,"; |
|
917 | - $sql.= " p.fk_bank as payment_id, p.amount as payment_amount, p.rowid as pid, e.ref as pref"; |
|
918 | - $sql.= " FROM ".MAIN_DB_PREFIX."expensereport as e "; |
|
919 | - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."expensereport_det as d ON d.fk_expensereport = e.rowid "; |
|
920 | - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."payment_expensereport as p ON p.fk_expensereport = e.rowid "; |
|
921 | - $sql.= " WHERE e.entity = " . $conf->entity; |
|
922 | - $sql.= " AND e.fk_statut in (6)"; |
|
914 | + $sql .= " d.total_localtax1 as total_localtax1, d.total_localtax2 as total_localtax2, "; |
|
915 | + $sql .= " e.date_debut as date_start, e.date_fin as date_end, e.fk_user_author,"; |
|
916 | + $sql .= " e.ref as facnum, e.total_ttc as ftotal_ttc, e.date_create, d.fk_c_type_fees as type,"; |
|
917 | + $sql .= " p.fk_bank as payment_id, p.amount as payment_amount, p.rowid as pid, e.ref as pref"; |
|
918 | + $sql .= " FROM ".MAIN_DB_PREFIX."expensereport as e "; |
|
919 | + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."expensereport_det as d ON d.fk_expensereport = e.rowid "; |
|
920 | + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."payment_expensereport as p ON p.fk_expensereport = e.rowid "; |
|
921 | + $sql .= " WHERE e.entity = ".$conf->entity; |
|
922 | + $sql .= " AND e.fk_statut in (6)"; |
|
923 | 923 | if ($y && $m) |
924 | 924 | { |
925 | - $sql.= " AND p.datep >= '".$db->idate(dol_get_first_day($y,$m,false))."'"; |
|
926 | - $sql.= " AND p.datep <= '".$db->idate(dol_get_last_day($y,$m,false))."'"; |
|
925 | + $sql .= " AND p.datep >= '".$db->idate(dol_get_first_day($y, $m, false))."'"; |
|
926 | + $sql .= " AND p.datep <= '".$db->idate(dol_get_last_day($y, $m, false))."'"; |
|
927 | 927 | } |
928 | 928 | else if ($y) |
929 | 929 | { |
930 | - $sql.= " AND p.datep >= '".$db->idate(dol_get_first_day($y,1,false))."'"; |
|
931 | - $sql.= " AND p.datep <= '".$db->idate(dol_get_last_day($y,12,false))."'"; |
|
930 | + $sql .= " AND p.datep >= '".$db->idate(dol_get_first_day($y, 1, false))."'"; |
|
931 | + $sql .= " AND p.datep <= '".$db->idate(dol_get_last_day($y, 12, false))."'"; |
|
932 | 932 | } |
933 | - if ($q) $sql.= " AND (date_format(p.datep,'%m') > ".(($q-1)*3)." AND date_format(p.datep,'%m') <= ".($q*3).")"; |
|
934 | - if ($date_start && $date_end) $sql.= " AND p.datep >= '".$db->idate($date_start)."' AND p.datep <= '".$db->idate($date_end)."'"; |
|
935 | - $sql.= " AND (d.product_type = -1"; |
|
936 | - $sql.= " OR e.date_debut is NOT null OR e.date_fin IS NOT NULL)"; // enhance detection of service |
|
937 | - if (empty($conf->global->MAIN_INCLUDE_ZERO_VAT_IN_REPORTS)) $sql.= " AND (d.".$f_rate." <> 0 OR d.total_tva <> 0)"; |
|
938 | - $sql.= " ORDER BY e.rowid"; |
|
939 | - |
|
940 | - if (! $sql) |
|
933 | + if ($q) $sql .= " AND (date_format(p.datep,'%m') > ".(($q - 1) * 3)." AND date_format(p.datep,'%m') <= ".($q * 3).")"; |
|
934 | + if ($date_start && $date_end) $sql .= " AND p.datep >= '".$db->idate($date_start)."' AND p.datep <= '".$db->idate($date_end)."'"; |
|
935 | + $sql .= " AND (d.product_type = -1"; |
|
936 | + $sql .= " OR e.date_debut is NOT null OR e.date_fin IS NOT NULL)"; // enhance detection of service |
|
937 | + if (empty($conf->global->MAIN_INCLUDE_ZERO_VAT_IN_REPORTS)) $sql .= " AND (d.".$f_rate." <> 0 OR d.total_tva <> 0)"; |
|
938 | + $sql .= " ORDER BY e.rowid"; |
|
939 | + |
|
940 | + if (!$sql) |
|
941 | 941 | { |
942 | - dol_syslog("Tax.lib.php::tax_by_rate no accountancy module enabled".$sql,LOG_ERR); |
|
943 | - return -1; // -1 = Not accountancy module enabled |
|
942 | + dol_syslog("Tax.lib.php::tax_by_rate no accountancy module enabled".$sql, LOG_ERR); |
|
943 | + return -1; // -1 = Not accountancy module enabled |
|
944 | 944 | } |
945 | 945 | if ($sql == 'TODO') return -2; // -2 = Feature not yet available |
946 | 946 | if ($sql != 'TODO') |
@@ -950,20 +950,20 @@ discard block |
||
950 | 950 | if ($resql) |
951 | 951 | { |
952 | 952 | $rate = -1; |
953 | - $oldrowid=''; |
|
954 | - while($assoc = $db->fetch_array($resql)) |
|
953 | + $oldrowid = ''; |
|
954 | + while ($assoc = $db->fetch_array($resql)) |
|
955 | 955 | { |
956 | 956 | // Code to avoid warnings when array entry not defined |
957 | - if (! isset($list[$assoc['rate']]['totalht'])) $list[$assoc['rate']]['totalht']=0; |
|
958 | - if (! isset($list[$assoc['rate']]['vat'])) $list[$assoc['rate']]['vat']=0; |
|
959 | - if (! isset($list[$assoc['rate']]['localtax1'])) $list[$assoc['rate']]['localtax1']=0; |
|
960 | - if (! isset($list[$assoc['rate']]['localtax2'])) $list[$assoc['rate']]['localtax2']=0; |
|
957 | + if (!isset($list[$assoc['rate']]['totalht'])) $list[$assoc['rate']]['totalht'] = 0; |
|
958 | + if (!isset($list[$assoc['rate']]['vat'])) $list[$assoc['rate']]['vat'] = 0; |
|
959 | + if (!isset($list[$assoc['rate']]['localtax1'])) $list[$assoc['rate']]['localtax1'] = 0; |
|
960 | + if (!isset($list[$assoc['rate']]['localtax2'])) $list[$assoc['rate']]['localtax2'] = 0; |
|
961 | 961 | |
962 | 962 | if ($assoc['rowid'] != $oldrowid) // Si rupture sur d.rowid |
963 | 963 | { |
964 | - $oldrowid=$assoc['rowid']; |
|
964 | + $oldrowid = $assoc['rowid']; |
|
965 | 965 | $list[$assoc['rate']]['totalht'] += $assoc['total_ht']; |
966 | - $list[$assoc['rate']]['vat'] += $assoc['total_vat']; |
|
966 | + $list[$assoc['rate']]['vat'] += $assoc['total_vat']; |
|
967 | 967 | $list[$assoc['rate']]['localtax1'] += $assoc['total_localtax1']; |
968 | 968 | $list[$assoc['rate']]['localtax2'] += $assoc['total_localtax2']; |
969 | 969 | } |