@@ -23,13 +23,13 @@ discard block |
||
23 | 23 | |
24 | 24 | // Copyright (C) 2018 Alxarafe/Alixar <[email protected]> |
25 | 25 | defined('BASE_PATH') or die('Single entry point through the index.php of the main folder'); |
26 | -require DOL_BASE_PATH . '/main.inc.php'; |
|
27 | -require_once DOL_DOCUMENT_ROOT . '/core/lib/donation.lib.php'; |
|
28 | -require_once DOL_DOCUMENT_ROOT . '/core/lib/functions2.lib.php'; |
|
29 | -require_once DOL_DOCUMENT_ROOT . '/don/class/don.class.php'; |
|
26 | +require DOL_BASE_PATH.'/main.inc.php'; |
|
27 | +require_once DOL_DOCUMENT_ROOT.'/core/lib/donation.lib.php'; |
|
28 | +require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; |
|
29 | +require_once DOL_DOCUMENT_ROOT.'/don/class/don.class.php'; |
|
30 | 30 | if (!empty($conf->projet->enabled)) { |
31 | - require_once DOL_DOCUMENT_ROOT . '/core/class/html.formprojet.class.php'; |
|
32 | - require_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php'; |
|
31 | + require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; |
|
32 | + require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; |
|
33 | 33 | } |
34 | 34 | |
35 | 35 | $langs->load("donations"); |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | /* |
57 | 57 | * View |
58 | 58 | */ |
59 | -$title = $langs->trans('Donation') . " - " . $langs->trans('Info'); |
|
59 | +$title = $langs->trans('Donation')." - ".$langs->trans('Info'); |
|
60 | 60 | $helpurl = ""; |
61 | 61 | llxHeader('', $title, $helpurl); |
62 | 62 | |
@@ -71,31 +71,31 @@ discard block |
||
71 | 71 | |
72 | 72 | dol_fiche_head($head, 'info', $langs->trans("Donation"), -1, 'generic'); |
73 | 73 | |
74 | -$linkback = '<a href="' . BASE_URI . '?controller=don&method=list' . (!empty($socid) ? '&socid=' . $socid : '') . '">' . $langs->trans("BackToList") . '</a>'; |
|
74 | +$linkback = '<a href="'.BASE_URI.'?controller=don&method=list'.(!empty($socid) ? '&socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>'; |
|
75 | 75 | |
76 | 76 | $morehtmlref = '<div class="refidno">'; |
77 | 77 | // Project |
78 | 78 | if (!empty($conf->projet->enabled)) { |
79 | 79 | $langs->load("projects"); |
80 | - $morehtmlref .= $langs->trans('Project') . ' '; |
|
80 | + $morehtmlref .= $langs->trans('Project').' '; |
|
81 | 81 | if ($user->rights->don->creer) { |
82 | 82 | if ($action != 'classify') |
83 | 83 | // $morehtmlref.='<a href="' . $_SERVER['PHP_SELF'] . '?action=classify&id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : '; |
84 | 84 | if ($action == 'classify') { |
85 | - $morehtmlref .= '<form method="post" action="' . $_SERVER['PHP_SELF'] . '&id=' . $object->id . '">'; |
|
85 | + $morehtmlref .= '<form method="post" action="'.$_SERVER['PHP_SELF'].'&id='.$object->id.'">'; |
|
86 | 86 | $morehtmlref .= '<input type="hidden" name="action" value="classin">'; |
87 | - $morehtmlref .= '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">'; |
|
87 | + $morehtmlref .= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
88 | 88 | $morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); |
89 | - $morehtmlref .= '<input type="submit" class="button valignmiddle" value="' . $langs->trans("Modify") . '">'; |
|
89 | + $morehtmlref .= '<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">'; |
|
90 | 90 | $morehtmlref .= '</form>'; |
91 | 91 | } else { |
92 | - $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'] . '&id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); |
|
92 | + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'&id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); |
|
93 | 93 | } |
94 | 94 | } else { |
95 | 95 | if (!empty($object->fk_project)) { |
96 | 96 | $proj = new Project($db); |
97 | 97 | $proj->fetch($object->fk_project); |
98 | - $morehtmlref .= '<a href="' . BASE_URI . 'controller=projet&method=card&id=' . $object->fk_project . '" title="' . $langs->trans('ShowProject') . '">'; |
|
98 | + $morehtmlref .= '<a href="'.BASE_URI.'controller=projet&method=card&id='.$object->fk_project.'" title="'.$langs->trans('ShowProject').'">'; |
|
99 | 99 | $morehtmlref .= $proj->ref; |
100 | 100 | $morehtmlref .= '</a>'; |
101 | 101 | } else { |
@@ -40,7 +40,9 @@ discard block |
||
40 | 40 | $projectid = (GETPOST('projectid') ? GETPOST('projectid', 'int') : 0); |
41 | 41 | |
42 | 42 | // Security check |
43 | -if ($user->societe_id) $socid = $user->societe_id; |
|
43 | +if ($user->societe_id) { |
|
44 | + $socid = $user->societe_id; |
|
45 | +} |
|
44 | 46 | $result = restrictedArea($user, 'don', $id, ''); |
45 | 47 | |
46 | 48 | $object = new Don($db); |
@@ -79,10 +81,11 @@ discard block |
||
79 | 81 | $langs->load("projects"); |
80 | 82 | $morehtmlref .= $langs->trans('Project') . ' '; |
81 | 83 | if ($user->rights->don->creer) { |
82 | - if ($action != 'classify') |
|
83 | - // $morehtmlref.='<a href="' . $_SERVER['PHP_SELF'] . '?action=classify&id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : '; |
|
84 | + if ($action != 'classify') { |
|
85 | + // $morehtmlref.='<a href="' . $_SERVER['PHP_SELF'] . '?action=classify&id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : '; |
|
84 | 86 | if ($action == 'classify') { |
85 | 87 | $morehtmlref .= '<form method="post" action="' . $_SERVER['PHP_SELF'] . '&id=' . $object->id . '">'; |
88 | + } |
|
86 | 89 | $morehtmlref .= '<input type="hidden" name="action" value="classin">'; |
87 | 90 | $morehtmlref .= '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">'; |
88 | 91 | $morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); |
@@ -85,8 +85,8 @@ discard block |
||
85 | 85 | |
86 | 86 | if ($action == 'classin' && $user->rights->don->creer) |
87 | 87 | { |
88 | - $object->fetch($id); |
|
89 | - $object->setProject($projectid); |
|
88 | + $object->fetch($id); |
|
89 | + $object->setProject($projectid); |
|
90 | 90 | } |
91 | 91 | |
92 | 92 | /* |
@@ -103,75 +103,75 @@ discard block |
||
103 | 103 | |
104 | 104 | if ($object->id) |
105 | 105 | { |
106 | - $object->fetch_thirdparty(); |
|
106 | + $object->fetch_thirdparty(); |
|
107 | 107 | |
108 | - $head=donation_prepare_head($object); |
|
108 | + $head=donation_prepare_head($object); |
|
109 | 109 | |
110 | - dol_fiche_head($head, 'documents', $langs->trans("Donation"), -1, 'generic'); |
|
110 | + dol_fiche_head($head, 'documents', $langs->trans("Donation"), -1, 'generic'); |
|
111 | 111 | |
112 | 112 | |
113 | - // Build file list |
|
114 | - $filearray=dol_dir_list($upload_dir,"files",0,'','(\.meta|_preview.*\.png)$',$sortfield,(strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC),1); |
|
115 | - $totalsize=0; |
|
116 | - foreach($filearray as $key => $file) |
|
117 | - { |
|
118 | - $totalsize+=$file['size']; |
|
119 | - } |
|
113 | + // Build file list |
|
114 | + $filearray=dol_dir_list($upload_dir,"files",0,'','(\.meta|_preview.*\.png)$',$sortfield,(strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC),1); |
|
115 | + $totalsize=0; |
|
116 | + foreach($filearray as $key => $file) |
|
117 | + { |
|
118 | + $totalsize+=$file['size']; |
|
119 | + } |
|
120 | 120 | |
121 | 121 | // $linkback = '<a href="'.DOL_URL_ROOT.'/don/list.php'.(! empty($socid)?'?socid='.$socid:'').'">'.$langs->trans("BackToList").'</a>'; |
122 | 122 | $linkback = '<a href="' . BASE_URI . '?controller=don&method=list' . (!empty($socid) ? '&socid=' . $socid : '') . '">' . $langs->trans("BackToList") . '</a>'; |
123 | 123 | |
124 | - $morehtmlref='<div class="refidno">'; |
|
125 | - // Project |
|
126 | - if (! empty($conf->projet->enabled)) |
|
127 | - { |
|
128 | - $langs->load("projects"); |
|
129 | - $morehtmlref.=$langs->trans('Project') . ' '; |
|
130 | - if ($user->rights->don->creer) |
|
131 | - { |
|
132 | - if ($action != 'classify') |
|
133 | - // $morehtmlref.='<a href="' . $_SERVER['PHP_SELF'] . '?action=classify&id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : '; |
|
134 | - if ($action == 'classify') { |
|
124 | + $morehtmlref='<div class="refidno">'; |
|
125 | + // Project |
|
126 | + if (! empty($conf->projet->enabled)) |
|
127 | + { |
|
128 | + $langs->load("projects"); |
|
129 | + $morehtmlref.=$langs->trans('Project') . ' '; |
|
130 | + if ($user->rights->don->creer) |
|
131 | + { |
|
132 | + if ($action != 'classify') |
|
133 | + // $morehtmlref.='<a href="' . $_SERVER['PHP_SELF'] . '?action=classify&id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : '; |
|
134 | + if ($action == 'classify') { |
|
135 | 135 | $morehtmlref .= '<form method="post" action="' . $_SERVER['PHP_SELF'] . '&id=' . $object->id . '">'; |
136 | - $morehtmlref.='<input type="hidden" name="action" value="classin">'; |
|
137 | - $morehtmlref.='<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
138 | - $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); |
|
139 | - $morehtmlref.='<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">'; |
|
140 | - $morehtmlref.='</form>'; |
|
141 | - } else { |
|
136 | + $morehtmlref.='<input type="hidden" name="action" value="classin">'; |
|
137 | + $morehtmlref.='<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
138 | + $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); |
|
139 | + $morehtmlref.='<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">'; |
|
140 | + $morehtmlref.='</form>'; |
|
141 | + } else { |
|
142 | 142 | $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'] . '&id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); |
143 | - } |
|
144 | - } else { |
|
145 | - if (! empty($object->fk_project)) { |
|
146 | - $proj = new Project($db); |
|
147 | - $proj->fetch($object->fk_project); |
|
143 | + } |
|
144 | + } else { |
|
145 | + if (! empty($object->fk_project)) { |
|
146 | + $proj = new Project($db); |
|
147 | + $proj->fetch($object->fk_project); |
|
148 | 148 | $morehtmlref .= '<a href="' . BASE_URI . '?controller=projet&method=card&id=' . $object->fk_project . '" title="' . $langs->trans('ShowProject') . '">'; |
149 | 149 | $morehtmlref .= $proj->ref; |
150 | - $morehtmlref.='</a>'; |
|
151 | - } else { |
|
152 | - $morehtmlref.=''; |
|
153 | - } |
|
154 | - } |
|
155 | - } |
|
156 | - $morehtmlref.='</div>'; |
|
150 | + $morehtmlref.='</a>'; |
|
151 | + } else { |
|
152 | + $morehtmlref.=''; |
|
153 | + } |
|
154 | + } |
|
155 | + } |
|
156 | + $morehtmlref.='</div>'; |
|
157 | 157 | |
158 | 158 | |
159 | - dol_banner_tab($object, 'rowid', $linkback, 1, 'rowid', 'ref', $morehtmlref); |
|
159 | + dol_banner_tab($object, 'rowid', $linkback, 1, 'rowid', 'ref', $morehtmlref); |
|
160 | 160 | |
161 | - print '<div class="fichecenter">'; |
|
162 | - print '<div class="underbanner clearboth"></div>'; |
|
161 | + print '<div class="fichecenter">'; |
|
162 | + print '<div class="underbanner clearboth"></div>'; |
|
163 | 163 | |
164 | 164 | print '<table class="border" width="100%">'; |
165 | 165 | |
166 | - // Ref |
|
167 | - /* |
|
166 | + // Ref |
|
167 | + /* |
|
168 | 168 | print '<tr><td class="titlefield">'.$langs->trans("Ref").'</td><td>'; |
169 | 169 | print $form->showrefnav($object, 'id', $linkback, 1, 'rowid', 'ref', ''); |
170 | 170 | print '</td></tr>'; |
171 | 171 | */ |
172 | 172 | |
173 | - // Societe |
|
174 | - //print "<tr><td>".$langs->trans("Company")."</td><td>".$object->client->getNomUrl(1)."</td></tr>"; |
|
173 | + // Societe |
|
174 | + //print "<tr><td>".$langs->trans("Company")."</td><td>".$object->client->getNomUrl(1)."</td></tr>"; |
|
175 | 175 | |
176 | 176 | print '<tr><td class="titlefield">'.$langs->trans("NbOfAttachedFiles").'</td><td colspan="3">'.count($filearray).'</td></tr>'; |
177 | 177 | print '<tr><td>'.$langs->trans("TotalSizeOfAttachedFiles").'</td><td colspan="3">'.dol_print_size($totalsize,1,1).'</td></tr>'; |
@@ -191,7 +191,7 @@ discard block |
||
191 | 191 | } |
192 | 192 | else |
193 | 193 | { |
194 | - print $langs->trans("ErrorUnknown"); |
|
194 | + print $langs->trans("ErrorUnknown"); |
|
195 | 195 | } |
196 | 196 | |
197 | 197 | llxFooter(); |
@@ -32,56 +32,56 @@ discard block |
||
32 | 32 | |
33 | 33 | // Copyright (C) 2018 Alxarafe/Alixar <[email protected]> |
34 | 34 | defined('BASE_PATH') or die('Single entry point through the index.php of the main folder'); |
35 | -require DOL_BASE_PATH . '/main.inc.php'; |
|
35 | +require DOL_BASE_PATH.'/main.inc.php'; |
|
36 | 36 | |
37 | 37 | require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; |
38 | 38 | require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; |
39 | 39 | require_once DOL_DOCUMENT_ROOT.'/core/lib/donation.lib.php'; |
40 | 40 | require_once DOL_DOCUMENT_ROOT.'/don/class/don.class.php'; |
41 | -if (! empty($conf->projet->enabled)) |
|
41 | +if (!empty($conf->projet->enabled)) |
|
42 | 42 | { |
43 | 43 | require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; |
44 | 44 | require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; |
45 | 45 | } |
46 | 46 | |
47 | 47 | // Load translation files required by the page |
48 | -$langs->loadLangs(array("companies","other","donations")); |
|
48 | +$langs->loadLangs(array("companies", "other", "donations")); |
|
49 | 49 | |
50 | -$id = GETPOST('id','int'); |
|
50 | +$id = GETPOST('id', 'int'); |
|
51 | 51 | $ref = GETPOST('ref', 'alpha'); |
52 | -$action = GETPOST('action','alpha'); |
|
53 | -$confirm = GETPOST('confirm','alpha'); |
|
52 | +$action = GETPOST('action', 'alpha'); |
|
53 | +$confirm = GETPOST('confirm', 'alpha'); |
|
54 | 54 | $projectid = (GETPOST('projectid') ? GETPOST('projectid', 'int') : 0); |
55 | 55 | |
56 | 56 | // Security check |
57 | -if ($user->societe_id) $socid=$user->societe_id; |
|
57 | +if ($user->societe_id) $socid = $user->societe_id; |
|
58 | 58 | $result = restrictedArea($user, 'don', $id, ''); |
59 | 59 | |
60 | 60 | |
61 | 61 | // Get parameters |
62 | -$sortfield = GETPOST('sortfield','alpha'); |
|
63 | -$sortorder = GETPOST('sortorder','alpha'); |
|
64 | -$page = GETPOST('page','int'); |
|
62 | +$sortfield = GETPOST('sortfield', 'alpha'); |
|
63 | +$sortorder = GETPOST('sortorder', 'alpha'); |
|
64 | +$page = GETPOST('page', 'int'); |
|
65 | 65 | if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 |
66 | 66 | $offset = $conf->liste_limit * $page; |
67 | 67 | $pageprev = $page - 1; |
68 | 68 | $pagenext = $page + 1; |
69 | -if (! $sortorder) $sortorder="ASC"; |
|
70 | -if (! $sortfield) $sortfield="name"; |
|
69 | +if (!$sortorder) $sortorder = "ASC"; |
|
70 | +if (!$sortfield) $sortfield = "name"; |
|
71 | 71 | |
72 | 72 | |
73 | 73 | $object = new Don($db); |
74 | 74 | $object->fetch($id, $ref); |
75 | 75 | |
76 | -$upload_dir = $conf->don->dir_output . '/' . get_exdir($filename,0,0,0,$object,'donation'). '/'. dol_sanitizeFileName($object->ref); |
|
77 | -$modulepart='don'; |
|
76 | +$upload_dir = $conf->don->dir_output.'/'.get_exdir($filename, 0, 0, 0, $object, 'donation').'/'.dol_sanitizeFileName($object->ref); |
|
77 | +$modulepart = 'don'; |
|
78 | 78 | |
79 | 79 | |
80 | 80 | /* |
81 | 81 | * Actions |
82 | 82 | */ |
83 | 83 | |
84 | -include_once DOL_DOCUMENT_ROOT . '/core/actions_linkedfiles.inc.php'; |
|
84 | +include_once DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php'; |
|
85 | 85 | |
86 | 86 | if ($action == 'classin' && $user->rights->don->creer) |
87 | 87 | { |
@@ -94,9 +94,9 @@ discard block |
||
94 | 94 | */ |
95 | 95 | |
96 | 96 | $form = new Form($db); |
97 | -if (! empty($conf->projet->enabled)) { $formproject = new FormProjets($db); } |
|
97 | +if (!empty($conf->projet->enabled)) { $formproject = new FormProjets($db); } |
|
98 | 98 | |
99 | -$title = $langs->trans('Donation') . " - " . $langs->trans('Documents'); |
|
99 | +$title = $langs->trans('Donation')." - ".$langs->trans('Documents'); |
|
100 | 100 | $helpurl = ""; |
101 | 101 | llxHeader('', $title, $helpurl); |
102 | 102 | |
@@ -105,55 +105,55 @@ discard block |
||
105 | 105 | { |
106 | 106 | $object->fetch_thirdparty(); |
107 | 107 | |
108 | - $head=donation_prepare_head($object); |
|
108 | + $head = donation_prepare_head($object); |
|
109 | 109 | |
110 | - dol_fiche_head($head, 'documents', $langs->trans("Donation"), -1, 'generic'); |
|
110 | + dol_fiche_head($head, 'documents', $langs->trans("Donation"), -1, 'generic'); |
|
111 | 111 | |
112 | 112 | |
113 | 113 | // Build file list |
114 | - $filearray=dol_dir_list($upload_dir,"files",0,'','(\.meta|_preview.*\.png)$',$sortfield,(strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC),1); |
|
115 | - $totalsize=0; |
|
116 | - foreach($filearray as $key => $file) |
|
114 | + $filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) == 'desc' ?SORT_DESC:SORT_ASC), 1); |
|
115 | + $totalsize = 0; |
|
116 | + foreach ($filearray as $key => $file) |
|
117 | 117 | { |
118 | - $totalsize+=$file['size']; |
|
118 | + $totalsize += $file['size']; |
|
119 | 119 | } |
120 | 120 | |
121 | 121 | // $linkback = '<a href="'.DOL_URL_ROOT.'/don/list.php'.(! empty($socid)?'?socid='.$socid:'').'">'.$langs->trans("BackToList").'</a>'; |
122 | - $linkback = '<a href="' . BASE_URI . '?controller=don&method=list' . (!empty($socid) ? '&socid=' . $socid : '') . '">' . $langs->trans("BackToList") . '</a>'; |
|
122 | + $linkback = '<a href="'.BASE_URI.'?controller=don&method=list'.(!empty($socid) ? '&socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>'; |
|
123 | 123 | |
124 | - $morehtmlref='<div class="refidno">'; |
|
124 | + $morehtmlref = '<div class="refidno">'; |
|
125 | 125 | // Project |
126 | - if (! empty($conf->projet->enabled)) |
|
126 | + if (!empty($conf->projet->enabled)) |
|
127 | 127 | { |
128 | 128 | $langs->load("projects"); |
129 | - $morehtmlref.=$langs->trans('Project') . ' '; |
|
129 | + $morehtmlref .= $langs->trans('Project').' '; |
|
130 | 130 | if ($user->rights->don->creer) |
131 | 131 | { |
132 | 132 | if ($action != 'classify') |
133 | 133 | // $morehtmlref.='<a href="' . $_SERVER['PHP_SELF'] . '?action=classify&id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : '; |
134 | 134 | if ($action == 'classify') { |
135 | - $morehtmlref .= '<form method="post" action="' . $_SERVER['PHP_SELF'] . '&id=' . $object->id . '">'; |
|
136 | - $morehtmlref.='<input type="hidden" name="action" value="classin">'; |
|
137 | - $morehtmlref.='<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
138 | - $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); |
|
139 | - $morehtmlref.='<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">'; |
|
140 | - $morehtmlref.='</form>'; |
|
135 | + $morehtmlref .= '<form method="post" action="'.$_SERVER['PHP_SELF'].'&id='.$object->id.'">'; |
|
136 | + $morehtmlref .= '<input type="hidden" name="action" value="classin">'; |
|
137 | + $morehtmlref .= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
138 | + $morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); |
|
139 | + $morehtmlref .= '<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">'; |
|
140 | + $morehtmlref .= '</form>'; |
|
141 | 141 | } else { |
142 | - $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'] . '&id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); |
|
142 | + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'&id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); |
|
143 | 143 | } |
144 | 144 | } else { |
145 | - if (! empty($object->fk_project)) { |
|
145 | + if (!empty($object->fk_project)) { |
|
146 | 146 | $proj = new Project($db); |
147 | 147 | $proj->fetch($object->fk_project); |
148 | - $morehtmlref .= '<a href="' . BASE_URI . '?controller=projet&method=card&id=' . $object->fk_project . '" title="' . $langs->trans('ShowProject') . '">'; |
|
148 | + $morehtmlref .= '<a href="'.BASE_URI.'?controller=projet&method=card&id='.$object->fk_project.'" title="'.$langs->trans('ShowProject').'">'; |
|
149 | 149 | $morehtmlref .= $proj->ref; |
150 | - $morehtmlref.='</a>'; |
|
150 | + $morehtmlref .= '</a>'; |
|
151 | 151 | } else { |
152 | - $morehtmlref.=''; |
|
152 | + $morehtmlref .= ''; |
|
153 | 153 | } |
154 | 154 | } |
155 | 155 | } |
156 | - $morehtmlref.='</div>'; |
|
156 | + $morehtmlref .= '</div>'; |
|
157 | 157 | |
158 | 158 | |
159 | 159 | dol_banner_tab($object, 'rowid', $linkback, 1, 'rowid', 'ref', $morehtmlref); |
@@ -174,7 +174,7 @@ discard block |
||
174 | 174 | //print "<tr><td>".$langs->trans("Company")."</td><td>".$object->client->getNomUrl(1)."</td></tr>"; |
175 | 175 | |
176 | 176 | print '<tr><td class="titlefield">'.$langs->trans("NbOfAttachedFiles").'</td><td colspan="3">'.count($filearray).'</td></tr>'; |
177 | - print '<tr><td>'.$langs->trans("TotalSizeOfAttachedFiles").'</td><td colspan="3">'.dol_print_size($totalsize,1,1).'</td></tr>'; |
|
177 | + print '<tr><td>'.$langs->trans("TotalSizeOfAttachedFiles").'</td><td colspan="3">'.dol_print_size($totalsize, 1, 1).'</td></tr>'; |
|
178 | 178 | print '</table>'; |
179 | 179 | |
180 | 180 | print '</div>'; |
@@ -186,8 +186,8 @@ discard block |
||
186 | 186 | $modulepart = 'don'; |
187 | 187 | $permission = $user->rights->don->lire; |
188 | 188 | $permtoedit = $user->rights->don->creer; |
189 | - $param = '&id=' . $object->id; |
|
190 | - include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_post_headers.tpl.php'; |
|
189 | + $param = '&id='.$object->id; |
|
190 | + include_once DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_post_headers.tpl.php'; |
|
191 | 191 | } |
192 | 192 | else |
193 | 193 | { |
@@ -54,7 +54,9 @@ discard block |
||
54 | 54 | $projectid = (GETPOST('projectid') ? GETPOST('projectid', 'int') : 0); |
55 | 55 | |
56 | 56 | // Security check |
57 | -if ($user->societe_id) $socid=$user->societe_id; |
|
57 | +if ($user->societe_id) { |
|
58 | + $socid=$user->societe_id; |
|
59 | +} |
|
58 | 60 | $result = restrictedArea($user, 'don', $id, ''); |
59 | 61 | |
60 | 62 | |
@@ -66,8 +68,12 @@ discard block |
||
66 | 68 | $offset = $conf->liste_limit * $page; |
67 | 69 | $pageprev = $page - 1; |
68 | 70 | $pagenext = $page + 1; |
69 | -if (! $sortorder) $sortorder="ASC"; |
|
70 | -if (! $sortfield) $sortfield="name"; |
|
71 | +if (! $sortorder) { |
|
72 | + $sortorder="ASC"; |
|
73 | +} |
|
74 | +if (! $sortfield) { |
|
75 | + $sortfield="name"; |
|
76 | +} |
|
71 | 77 | |
72 | 78 | |
73 | 79 | $object = new Don($db); |
@@ -129,10 +135,11 @@ discard block |
||
129 | 135 | $morehtmlref.=$langs->trans('Project') . ' '; |
130 | 136 | if ($user->rights->don->creer) |
131 | 137 | { |
132 | - if ($action != 'classify') |
|
133 | - // $morehtmlref.='<a href="' . $_SERVER['PHP_SELF'] . '?action=classify&id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : '; |
|
138 | + if ($action != 'classify') { |
|
139 | + // $morehtmlref.='<a href="' . $_SERVER['PHP_SELF'] . '?action=classify&id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : '; |
|
134 | 140 | if ($action == 'classify') { |
135 | 141 | $morehtmlref .= '<form method="post" action="' . $_SERVER['PHP_SELF'] . '&id=' . $object->id . '">'; |
142 | + } |
|
136 | 143 | $morehtmlref.='<input type="hidden" name="action" value="classin">'; |
137 | 144 | $morehtmlref.='<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
138 | 145 | $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); |
@@ -188,8 +195,7 @@ discard block |
||
188 | 195 | $permtoedit = $user->rights->don->creer; |
189 | 196 | $param = '&id=' . $object->id; |
190 | 197 | include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_post_headers.tpl.php'; |
191 | -} |
|
192 | -else |
|
198 | +} else |
|
193 | 199 | { |
194 | 200 | print $langs->trans("ErrorUnknown"); |
195 | 201 | } |
@@ -50,7 +50,7 @@ |
||
50 | 50 | $h = 0; |
51 | 51 | $head = arolimar123ray(); |
52 | 52 | |
53 | - $head[$h][0] = BASE_URI . '?controller=admin&method=dav&id=' . $object->id; |
|
53 | + $head[$h][0] = BASE_URI.'?controller=admin&method=dav&id='.$object->id; |
|
54 | 54 | $head[$h][1] = $langs->trans("WebDAV"); |
55 | 55 | $head[$h][2] = 'webdav'; |
56 | 56 | $h++; |
@@ -23,19 +23,21 @@ |
||
23 | 23 | |
24 | 24 | // define CDAV_CONTACT_TAG if not |
25 | 25 | if (!defined('CDAV_CONTACT_TAG')) { |
26 | - if (isset($conf->global->CDAV_CONTACT_TAG)) |
|
27 | - define('CDAV_CONTACT_TAG', $conf->global->CDAV_CONTACT_TAG); |
|
28 | - else |
|
29 | - define('CDAV_CONTACT_TAG', ''); |
|
30 | -} |
|
26 | + if (isset($conf->global->CDAV_CONTACT_TAG)) { |
|
27 | + define('CDAV_CONTACT_TAG', $conf->global->CDAV_CONTACT_TAG); |
|
28 | + } else { |
|
29 | + define('CDAV_CONTACT_TAG', ''); |
|
30 | + } |
|
31 | + } |
|
31 | 32 | |
32 | 33 | // define CDAV_URI_KEY if not |
33 | 34 | if (!defined('CDAV_URI_KEY')) { |
34 | - if (isset($conf->global->CDAV_URI_KEY)) |
|
35 | - define('CDAV_URI_KEY', $conf->global->CDAV_URI_KEY); |
|
36 | - else |
|
37 | - define('CDAV_URI_KEY', substr(md5($_SERVER['HTTP_HOST']), 0, 8)); |
|
38 | -} |
|
35 | + if (isset($conf->global->CDAV_URI_KEY)) { |
|
36 | + define('CDAV_URI_KEY', $conf->global->CDAV_URI_KEY); |
|
37 | + } else { |
|
38 | + define('CDAV_URI_KEY', substr(md5($_SERVER['HTTP_HOST']), 0, 8)); |
|
39 | + } |
|
40 | + } |
|
39 | 41 | |
40 | 42 | |
41 | 43 | /** |
@@ -37,8 +37,8 @@ discard block |
||
37 | 37 | require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; |
38 | 38 | require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; |
39 | 39 | if (! empty($conf->projet->enabled)) { |
40 | - require_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php'; |
|
41 | - //require_once DOL_DOCUMENT_ROOT . '/core/class/html.formprojet.class.php'; |
|
40 | + require_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php'; |
|
41 | + //require_once DOL_DOCUMENT_ROOT . '/core/class/html.formprojet.class.php'; |
|
42 | 42 | } |
43 | 43 | require_once DOL_DOCUMENT_ROOT . '/core/class/html.formprojet.class.php'; |
44 | 44 | require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php'; |
@@ -98,11 +98,11 @@ discard block |
||
98 | 98 | $object = new FactureRec($db); |
99 | 99 | if (($id > 0 || $ref) && $action != 'create' && $action != 'add') |
100 | 100 | { |
101 | - $ret = $object->fetch($id, $ref); |
|
102 | - if (!$ret) |
|
103 | - { |
|
104 | - setEventMessages($langs->trans("ErrorRecordNotFound"), null, 'errors'); |
|
105 | - } |
|
101 | + $ret = $object->fetch($id, $ref); |
|
102 | + if (!$ret) |
|
103 | + { |
|
104 | + setEventMessages($langs->trans("ErrorRecordNotFound"), null, 'errors'); |
|
105 | + } |
|
106 | 106 | } |
107 | 107 | |
108 | 108 | // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context |
@@ -118,30 +118,30 @@ discard block |
||
118 | 118 | $permissiontoedit = $user->rights->facture->creer; // Used by the include of actions_lineupdonw.inc.php |
119 | 119 | |
120 | 120 | $arrayfields=array( |
121 | - 'f.titre'=>array('label'=>$langs->trans("Ref"), 'checked'=>1), |
|
122 | - 's.nom'=>array('label'=>$langs->trans("ThirdParty"), 'checked'=>1), |
|
123 | - 'f.total'=>array('label'=>$langs->trans("AmountHT"), 'checked'=>1), |
|
124 | - 'f.tva'=>array('label'=>$langs->trans("AmountVAT"), 'checked'=>1), |
|
125 | - 'f.total_ttc'=>array('label'=>$langs->trans("AmountTTC"), 'checked'=>1), |
|
126 | - 'f.fk_mode_reglement'=>array('label'=>$langs->trans("PaymentMode"), 'checked'=>0), |
|
127 | - 'f.fk_cond_reglement'=>array('label'=>$langs->trans("PaymentTerm"), 'checked'=>0), |
|
128 | - 'recurring'=>array('label'=>$langs->trans("RecurringInvoiceTemplate"), 'checked'=>1), |
|
129 | - 'f.frequency'=>array('label'=>$langs->trans("Frequency"), 'checked'=>1), |
|
130 | - 'f.unit_frequency'=>array('label'=>$langs->trans("FrequencyUnit"), 'checked'=>1), |
|
131 | - 'f.nb_gen_done'=>array('label'=>$langs->trans("NbOfGenerationDoneShort"), 'checked'=>1), |
|
132 | - 'f.date_last_gen'=>array('label'=>$langs->trans("DateLastGenerationShort"), 'checked'=>1), |
|
133 | - 'f.date_when'=>array('label'=>$langs->trans("NextDateToExecutionShort"), 'checked'=>1), |
|
134 | - 'status'=>array('label'=>$langs->trans("Status"), 'checked'=>1, 'position'=>100), |
|
135 | - 'f.datec'=>array('label'=>$langs->trans("DateCreation"), 'checked'=>0, 'position'=>500), |
|
136 | - 'f.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>500), |
|
121 | + 'f.titre'=>array('label'=>$langs->trans("Ref"), 'checked'=>1), |
|
122 | + 's.nom'=>array('label'=>$langs->trans("ThirdParty"), 'checked'=>1), |
|
123 | + 'f.total'=>array('label'=>$langs->trans("AmountHT"), 'checked'=>1), |
|
124 | + 'f.tva'=>array('label'=>$langs->trans("AmountVAT"), 'checked'=>1), |
|
125 | + 'f.total_ttc'=>array('label'=>$langs->trans("AmountTTC"), 'checked'=>1), |
|
126 | + 'f.fk_mode_reglement'=>array('label'=>$langs->trans("PaymentMode"), 'checked'=>0), |
|
127 | + 'f.fk_cond_reglement'=>array('label'=>$langs->trans("PaymentTerm"), 'checked'=>0), |
|
128 | + 'recurring'=>array('label'=>$langs->trans("RecurringInvoiceTemplate"), 'checked'=>1), |
|
129 | + 'f.frequency'=>array('label'=>$langs->trans("Frequency"), 'checked'=>1), |
|
130 | + 'f.unit_frequency'=>array('label'=>$langs->trans("FrequencyUnit"), 'checked'=>1), |
|
131 | + 'f.nb_gen_done'=>array('label'=>$langs->trans("NbOfGenerationDoneShort"), 'checked'=>1), |
|
132 | + 'f.date_last_gen'=>array('label'=>$langs->trans("DateLastGenerationShort"), 'checked'=>1), |
|
133 | + 'f.date_when'=>array('label'=>$langs->trans("NextDateToExecutionShort"), 'checked'=>1), |
|
134 | + 'status'=>array('label'=>$langs->trans("Status"), 'checked'=>1, 'position'=>100), |
|
135 | + 'f.datec'=>array('label'=>$langs->trans("DateCreation"), 'checked'=>0, 'position'=>500), |
|
136 | + 'f.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>500), |
|
137 | 137 | ); |
138 | 138 | // Extra fields |
139 | 139 | if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) |
140 | 140 | { |
141 | - foreach($extrafields->attribute_label as $key => $val) |
|
142 | - { |
|
143 | - if (! empty($extrafields->attribute_list[$key])) $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>(($extrafields->attribute_list[$key]<0)?0:1), 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>(abs($extrafields->attribute_list[$key])!=3 && $extrafields->attribute_perms[$key])); |
|
144 | - } |
|
141 | + foreach($extrafields->attribute_label as $key => $val) |
|
142 | + { |
|
143 | + if (! empty($extrafields->attribute_list[$key])) $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>(($extrafields->attribute_list[$key]<0)?0:1), 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>(abs($extrafields->attribute_list[$key])!=3 && $extrafields->attribute_perms[$key])); |
|
144 | + } |
|
145 | 145 | } |
146 | 146 | |
147 | 147 | |
@@ -158,36 +158,36 @@ discard block |
||
158 | 158 | |
159 | 159 | if (empty($reshook)) |
160 | 160 | { |
161 | - if (GETPOST('cancel','alpha')) $action=''; |
|
162 | - |
|
163 | - // Selection of new fields |
|
164 | - include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; |
|
165 | - |
|
166 | - // Do we click on purge search criteria ? |
|
167 | - if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha')) // All test are required to be compatible with all browsers |
|
168 | - { |
|
169 | - $search_ref=''; |
|
170 | - $search_societe=''; |
|
171 | - $search_montant_ht=''; |
|
172 | - $search_montant_vat=''; |
|
173 | - $search_montant_ttc=''; |
|
174 | - $search_payment_mode=''; |
|
175 | - $search_payment_term=''; |
|
176 | - $search_day=''; |
|
177 | - $search_year=''; |
|
178 | - $search_month=''; |
|
179 | - $search_day_date_when=''; |
|
180 | - $search_year_date_when=''; |
|
181 | - $search_month_date_when=''; |
|
182 | - $search_recurring=''; |
|
183 | - $search_frequency=''; |
|
184 | - $search_unit_frequency=''; |
|
185 | - $search_status=''; |
|
186 | - $search_array_options=array(); |
|
187 | - } |
|
188 | - |
|
189 | - // Mass actions |
|
190 | - /*$objectclass='MyObject'; |
|
161 | + if (GETPOST('cancel','alpha')) $action=''; |
|
162 | + |
|
163 | + // Selection of new fields |
|
164 | + include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; |
|
165 | + |
|
166 | + // Do we click on purge search criteria ? |
|
167 | + if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha')) // All test are required to be compatible with all browsers |
|
168 | + { |
|
169 | + $search_ref=''; |
|
170 | + $search_societe=''; |
|
171 | + $search_montant_ht=''; |
|
172 | + $search_montant_vat=''; |
|
173 | + $search_montant_ttc=''; |
|
174 | + $search_payment_mode=''; |
|
175 | + $search_payment_term=''; |
|
176 | + $search_day=''; |
|
177 | + $search_year=''; |
|
178 | + $search_month=''; |
|
179 | + $search_day_date_when=''; |
|
180 | + $search_year_date_when=''; |
|
181 | + $search_month_date_when=''; |
|
182 | + $search_recurring=''; |
|
183 | + $search_frequency=''; |
|
184 | + $search_unit_frequency=''; |
|
185 | + $search_status=''; |
|
186 | + $search_array_options=array(); |
|
187 | + } |
|
188 | + |
|
189 | + // Mass actions |
|
190 | + /*$objectclass='MyObject'; |
|
191 | 191 | $objectlabel='MyObject'; |
192 | 192 | $permtoread = $user->rights->mymodule->read; |
193 | 193 | $permtodelete = $user->rights->mymodule->delete; |
@@ -222,12 +222,12 @@ discard block |
||
222 | 222 | $sql.= " f.fk_cond_reglement, f.fk_mode_reglement"; |
223 | 223 | $sql.= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture_rec as f"; |
224 | 224 | if (! $user->rights->societe->client->voir && ! $socid) { |
225 | - $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; |
|
225 | + $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; |
|
226 | 226 | } |
227 | 227 | $sql.= " WHERE f.fk_soc = s.rowid"; |
228 | 228 | $sql.= ' AND f.entity IN ('.getEntity('invoice').')'; |
229 | 229 | if (! $user->rights->societe->client->voir && ! $socid) { |
230 | - $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; |
|
230 | + $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; |
|
231 | 231 | } |
232 | 232 | if ($search_ref) $sql .= natural_search('f.titre', $search_ref); |
233 | 233 | if ($search_societe) $sql .= natural_search('s.nom', $search_societe); |
@@ -242,35 +242,35 @@ discard block |
||
242 | 242 | if ($search_unit_frequency != '') $sql .= ' AND f.frequency > 0'.natural_search('f.unit_frequency', $search_unit_frequency); |
243 | 243 | if ($search_status != '' && $search_status >= -1) |
244 | 244 | { |
245 | - if ($search_status == 0) $sql.= ' AND frequency = 0 AND suspended = 0'; |
|
246 | - if ($search_status == 1) $sql.= ' AND frequency != 0 AND suspended = 0'; |
|
247 | - if ($search_status == -1) $sql.= ' AND suspended = 1'; |
|
245 | + if ($search_status == 0) $sql.= ' AND frequency = 0 AND suspended = 0'; |
|
246 | + if ($search_status == 1) $sql.= ' AND frequency != 0 AND suspended = 0'; |
|
247 | + if ($search_status == -1) $sql.= ' AND suspended = 1'; |
|
248 | 248 | } |
249 | 249 | if ($search_month > 0) |
250 | 250 | { |
251 | - if ($search_year > 0 && empty($search_day)) |
|
252 | - $sql.= " AND f.date_last_gen BETWEEN '".$db->idate(dol_get_first_day($search_year,$search_month,false))."' AND '".$db->idate(dol_get_last_day($search_year,$search_month,false))."'"; |
|
253 | - else if ($search_year > 0 && ! empty($search_day)) |
|
254 | - $sql.= " AND f.date_last_gen BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $search_month, $search_day, $search_year))."' AND '".$db->idate(dol_mktime(23, 59, 59, $search_month, $search_day, $search_year))."'"; |
|
255 | - else |
|
256 | - $sql.= " AND date_format(f.date_last_gen, '%m') = '".$db->escape($search_month)."'"; |
|
251 | + if ($search_year > 0 && empty($search_day)) |
|
252 | + $sql.= " AND f.date_last_gen BETWEEN '".$db->idate(dol_get_first_day($search_year,$search_month,false))."' AND '".$db->idate(dol_get_last_day($search_year,$search_month,false))."'"; |
|
253 | + else if ($search_year > 0 && ! empty($search_day)) |
|
254 | + $sql.= " AND f.date_last_gen BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $search_month, $search_day, $search_year))."' AND '".$db->idate(dol_mktime(23, 59, 59, $search_month, $search_day, $search_year))."'"; |
|
255 | + else |
|
256 | + $sql.= " AND date_format(f.date_last_gen, '%m') = '".$db->escape($search_month)."'"; |
|
257 | 257 | } |
258 | 258 | else if ($search_year > 0) |
259 | 259 | { |
260 | - $sql.= " AND f.date_last_gen BETWEEN '".$db->idate(dol_get_first_day($search_year,1,false))."' AND '".$db->idate(dol_get_last_day($search_year,12,false))."'"; |
|
260 | + $sql.= " AND f.date_last_gen BETWEEN '".$db->idate(dol_get_first_day($search_year,1,false))."' AND '".$db->idate(dol_get_last_day($search_year,12,false))."'"; |
|
261 | 261 | } |
262 | 262 | if ($search_month_date_when > 0) |
263 | 263 | { |
264 | - if ($search_year_date_when > 0 && empty($search_day_date_when)) |
|
265 | - $sql.= " AND f.date_when BETWEEN '".$db->idate(dol_get_first_day($search_year_date_when,$search_month_date_when,false))."' AND '".$db->idate(dol_get_last_day($search_year_date_when,$search_month_date_when,false))."'"; |
|
266 | - else if ($search_year_date_when > 0 && ! empty($search_day_date_when)) |
|
267 | - $sql.= " AND f.date_date_when_reglement BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $search_month_date_when, $search_day_date_when, $search_year_date_when))."' AND '".$db->idate(dol_mktime(23, 59, 59, $search_month_date_when, $search_day_date_when, $search_year_date_when))."'"; |
|
268 | - else |
|
269 | - $sql.= " AND date_format(f.date_when, '%m') = '".$db->escape($search_month_date_when)."'"; |
|
264 | + if ($search_year_date_when > 0 && empty($search_day_date_when)) |
|
265 | + $sql.= " AND f.date_when BETWEEN '".$db->idate(dol_get_first_day($search_year_date_when,$search_month_date_when,false))."' AND '".$db->idate(dol_get_last_day($search_year_date_when,$search_month_date_when,false))."'"; |
|
266 | + else if ($search_year_date_when > 0 && ! empty($search_day_date_when)) |
|
267 | + $sql.= " AND f.date_date_when_reglement BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $search_month_date_when, $search_day_date_when, $search_year_date_when))."' AND '".$db->idate(dol_mktime(23, 59, 59, $search_month_date_when, $search_day_date_when, $search_year_date_when))."'"; |
|
268 | + else |
|
269 | + $sql.= " AND date_format(f.date_when, '%m') = '".$db->escape($search_month_date_when)."'"; |
|
270 | 270 | } |
271 | 271 | else if ($search_year_date_when > 0) |
272 | 272 | { |
273 | - $sql.= " AND f.date_when BETWEEN '".$db->idate(dol_get_first_day($search_year_date_when,1,false))."' AND '".$db->idate(dol_get_last_day($search_year_date_when,12,false))."'"; |
|
273 | + $sql.= " AND f.date_when BETWEEN '".$db->idate(dol_get_first_day($search_year_date_when,1,false))."' AND '".$db->idate(dol_get_last_day($search_year_date_when,12,false))."'"; |
|
274 | 274 | } |
275 | 275 | |
276 | 276 | $sql.= $db->order($sortfield, $sortorder); |
@@ -278,13 +278,13 @@ discard block |
||
278 | 278 | $nbtotalofrecords = ''; |
279 | 279 | if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) |
280 | 280 | { |
281 | - $result = $db->query($sql); |
|
282 | - $nbtotalofrecords = $db->num_rows($result); |
|
283 | - if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 |
|
284 | - { |
|
285 | - $page = 0; |
|
286 | - $offset = 0; |
|
287 | - } |
|
281 | + $result = $db->query($sql); |
|
282 | + $nbtotalofrecords = $db->num_rows($result); |
|
283 | + if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 |
|
284 | + { |
|
285 | + $page = 0; |
|
286 | + $offset = 0; |
|
287 | + } |
|
288 | 288 | } |
289 | 289 | |
290 | 290 | $sql.= $db->plimit($limit+1,$offset); |
@@ -292,423 +292,423 @@ discard block |
||
292 | 292 | $resql = $db->query($sql); |
293 | 293 | if ($resql) |
294 | 294 | { |
295 | - $num = $db->num_rows($resql); |
|
296 | - |
|
297 | - $param=''; |
|
298 | - if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage); |
|
299 | - if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit); |
|
300 | - if ($socid) $param.='&socid='.urlencode($socid); |
|
301 | - if ($search_day) $param.='&search_day='.urlencode($search_day); |
|
302 | - if ($search_month) $param.='&search_month='.urlencode($search_month); |
|
303 | - if ($search_year) $param.='&search_year=' .urlencode($search_year); |
|
304 | - if ($search_day_date_when) $param.='&search_day_date_when='.urlencode($search_day_date_when); |
|
305 | - if ($search_month_date_when) $param.='&search_month_date_when='.urlencode($search_month_date_when); |
|
306 | - if ($search_year_date_when) $param.='&search_year_date_when=' .urlencode($search_year_date_when); |
|
307 | - if ($search_ref) $param.='&search_ref=' .urlencode($search_ref); |
|
308 | - if ($search_societe) $param.='&search_societe=' .urlencode($search_societe); |
|
309 | - if ($search_montant_ht != '') $param.='&search_montant_ht=' .urlencode($search_montant_ht); |
|
310 | - if ($search_montant_vat != '') $param.='&search_montant_vat='.urlencode($search_montant_vat); |
|
311 | - if ($search_montant_ttc != '') $param.='&search_montant_ttc='.urlencode($search_montant_ttc); |
|
312 | - if ($search_payment_mode != '') $param.='&search_payment_mode='.urlencode($search_payment_mode); |
|
313 | - if ($search_payment_type != '') $param.='&search_payment_type='.urlencode($search_payment_type); |
|
314 | - if ($search_recurring != '' && $search_recurrning != '-1') $param.='&search_recurring=' .urlencode($search_recurring); |
|
315 | - if ($search_frequency > 0) $param.='&search_frequency=' .urlencode($search_frequency); |
|
316 | - if ($search_unit_frequency != '') $param.='&search_unit_frequency='.urlencode($search_unit_frequency); |
|
317 | - if ($search_status != '') $param.='&search_status='.urlencode($search_status); |
|
318 | - if ($option) $param.="&option=".urlencode($option); |
|
319 | - if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss); |
|
320 | - // Add $param from extra fields |
|
321 | - include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; |
|
322 | - |
|
323 | - $massactionbutton=$form->selectMassAction('', $massaction == 'presend' ? array() : array('presend'=>$langs->trans("SendByMail"), 'builddoc'=>$langs->trans("PDFMerge"))); |
|
324 | - |
|
325 | - $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; |
|
326 | - $selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields |
|
327 | - //$selectedfields.=$form->showCheckAddButtons('checkforselect', 1); |
|
328 | - |
|
329 | - print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'; |
|
330 | - if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">'; |
|
331 | - print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
332 | - print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">'; |
|
333 | - print '<input type="hidden" name="action" value="list">'; |
|
334 | - print '<input type="hidden" name="sortfield" value="'.$sortfield.'">'; |
|
335 | - print '<input type="hidden" name="sortorder" value="'.$sortorder.'">'; |
|
336 | - print '<input type="hidden" name="page" value="'.$page.'">'; |
|
337 | - print '<input type="hidden" name="contextpage" value="'.$contextpage.'">'; |
|
338 | - print '<input type="hidden" name="viewstatut" value="'.$viewstatut.'">'; |
|
339 | - |
|
340 | - print_barre_liste($langs->trans("RepeatableInvoices"),$page,$_SERVER['PHP_SELF'],$param,$sortfield,$sortorder,'',$num,$nbtotalofrecords,'title_accountancy.png',0,'','', $limit); |
|
341 | - |
|
342 | - print $langs->trans("ToCreateAPredefinedInvoice", $langs->transnoentitiesnoconv("ChangeIntoRepeatableInvoice")).'<br><br>'; |
|
343 | - |
|
344 | - $i = 0; |
|
345 | - |
|
346 | - print '<div class="div-table-responsive">'; |
|
347 | - print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n"; |
|
348 | - |
|
349 | - // Filters lines |
|
350 | - print '<tr class="liste_titre_filter">'; |
|
351 | - // Ref |
|
352 | - if (! empty($arrayfields['f.titre']['checked'])) |
|
353 | - { |
|
354 | - print '<td class="liste_titre" align="left">'; |
|
355 | - print '<input class="flat" size="6" type="text" name="search_ref" value="'.dol_escape_htmltag($search_ref).'">'; |
|
356 | - print '</td>'; |
|
357 | - } |
|
358 | - // Thirpdarty |
|
359 | - if (! empty($arrayfields['s.nom']['checked'])) |
|
360 | - { |
|
361 | - print '<td class="liste_titre" align="left"><input class="flat" type="text" size="8" name="search_societe" value="'.dol_escape_htmltag($search_societe).'"></td>'; |
|
362 | - } |
|
363 | - if (! empty($arrayfields['f.total']['checked'])) |
|
364 | - { |
|
365 | - // Amount net |
|
366 | - print '<td class="liste_titre" align="right">'; |
|
367 | - print '<input class="flat" type="text" size="5" name="search_montant_ht" value="'.dol_escape_htmltag($search_montant_ht).'">'; |
|
368 | - print '</td>'; |
|
369 | - } |
|
370 | - if (! empty($arrayfields['f.tva']['checked'])) |
|
371 | - { |
|
372 | - // Amount Vat |
|
373 | - print '<td class="liste_titre" align="right">'; |
|
374 | - print '<input class="flat" type="text" size="5" name="search_montant_vat" value="'.dol_escape_htmltag($search_montant_vat).'">'; |
|
375 | - print '</td>'; |
|
376 | - } |
|
377 | - if (! empty($arrayfields['f.total_ttc']['checked'])) |
|
378 | - { |
|
379 | - // Amount |
|
380 | - print '<td class="liste_titre" align="right">'; |
|
381 | - print '<input class="flat" type="text" size="5" name="search_montant_ttc" value="'.dol_escape_htmltag($search_montant_ttc).'">'; |
|
382 | - print '</td>'; |
|
383 | - } |
|
384 | - if (! empty($arrayfields['f.fk_cond_reglement']['checked'])) |
|
385 | - { |
|
386 | - // Payment term |
|
387 | - print '<td class="liste_titre" align="right">'; |
|
388 | - print $form->select_conditions_paiements($search_payment_term, 'search_payment_term', -1, 1, 1, 'maxwidth100'); |
|
389 | - print "</td>"; |
|
390 | - } |
|
391 | - if (! empty($arrayfields['f.fk_mode_reglement']['checked'])) |
|
392 | - { |
|
393 | - // Payment mode |
|
394 | - print '<td class="liste_titre" align="right">'; |
|
395 | - print $form->select_types_paiements($search_payment_mode, 'search_payment_mode', '', 0, 1, 1, 0, 1, 'maxwidth100'); |
|
396 | - print '</td>'; |
|
397 | - } |
|
398 | - if (! empty($arrayfields['recurring']['checked'])) |
|
399 | - { |
|
400 | - // Recurring or not |
|
401 | - print '<td class="liste_titre" align="center">'; |
|
402 | - print $form->selectyesno('search_recurring', $search_recurring, 1, false, 1); |
|
403 | - print '</td>'; |
|
404 | - } |
|
405 | - if (! empty($arrayfields['f.frequency']['checked'])) |
|
406 | - { |
|
407 | - // Recurring or not |
|
408 | - print '<td class="liste_titre" align="center">'; |
|
409 | - print '<input class="flat" type="text" size="1" name="search_frequency" value="'.dol_escape_htmltag($search_frequency).'">'; |
|
410 | - print '</td>'; |
|
411 | - } |
|
412 | - if (! empty($arrayfields['f.unit_frequency']['checked'])) |
|
413 | - { |
|
414 | - // Frequency unit |
|
415 | - print '<td class="liste_titre" align="center">'; |
|
416 | - print '<input class="flat" type="text" size="1" name="search_unit_frequency" value="'.dol_escape_htmltag($search_unit_frequency).'">'; |
|
417 | - print '</td>'; |
|
418 | - } |
|
419 | - if (! empty($arrayfields['f.nb_gen_done']['checked'])) |
|
420 | - { |
|
421 | - // Nb generation |
|
422 | - print '<td class="liste_titre" align="center">'; |
|
423 | - print '</td>'; |
|
424 | - } |
|
425 | - // Date invoice |
|
426 | - if (! empty($arrayfields['f.date_last_gen']['checked'])) |
|
427 | - { |
|
428 | - print '<td class="liste_titre nowraponall" align="center">'; |
|
429 | - if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print '<input class="flat valignmiddle" type="text" size="1" maxlength="2" name="search_day" value="'.$search_day.'">'; |
|
430 | - print '<input class="flat valignmiddle width25" type="text" size="1" maxlength="2" name="search_month" value="'.$search_month.'">'; |
|
431 | - $formother->select_year($search_year?$search_year:-1,'search_year',1, 20, 5, 0, 0, '', 'witdhauto valignmiddle'); |
|
432 | - print '</td>'; |
|
433 | - } |
|
434 | - // Date next generation |
|
435 | - if (! empty($arrayfields['f.date_when']['checked'])) |
|
436 | - { |
|
437 | - print '<td class="liste_titre nowraponall" align="center">'; |
|
438 | - if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print '<input class="flat valignmiddle" type="text" size="1" maxlength="2" name="search_day_date_when" value="'.$search_day_date_when.'">'; |
|
439 | - print '<input class="flat valignmiddle width25" type="text" size="1" maxlength="2" name="search_month_date_when" value="'.$search_month_date_when.'">'; |
|
440 | - $formother->select_year($search_year_date_when?$search_year_date_when:-1,'search_year_date_when',1, 20, 5, 0, 0, '', 'witdhauto valignmiddle'); |
|
441 | - print '</td>'; |
|
442 | - } |
|
443 | - // Extra fields |
|
444 | - include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; |
|
445 | - |
|
446 | - // Fields from hook |
|
447 | - $parameters=array('arrayfields'=>$arrayfields); |
|
448 | - $reshook=$hookmanager->executeHooks('printFieldListOption',$parameters); // Note that $action and $object may have been modified by hook |
|
449 | - print $hookmanager->resPrint; |
|
450 | - // Date creation |
|
451 | - if (! empty($arrayfields['f.datec']['checked'])) |
|
452 | - { |
|
453 | - print '<td class="liste_titre">'; |
|
454 | - print '</td>'; |
|
455 | - } |
|
456 | - // Date modification |
|
457 | - if (! empty($arrayfields['f.tms']['checked'])) |
|
458 | - { |
|
459 | - print '<td class="liste_titre">'; |
|
460 | - print '</td>'; |
|
461 | - } |
|
462 | - // Status |
|
463 | - if (! empty($arrayfields['status']['checked'])) |
|
464 | - { |
|
465 | - print '<td class="liste_titre" align="center">'; |
|
466 | - $liststatus=array( |
|
467 | - 0=>$langs->trans("Draft"), |
|
468 | - 1=>$langs->trans("Active"), |
|
469 | - -1=>$langs->trans("Disabled"), |
|
470 | - ); |
|
471 | - print $form->selectarray('search_status', $liststatus, $search_status, -2); |
|
472 | - print '</td>'; |
|
473 | - } |
|
474 | - // Action column |
|
475 | - print '<td class="liste_titre" align="middle">'; |
|
476 | - $searchpicto=$form->showFilterAndCheckAddButtons(0, 'checkforselect', 1); |
|
477 | - print $searchpicto; |
|
478 | - print '</td>'; |
|
479 | - print "</tr>\n"; |
|
480 | - |
|
481 | - |
|
482 | - print '<tr class="liste_titre">'; |
|
483 | - if (! empty($arrayfields['f.titre']['checked'])) print_liste_field_titre($arrayfields['f.titre']['label'],$_SERVER['PHP_SELF'],"f.titre","",$param,"",$sortfield,$sortorder); |
|
484 | - if (! empty($arrayfields['s.nom']['checked'])) print_liste_field_titre($arrayfields['s.nom']['label'],$_SERVER['PHP_SELF'],"s.nom","",$param,"",$sortfield,$sortorder); |
|
485 | - if (! empty($arrayfields['f.total']['checked'])) print_liste_field_titre($arrayfields['f.total']['label'],$_SERVER['PHP_SELF'],"f.total","",$param,'align="right"',$sortfield,$sortorder); |
|
486 | - if (! empty($arrayfields['f.tva']['checked'])) print_liste_field_titre($arrayfields['f.tva']['label'],$_SERVER['PHP_SELF'],"f.tva","",$param,'align="right"',$sortfield,$sortorder); |
|
487 | - if (! empty($arrayfields['f.total_ttc']['checked'])) print_liste_field_titre($arrayfields['f.total_ttc']['label'],$_SERVER['PHP_SELF'],"f.total_ttc","",$param,'align="right"',$sortfield,$sortorder); |
|
488 | - if (! empty($arrayfields['f.fk_cond_reglement']['checked'])) print_liste_field_titre($arrayfields['f.fk_cond_reglement']['label'],$_SERVER['PHP_SELF'],"f.fk_cond_reglement","",$param,'',$sortfield,$sortorder); |
|
489 | - if (! empty($arrayfields['f.fk_mode_reglement']['checked'])) print_liste_field_titre($arrayfields['f.fk_mode_reglement']['label'],$_SERVER['PHP_SELF'],"f.fk_mode_reglement","",$param,'',$sortfield,$sortorder); |
|
490 | - if (! empty($arrayfields['recurring']['checked'])) print_liste_field_titre($arrayfields['recurring']['label'],$_SERVER['PHP_SELF'],"recurring","",$param,'align="center"',$sortfield,$sortorder); |
|
491 | - if (! empty($arrayfields['f.frequency']['checked'])) print_liste_field_titre($arrayfields['f.frequency']['label'],$_SERVER['PHP_SELF'],"f.frequency","",$param,'align="center"',$sortfield,$sortorder); |
|
492 | - if (! empty($arrayfields['f.unit_frequency']['checked'])) print_liste_field_titre($arrayfields['f.unit_frequency']['label'],$_SERVER['PHP_SELF'],"f.unit_frequency","",$param,'align="center"',$sortfield,$sortorder); |
|
493 | - if (! empty($arrayfields['f.nb_gen_done']['checked'])) print_liste_field_titre($arrayfields['f.nb_gen_done']['label'],$_SERVER['PHP_SELF'],"f.nb_gen_done","",$param,'align="center"',$sortfield,$sortorder); |
|
494 | - if (! empty($arrayfields['f.date_last_gen']['checked'])) print_liste_field_titre($arrayfields['f.date_last_gen']['label'],$_SERVER['PHP_SELF'],"f.date_last_gen","",$param,'align="center"',$sortfield,$sortorder); |
|
495 | - if (! empty($arrayfields['f.date_when']['checked'])) print_liste_field_titre($arrayfields['f.date_when']['label'],$_SERVER['PHP_SELF'],"f.date_when","",$param,'align="center"',$sortfield,$sortorder); |
|
496 | - if (! empty($arrayfields['f.datec']['checked'])) print_liste_field_titre($arrayfields['f.datec']['label'],$_SERVER['PHP_SELF'],"f.datec","",$param,'align="center"',$sortfield,$sortorder); |
|
497 | - if (! empty($arrayfields['f.tms']['checked'])) print_liste_field_titre($arrayfields['f.tms']['label'],$_SERVER['PHP_SELF'],"f.tms","",$param,'align="center"',$sortfield,$sortorder); |
|
498 | - if (! empty($arrayfields['status']['checked'])) print_liste_field_titre($arrayfields['status']['label'],$_SERVER['PHP_SELF'],"f.suspended,f.frequency","",$param,'align="center"',$sortfield,$sortorder); |
|
499 | - print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"],"",'','','align="center"',$sortfield,$sortorder,'nomaxwidthsearch ')."\n"; |
|
500 | - print "</tr>\n"; |
|
501 | - |
|
502 | - if ($num > 0) |
|
503 | - { |
|
504 | - $i=0; |
|
505 | - $totalarray=array(); |
|
506 | - while ($i < min($num,$limit)) |
|
507 | - { |
|
508 | - $objp = $db->fetch_object($resql); |
|
509 | - if (empty($objp)) break; |
|
510 | - |
|
511 | - $companystatic->id=$objp->socid; |
|
512 | - $companystatic->name=$objp->name; |
|
513 | - |
|
514 | - $invoicerectmp->id=$objp->id?$objp->id:$objp->facid; |
|
515 | - $invoicerectmp->frequency=$objp->frequency; |
|
516 | - $invoicerectmp->suspended=$objp->suspended; |
|
517 | - $invoicerectmp->unit_frequency=$objp->unit_frequency; |
|
518 | - $invoicerectmp->nb_gen_max=$objp->nb_gen_max; |
|
519 | - $invoicerectmp->nb_gen_done=$objp->nb_gen_done; |
|
520 | - $invoicerectmp->ref=$objp->titre; |
|
521 | - |
|
522 | - print '<tr class="oddeven">'; |
|
523 | - |
|
524 | - if (! empty($arrayfields['f.titre']['checked'])) |
|
525 | - { |
|
526 | - print '<td>'; |
|
527 | - print $invoicerectmp->getNomUrl(1); |
|
528 | - print "</a>"; |
|
529 | - print "</td>\n"; |
|
530 | - if (! $i) $totalarray['nbfield']++; |
|
531 | - } |
|
532 | - if (! empty($arrayfields['s.nom']['checked'])) |
|
533 | - { |
|
534 | - print '<td class="tdoverflowmax200">'.$companystatic->getNomUrl(1,'customer').'</td>'; |
|
535 | - if (! $i) $totalarray['nbfield']++; |
|
536 | - } |
|
537 | - if (! empty($arrayfields['f.total']['checked'])) |
|
538 | - { |
|
539 | - print '<td align="right">'.price($objp->total).'</td>'."\n"; |
|
540 | - if (! $i) $totalarray['nbfield']++; |
|
541 | - if (! $i) $totalarray['pos'][$totalarray['nbfield']]='f.total'; |
|
542 | - $totalarray['val']['f.total'] += $objp->total; |
|
543 | - } |
|
544 | - if (! empty($arrayfields['f.tva']['checked'])) |
|
545 | - { |
|
546 | - print '<td align="right">'.price($objp->total_vat).'</td>'."\n"; |
|
547 | - if (! $i) $totalarray['nbfield']++; |
|
548 | - if (! $i) $totalarray['pos'][$totalarray['nbfield']]='f.tva'; |
|
549 | - $totalarray['val']['f.tva'] += $objp->total_vat; |
|
550 | - } |
|
551 | - if (! empty($arrayfields['f.total_ttc']['checked'])) |
|
552 | - { |
|
553 | - print '<td align="right">'.price($objp->total_ttc).'</td>'."\n"; |
|
554 | - if (! $i) $totalarray['nbfield']++; |
|
555 | - if (! $i) $totalarray['pos'][$totalarray['nbfield']]='f.total_ttc'; |
|
556 | - $totalarray['val']['f.total_ttc'] += $objp->total_ttc; |
|
557 | - } |
|
558 | - // Payment term |
|
559 | - if (! empty($arrayfields['f.fk_cond_reglement']['checked'])) |
|
560 | - { |
|
561 | - print '<td align="right">'; |
|
562 | - print $form->form_conditions_reglement('', $objp->fk_cond_reglement, 'none'); |
|
563 | - print '</td>'."\n"; |
|
564 | - if (! $i) $totalarray['nbfield']++; |
|
565 | - } |
|
566 | - // Payment mode |
|
567 | - if (! empty($arrayfields['f.fk_mode_reglement']['checked'])) |
|
568 | - { |
|
569 | - print '<td align="right">'; |
|
570 | - print $form->form_modes_reglement('', $objp->fk_mode_reglement, 'none'); |
|
571 | - print '</td>'."\n"; |
|
572 | - if (! $i) $totalarray['nbfield']++; |
|
573 | - } |
|
574 | - if (! empty($arrayfields['recurring']['checked'])) |
|
575 | - { |
|
576 | - print '<td align="center">'.yn($objp->frequency?1:0).'</td>'; |
|
577 | - if (! $i) $totalarray['nbfield']++; |
|
578 | - } |
|
579 | - if (! empty($arrayfields['f.frequency']['checked'])) |
|
580 | - { |
|
581 | - print '<td align="center">'.($objp->frequency > 0 ? $objp->frequency : '').'</td>'; |
|
582 | - if (! $i) $totalarray['nbfield']++; |
|
583 | - } |
|
584 | - if (! empty($arrayfields['f.unit_frequency']['checked'])) |
|
585 | - { |
|
586 | - print '<td align="center">'.($objp->frequency > 0 ? $objp->unit_frequency : '').'</td>'; |
|
587 | - if (! $i) $totalarray['nbfield']++; |
|
588 | - } |
|
589 | - if (! empty($arrayfields['f.nb_gen_done']['checked'])) |
|
590 | - { |
|
591 | - print '<td align="center">'; |
|
592 | - print ($objp->frequency > 0 ? $objp->nb_gen_done.($objp->nb_gen_max>0?' / '. $objp->nb_gen_max:'') : '<span class="opacitymedium">'.$langs->trans('NA').'</span>'); |
|
593 | - print '</td>'; |
|
594 | - if (! $i) $totalarray['nbfield']++; |
|
595 | - } |
|
596 | - // Date last generation |
|
597 | - if (! empty($arrayfields['f.date_last_gen']['checked'])) |
|
598 | - { |
|
599 | - print '<td align="center">'; |
|
600 | - print ($objp->frequency > 0 ? dol_print_date($db->jdate($objp->date_last_gen),'day') : '<span class="opacitymedium">'.$langs->trans('NA').'</span>'); |
|
601 | - print '</td>'; |
|
602 | - if (! $i) $totalarray['nbfield']++; |
|
603 | - } |
|
604 | - // Date next generation |
|
605 | - if (! empty($arrayfields['f.date_when']['checked'])) |
|
606 | - { |
|
607 | - print '<td align="center">'; |
|
608 | - print '<div class="nowraponall">'; |
|
609 | - print ($objp->frequency ? ($invoicerectmp->isMaxNbGenReached()?'<strike>':'').dol_print_date($db->jdate($objp->date_when),'day').($invoicerectmp->isMaxNbGenReached()?'</strike>':'') : '<span class="opacitymedium">'.$langs->trans('NA').'</span>'); |
|
610 | - if (! $invoicerectmp->isMaxNbGenReached()) |
|
611 | - { |
|
612 | - if (! $objp->suspended && $objp->frequency > 0 && $db->jdate($objp->date_when) && $db->jdate($objp->date_when) < $now) print img_warning($langs->trans("Late")); |
|
613 | - } |
|
614 | - else |
|
615 | - { |
|
616 | - print img_info($langs->trans("MaxNumberOfGenerationReached")); |
|
617 | - } |
|
618 | - print '</div>'; |
|
619 | - print '</td>'; |
|
620 | - if (! $i) $totalarray['nbfield']++; |
|
621 | - } |
|
622 | - if (! empty($arrayfields['f.datec']['checked'])) |
|
623 | - { |
|
624 | - print '<td align="center">'; |
|
625 | - print dol_print_date($db->jdate($objp->datec),'dayhour'); |
|
626 | - print '</td>'; |
|
627 | - if (! $i) $totalarray['nbfield']++; |
|
628 | - } |
|
629 | - if (! empty($arrayfields['f.tms']['checked'])) |
|
630 | - { |
|
631 | - print '<td align="center">'; |
|
632 | - print dol_print_date($db->jdate($objp->tms),'dayhour'); |
|
633 | - print '</td>'; |
|
634 | - if (! $i) $totalarray['nbfield']++; |
|
635 | - } |
|
636 | - if (! empty($arrayfields['status']['checked'])) |
|
637 | - { |
|
638 | - print '<td align="center">'; |
|
639 | - print $invoicerectmp->getLibStatut(3,0); |
|
640 | - print '</td>'; |
|
641 | - if (! $i) $totalarray['nbfield']++; |
|
642 | - } |
|
643 | - // Action column |
|
644 | - print '<td align="center">'; |
|
645 | - if ($user->rights->facture->creer && empty($invoicerectmp->suspended)) |
|
646 | - { |
|
647 | - if ($invoicerectmp->isMaxNbGenReached()) |
|
648 | - { |
|
649 | - print $langs->trans("MaxNumberOfGenerationReached"); |
|
650 | - } |
|
651 | - elseif (empty($objp->frequency) || $db->jdate($objp->date_when) <= $today) |
|
652 | - { |
|
295 | + $num = $db->num_rows($resql); |
|
296 | + |
|
297 | + $param=''; |
|
298 | + if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage); |
|
299 | + if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit); |
|
300 | + if ($socid) $param.='&socid='.urlencode($socid); |
|
301 | + if ($search_day) $param.='&search_day='.urlencode($search_day); |
|
302 | + if ($search_month) $param.='&search_month='.urlencode($search_month); |
|
303 | + if ($search_year) $param.='&search_year=' .urlencode($search_year); |
|
304 | + if ($search_day_date_when) $param.='&search_day_date_when='.urlencode($search_day_date_when); |
|
305 | + if ($search_month_date_when) $param.='&search_month_date_when='.urlencode($search_month_date_when); |
|
306 | + if ($search_year_date_when) $param.='&search_year_date_when=' .urlencode($search_year_date_when); |
|
307 | + if ($search_ref) $param.='&search_ref=' .urlencode($search_ref); |
|
308 | + if ($search_societe) $param.='&search_societe=' .urlencode($search_societe); |
|
309 | + if ($search_montant_ht != '') $param.='&search_montant_ht=' .urlencode($search_montant_ht); |
|
310 | + if ($search_montant_vat != '') $param.='&search_montant_vat='.urlencode($search_montant_vat); |
|
311 | + if ($search_montant_ttc != '') $param.='&search_montant_ttc='.urlencode($search_montant_ttc); |
|
312 | + if ($search_payment_mode != '') $param.='&search_payment_mode='.urlencode($search_payment_mode); |
|
313 | + if ($search_payment_type != '') $param.='&search_payment_type='.urlencode($search_payment_type); |
|
314 | + if ($search_recurring != '' && $search_recurrning != '-1') $param.='&search_recurring=' .urlencode($search_recurring); |
|
315 | + if ($search_frequency > 0) $param.='&search_frequency=' .urlencode($search_frequency); |
|
316 | + if ($search_unit_frequency != '') $param.='&search_unit_frequency='.urlencode($search_unit_frequency); |
|
317 | + if ($search_status != '') $param.='&search_status='.urlencode($search_status); |
|
318 | + if ($option) $param.="&option=".urlencode($option); |
|
319 | + if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss); |
|
320 | + // Add $param from extra fields |
|
321 | + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; |
|
322 | + |
|
323 | + $massactionbutton=$form->selectMassAction('', $massaction == 'presend' ? array() : array('presend'=>$langs->trans("SendByMail"), 'builddoc'=>$langs->trans("PDFMerge"))); |
|
324 | + |
|
325 | + $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; |
|
326 | + $selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields |
|
327 | + //$selectedfields.=$form->showCheckAddButtons('checkforselect', 1); |
|
328 | + |
|
329 | + print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'; |
|
330 | + if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">'; |
|
331 | + print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
332 | + print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">'; |
|
333 | + print '<input type="hidden" name="action" value="list">'; |
|
334 | + print '<input type="hidden" name="sortfield" value="'.$sortfield.'">'; |
|
335 | + print '<input type="hidden" name="sortorder" value="'.$sortorder.'">'; |
|
336 | + print '<input type="hidden" name="page" value="'.$page.'">'; |
|
337 | + print '<input type="hidden" name="contextpage" value="'.$contextpage.'">'; |
|
338 | + print '<input type="hidden" name="viewstatut" value="'.$viewstatut.'">'; |
|
339 | + |
|
340 | + print_barre_liste($langs->trans("RepeatableInvoices"),$page,$_SERVER['PHP_SELF'],$param,$sortfield,$sortorder,'',$num,$nbtotalofrecords,'title_accountancy.png',0,'','', $limit); |
|
341 | + |
|
342 | + print $langs->trans("ToCreateAPredefinedInvoice", $langs->transnoentitiesnoconv("ChangeIntoRepeatableInvoice")).'<br><br>'; |
|
343 | + |
|
344 | + $i = 0; |
|
345 | + |
|
346 | + print '<div class="div-table-responsive">'; |
|
347 | + print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n"; |
|
348 | + |
|
349 | + // Filters lines |
|
350 | + print '<tr class="liste_titre_filter">'; |
|
351 | + // Ref |
|
352 | + if (! empty($arrayfields['f.titre']['checked'])) |
|
353 | + { |
|
354 | + print '<td class="liste_titre" align="left">'; |
|
355 | + print '<input class="flat" size="6" type="text" name="search_ref" value="'.dol_escape_htmltag($search_ref).'">'; |
|
356 | + print '</td>'; |
|
357 | + } |
|
358 | + // Thirpdarty |
|
359 | + if (! empty($arrayfields['s.nom']['checked'])) |
|
360 | + { |
|
361 | + print '<td class="liste_titre" align="left"><input class="flat" type="text" size="8" name="search_societe" value="'.dol_escape_htmltag($search_societe).'"></td>'; |
|
362 | + } |
|
363 | + if (! empty($arrayfields['f.total']['checked'])) |
|
364 | + { |
|
365 | + // Amount net |
|
366 | + print '<td class="liste_titre" align="right">'; |
|
367 | + print '<input class="flat" type="text" size="5" name="search_montant_ht" value="'.dol_escape_htmltag($search_montant_ht).'">'; |
|
368 | + print '</td>'; |
|
369 | + } |
|
370 | + if (! empty($arrayfields['f.tva']['checked'])) |
|
371 | + { |
|
372 | + // Amount Vat |
|
373 | + print '<td class="liste_titre" align="right">'; |
|
374 | + print '<input class="flat" type="text" size="5" name="search_montant_vat" value="'.dol_escape_htmltag($search_montant_vat).'">'; |
|
375 | + print '</td>'; |
|
376 | + } |
|
377 | + if (! empty($arrayfields['f.total_ttc']['checked'])) |
|
378 | + { |
|
379 | + // Amount |
|
380 | + print '<td class="liste_titre" align="right">'; |
|
381 | + print '<input class="flat" type="text" size="5" name="search_montant_ttc" value="'.dol_escape_htmltag($search_montant_ttc).'">'; |
|
382 | + print '</td>'; |
|
383 | + } |
|
384 | + if (! empty($arrayfields['f.fk_cond_reglement']['checked'])) |
|
385 | + { |
|
386 | + // Payment term |
|
387 | + print '<td class="liste_titre" align="right">'; |
|
388 | + print $form->select_conditions_paiements($search_payment_term, 'search_payment_term', -1, 1, 1, 'maxwidth100'); |
|
389 | + print "</td>"; |
|
390 | + } |
|
391 | + if (! empty($arrayfields['f.fk_mode_reglement']['checked'])) |
|
392 | + { |
|
393 | + // Payment mode |
|
394 | + print '<td class="liste_titre" align="right">'; |
|
395 | + print $form->select_types_paiements($search_payment_mode, 'search_payment_mode', '', 0, 1, 1, 0, 1, 'maxwidth100'); |
|
396 | + print '</td>'; |
|
397 | + } |
|
398 | + if (! empty($arrayfields['recurring']['checked'])) |
|
399 | + { |
|
400 | + // Recurring or not |
|
401 | + print '<td class="liste_titre" align="center">'; |
|
402 | + print $form->selectyesno('search_recurring', $search_recurring, 1, false, 1); |
|
403 | + print '</td>'; |
|
404 | + } |
|
405 | + if (! empty($arrayfields['f.frequency']['checked'])) |
|
406 | + { |
|
407 | + // Recurring or not |
|
408 | + print '<td class="liste_titre" align="center">'; |
|
409 | + print '<input class="flat" type="text" size="1" name="search_frequency" value="'.dol_escape_htmltag($search_frequency).'">'; |
|
410 | + print '</td>'; |
|
411 | + } |
|
412 | + if (! empty($arrayfields['f.unit_frequency']['checked'])) |
|
413 | + { |
|
414 | + // Frequency unit |
|
415 | + print '<td class="liste_titre" align="center">'; |
|
416 | + print '<input class="flat" type="text" size="1" name="search_unit_frequency" value="'.dol_escape_htmltag($search_unit_frequency).'">'; |
|
417 | + print '</td>'; |
|
418 | + } |
|
419 | + if (! empty($arrayfields['f.nb_gen_done']['checked'])) |
|
420 | + { |
|
421 | + // Nb generation |
|
422 | + print '<td class="liste_titre" align="center">'; |
|
423 | + print '</td>'; |
|
424 | + } |
|
425 | + // Date invoice |
|
426 | + if (! empty($arrayfields['f.date_last_gen']['checked'])) |
|
427 | + { |
|
428 | + print '<td class="liste_titre nowraponall" align="center">'; |
|
429 | + if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print '<input class="flat valignmiddle" type="text" size="1" maxlength="2" name="search_day" value="'.$search_day.'">'; |
|
430 | + print '<input class="flat valignmiddle width25" type="text" size="1" maxlength="2" name="search_month" value="'.$search_month.'">'; |
|
431 | + $formother->select_year($search_year?$search_year:-1,'search_year',1, 20, 5, 0, 0, '', 'witdhauto valignmiddle'); |
|
432 | + print '</td>'; |
|
433 | + } |
|
434 | + // Date next generation |
|
435 | + if (! empty($arrayfields['f.date_when']['checked'])) |
|
436 | + { |
|
437 | + print '<td class="liste_titre nowraponall" align="center">'; |
|
438 | + if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print '<input class="flat valignmiddle" type="text" size="1" maxlength="2" name="search_day_date_when" value="'.$search_day_date_when.'">'; |
|
439 | + print '<input class="flat valignmiddle width25" type="text" size="1" maxlength="2" name="search_month_date_when" value="'.$search_month_date_when.'">'; |
|
440 | + $formother->select_year($search_year_date_when?$search_year_date_when:-1,'search_year_date_when',1, 20, 5, 0, 0, '', 'witdhauto valignmiddle'); |
|
441 | + print '</td>'; |
|
442 | + } |
|
443 | + // Extra fields |
|
444 | + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; |
|
445 | + |
|
446 | + // Fields from hook |
|
447 | + $parameters=array('arrayfields'=>$arrayfields); |
|
448 | + $reshook=$hookmanager->executeHooks('printFieldListOption',$parameters); // Note that $action and $object may have been modified by hook |
|
449 | + print $hookmanager->resPrint; |
|
450 | + // Date creation |
|
451 | + if (! empty($arrayfields['f.datec']['checked'])) |
|
452 | + { |
|
453 | + print '<td class="liste_titre">'; |
|
454 | + print '</td>'; |
|
455 | + } |
|
456 | + // Date modification |
|
457 | + if (! empty($arrayfields['f.tms']['checked'])) |
|
458 | + { |
|
459 | + print '<td class="liste_titre">'; |
|
460 | + print '</td>'; |
|
461 | + } |
|
462 | + // Status |
|
463 | + if (! empty($arrayfields['status']['checked'])) |
|
464 | + { |
|
465 | + print '<td class="liste_titre" align="center">'; |
|
466 | + $liststatus=array( |
|
467 | + 0=>$langs->trans("Draft"), |
|
468 | + 1=>$langs->trans("Active"), |
|
469 | + -1=>$langs->trans("Disabled"), |
|
470 | + ); |
|
471 | + print $form->selectarray('search_status', $liststatus, $search_status, -2); |
|
472 | + print '</td>'; |
|
473 | + } |
|
474 | + // Action column |
|
475 | + print '<td class="liste_titre" align="middle">'; |
|
476 | + $searchpicto=$form->showFilterAndCheckAddButtons(0, 'checkforselect', 1); |
|
477 | + print $searchpicto; |
|
478 | + print '</td>'; |
|
479 | + print "</tr>\n"; |
|
480 | + |
|
481 | + |
|
482 | + print '<tr class="liste_titre">'; |
|
483 | + if (! empty($arrayfields['f.titre']['checked'])) print_liste_field_titre($arrayfields['f.titre']['label'],$_SERVER['PHP_SELF'],"f.titre","",$param,"",$sortfield,$sortorder); |
|
484 | + if (! empty($arrayfields['s.nom']['checked'])) print_liste_field_titre($arrayfields['s.nom']['label'],$_SERVER['PHP_SELF'],"s.nom","",$param,"",$sortfield,$sortorder); |
|
485 | + if (! empty($arrayfields['f.total']['checked'])) print_liste_field_titre($arrayfields['f.total']['label'],$_SERVER['PHP_SELF'],"f.total","",$param,'align="right"',$sortfield,$sortorder); |
|
486 | + if (! empty($arrayfields['f.tva']['checked'])) print_liste_field_titre($arrayfields['f.tva']['label'],$_SERVER['PHP_SELF'],"f.tva","",$param,'align="right"',$sortfield,$sortorder); |
|
487 | + if (! empty($arrayfields['f.total_ttc']['checked'])) print_liste_field_titre($arrayfields['f.total_ttc']['label'],$_SERVER['PHP_SELF'],"f.total_ttc","",$param,'align="right"',$sortfield,$sortorder); |
|
488 | + if (! empty($arrayfields['f.fk_cond_reglement']['checked'])) print_liste_field_titre($arrayfields['f.fk_cond_reglement']['label'],$_SERVER['PHP_SELF'],"f.fk_cond_reglement","",$param,'',$sortfield,$sortorder); |
|
489 | + if (! empty($arrayfields['f.fk_mode_reglement']['checked'])) print_liste_field_titre($arrayfields['f.fk_mode_reglement']['label'],$_SERVER['PHP_SELF'],"f.fk_mode_reglement","",$param,'',$sortfield,$sortorder); |
|
490 | + if (! empty($arrayfields['recurring']['checked'])) print_liste_field_titre($arrayfields['recurring']['label'],$_SERVER['PHP_SELF'],"recurring","",$param,'align="center"',$sortfield,$sortorder); |
|
491 | + if (! empty($arrayfields['f.frequency']['checked'])) print_liste_field_titre($arrayfields['f.frequency']['label'],$_SERVER['PHP_SELF'],"f.frequency","",$param,'align="center"',$sortfield,$sortorder); |
|
492 | + if (! empty($arrayfields['f.unit_frequency']['checked'])) print_liste_field_titre($arrayfields['f.unit_frequency']['label'],$_SERVER['PHP_SELF'],"f.unit_frequency","",$param,'align="center"',$sortfield,$sortorder); |
|
493 | + if (! empty($arrayfields['f.nb_gen_done']['checked'])) print_liste_field_titre($arrayfields['f.nb_gen_done']['label'],$_SERVER['PHP_SELF'],"f.nb_gen_done","",$param,'align="center"',$sortfield,$sortorder); |
|
494 | + if (! empty($arrayfields['f.date_last_gen']['checked'])) print_liste_field_titre($arrayfields['f.date_last_gen']['label'],$_SERVER['PHP_SELF'],"f.date_last_gen","",$param,'align="center"',$sortfield,$sortorder); |
|
495 | + if (! empty($arrayfields['f.date_when']['checked'])) print_liste_field_titre($arrayfields['f.date_when']['label'],$_SERVER['PHP_SELF'],"f.date_when","",$param,'align="center"',$sortfield,$sortorder); |
|
496 | + if (! empty($arrayfields['f.datec']['checked'])) print_liste_field_titre($arrayfields['f.datec']['label'],$_SERVER['PHP_SELF'],"f.datec","",$param,'align="center"',$sortfield,$sortorder); |
|
497 | + if (! empty($arrayfields['f.tms']['checked'])) print_liste_field_titre($arrayfields['f.tms']['label'],$_SERVER['PHP_SELF'],"f.tms","",$param,'align="center"',$sortfield,$sortorder); |
|
498 | + if (! empty($arrayfields['status']['checked'])) print_liste_field_titre($arrayfields['status']['label'],$_SERVER['PHP_SELF'],"f.suspended,f.frequency","",$param,'align="center"',$sortfield,$sortorder); |
|
499 | + print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"],"",'','','align="center"',$sortfield,$sortorder,'nomaxwidthsearch ')."\n"; |
|
500 | + print "</tr>\n"; |
|
501 | + |
|
502 | + if ($num > 0) |
|
503 | + { |
|
504 | + $i=0; |
|
505 | + $totalarray=array(); |
|
506 | + while ($i < min($num,$limit)) |
|
507 | + { |
|
508 | + $objp = $db->fetch_object($resql); |
|
509 | + if (empty($objp)) break; |
|
510 | + |
|
511 | + $companystatic->id=$objp->socid; |
|
512 | + $companystatic->name=$objp->name; |
|
513 | + |
|
514 | + $invoicerectmp->id=$objp->id?$objp->id:$objp->facid; |
|
515 | + $invoicerectmp->frequency=$objp->frequency; |
|
516 | + $invoicerectmp->suspended=$objp->suspended; |
|
517 | + $invoicerectmp->unit_frequency=$objp->unit_frequency; |
|
518 | + $invoicerectmp->nb_gen_max=$objp->nb_gen_max; |
|
519 | + $invoicerectmp->nb_gen_done=$objp->nb_gen_done; |
|
520 | + $invoicerectmp->ref=$objp->titre; |
|
521 | + |
|
522 | + print '<tr class="oddeven">'; |
|
523 | + |
|
524 | + if (! empty($arrayfields['f.titre']['checked'])) |
|
525 | + { |
|
526 | + print '<td>'; |
|
527 | + print $invoicerectmp->getNomUrl(1); |
|
528 | + print "</a>"; |
|
529 | + print "</td>\n"; |
|
530 | + if (! $i) $totalarray['nbfield']++; |
|
531 | + } |
|
532 | + if (! empty($arrayfields['s.nom']['checked'])) |
|
533 | + { |
|
534 | + print '<td class="tdoverflowmax200">'.$companystatic->getNomUrl(1,'customer').'</td>'; |
|
535 | + if (! $i) $totalarray['nbfield']++; |
|
536 | + } |
|
537 | + if (! empty($arrayfields['f.total']['checked'])) |
|
538 | + { |
|
539 | + print '<td align="right">'.price($objp->total).'</td>'."\n"; |
|
540 | + if (! $i) $totalarray['nbfield']++; |
|
541 | + if (! $i) $totalarray['pos'][$totalarray['nbfield']]='f.total'; |
|
542 | + $totalarray['val']['f.total'] += $objp->total; |
|
543 | + } |
|
544 | + if (! empty($arrayfields['f.tva']['checked'])) |
|
545 | + { |
|
546 | + print '<td align="right">'.price($objp->total_vat).'</td>'."\n"; |
|
547 | + if (! $i) $totalarray['nbfield']++; |
|
548 | + if (! $i) $totalarray['pos'][$totalarray['nbfield']]='f.tva'; |
|
549 | + $totalarray['val']['f.tva'] += $objp->total_vat; |
|
550 | + } |
|
551 | + if (! empty($arrayfields['f.total_ttc']['checked'])) |
|
552 | + { |
|
553 | + print '<td align="right">'.price($objp->total_ttc).'</td>'."\n"; |
|
554 | + if (! $i) $totalarray['nbfield']++; |
|
555 | + if (! $i) $totalarray['pos'][$totalarray['nbfield']]='f.total_ttc'; |
|
556 | + $totalarray['val']['f.total_ttc'] += $objp->total_ttc; |
|
557 | + } |
|
558 | + // Payment term |
|
559 | + if (! empty($arrayfields['f.fk_cond_reglement']['checked'])) |
|
560 | + { |
|
561 | + print '<td align="right">'; |
|
562 | + print $form->form_conditions_reglement('', $objp->fk_cond_reglement, 'none'); |
|
563 | + print '</td>'."\n"; |
|
564 | + if (! $i) $totalarray['nbfield']++; |
|
565 | + } |
|
566 | + // Payment mode |
|
567 | + if (! empty($arrayfields['f.fk_mode_reglement']['checked'])) |
|
568 | + { |
|
569 | + print '<td align="right">'; |
|
570 | + print $form->form_modes_reglement('', $objp->fk_mode_reglement, 'none'); |
|
571 | + print '</td>'."\n"; |
|
572 | + if (! $i) $totalarray['nbfield']++; |
|
573 | + } |
|
574 | + if (! empty($arrayfields['recurring']['checked'])) |
|
575 | + { |
|
576 | + print '<td align="center">'.yn($objp->frequency?1:0).'</td>'; |
|
577 | + if (! $i) $totalarray['nbfield']++; |
|
578 | + } |
|
579 | + if (! empty($arrayfields['f.frequency']['checked'])) |
|
580 | + { |
|
581 | + print '<td align="center">'.($objp->frequency > 0 ? $objp->frequency : '').'</td>'; |
|
582 | + if (! $i) $totalarray['nbfield']++; |
|
583 | + } |
|
584 | + if (! empty($arrayfields['f.unit_frequency']['checked'])) |
|
585 | + { |
|
586 | + print '<td align="center">'.($objp->frequency > 0 ? $objp->unit_frequency : '').'</td>'; |
|
587 | + if (! $i) $totalarray['nbfield']++; |
|
588 | + } |
|
589 | + if (! empty($arrayfields['f.nb_gen_done']['checked'])) |
|
590 | + { |
|
591 | + print '<td align="center">'; |
|
592 | + print ($objp->frequency > 0 ? $objp->nb_gen_done.($objp->nb_gen_max>0?' / '. $objp->nb_gen_max:'') : '<span class="opacitymedium">'.$langs->trans('NA').'</span>'); |
|
593 | + print '</td>'; |
|
594 | + if (! $i) $totalarray['nbfield']++; |
|
595 | + } |
|
596 | + // Date last generation |
|
597 | + if (! empty($arrayfields['f.date_last_gen']['checked'])) |
|
598 | + { |
|
599 | + print '<td align="center">'; |
|
600 | + print ($objp->frequency > 0 ? dol_print_date($db->jdate($objp->date_last_gen),'day') : '<span class="opacitymedium">'.$langs->trans('NA').'</span>'); |
|
601 | + print '</td>'; |
|
602 | + if (! $i) $totalarray['nbfield']++; |
|
603 | + } |
|
604 | + // Date next generation |
|
605 | + if (! empty($arrayfields['f.date_when']['checked'])) |
|
606 | + { |
|
607 | + print '<td align="center">'; |
|
608 | + print '<div class="nowraponall">'; |
|
609 | + print ($objp->frequency ? ($invoicerectmp->isMaxNbGenReached()?'<strike>':'').dol_print_date($db->jdate($objp->date_when),'day').($invoicerectmp->isMaxNbGenReached()?'</strike>':'') : '<span class="opacitymedium">'.$langs->trans('NA').'</span>'); |
|
610 | + if (! $invoicerectmp->isMaxNbGenReached()) |
|
611 | + { |
|
612 | + if (! $objp->suspended && $objp->frequency > 0 && $db->jdate($objp->date_when) && $db->jdate($objp->date_when) < $now) print img_warning($langs->trans("Late")); |
|
613 | + } |
|
614 | + else |
|
615 | + { |
|
616 | + print img_info($langs->trans("MaxNumberOfGenerationReached")); |
|
617 | + } |
|
618 | + print '</div>'; |
|
619 | + print '</td>'; |
|
620 | + if (! $i) $totalarray['nbfield']++; |
|
621 | + } |
|
622 | + if (! empty($arrayfields['f.datec']['checked'])) |
|
623 | + { |
|
624 | + print '<td align="center">'; |
|
625 | + print dol_print_date($db->jdate($objp->datec),'dayhour'); |
|
626 | + print '</td>'; |
|
627 | + if (! $i) $totalarray['nbfield']++; |
|
628 | + } |
|
629 | + if (! empty($arrayfields['f.tms']['checked'])) |
|
630 | + { |
|
631 | + print '<td align="center">'; |
|
632 | + print dol_print_date($db->jdate($objp->tms),'dayhour'); |
|
633 | + print '</td>'; |
|
634 | + if (! $i) $totalarray['nbfield']++; |
|
635 | + } |
|
636 | + if (! empty($arrayfields['status']['checked'])) |
|
637 | + { |
|
638 | + print '<td align="center">'; |
|
639 | + print $invoicerectmp->getLibStatut(3,0); |
|
640 | + print '</td>'; |
|
641 | + if (! $i) $totalarray['nbfield']++; |
|
642 | + } |
|
643 | + // Action column |
|
644 | + print '<td align="center">'; |
|
645 | + if ($user->rights->facture->creer && empty($invoicerectmp->suspended)) |
|
646 | + { |
|
647 | + if ($invoicerectmp->isMaxNbGenReached()) |
|
648 | + { |
|
649 | + print $langs->trans("MaxNumberOfGenerationReached"); |
|
650 | + } |
|
651 | + elseif (empty($objp->frequency) || $db->jdate($objp->date_when) <= $today) |
|
652 | + { |
|
653 | 653 | print '<a href="' . BASE_URI . '?controller=compta/facture&method=card&action=create&socid=' . $objp->socid . '&fac_rec=' . $objp->facid . '">'; |
654 | - print $langs->trans("CreateBill").'</a>'; |
|
655 | - } |
|
656 | - else |
|
657 | - { |
|
658 | - print $form->textwithpicto('', $langs->trans("DateIsNotEnough")); |
|
659 | - } |
|
660 | - } |
|
661 | - else |
|
662 | - { |
|
663 | - print " "; |
|
664 | - } |
|
665 | - if (! $i) $totalarray['nbfield']++; |
|
666 | - print "</td>"; |
|
667 | - |
|
668 | - print "</tr>\n"; |
|
669 | - |
|
670 | - $i++; |
|
671 | - } |
|
672 | - } |
|
673 | - else |
|
674 | - { |
|
675 | - $colspan=1; |
|
676 | - foreach($arrayfields as $key => $val) { if (! empty($val['checked'])) $colspan++; } |
|
677 | - print '<tr><td colspan="'.$colspan.'" class="opacitymedium">'.$langs->trans("NoRecordFound").'</td></tr>'; |
|
678 | - } |
|
679 | - |
|
680 | - //var_dump($totalarray); |
|
681 | - // Show total line |
|
682 | - if (isset($totalarray['pos'])) |
|
683 | - { |
|
684 | - print '<tr class="liste_total">'; |
|
685 | - $i=0; |
|
686 | - while ($i < $totalarray['nbfield']) |
|
687 | - { |
|
688 | - $i++; |
|
689 | - if (! empty($totalarray['pos'][$i])) print '<td align="right">'.price($totalarray['val'][$totalarray['pos'][$i]]).'</td>'; |
|
690 | - else |
|
691 | - { |
|
692 | - if ($i == 1) |
|
693 | - { |
|
694 | - if ($num < $limit) print '<td align="left">'.$langs->trans("Total").'</td>'; |
|
695 | - else print '<td align="left">'.$langs->trans("Totalforthispage").'</td>'; |
|
696 | - } |
|
697 | - else print '<td></td>'; |
|
698 | - } |
|
699 | - } |
|
700 | - print '</tr>'; |
|
701 | - } |
|
702 | - |
|
703 | - print "</table>"; |
|
704 | - print "</div>"; |
|
705 | - print "</form>"; |
|
706 | - |
|
707 | - $db->free($resql); |
|
654 | + print $langs->trans("CreateBill").'</a>'; |
|
655 | + } |
|
656 | + else |
|
657 | + { |
|
658 | + print $form->textwithpicto('', $langs->trans("DateIsNotEnough")); |
|
659 | + } |
|
660 | + } |
|
661 | + else |
|
662 | + { |
|
663 | + print " "; |
|
664 | + } |
|
665 | + if (! $i) $totalarray['nbfield']++; |
|
666 | + print "</td>"; |
|
667 | + |
|
668 | + print "</tr>\n"; |
|
669 | + |
|
670 | + $i++; |
|
671 | + } |
|
672 | + } |
|
673 | + else |
|
674 | + { |
|
675 | + $colspan=1; |
|
676 | + foreach($arrayfields as $key => $val) { if (! empty($val['checked'])) $colspan++; } |
|
677 | + print '<tr><td colspan="'.$colspan.'" class="opacitymedium">'.$langs->trans("NoRecordFound").'</td></tr>'; |
|
678 | + } |
|
679 | + |
|
680 | + //var_dump($totalarray); |
|
681 | + // Show total line |
|
682 | + if (isset($totalarray['pos'])) |
|
683 | + { |
|
684 | + print '<tr class="liste_total">'; |
|
685 | + $i=0; |
|
686 | + while ($i < $totalarray['nbfield']) |
|
687 | + { |
|
688 | + $i++; |
|
689 | + if (! empty($totalarray['pos'][$i])) print '<td align="right">'.price($totalarray['val'][$totalarray['pos'][$i]]).'</td>'; |
|
690 | + else |
|
691 | + { |
|
692 | + if ($i == 1) |
|
693 | + { |
|
694 | + if ($num < $limit) print '<td align="left">'.$langs->trans("Total").'</td>'; |
|
695 | + else print '<td align="left">'.$langs->trans("Totalforthispage").'</td>'; |
|
696 | + } |
|
697 | + else print '<td></td>'; |
|
698 | + } |
|
699 | + } |
|
700 | + print '</tr>'; |
|
701 | + } |
|
702 | + |
|
703 | + print "</table>"; |
|
704 | + print "</div>"; |
|
705 | + print "</form>"; |
|
706 | + |
|
707 | + $db->free($resql); |
|
708 | 708 | } |
709 | 709 | else |
710 | 710 | { |
711 | - dol_print_error($db); |
|
711 | + dol_print_error($db); |
|
712 | 712 | } |
713 | 713 | |
714 | 714 | // End of page |
@@ -32,66 +32,66 @@ discard block |
||
32 | 32 | |
33 | 33 | // Copyright (C) 2018 Alxarafe/Alixar <[email protected]> |
34 | 34 | defined('BASE_PATH') or die('Single entry point through the index.php of the main folder'); |
35 | -require DOL_BASE_PATH . '/main.inc.php'; |
|
35 | +require DOL_BASE_PATH.'/main.inc.php'; |
|
36 | 36 | require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture-rec.class.php'; |
37 | 37 | require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; |
38 | 38 | require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; |
39 | -if (! empty($conf->projet->enabled)) { |
|
40 | - require_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php'; |
|
39 | +if (!empty($conf->projet->enabled)) { |
|
40 | + require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; |
|
41 | 41 | //require_once DOL_DOCUMENT_ROOT . '/core/class/html.formprojet.class.php'; |
42 | 42 | } |
43 | -require_once DOL_DOCUMENT_ROOT . '/core/class/html.formprojet.class.php'; |
|
44 | -require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php'; |
|
45 | -require_once DOL_DOCUMENT_ROOT . '/core/lib/invoice.lib.php'; |
|
46 | -require_once DOL_DOCUMENT_ROOT . '/core/class/extrafields.class.php'; |
|
43 | +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; |
|
44 | +require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; |
|
45 | +require_once DOL_DOCUMENT_ROOT.'/core/lib/invoice.lib.php'; |
|
46 | +require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; |
|
47 | 47 | |
48 | 48 | // Load translation files required by the page |
49 | 49 | $langs->loadLangs(array('bills', 'compta', 'admin', 'other')); |
50 | 50 | |
51 | -$action = GETPOST('action','alpha'); |
|
52 | -$massaction = GETPOST('massaction','alpha'); |
|
53 | -$show_files = GETPOST('show_files','int'); |
|
54 | -$confirm = GETPOST('confirm','alpha'); |
|
51 | +$action = GETPOST('action', 'alpha'); |
|
52 | +$massaction = GETPOST('massaction', 'alpha'); |
|
53 | +$show_files = GETPOST('show_files', 'int'); |
|
54 | +$confirm = GETPOST('confirm', 'alpha'); |
|
55 | 55 | $cancel = GETPOST('cancel', 'alpha'); |
56 | 56 | $toselect = GETPOST('toselect', 'array'); |
57 | -$contextpage= GETPOST('contextpage','aZ')?GETPOST('contextpage','aZ'):'invoicetemplatelist'; // To manage different context of search |
|
57 | +$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'invoicetemplatelist'; // To manage different context of search |
|
58 | 58 | |
59 | 59 | // Security check |
60 | -$id=(GETPOST('facid','int')?GETPOST('facid','int'):GETPOST('id','int')); |
|
61 | -$lineid=GETPOST('lineid','int'); |
|
62 | -$ref=GETPOST('ref','alpha'); |
|
63 | -if ($user->societe_id) $socid=$user->societe_id; |
|
60 | +$id = (GETPOST('facid', 'int') ?GETPOST('facid', 'int') : GETPOST('id', 'int')); |
|
61 | +$lineid = GETPOST('lineid', 'int'); |
|
62 | +$ref = GETPOST('ref', 'alpha'); |
|
63 | +if ($user->societe_id) $socid = $user->societe_id; |
|
64 | 64 | $objecttype = 'facture_rec'; |
65 | 65 | if ($action == "create" || $action == "add") $objecttype = ''; |
66 | 66 | $result = restrictedArea($user, 'facture', $id, $objecttype); |
67 | -$projectid = GETPOST('projectid','int'); |
|
68 | - |
|
69 | -$search_ref=GETPOST('search_ref'); |
|
70 | -$search_societe=GETPOST('search_societe'); |
|
71 | -$search_montant_ht=GETPOST('search_montant_ht'); |
|
72 | -$search_montant_vat=GETPOST('search_montant_vat'); |
|
73 | -$search_montant_ttc=GETPOST('search_montant_ttc'); |
|
74 | -$search_payment_mode=GETPOST('search_payment_mode'); |
|
75 | -$search_payment_term=GETPOST('search_payment_term'); |
|
76 | -$search_day=GETPOST('search_day','int'); |
|
77 | -$search_year=GETPOST('search_year','int'); |
|
78 | -$search_month=GETPOST('search_month','int'); |
|
79 | -$search_day_date_when=GETPOST('search_day_date_when','int'); |
|
80 | -$search_year_date_when=GETPOST('search_year_date_when','int'); |
|
81 | -$search_month_date_when=GETPOST('search_month_date_when','int'); |
|
82 | -$search_recurring=GETPOST('search_recurring','int'); |
|
83 | -$search_frequency=GETPOST('search_frequency','alpha'); |
|
84 | -$search_unit_frequency=GETPOST('search_unit_frequency','alpha'); |
|
85 | -$search_status=GETPOST('search_status','int'); |
|
86 | - |
|
87 | -$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; |
|
88 | -$sortfield = GETPOST("sortfield",'alpha'); |
|
89 | -$sortorder = GETPOST("sortorder",'alpha'); |
|
90 | -$page = GETPOST("page",'int'); |
|
67 | +$projectid = GETPOST('projectid', 'int'); |
|
68 | + |
|
69 | +$search_ref = GETPOST('search_ref'); |
|
70 | +$search_societe = GETPOST('search_societe'); |
|
71 | +$search_montant_ht = GETPOST('search_montant_ht'); |
|
72 | +$search_montant_vat = GETPOST('search_montant_vat'); |
|
73 | +$search_montant_ttc = GETPOST('search_montant_ttc'); |
|
74 | +$search_payment_mode = GETPOST('search_payment_mode'); |
|
75 | +$search_payment_term = GETPOST('search_payment_term'); |
|
76 | +$search_day = GETPOST('search_day', 'int'); |
|
77 | +$search_year = GETPOST('search_year', 'int'); |
|
78 | +$search_month = GETPOST('search_month', 'int'); |
|
79 | +$search_day_date_when = GETPOST('search_day_date_when', 'int'); |
|
80 | +$search_year_date_when = GETPOST('search_year_date_when', 'int'); |
|
81 | +$search_month_date_when = GETPOST('search_month_date_when', 'int'); |
|
82 | +$search_recurring = GETPOST('search_recurring', 'int'); |
|
83 | +$search_frequency = GETPOST('search_frequency', 'alpha'); |
|
84 | +$search_unit_frequency = GETPOST('search_unit_frequency', 'alpha'); |
|
85 | +$search_status = GETPOST('search_status', 'int'); |
|
86 | + |
|
87 | +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; |
|
88 | +$sortfield = GETPOST("sortfield", 'alpha'); |
|
89 | +$sortorder = GETPOST("sortorder", 'alpha'); |
|
90 | +$page = GETPOST("page", 'int'); |
|
91 | 91 | if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 |
92 | 92 | $offset = $limit * $page; |
93 | -if (! $sortorder) $sortorder='DESC'; |
|
94 | -if (! $sortfield) $sortfield='f.titre'; |
|
93 | +if (!$sortorder) $sortorder = 'DESC'; |
|
94 | +if (!$sortfield) $sortfield = 'f.titre'; |
|
95 | 95 | $pageprev = $page - 1; |
96 | 96 | $pagenext = $page + 1; |
97 | 97 | |
@@ -106,18 +106,18 @@ discard block |
||
106 | 106 | } |
107 | 107 | |
108 | 108 | // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context |
109 | -$hookmanager->initHooks(array('invoicereccard','globalcard')); |
|
109 | +$hookmanager->initHooks(array('invoicereccard', 'globalcard')); |
|
110 | 110 | $extrafields = new ExtraFields($db); |
111 | 111 | |
112 | 112 | // fetch optionals attributes and labels |
113 | 113 | $extralabels = $extrafields->fetch_name_optionals_label('facture_rec'); |
114 | -$search_array_options=$extrafields->getOptionalsFromPost($object->table_element,'','search_'); |
|
114 | +$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); |
|
115 | 115 | |
116 | 116 | $permissionnote = $user->rights->facture->creer; // Used by the include of actions_setnotes.inc.php |
117 | -$permissiondellink=$user->rights->facture->creer; // Used by the include of actions_dellink.inc.php |
|
117 | +$permissiondellink = $user->rights->facture->creer; // Used by the include of actions_dellink.inc.php |
|
118 | 118 | $permissiontoedit = $user->rights->facture->creer; // Used by the include of actions_lineupdonw.inc.php |
119 | 119 | |
120 | -$arrayfields=array( |
|
120 | +$arrayfields = array( |
|
121 | 121 | 'f.titre'=>array('label'=>$langs->trans("Ref"), 'checked'=>1), |
122 | 122 | 's.nom'=>array('label'=>$langs->trans("ThirdParty"), 'checked'=>1), |
123 | 123 | 'f.total'=>array('label'=>$langs->trans("AmountHT"), 'checked'=>1), |
@@ -138,9 +138,9 @@ discard block |
||
138 | 138 | // Extra fields |
139 | 139 | if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) |
140 | 140 | { |
141 | - foreach($extrafields->attribute_label as $key => $val) |
|
141 | + foreach ($extrafields->attribute_label as $key => $val) |
|
142 | 142 | { |
143 | - if (! empty($extrafields->attribute_list[$key])) $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>(($extrafields->attribute_list[$key]<0)?0:1), 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>(abs($extrafields->attribute_list[$key])!=3 && $extrafields->attribute_perms[$key])); |
|
143 | + if (!empty($extrafields->attribute_list[$key])) $arrayfields["ef.".$key] = array('label'=>$extrafields->attribute_label[$key], 'checked'=>(($extrafields->attribute_list[$key] < 0) ? 0 : 1), 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>(abs($extrafields->attribute_list[$key]) != 3 && $extrafields->attribute_perms[$key])); |
|
144 | 144 | } |
145 | 145 | } |
146 | 146 | |
@@ -149,8 +149,8 @@ discard block |
||
149 | 149 | * Actions |
150 | 150 | */ |
151 | 151 | |
152 | -if (GETPOST('cancel','alpha')) { $action='list'; $massaction=''; } |
|
153 | -if (! GETPOST('confirmmassaction','alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction=''; } |
|
152 | +if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; } |
|
153 | +if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; } |
|
154 | 154 | |
155 | 155 | $parameters = array('socid' => $socid); |
156 | 156 | $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks |
@@ -158,32 +158,32 @@ discard block |
||
158 | 158 | |
159 | 159 | if (empty($reshook)) |
160 | 160 | { |
161 | - if (GETPOST('cancel','alpha')) $action=''; |
|
161 | + if (GETPOST('cancel', 'alpha')) $action = ''; |
|
162 | 162 | |
163 | 163 | // Selection of new fields |
164 | 164 | include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; |
165 | 165 | |
166 | 166 | // Do we click on purge search criteria ? |
167 | - if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha')) // All test are required to be compatible with all browsers |
|
167 | + if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All test are required to be compatible with all browsers |
|
168 | 168 | { |
169 | - $search_ref=''; |
|
170 | - $search_societe=''; |
|
171 | - $search_montant_ht=''; |
|
172 | - $search_montant_vat=''; |
|
173 | - $search_montant_ttc=''; |
|
174 | - $search_payment_mode=''; |
|
175 | - $search_payment_term=''; |
|
176 | - $search_day=''; |
|
177 | - $search_year=''; |
|
178 | - $search_month=''; |
|
179 | - $search_day_date_when=''; |
|
180 | - $search_year_date_when=''; |
|
181 | - $search_month_date_when=''; |
|
182 | - $search_recurring=''; |
|
183 | - $search_frequency=''; |
|
184 | - $search_unit_frequency=''; |
|
185 | - $search_status=''; |
|
186 | - $search_array_options=array(); |
|
169 | + $search_ref = ''; |
|
170 | + $search_societe = ''; |
|
171 | + $search_montant_ht = ''; |
|
172 | + $search_montant_vat = ''; |
|
173 | + $search_montant_ttc = ''; |
|
174 | + $search_payment_mode = ''; |
|
175 | + $search_payment_term = ''; |
|
176 | + $search_day = ''; |
|
177 | + $search_year = ''; |
|
178 | + $search_month = ''; |
|
179 | + $search_day_date_when = ''; |
|
180 | + $search_year_date_when = ''; |
|
181 | + $search_month_date_when = ''; |
|
182 | + $search_recurring = ''; |
|
183 | + $search_frequency = ''; |
|
184 | + $search_unit_frequency = ''; |
|
185 | + $search_status = ''; |
|
186 | + $search_array_options = array(); |
|
187 | 187 | } |
188 | 188 | |
189 | 189 | // Mass actions |
@@ -200,33 +200,33 @@ discard block |
||
200 | 200 | * View |
201 | 201 | */ |
202 | 202 | |
203 | -llxHeader('',$langs->trans("RepeatableInvoices"),'ch-facture.html#s-fac-facture-rec'); |
|
203 | +llxHeader('', $langs->trans("RepeatableInvoices"), 'ch-facture.html#s-fac-facture-rec'); |
|
204 | 204 | |
205 | 205 | $form = new Form($db); |
206 | 206 | $formother = new FormOther($db); |
207 | -if (! empty($conf->projet->enabled)) { $formproject = new FormProjets($db); } |
|
207 | +if (!empty($conf->projet->enabled)) { $formproject = new FormProjets($db); } |
|
208 | 208 | $companystatic = new Societe($db); |
209 | 209 | $invoicerectmp = new FactureRec($db); |
210 | 210 | |
211 | 211 | $now = dol_now(); |
212 | -$tmparray=dol_getdate($now); |
|
213 | -$today = dol_mktime(23,59,59,$tmparray['mon'],$tmparray['mday'],$tmparray['year']); // Today is last second of current day |
|
212 | +$tmparray = dol_getdate($now); |
|
213 | +$today = dol_mktime(23, 59, 59, $tmparray['mon'], $tmparray['mday'], $tmparray['year']); // Today is last second of current day |
|
214 | 214 | |
215 | 215 | |
216 | 216 | /* |
217 | 217 | * List mode |
218 | 218 | */ |
219 | 219 | $sql = "SELECT s.nom as name, s.rowid as socid, f.rowid as facid, f.titre, f.total, f.tva as total_vat, f.total_ttc, f.frequency, f.unit_frequency,"; |
220 | -$sql.= " f.nb_gen_done, f.nb_gen_max, f.date_last_gen, f.date_when, f.suspended,"; |
|
221 | -$sql.= " f.datec, f.tms,"; |
|
222 | -$sql.= " f.fk_cond_reglement, f.fk_mode_reglement"; |
|
223 | -$sql.= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture_rec as f"; |
|
224 | -if (! $user->rights->societe->client->voir && ! $socid) { |
|
220 | +$sql .= " f.nb_gen_done, f.nb_gen_max, f.date_last_gen, f.date_when, f.suspended,"; |
|
221 | +$sql .= " f.datec, f.tms,"; |
|
222 | +$sql .= " f.fk_cond_reglement, f.fk_mode_reglement"; |
|
223 | +$sql .= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture_rec as f"; |
|
224 | +if (!$user->rights->societe->client->voir && !$socid) { |
|
225 | 225 | $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; |
226 | 226 | } |
227 | -$sql.= " WHERE f.fk_soc = s.rowid"; |
|
228 | -$sql.= ' AND f.entity IN ('.getEntity('invoice').')'; |
|
229 | -if (! $user->rights->societe->client->voir && ! $socid) { |
|
227 | +$sql .= " WHERE f.fk_soc = s.rowid"; |
|
228 | +$sql .= ' AND f.entity IN ('.getEntity('invoice').')'; |
|
229 | +if (!$user->rights->societe->client->voir && !$socid) { |
|
230 | 230 | $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; |
231 | 231 | } |
232 | 232 | if ($search_ref) $sql .= natural_search('f.titre', $search_ref); |
@@ -234,46 +234,46 @@ discard block |
||
234 | 234 | if ($search_montant_ht != '') $sql .= natural_search('f.total', $search_montant_ht, 1); |
235 | 235 | if ($search_montant_vat != '') $sql .= natural_search('f.tva', $search_montant_vat, 1); |
236 | 236 | if ($search_montant_ttc != '') $sql .= natural_search('f.total_ttc', $search_montant_ttc, 1); |
237 | -if (! empty($search_payment_mode) && $search_payment_mode != '-1') $sql .= natural_search('f.fk_mode_reglement', $search_payment_mode, 1); |
|
238 | -if (! empty($search_payment_term) && $search_payment_term != '-1') $sql .= natural_search('f.fk_cond_reglement', $search_payment_term, 1); |
|
237 | +if (!empty($search_payment_mode) && $search_payment_mode != '-1') $sql .= natural_search('f.fk_mode_reglement', $search_payment_mode, 1); |
|
238 | +if (!empty($search_payment_term) && $search_payment_term != '-1') $sql .= natural_search('f.fk_cond_reglement', $search_payment_term, 1); |
|
239 | 239 | if ($search_recurring == '1') $sql .= ' AND f.frequency > 0'; |
240 | 240 | if ($search_recurring == '0') $sql .= ' AND (f.frequency IS NULL or f.frequency = 0)'; |
241 | 241 | if ($search_frequency != '') $sql .= natural_search('f.frequency', $search_frequency, 1); |
242 | 242 | if ($search_unit_frequency != '') $sql .= ' AND f.frequency > 0'.natural_search('f.unit_frequency', $search_unit_frequency); |
243 | 243 | if ($search_status != '' && $search_status >= -1) |
244 | 244 | { |
245 | - if ($search_status == 0) $sql.= ' AND frequency = 0 AND suspended = 0'; |
|
246 | - if ($search_status == 1) $sql.= ' AND frequency != 0 AND suspended = 0'; |
|
247 | - if ($search_status == -1) $sql.= ' AND suspended = 1'; |
|
245 | + if ($search_status == 0) $sql .= ' AND frequency = 0 AND suspended = 0'; |
|
246 | + if ($search_status == 1) $sql .= ' AND frequency != 0 AND suspended = 0'; |
|
247 | + if ($search_status == -1) $sql .= ' AND suspended = 1'; |
|
248 | 248 | } |
249 | 249 | if ($search_month > 0) |
250 | 250 | { |
251 | 251 | if ($search_year > 0 && empty($search_day)) |
252 | - $sql.= " AND f.date_last_gen BETWEEN '".$db->idate(dol_get_first_day($search_year,$search_month,false))."' AND '".$db->idate(dol_get_last_day($search_year,$search_month,false))."'"; |
|
253 | - else if ($search_year > 0 && ! empty($search_day)) |
|
254 | - $sql.= " AND f.date_last_gen BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $search_month, $search_day, $search_year))."' AND '".$db->idate(dol_mktime(23, 59, 59, $search_month, $search_day, $search_year))."'"; |
|
252 | + $sql .= " AND f.date_last_gen BETWEEN '".$db->idate(dol_get_first_day($search_year, $search_month, false))."' AND '".$db->idate(dol_get_last_day($search_year, $search_month, false))."'"; |
|
253 | + else if ($search_year > 0 && !empty($search_day)) |
|
254 | + $sql .= " AND f.date_last_gen BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $search_month, $search_day, $search_year))."' AND '".$db->idate(dol_mktime(23, 59, 59, $search_month, $search_day, $search_year))."'"; |
|
255 | 255 | else |
256 | - $sql.= " AND date_format(f.date_last_gen, '%m') = '".$db->escape($search_month)."'"; |
|
256 | + $sql .= " AND date_format(f.date_last_gen, '%m') = '".$db->escape($search_month)."'"; |
|
257 | 257 | } |
258 | 258 | else if ($search_year > 0) |
259 | 259 | { |
260 | - $sql.= " AND f.date_last_gen BETWEEN '".$db->idate(dol_get_first_day($search_year,1,false))."' AND '".$db->idate(dol_get_last_day($search_year,12,false))."'"; |
|
260 | + $sql .= " AND f.date_last_gen BETWEEN '".$db->idate(dol_get_first_day($search_year, 1, false))."' AND '".$db->idate(dol_get_last_day($search_year, 12, false))."'"; |
|
261 | 261 | } |
262 | 262 | if ($search_month_date_when > 0) |
263 | 263 | { |
264 | 264 | if ($search_year_date_when > 0 && empty($search_day_date_when)) |
265 | - $sql.= " AND f.date_when BETWEEN '".$db->idate(dol_get_first_day($search_year_date_when,$search_month_date_when,false))."' AND '".$db->idate(dol_get_last_day($search_year_date_when,$search_month_date_when,false))."'"; |
|
266 | - else if ($search_year_date_when > 0 && ! empty($search_day_date_when)) |
|
267 | - $sql.= " AND f.date_date_when_reglement BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $search_month_date_when, $search_day_date_when, $search_year_date_when))."' AND '".$db->idate(dol_mktime(23, 59, 59, $search_month_date_when, $search_day_date_when, $search_year_date_when))."'"; |
|
265 | + $sql .= " AND f.date_when BETWEEN '".$db->idate(dol_get_first_day($search_year_date_when, $search_month_date_when, false))."' AND '".$db->idate(dol_get_last_day($search_year_date_when, $search_month_date_when, false))."'"; |
|
266 | + else if ($search_year_date_when > 0 && !empty($search_day_date_when)) |
|
267 | + $sql .= " AND f.date_date_when_reglement BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $search_month_date_when, $search_day_date_when, $search_year_date_when))."' AND '".$db->idate(dol_mktime(23, 59, 59, $search_month_date_when, $search_day_date_when, $search_year_date_when))."'"; |
|
268 | 268 | else |
269 | - $sql.= " AND date_format(f.date_when, '%m') = '".$db->escape($search_month_date_when)."'"; |
|
269 | + $sql .= " AND date_format(f.date_when, '%m') = '".$db->escape($search_month_date_when)."'"; |
|
270 | 270 | } |
271 | 271 | else if ($search_year_date_when > 0) |
272 | 272 | { |
273 | - $sql.= " AND f.date_when BETWEEN '".$db->idate(dol_get_first_day($search_year_date_when,1,false))."' AND '".$db->idate(dol_get_last_day($search_year_date_when,12,false))."'"; |
|
273 | + $sql .= " AND f.date_when BETWEEN '".$db->idate(dol_get_first_day($search_year_date_when, 1, false))."' AND '".$db->idate(dol_get_last_day($search_year_date_when, 12, false))."'"; |
|
274 | 274 | } |
275 | 275 | |
276 | -$sql.= $db->order($sortfield, $sortorder); |
|
276 | +$sql .= $db->order($sortfield, $sortorder); |
|
277 | 277 | |
278 | 278 | $nbtotalofrecords = ''; |
279 | 279 | if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) |
@@ -287,43 +287,43 @@ discard block |
||
287 | 287 | } |
288 | 288 | } |
289 | 289 | |
290 | -$sql.= $db->plimit($limit+1,$offset); |
|
290 | +$sql .= $db->plimit($limit + 1, $offset); |
|
291 | 291 | |
292 | 292 | $resql = $db->query($sql); |
293 | 293 | if ($resql) |
294 | 294 | { |
295 | 295 | $num = $db->num_rows($resql); |
296 | 296 | |
297 | - $param=''; |
|
298 | - if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage); |
|
299 | - if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit); |
|
300 | - if ($socid) $param.='&socid='.urlencode($socid); |
|
301 | - if ($search_day) $param.='&search_day='.urlencode($search_day); |
|
302 | - if ($search_month) $param.='&search_month='.urlencode($search_month); |
|
303 | - if ($search_year) $param.='&search_year=' .urlencode($search_year); |
|
304 | - if ($search_day_date_when) $param.='&search_day_date_when='.urlencode($search_day_date_when); |
|
305 | - if ($search_month_date_when) $param.='&search_month_date_when='.urlencode($search_month_date_when); |
|
306 | - if ($search_year_date_when) $param.='&search_year_date_when=' .urlencode($search_year_date_when); |
|
307 | - if ($search_ref) $param.='&search_ref=' .urlencode($search_ref); |
|
308 | - if ($search_societe) $param.='&search_societe=' .urlencode($search_societe); |
|
309 | - if ($search_montant_ht != '') $param.='&search_montant_ht=' .urlencode($search_montant_ht); |
|
310 | - if ($search_montant_vat != '') $param.='&search_montant_vat='.urlencode($search_montant_vat); |
|
311 | - if ($search_montant_ttc != '') $param.='&search_montant_ttc='.urlencode($search_montant_ttc); |
|
312 | - if ($search_payment_mode != '') $param.='&search_payment_mode='.urlencode($search_payment_mode); |
|
313 | - if ($search_payment_type != '') $param.='&search_payment_type='.urlencode($search_payment_type); |
|
314 | - if ($search_recurring != '' && $search_recurrning != '-1') $param.='&search_recurring=' .urlencode($search_recurring); |
|
315 | - if ($search_frequency > 0) $param.='&search_frequency=' .urlencode($search_frequency); |
|
316 | - if ($search_unit_frequency != '') $param.='&search_unit_frequency='.urlencode($search_unit_frequency); |
|
317 | - if ($search_status != '') $param.='&search_status='.urlencode($search_status); |
|
318 | - if ($option) $param.="&option=".urlencode($option); |
|
319 | - if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss); |
|
297 | + $param = ''; |
|
298 | + if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); |
|
299 | + if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); |
|
300 | + if ($socid) $param .= '&socid='.urlencode($socid); |
|
301 | + if ($search_day) $param .= '&search_day='.urlencode($search_day); |
|
302 | + if ($search_month) $param .= '&search_month='.urlencode($search_month); |
|
303 | + if ($search_year) $param .= '&search_year='.urlencode($search_year); |
|
304 | + if ($search_day_date_when) $param .= '&search_day_date_when='.urlencode($search_day_date_when); |
|
305 | + if ($search_month_date_when) $param .= '&search_month_date_when='.urlencode($search_month_date_when); |
|
306 | + if ($search_year_date_when) $param .= '&search_year_date_when='.urlencode($search_year_date_when); |
|
307 | + if ($search_ref) $param .= '&search_ref='.urlencode($search_ref); |
|
308 | + if ($search_societe) $param .= '&search_societe='.urlencode($search_societe); |
|
309 | + if ($search_montant_ht != '') $param .= '&search_montant_ht='.urlencode($search_montant_ht); |
|
310 | + if ($search_montant_vat != '') $param .= '&search_montant_vat='.urlencode($search_montant_vat); |
|
311 | + if ($search_montant_ttc != '') $param .= '&search_montant_ttc='.urlencode($search_montant_ttc); |
|
312 | + if ($search_payment_mode != '') $param .= '&search_payment_mode='.urlencode($search_payment_mode); |
|
313 | + if ($search_payment_type != '') $param .= '&search_payment_type='.urlencode($search_payment_type); |
|
314 | + if ($search_recurring != '' && $search_recurrning != '-1') $param .= '&search_recurring='.urlencode($search_recurring); |
|
315 | + if ($search_frequency > 0) $param .= '&search_frequency='.urlencode($search_frequency); |
|
316 | + if ($search_unit_frequency != '') $param .= '&search_unit_frequency='.urlencode($search_unit_frequency); |
|
317 | + if ($search_status != '') $param .= '&search_status='.urlencode($search_status); |
|
318 | + if ($option) $param .= "&option=".urlencode($option); |
|
319 | + if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss); |
|
320 | 320 | // Add $param from extra fields |
321 | 321 | include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; |
322 | 322 | |
323 | - $massactionbutton=$form->selectMassAction('', $massaction == 'presend' ? array() : array('presend'=>$langs->trans("SendByMail"), 'builddoc'=>$langs->trans("PDFMerge"))); |
|
323 | + $massactionbutton = $form->selectMassAction('', $massaction == 'presend' ? array() : array('presend'=>$langs->trans("SendByMail"), 'builddoc'=>$langs->trans("PDFMerge"))); |
|
324 | 324 | |
325 | - $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; |
|
326 | - $selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields |
|
325 | + $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; |
|
326 | + $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields |
|
327 | 327 | //$selectedfields.=$form->showCheckAddButtons('checkforselect', 1); |
328 | 328 | |
329 | 329 | print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'; |
@@ -337,133 +337,133 @@ discard block |
||
337 | 337 | print '<input type="hidden" name="contextpage" value="'.$contextpage.'">'; |
338 | 338 | print '<input type="hidden" name="viewstatut" value="'.$viewstatut.'">'; |
339 | 339 | |
340 | - print_barre_liste($langs->trans("RepeatableInvoices"),$page,$_SERVER['PHP_SELF'],$param,$sortfield,$sortorder,'',$num,$nbtotalofrecords,'title_accountancy.png',0,'','', $limit); |
|
340 | + print_barre_liste($langs->trans("RepeatableInvoices"), $page, $_SERVER['PHP_SELF'], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_accountancy.png', 0, '', '', $limit); |
|
341 | 341 | |
342 | 342 | print $langs->trans("ToCreateAPredefinedInvoice", $langs->transnoentitiesnoconv("ChangeIntoRepeatableInvoice")).'<br><br>'; |
343 | 343 | |
344 | 344 | $i = 0; |
345 | 345 | |
346 | 346 | print '<div class="div-table-responsive">'; |
347 | - print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n"; |
|
347 | + print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n"; |
|
348 | 348 | |
349 | 349 | // Filters lines |
350 | 350 | print '<tr class="liste_titre_filter">'; |
351 | 351 | // Ref |
352 | - if (! empty($arrayfields['f.titre']['checked'])) |
|
352 | + if (!empty($arrayfields['f.titre']['checked'])) |
|
353 | 353 | { |
354 | 354 | print '<td class="liste_titre" align="left">'; |
355 | 355 | print '<input class="flat" size="6" type="text" name="search_ref" value="'.dol_escape_htmltag($search_ref).'">'; |
356 | 356 | print '</td>'; |
357 | 357 | } |
358 | 358 | // Thirpdarty |
359 | - if (! empty($arrayfields['s.nom']['checked'])) |
|
359 | + if (!empty($arrayfields['s.nom']['checked'])) |
|
360 | 360 | { |
361 | 361 | print '<td class="liste_titre" align="left"><input class="flat" type="text" size="8" name="search_societe" value="'.dol_escape_htmltag($search_societe).'"></td>'; |
362 | 362 | } |
363 | - if (! empty($arrayfields['f.total']['checked'])) |
|
363 | + if (!empty($arrayfields['f.total']['checked'])) |
|
364 | 364 | { |
365 | 365 | // Amount net |
366 | 366 | print '<td class="liste_titre" align="right">'; |
367 | 367 | print '<input class="flat" type="text" size="5" name="search_montant_ht" value="'.dol_escape_htmltag($search_montant_ht).'">'; |
368 | 368 | print '</td>'; |
369 | 369 | } |
370 | - if (! empty($arrayfields['f.tva']['checked'])) |
|
370 | + if (!empty($arrayfields['f.tva']['checked'])) |
|
371 | 371 | { |
372 | 372 | // Amount Vat |
373 | 373 | print '<td class="liste_titre" align="right">'; |
374 | 374 | print '<input class="flat" type="text" size="5" name="search_montant_vat" value="'.dol_escape_htmltag($search_montant_vat).'">'; |
375 | 375 | print '</td>'; |
376 | 376 | } |
377 | - if (! empty($arrayfields['f.total_ttc']['checked'])) |
|
377 | + if (!empty($arrayfields['f.total_ttc']['checked'])) |
|
378 | 378 | { |
379 | 379 | // Amount |
380 | 380 | print '<td class="liste_titre" align="right">'; |
381 | 381 | print '<input class="flat" type="text" size="5" name="search_montant_ttc" value="'.dol_escape_htmltag($search_montant_ttc).'">'; |
382 | 382 | print '</td>'; |
383 | 383 | } |
384 | - if (! empty($arrayfields['f.fk_cond_reglement']['checked'])) |
|
384 | + if (!empty($arrayfields['f.fk_cond_reglement']['checked'])) |
|
385 | 385 | { |
386 | 386 | // Payment term |
387 | 387 | print '<td class="liste_titre" align="right">'; |
388 | 388 | print $form->select_conditions_paiements($search_payment_term, 'search_payment_term', -1, 1, 1, 'maxwidth100'); |
389 | 389 | print "</td>"; |
390 | 390 | } |
391 | - if (! empty($arrayfields['f.fk_mode_reglement']['checked'])) |
|
391 | + if (!empty($arrayfields['f.fk_mode_reglement']['checked'])) |
|
392 | 392 | { |
393 | 393 | // Payment mode |
394 | 394 | print '<td class="liste_titre" align="right">'; |
395 | 395 | print $form->select_types_paiements($search_payment_mode, 'search_payment_mode', '', 0, 1, 1, 0, 1, 'maxwidth100'); |
396 | 396 | print '</td>'; |
397 | 397 | } |
398 | - if (! empty($arrayfields['recurring']['checked'])) |
|
398 | + if (!empty($arrayfields['recurring']['checked'])) |
|
399 | 399 | { |
400 | 400 | // Recurring or not |
401 | 401 | print '<td class="liste_titre" align="center">'; |
402 | 402 | print $form->selectyesno('search_recurring', $search_recurring, 1, false, 1); |
403 | 403 | print '</td>'; |
404 | 404 | } |
405 | - if (! empty($arrayfields['f.frequency']['checked'])) |
|
405 | + if (!empty($arrayfields['f.frequency']['checked'])) |
|
406 | 406 | { |
407 | 407 | // Recurring or not |
408 | 408 | print '<td class="liste_titre" align="center">'; |
409 | 409 | print '<input class="flat" type="text" size="1" name="search_frequency" value="'.dol_escape_htmltag($search_frequency).'">'; |
410 | 410 | print '</td>'; |
411 | 411 | } |
412 | - if (! empty($arrayfields['f.unit_frequency']['checked'])) |
|
412 | + if (!empty($arrayfields['f.unit_frequency']['checked'])) |
|
413 | 413 | { |
414 | 414 | // Frequency unit |
415 | 415 | print '<td class="liste_titre" align="center">'; |
416 | 416 | print '<input class="flat" type="text" size="1" name="search_unit_frequency" value="'.dol_escape_htmltag($search_unit_frequency).'">'; |
417 | 417 | print '</td>'; |
418 | 418 | } |
419 | - if (! empty($arrayfields['f.nb_gen_done']['checked'])) |
|
419 | + if (!empty($arrayfields['f.nb_gen_done']['checked'])) |
|
420 | 420 | { |
421 | 421 | // Nb generation |
422 | 422 | print '<td class="liste_titre" align="center">'; |
423 | 423 | print '</td>'; |
424 | 424 | } |
425 | 425 | // Date invoice |
426 | - if (! empty($arrayfields['f.date_last_gen']['checked'])) |
|
426 | + if (!empty($arrayfields['f.date_last_gen']['checked'])) |
|
427 | 427 | { |
428 | 428 | print '<td class="liste_titre nowraponall" align="center">'; |
429 | - if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print '<input class="flat valignmiddle" type="text" size="1" maxlength="2" name="search_day" value="'.$search_day.'">'; |
|
429 | + if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print '<input class="flat valignmiddle" type="text" size="1" maxlength="2" name="search_day" value="'.$search_day.'">'; |
|
430 | 430 | print '<input class="flat valignmiddle width25" type="text" size="1" maxlength="2" name="search_month" value="'.$search_month.'">'; |
431 | - $formother->select_year($search_year?$search_year:-1,'search_year',1, 20, 5, 0, 0, '', 'witdhauto valignmiddle'); |
|
431 | + $formother->select_year($search_year ? $search_year : -1, 'search_year', 1, 20, 5, 0, 0, '', 'witdhauto valignmiddle'); |
|
432 | 432 | print '</td>'; |
433 | 433 | } |
434 | 434 | // Date next generation |
435 | - if (! empty($arrayfields['f.date_when']['checked'])) |
|
435 | + if (!empty($arrayfields['f.date_when']['checked'])) |
|
436 | 436 | { |
437 | 437 | print '<td class="liste_titre nowraponall" align="center">'; |
438 | - if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print '<input class="flat valignmiddle" type="text" size="1" maxlength="2" name="search_day_date_when" value="'.$search_day_date_when.'">'; |
|
438 | + if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print '<input class="flat valignmiddle" type="text" size="1" maxlength="2" name="search_day_date_when" value="'.$search_day_date_when.'">'; |
|
439 | 439 | print '<input class="flat valignmiddle width25" type="text" size="1" maxlength="2" name="search_month_date_when" value="'.$search_month_date_when.'">'; |
440 | - $formother->select_year($search_year_date_when?$search_year_date_when:-1,'search_year_date_when',1, 20, 5, 0, 0, '', 'witdhauto valignmiddle'); |
|
440 | + $formother->select_year($search_year_date_when ? $search_year_date_when : -1, 'search_year_date_when', 1, 20, 5, 0, 0, '', 'witdhauto valignmiddle'); |
|
441 | 441 | print '</td>'; |
442 | 442 | } |
443 | 443 | // Extra fields |
444 | 444 | include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; |
445 | 445 | |
446 | 446 | // Fields from hook |
447 | - $parameters=array('arrayfields'=>$arrayfields); |
|
448 | - $reshook=$hookmanager->executeHooks('printFieldListOption',$parameters); // Note that $action and $object may have been modified by hook |
|
447 | + $parameters = array('arrayfields'=>$arrayfields); |
|
448 | + $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook |
|
449 | 449 | print $hookmanager->resPrint; |
450 | 450 | // Date creation |
451 | - if (! empty($arrayfields['f.datec']['checked'])) |
|
451 | + if (!empty($arrayfields['f.datec']['checked'])) |
|
452 | 452 | { |
453 | 453 | print '<td class="liste_titre">'; |
454 | 454 | print '</td>'; |
455 | 455 | } |
456 | 456 | // Date modification |
457 | - if (! empty($arrayfields['f.tms']['checked'])) |
|
457 | + if (!empty($arrayfields['f.tms']['checked'])) |
|
458 | 458 | { |
459 | 459 | print '<td class="liste_titre">'; |
460 | 460 | print '</td>'; |
461 | 461 | } |
462 | 462 | // Status |
463 | - if (! empty($arrayfields['status']['checked'])) |
|
463 | + if (!empty($arrayfields['status']['checked'])) |
|
464 | 464 | { |
465 | 465 | print '<td class="liste_titre" align="center">'; |
466 | - $liststatus=array( |
|
466 | + $liststatus = array( |
|
467 | 467 | 0=>$langs->trans("Draft"), |
468 | 468 | 1=>$langs->trans("Active"), |
469 | 469 | -1=>$langs->trans("Disabled"), |
@@ -473,143 +473,143 @@ discard block |
||
473 | 473 | } |
474 | 474 | // Action column |
475 | 475 | print '<td class="liste_titre" align="middle">'; |
476 | - $searchpicto=$form->showFilterAndCheckAddButtons(0, 'checkforselect', 1); |
|
476 | + $searchpicto = $form->showFilterAndCheckAddButtons(0, 'checkforselect', 1); |
|
477 | 477 | print $searchpicto; |
478 | 478 | print '</td>'; |
479 | 479 | print "</tr>\n"; |
480 | 480 | |
481 | 481 | |
482 | 482 | print '<tr class="liste_titre">'; |
483 | - if (! empty($arrayfields['f.titre']['checked'])) print_liste_field_titre($arrayfields['f.titre']['label'],$_SERVER['PHP_SELF'],"f.titre","",$param,"",$sortfield,$sortorder); |
|
484 | - if (! empty($arrayfields['s.nom']['checked'])) print_liste_field_titre($arrayfields['s.nom']['label'],$_SERVER['PHP_SELF'],"s.nom","",$param,"",$sortfield,$sortorder); |
|
485 | - if (! empty($arrayfields['f.total']['checked'])) print_liste_field_titre($arrayfields['f.total']['label'],$_SERVER['PHP_SELF'],"f.total","",$param,'align="right"',$sortfield,$sortorder); |
|
486 | - if (! empty($arrayfields['f.tva']['checked'])) print_liste_field_titre($arrayfields['f.tva']['label'],$_SERVER['PHP_SELF'],"f.tva","",$param,'align="right"',$sortfield,$sortorder); |
|
487 | - if (! empty($arrayfields['f.total_ttc']['checked'])) print_liste_field_titre($arrayfields['f.total_ttc']['label'],$_SERVER['PHP_SELF'],"f.total_ttc","",$param,'align="right"',$sortfield,$sortorder); |
|
488 | - if (! empty($arrayfields['f.fk_cond_reglement']['checked'])) print_liste_field_titre($arrayfields['f.fk_cond_reglement']['label'],$_SERVER['PHP_SELF'],"f.fk_cond_reglement","",$param,'',$sortfield,$sortorder); |
|
489 | - if (! empty($arrayfields['f.fk_mode_reglement']['checked'])) print_liste_field_titre($arrayfields['f.fk_mode_reglement']['label'],$_SERVER['PHP_SELF'],"f.fk_mode_reglement","",$param,'',$sortfield,$sortorder); |
|
490 | - if (! empty($arrayfields['recurring']['checked'])) print_liste_field_titre($arrayfields['recurring']['label'],$_SERVER['PHP_SELF'],"recurring","",$param,'align="center"',$sortfield,$sortorder); |
|
491 | - if (! empty($arrayfields['f.frequency']['checked'])) print_liste_field_titre($arrayfields['f.frequency']['label'],$_SERVER['PHP_SELF'],"f.frequency","",$param,'align="center"',$sortfield,$sortorder); |
|
492 | - if (! empty($arrayfields['f.unit_frequency']['checked'])) print_liste_field_titre($arrayfields['f.unit_frequency']['label'],$_SERVER['PHP_SELF'],"f.unit_frequency","",$param,'align="center"',$sortfield,$sortorder); |
|
493 | - if (! empty($arrayfields['f.nb_gen_done']['checked'])) print_liste_field_titre($arrayfields['f.nb_gen_done']['label'],$_SERVER['PHP_SELF'],"f.nb_gen_done","",$param,'align="center"',$sortfield,$sortorder); |
|
494 | - if (! empty($arrayfields['f.date_last_gen']['checked'])) print_liste_field_titre($arrayfields['f.date_last_gen']['label'],$_SERVER['PHP_SELF'],"f.date_last_gen","",$param,'align="center"',$sortfield,$sortorder); |
|
495 | - if (! empty($arrayfields['f.date_when']['checked'])) print_liste_field_titre($arrayfields['f.date_when']['label'],$_SERVER['PHP_SELF'],"f.date_when","",$param,'align="center"',$sortfield,$sortorder); |
|
496 | - if (! empty($arrayfields['f.datec']['checked'])) print_liste_field_titre($arrayfields['f.datec']['label'],$_SERVER['PHP_SELF'],"f.datec","",$param,'align="center"',$sortfield,$sortorder); |
|
497 | - if (! empty($arrayfields['f.tms']['checked'])) print_liste_field_titre($arrayfields['f.tms']['label'],$_SERVER['PHP_SELF'],"f.tms","",$param,'align="center"',$sortfield,$sortorder); |
|
498 | - if (! empty($arrayfields['status']['checked'])) print_liste_field_titre($arrayfields['status']['label'],$_SERVER['PHP_SELF'],"f.suspended,f.frequency","",$param,'align="center"',$sortfield,$sortorder); |
|
499 | - print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"],"",'','','align="center"',$sortfield,$sortorder,'nomaxwidthsearch ')."\n"; |
|
483 | + if (!empty($arrayfields['f.titre']['checked'])) print_liste_field_titre($arrayfields['f.titre']['label'], $_SERVER['PHP_SELF'], "f.titre", "", $param, "", $sortfield, $sortorder); |
|
484 | + if (!empty($arrayfields['s.nom']['checked'])) print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER['PHP_SELF'], "s.nom", "", $param, "", $sortfield, $sortorder); |
|
485 | + if (!empty($arrayfields['f.total']['checked'])) print_liste_field_titre($arrayfields['f.total']['label'], $_SERVER['PHP_SELF'], "f.total", "", $param, 'align="right"', $sortfield, $sortorder); |
|
486 | + if (!empty($arrayfields['f.tva']['checked'])) print_liste_field_titre($arrayfields['f.tva']['label'], $_SERVER['PHP_SELF'], "f.tva", "", $param, 'align="right"', $sortfield, $sortorder); |
|
487 | + if (!empty($arrayfields['f.total_ttc']['checked'])) print_liste_field_titre($arrayfields['f.total_ttc']['label'], $_SERVER['PHP_SELF'], "f.total_ttc", "", $param, 'align="right"', $sortfield, $sortorder); |
|
488 | + if (!empty($arrayfields['f.fk_cond_reglement']['checked'])) print_liste_field_titre($arrayfields['f.fk_cond_reglement']['label'], $_SERVER['PHP_SELF'], "f.fk_cond_reglement", "", $param, '', $sortfield, $sortorder); |
|
489 | + if (!empty($arrayfields['f.fk_mode_reglement']['checked'])) print_liste_field_titre($arrayfields['f.fk_mode_reglement']['label'], $_SERVER['PHP_SELF'], "f.fk_mode_reglement", "", $param, '', $sortfield, $sortorder); |
|
490 | + if (!empty($arrayfields['recurring']['checked'])) print_liste_field_titre($arrayfields['recurring']['label'], $_SERVER['PHP_SELF'], "recurring", "", $param, 'align="center"', $sortfield, $sortorder); |
|
491 | + if (!empty($arrayfields['f.frequency']['checked'])) print_liste_field_titre($arrayfields['f.frequency']['label'], $_SERVER['PHP_SELF'], "f.frequency", "", $param, 'align="center"', $sortfield, $sortorder); |
|
492 | + if (!empty($arrayfields['f.unit_frequency']['checked'])) print_liste_field_titre($arrayfields['f.unit_frequency']['label'], $_SERVER['PHP_SELF'], "f.unit_frequency", "", $param, 'align="center"', $sortfield, $sortorder); |
|
493 | + if (!empty($arrayfields['f.nb_gen_done']['checked'])) print_liste_field_titre($arrayfields['f.nb_gen_done']['label'], $_SERVER['PHP_SELF'], "f.nb_gen_done", "", $param, 'align="center"', $sortfield, $sortorder); |
|
494 | + if (!empty($arrayfields['f.date_last_gen']['checked'])) print_liste_field_titre($arrayfields['f.date_last_gen']['label'], $_SERVER['PHP_SELF'], "f.date_last_gen", "", $param, 'align="center"', $sortfield, $sortorder); |
|
495 | + if (!empty($arrayfields['f.date_when']['checked'])) print_liste_field_titre($arrayfields['f.date_when']['label'], $_SERVER['PHP_SELF'], "f.date_when", "", $param, 'align="center"', $sortfield, $sortorder); |
|
496 | + if (!empty($arrayfields['f.datec']['checked'])) print_liste_field_titre($arrayfields['f.datec']['label'], $_SERVER['PHP_SELF'], "f.datec", "", $param, 'align="center"', $sortfield, $sortorder); |
|
497 | + if (!empty($arrayfields['f.tms']['checked'])) print_liste_field_titre($arrayfields['f.tms']['label'], $_SERVER['PHP_SELF'], "f.tms", "", $param, 'align="center"', $sortfield, $sortorder); |
|
498 | + if (!empty($arrayfields['status']['checked'])) print_liste_field_titre($arrayfields['status']['label'], $_SERVER['PHP_SELF'], "f.suspended,f.frequency", "", $param, 'align="center"', $sortfield, $sortorder); |
|
499 | + print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', 'align="center"', $sortfield, $sortorder, 'nomaxwidthsearch ')."\n"; |
|
500 | 500 | print "</tr>\n"; |
501 | 501 | |
502 | 502 | if ($num > 0) |
503 | 503 | { |
504 | - $i=0; |
|
505 | - $totalarray=array(); |
|
506 | - while ($i < min($num,$limit)) |
|
504 | + $i = 0; |
|
505 | + $totalarray = array(); |
|
506 | + while ($i < min($num, $limit)) |
|
507 | 507 | { |
508 | 508 | $objp = $db->fetch_object($resql); |
509 | 509 | if (empty($objp)) break; |
510 | 510 | |
511 | - $companystatic->id=$objp->socid; |
|
512 | - $companystatic->name=$objp->name; |
|
511 | + $companystatic->id = $objp->socid; |
|
512 | + $companystatic->name = $objp->name; |
|
513 | 513 | |
514 | - $invoicerectmp->id=$objp->id?$objp->id:$objp->facid; |
|
515 | - $invoicerectmp->frequency=$objp->frequency; |
|
516 | - $invoicerectmp->suspended=$objp->suspended; |
|
517 | - $invoicerectmp->unit_frequency=$objp->unit_frequency; |
|
518 | - $invoicerectmp->nb_gen_max=$objp->nb_gen_max; |
|
519 | - $invoicerectmp->nb_gen_done=$objp->nb_gen_done; |
|
520 | - $invoicerectmp->ref=$objp->titre; |
|
514 | + $invoicerectmp->id = $objp->id ? $objp->id : $objp->facid; |
|
515 | + $invoicerectmp->frequency = $objp->frequency; |
|
516 | + $invoicerectmp->suspended = $objp->suspended; |
|
517 | + $invoicerectmp->unit_frequency = $objp->unit_frequency; |
|
518 | + $invoicerectmp->nb_gen_max = $objp->nb_gen_max; |
|
519 | + $invoicerectmp->nb_gen_done = $objp->nb_gen_done; |
|
520 | + $invoicerectmp->ref = $objp->titre; |
|
521 | 521 | |
522 | 522 | print '<tr class="oddeven">'; |
523 | 523 | |
524 | - if (! empty($arrayfields['f.titre']['checked'])) |
|
524 | + if (!empty($arrayfields['f.titre']['checked'])) |
|
525 | 525 | { |
526 | 526 | print '<td>'; |
527 | 527 | print $invoicerectmp->getNomUrl(1); |
528 | 528 | print "</a>"; |
529 | 529 | print "</td>\n"; |
530 | - if (! $i) $totalarray['nbfield']++; |
|
530 | + if (!$i) $totalarray['nbfield']++; |
|
531 | 531 | } |
532 | - if (! empty($arrayfields['s.nom']['checked'])) |
|
532 | + if (!empty($arrayfields['s.nom']['checked'])) |
|
533 | 533 | { |
534 | - print '<td class="tdoverflowmax200">'.$companystatic->getNomUrl(1,'customer').'</td>'; |
|
535 | - if (! $i) $totalarray['nbfield']++; |
|
534 | + print '<td class="tdoverflowmax200">'.$companystatic->getNomUrl(1, 'customer').'</td>'; |
|
535 | + if (!$i) $totalarray['nbfield']++; |
|
536 | 536 | } |
537 | - if (! empty($arrayfields['f.total']['checked'])) |
|
537 | + if (!empty($arrayfields['f.total']['checked'])) |
|
538 | 538 | { |
539 | 539 | print '<td align="right">'.price($objp->total).'</td>'."\n"; |
540 | - if (! $i) $totalarray['nbfield']++; |
|
541 | - if (! $i) $totalarray['pos'][$totalarray['nbfield']]='f.total'; |
|
540 | + if (!$i) $totalarray['nbfield']++; |
|
541 | + if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'f.total'; |
|
542 | 542 | $totalarray['val']['f.total'] += $objp->total; |
543 | 543 | } |
544 | - if (! empty($arrayfields['f.tva']['checked'])) |
|
544 | + if (!empty($arrayfields['f.tva']['checked'])) |
|
545 | 545 | { |
546 | 546 | print '<td align="right">'.price($objp->total_vat).'</td>'."\n"; |
547 | - if (! $i) $totalarray['nbfield']++; |
|
548 | - if (! $i) $totalarray['pos'][$totalarray['nbfield']]='f.tva'; |
|
547 | + if (!$i) $totalarray['nbfield']++; |
|
548 | + if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'f.tva'; |
|
549 | 549 | $totalarray['val']['f.tva'] += $objp->total_vat; |
550 | 550 | } |
551 | - if (! empty($arrayfields['f.total_ttc']['checked'])) |
|
551 | + if (!empty($arrayfields['f.total_ttc']['checked'])) |
|
552 | 552 | { |
553 | 553 | print '<td align="right">'.price($objp->total_ttc).'</td>'."\n"; |
554 | - if (! $i) $totalarray['nbfield']++; |
|
555 | - if (! $i) $totalarray['pos'][$totalarray['nbfield']]='f.total_ttc'; |
|
554 | + if (!$i) $totalarray['nbfield']++; |
|
555 | + if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'f.total_ttc'; |
|
556 | 556 | $totalarray['val']['f.total_ttc'] += $objp->total_ttc; |
557 | 557 | } |
558 | 558 | // Payment term |
559 | - if (! empty($arrayfields['f.fk_cond_reglement']['checked'])) |
|
559 | + if (!empty($arrayfields['f.fk_cond_reglement']['checked'])) |
|
560 | 560 | { |
561 | 561 | print '<td align="right">'; |
562 | 562 | print $form->form_conditions_reglement('', $objp->fk_cond_reglement, 'none'); |
563 | 563 | print '</td>'."\n"; |
564 | - if (! $i) $totalarray['nbfield']++; |
|
564 | + if (!$i) $totalarray['nbfield']++; |
|
565 | 565 | } |
566 | 566 | // Payment mode |
567 | - if (! empty($arrayfields['f.fk_mode_reglement']['checked'])) |
|
567 | + if (!empty($arrayfields['f.fk_mode_reglement']['checked'])) |
|
568 | 568 | { |
569 | 569 | print '<td align="right">'; |
570 | 570 | print $form->form_modes_reglement('', $objp->fk_mode_reglement, 'none'); |
571 | 571 | print '</td>'."\n"; |
572 | - if (! $i) $totalarray['nbfield']++; |
|
572 | + if (!$i) $totalarray['nbfield']++; |
|
573 | 573 | } |
574 | - if (! empty($arrayfields['recurring']['checked'])) |
|
574 | + if (!empty($arrayfields['recurring']['checked'])) |
|
575 | 575 | { |
576 | - print '<td align="center">'.yn($objp->frequency?1:0).'</td>'; |
|
577 | - if (! $i) $totalarray['nbfield']++; |
|
576 | + print '<td align="center">'.yn($objp->frequency ? 1 : 0).'</td>'; |
|
577 | + if (!$i) $totalarray['nbfield']++; |
|
578 | 578 | } |
579 | - if (! empty($arrayfields['f.frequency']['checked'])) |
|
579 | + if (!empty($arrayfields['f.frequency']['checked'])) |
|
580 | 580 | { |
581 | 581 | print '<td align="center">'.($objp->frequency > 0 ? $objp->frequency : '').'</td>'; |
582 | - if (! $i) $totalarray['nbfield']++; |
|
582 | + if (!$i) $totalarray['nbfield']++; |
|
583 | 583 | } |
584 | - if (! empty($arrayfields['f.unit_frequency']['checked'])) |
|
584 | + if (!empty($arrayfields['f.unit_frequency']['checked'])) |
|
585 | 585 | { |
586 | 586 | print '<td align="center">'.($objp->frequency > 0 ? $objp->unit_frequency : '').'</td>'; |
587 | - if (! $i) $totalarray['nbfield']++; |
|
587 | + if (!$i) $totalarray['nbfield']++; |
|
588 | 588 | } |
589 | - if (! empty($arrayfields['f.nb_gen_done']['checked'])) |
|
589 | + if (!empty($arrayfields['f.nb_gen_done']['checked'])) |
|
590 | 590 | { |
591 | 591 | print '<td align="center">'; |
592 | - print ($objp->frequency > 0 ? $objp->nb_gen_done.($objp->nb_gen_max>0?' / '. $objp->nb_gen_max:'') : '<span class="opacitymedium">'.$langs->trans('NA').'</span>'); |
|
592 | + print ($objp->frequency > 0 ? $objp->nb_gen_done.($objp->nb_gen_max > 0 ? ' / '.$objp->nb_gen_max : '') : '<span class="opacitymedium">'.$langs->trans('NA').'</span>'); |
|
593 | 593 | print '</td>'; |
594 | - if (! $i) $totalarray['nbfield']++; |
|
594 | + if (!$i) $totalarray['nbfield']++; |
|
595 | 595 | } |
596 | 596 | // Date last generation |
597 | - if (! empty($arrayfields['f.date_last_gen']['checked'])) |
|
597 | + if (!empty($arrayfields['f.date_last_gen']['checked'])) |
|
598 | 598 | { |
599 | 599 | print '<td align="center">'; |
600 | - print ($objp->frequency > 0 ? dol_print_date($db->jdate($objp->date_last_gen),'day') : '<span class="opacitymedium">'.$langs->trans('NA').'</span>'); |
|
600 | + print ($objp->frequency > 0 ? dol_print_date($db->jdate($objp->date_last_gen), 'day') : '<span class="opacitymedium">'.$langs->trans('NA').'</span>'); |
|
601 | 601 | print '</td>'; |
602 | - if (! $i) $totalarray['nbfield']++; |
|
602 | + if (!$i) $totalarray['nbfield']++; |
|
603 | 603 | } |
604 | 604 | // Date next generation |
605 | - if (! empty($arrayfields['f.date_when']['checked'])) |
|
605 | + if (!empty($arrayfields['f.date_when']['checked'])) |
|
606 | 606 | { |
607 | 607 | print '<td align="center">'; |
608 | 608 | print '<div class="nowraponall">'; |
609 | - print ($objp->frequency ? ($invoicerectmp->isMaxNbGenReached()?'<strike>':'').dol_print_date($db->jdate($objp->date_when),'day').($invoicerectmp->isMaxNbGenReached()?'</strike>':'') : '<span class="opacitymedium">'.$langs->trans('NA').'</span>'); |
|
610 | - if (! $invoicerectmp->isMaxNbGenReached()) |
|
609 | + print ($objp->frequency ? ($invoicerectmp->isMaxNbGenReached() ? '<strike>' : '').dol_print_date($db->jdate($objp->date_when), 'day').($invoicerectmp->isMaxNbGenReached() ? '</strike>' : '') : '<span class="opacitymedium">'.$langs->trans('NA').'</span>'); |
|
610 | + if (!$invoicerectmp->isMaxNbGenReached()) |
|
611 | 611 | { |
612 | - if (! $objp->suspended && $objp->frequency > 0 && $db->jdate($objp->date_when) && $db->jdate($objp->date_when) < $now) print img_warning($langs->trans("Late")); |
|
612 | + if (!$objp->suspended && $objp->frequency > 0 && $db->jdate($objp->date_when) && $db->jdate($objp->date_when) < $now) print img_warning($langs->trans("Late")); |
|
613 | 613 | } |
614 | 614 | else |
615 | 615 | { |
@@ -617,28 +617,28 @@ discard block |
||
617 | 617 | } |
618 | 618 | print '</div>'; |
619 | 619 | print '</td>'; |
620 | - if (! $i) $totalarray['nbfield']++; |
|
620 | + if (!$i) $totalarray['nbfield']++; |
|
621 | 621 | } |
622 | - if (! empty($arrayfields['f.datec']['checked'])) |
|
622 | + if (!empty($arrayfields['f.datec']['checked'])) |
|
623 | 623 | { |
624 | 624 | print '<td align="center">'; |
625 | - print dol_print_date($db->jdate($objp->datec),'dayhour'); |
|
625 | + print dol_print_date($db->jdate($objp->datec), 'dayhour'); |
|
626 | 626 | print '</td>'; |
627 | - if (! $i) $totalarray['nbfield']++; |
|
627 | + if (!$i) $totalarray['nbfield']++; |
|
628 | 628 | } |
629 | - if (! empty($arrayfields['f.tms']['checked'])) |
|
629 | + if (!empty($arrayfields['f.tms']['checked'])) |
|
630 | 630 | { |
631 | 631 | print '<td align="center">'; |
632 | - print dol_print_date($db->jdate($objp->tms),'dayhour'); |
|
632 | + print dol_print_date($db->jdate($objp->tms), 'dayhour'); |
|
633 | 633 | print '</td>'; |
634 | - if (! $i) $totalarray['nbfield']++; |
|
634 | + if (!$i) $totalarray['nbfield']++; |
|
635 | 635 | } |
636 | - if (! empty($arrayfields['status']['checked'])) |
|
636 | + if (!empty($arrayfields['status']['checked'])) |
|
637 | 637 | { |
638 | 638 | print '<td align="center">'; |
639 | - print $invoicerectmp->getLibStatut(3,0); |
|
639 | + print $invoicerectmp->getLibStatut(3, 0); |
|
640 | 640 | print '</td>'; |
641 | - if (! $i) $totalarray['nbfield']++; |
|
641 | + if (!$i) $totalarray['nbfield']++; |
|
642 | 642 | } |
643 | 643 | // Action column |
644 | 644 | print '<td align="center">'; |
@@ -650,7 +650,7 @@ discard block |
||
650 | 650 | } |
651 | 651 | elseif (empty($objp->frequency) || $db->jdate($objp->date_when) <= $today) |
652 | 652 | { |
653 | - print '<a href="' . BASE_URI . '?controller=compta/facture&method=card&action=create&socid=' . $objp->socid . '&fac_rec=' . $objp->facid . '">'; |
|
653 | + print '<a href="'.BASE_URI.'?controller=compta/facture&method=card&action=create&socid='.$objp->socid.'&fac_rec='.$objp->facid.'">'; |
|
654 | 654 | print $langs->trans("CreateBill").'</a>'; |
655 | 655 | } |
656 | 656 | else |
@@ -662,7 +662,7 @@ discard block |
||
662 | 662 | { |
663 | 663 | print " "; |
664 | 664 | } |
665 | - if (! $i) $totalarray['nbfield']++; |
|
665 | + if (!$i) $totalarray['nbfield']++; |
|
666 | 666 | print "</td>"; |
667 | 667 | |
668 | 668 | print "</tr>\n"; |
@@ -672,8 +672,8 @@ discard block |
||
672 | 672 | } |
673 | 673 | else |
674 | 674 | { |
675 | - $colspan=1; |
|
676 | - foreach($arrayfields as $key => $val) { if (! empty($val['checked'])) $colspan++; } |
|
675 | + $colspan = 1; |
|
676 | + foreach ($arrayfields as $key => $val) { if (!empty($val['checked'])) $colspan++; } |
|
677 | 677 | print '<tr><td colspan="'.$colspan.'" class="opacitymedium">'.$langs->trans("NoRecordFound").'</td></tr>'; |
678 | 678 | } |
679 | 679 | |
@@ -682,11 +682,11 @@ discard block |
||
682 | 682 | if (isset($totalarray['pos'])) |
683 | 683 | { |
684 | 684 | print '<tr class="liste_total">'; |
685 | - $i=0; |
|
685 | + $i = 0; |
|
686 | 686 | while ($i < $totalarray['nbfield']) |
687 | 687 | { |
688 | 688 | $i++; |
689 | - if (! empty($totalarray['pos'][$i])) print '<td align="right">'.price($totalarray['val'][$totalarray['pos'][$i]]).'</td>'; |
|
689 | + if (!empty($totalarray['pos'][$i])) print '<td align="right">'.price($totalarray['val'][$totalarray['pos'][$i]]).'</td>'; |
|
690 | 690 | else |
691 | 691 | { |
692 | 692 | if ($i == 1) |
@@ -60,9 +60,13 @@ discard block |
||
60 | 60 | $id=(GETPOST('facid','int')?GETPOST('facid','int'):GETPOST('id','int')); |
61 | 61 | $lineid=GETPOST('lineid','int'); |
62 | 62 | $ref=GETPOST('ref','alpha'); |
63 | -if ($user->societe_id) $socid=$user->societe_id; |
|
63 | +if ($user->societe_id) { |
|
64 | + $socid=$user->societe_id; |
|
65 | +} |
|
64 | 66 | $objecttype = 'facture_rec'; |
65 | -if ($action == "create" || $action == "add") $objecttype = ''; |
|
67 | +if ($action == "create" || $action == "add") { |
|
68 | + $objecttype = ''; |
|
69 | +} |
|
66 | 70 | $result = restrictedArea($user, 'facture', $id, $objecttype); |
67 | 71 | $projectid = GETPOST('projectid','int'); |
68 | 72 | |
@@ -90,8 +94,12 @@ discard block |
||
90 | 94 | $page = GETPOST("page",'int'); |
91 | 95 | if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 |
92 | 96 | $offset = $limit * $page; |
93 | -if (! $sortorder) $sortorder='DESC'; |
|
94 | -if (! $sortfield) $sortfield='f.titre'; |
|
97 | +if (! $sortorder) { |
|
98 | + $sortorder='DESC'; |
|
99 | +} |
|
100 | +if (! $sortfield) { |
|
101 | + $sortfield='f.titre'; |
|
102 | +} |
|
95 | 103 | $pageprev = $page - 1; |
96 | 104 | $pagenext = $page + 1; |
97 | 105 | |
@@ -140,7 +148,9 @@ discard block |
||
140 | 148 | { |
141 | 149 | foreach($extrafields->attribute_label as $key => $val) |
142 | 150 | { |
143 | - if (! empty($extrafields->attribute_list[$key])) $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>(($extrafields->attribute_list[$key]<0)?0:1), 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>(abs($extrafields->attribute_list[$key])!=3 && $extrafields->attribute_perms[$key])); |
|
151 | + if (! empty($extrafields->attribute_list[$key])) { |
|
152 | + $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>(($extrafields->attribute_list[$key]<0)?0:1), 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>(abs($extrafields->attribute_list[$key])!=3 && $extrafields->attribute_perms[$key])); |
|
153 | + } |
|
144 | 154 | } |
145 | 155 | } |
146 | 156 | |
@@ -154,19 +164,25 @@ discard block |
||
154 | 164 | |
155 | 165 | $parameters = array('socid' => $socid); |
156 | 166 | $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks |
157 | -if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); |
|
167 | +if ($reshook < 0) { |
|
168 | + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); |
|
169 | +} |
|
158 | 170 | |
159 | 171 | if (empty($reshook)) |
160 | 172 | { |
161 | - if (GETPOST('cancel','alpha')) $action=''; |
|
173 | + if (GETPOST('cancel','alpha')) { |
|
174 | + $action=''; |
|
175 | + } |
|
162 | 176 | |
163 | 177 | // Selection of new fields |
164 | 178 | include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; |
165 | 179 | |
166 | 180 | // Do we click on purge search criteria ? |
167 | - if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha')) // All test are required to be compatible with all browsers |
|
181 | + if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha')) { |
|
182 | + // All test are required to be compatible with all browsers |
|
168 | 183 | { |
169 | 184 | $search_ref=''; |
185 | + } |
|
170 | 186 | $search_societe=''; |
171 | 187 | $search_montant_ht=''; |
172 | 188 | $search_montant_vat=''; |
@@ -229,46 +245,74 @@ discard block |
||
229 | 245 | if (! $user->rights->societe->client->voir && ! $socid) { |
230 | 246 | $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; |
231 | 247 | } |
232 | -if ($search_ref) $sql .= natural_search('f.titre', $search_ref); |
|
233 | -if ($search_societe) $sql .= natural_search('s.nom', $search_societe); |
|
234 | -if ($search_montant_ht != '') $sql .= natural_search('f.total', $search_montant_ht, 1); |
|
235 | -if ($search_montant_vat != '') $sql .= natural_search('f.tva', $search_montant_vat, 1); |
|
236 | -if ($search_montant_ttc != '') $sql .= natural_search('f.total_ttc', $search_montant_ttc, 1); |
|
237 | -if (! empty($search_payment_mode) && $search_payment_mode != '-1') $sql .= natural_search('f.fk_mode_reglement', $search_payment_mode, 1); |
|
238 | -if (! empty($search_payment_term) && $search_payment_term != '-1') $sql .= natural_search('f.fk_cond_reglement', $search_payment_term, 1); |
|
239 | -if ($search_recurring == '1') $sql .= ' AND f.frequency > 0'; |
|
240 | -if ($search_recurring == '0') $sql .= ' AND (f.frequency IS NULL or f.frequency = 0)'; |
|
241 | -if ($search_frequency != '') $sql .= natural_search('f.frequency', $search_frequency, 1); |
|
242 | -if ($search_unit_frequency != '') $sql .= ' AND f.frequency > 0'.natural_search('f.unit_frequency', $search_unit_frequency); |
|
248 | +if ($search_ref) { |
|
249 | + $sql .= natural_search('f.titre', $search_ref); |
|
250 | +} |
|
251 | +if ($search_societe) { |
|
252 | + $sql .= natural_search('s.nom', $search_societe); |
|
253 | +} |
|
254 | +if ($search_montant_ht != '') { |
|
255 | + $sql .= natural_search('f.total', $search_montant_ht, 1); |
|
256 | +} |
|
257 | +if ($search_montant_vat != '') { |
|
258 | + $sql .= natural_search('f.tva', $search_montant_vat, 1); |
|
259 | +} |
|
260 | +if ($search_montant_ttc != '') { |
|
261 | + $sql .= natural_search('f.total_ttc', $search_montant_ttc, 1); |
|
262 | +} |
|
263 | +if (! empty($search_payment_mode) && $search_payment_mode != '-1') { |
|
264 | + $sql .= natural_search('f.fk_mode_reglement', $search_payment_mode, 1); |
|
265 | +} |
|
266 | +if (! empty($search_payment_term) && $search_payment_term != '-1') { |
|
267 | + $sql .= natural_search('f.fk_cond_reglement', $search_payment_term, 1); |
|
268 | +} |
|
269 | +if ($search_recurring == '1') { |
|
270 | + $sql .= ' AND f.frequency > 0'; |
|
271 | +} |
|
272 | +if ($search_recurring == '0') { |
|
273 | + $sql .= ' AND (f.frequency IS NULL or f.frequency = 0)'; |
|
274 | +} |
|
275 | +if ($search_frequency != '') { |
|
276 | + $sql .= natural_search('f.frequency', $search_frequency, 1); |
|
277 | +} |
|
278 | +if ($search_unit_frequency != '') { |
|
279 | + $sql .= ' AND f.frequency > 0'.natural_search('f.unit_frequency', $search_unit_frequency); |
|
280 | +} |
|
243 | 281 | if ($search_status != '' && $search_status >= -1) |
244 | 282 | { |
245 | - if ($search_status == 0) $sql.= ' AND frequency = 0 AND suspended = 0'; |
|
246 | - if ($search_status == 1) $sql.= ' AND frequency != 0 AND suspended = 0'; |
|
247 | - if ($search_status == -1) $sql.= ' AND suspended = 1'; |
|
248 | -} |
|
283 | + if ($search_status == 0) { |
|
284 | + $sql.= ' AND frequency = 0 AND suspended = 0'; |
|
285 | + } |
|
286 | + if ($search_status == 1) { |
|
287 | + $sql.= ' AND frequency != 0 AND suspended = 0'; |
|
288 | + } |
|
289 | + if ($search_status == -1) { |
|
290 | + $sql.= ' AND suspended = 1'; |
|
291 | + } |
|
292 | + } |
|
249 | 293 | if ($search_month > 0) |
250 | 294 | { |
251 | - if ($search_year > 0 && empty($search_day)) |
|
252 | - $sql.= " AND f.date_last_gen BETWEEN '".$db->idate(dol_get_first_day($search_year,$search_month,false))."' AND '".$db->idate(dol_get_last_day($search_year,$search_month,false))."'"; |
|
253 | - else if ($search_year > 0 && ! empty($search_day)) |
|
254 | - $sql.= " AND f.date_last_gen BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $search_month, $search_day, $search_year))."' AND '".$db->idate(dol_mktime(23, 59, 59, $search_month, $search_day, $search_year))."'"; |
|
255 | - else |
|
256 | - $sql.= " AND date_format(f.date_last_gen, '%m') = '".$db->escape($search_month)."'"; |
|
257 | -} |
|
258 | -else if ($search_year > 0) |
|
295 | + if ($search_year > 0 && empty($search_day)) { |
|
296 | + $sql.= " AND f.date_last_gen BETWEEN '".$db->idate(dol_get_first_day($search_year,$search_month,false))."' AND '".$db->idate(dol_get_last_day($search_year,$search_month,false))."'"; |
|
297 | + } else if ($search_year > 0 && ! empty($search_day)) { |
|
298 | + $sql.= " AND f.date_last_gen BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $search_month, $search_day, $search_year))."' AND '".$db->idate(dol_mktime(23, 59, 59, $search_month, $search_day, $search_year))."'"; |
|
299 | + } else { |
|
300 | + $sql.= " AND date_format(f.date_last_gen, '%m') = '".$db->escape($search_month)."'"; |
|
301 | + } |
|
302 | + } else if ($search_year > 0) |
|
259 | 303 | { |
260 | 304 | $sql.= " AND f.date_last_gen BETWEEN '".$db->idate(dol_get_first_day($search_year,1,false))."' AND '".$db->idate(dol_get_last_day($search_year,12,false))."'"; |
261 | 305 | } |
262 | 306 | if ($search_month_date_when > 0) |
263 | 307 | { |
264 | - if ($search_year_date_when > 0 && empty($search_day_date_when)) |
|
265 | - $sql.= " AND f.date_when BETWEEN '".$db->idate(dol_get_first_day($search_year_date_when,$search_month_date_when,false))."' AND '".$db->idate(dol_get_last_day($search_year_date_when,$search_month_date_when,false))."'"; |
|
266 | - else if ($search_year_date_when > 0 && ! empty($search_day_date_when)) |
|
267 | - $sql.= " AND f.date_date_when_reglement BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $search_month_date_when, $search_day_date_when, $search_year_date_when))."' AND '".$db->idate(dol_mktime(23, 59, 59, $search_month_date_when, $search_day_date_when, $search_year_date_when))."'"; |
|
268 | - else |
|
269 | - $sql.= " AND date_format(f.date_when, '%m') = '".$db->escape($search_month_date_when)."'"; |
|
270 | -} |
|
271 | -else if ($search_year_date_when > 0) |
|
308 | + if ($search_year_date_when > 0 && empty($search_day_date_when)) { |
|
309 | + $sql.= " AND f.date_when BETWEEN '".$db->idate(dol_get_first_day($search_year_date_when,$search_month_date_when,false))."' AND '".$db->idate(dol_get_last_day($search_year_date_when,$search_month_date_when,false))."'"; |
|
310 | + } else if ($search_year_date_when > 0 && ! empty($search_day_date_when)) { |
|
311 | + $sql.= " AND f.date_date_when_reglement BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $search_month_date_when, $search_day_date_when, $search_year_date_when))."' AND '".$db->idate(dol_mktime(23, 59, 59, $search_month_date_when, $search_day_date_when, $search_year_date_when))."'"; |
|
312 | + } else { |
|
313 | + $sql.= " AND date_format(f.date_when, '%m') = '".$db->escape($search_month_date_when)."'"; |
|
314 | + } |
|
315 | + } else if ($search_year_date_when > 0) |
|
272 | 316 | { |
273 | 317 | $sql.= " AND f.date_when BETWEEN '".$db->idate(dol_get_first_day($search_year_date_when,1,false))."' AND '".$db->idate(dol_get_last_day($search_year_date_when,12,false))."'"; |
274 | 318 | } |
@@ -280,9 +324,11 @@ discard block |
||
280 | 324 | { |
281 | 325 | $result = $db->query($sql); |
282 | 326 | $nbtotalofrecords = $db->num_rows($result); |
283 | - if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 |
|
327 | + if (($page * $limit) > $nbtotalofrecords) { |
|
328 | + // if total resultset is smaller then paging size (filtering), goto and load page 0 |
|
284 | 329 | { |
285 | 330 | $page = 0; |
331 | + } |
|
286 | 332 | $offset = 0; |
287 | 333 | } |
288 | 334 | } |
@@ -295,28 +341,72 @@ discard block |
||
295 | 341 | $num = $db->num_rows($resql); |
296 | 342 | |
297 | 343 | $param=''; |
298 | - if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage); |
|
299 | - if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit); |
|
300 | - if ($socid) $param.='&socid='.urlencode($socid); |
|
301 | - if ($search_day) $param.='&search_day='.urlencode($search_day); |
|
302 | - if ($search_month) $param.='&search_month='.urlencode($search_month); |
|
303 | - if ($search_year) $param.='&search_year=' .urlencode($search_year); |
|
304 | - if ($search_day_date_when) $param.='&search_day_date_when='.urlencode($search_day_date_when); |
|
305 | - if ($search_month_date_when) $param.='&search_month_date_when='.urlencode($search_month_date_when); |
|
306 | - if ($search_year_date_when) $param.='&search_year_date_when=' .urlencode($search_year_date_when); |
|
307 | - if ($search_ref) $param.='&search_ref=' .urlencode($search_ref); |
|
308 | - if ($search_societe) $param.='&search_societe=' .urlencode($search_societe); |
|
309 | - if ($search_montant_ht != '') $param.='&search_montant_ht=' .urlencode($search_montant_ht); |
|
310 | - if ($search_montant_vat != '') $param.='&search_montant_vat='.urlencode($search_montant_vat); |
|
311 | - if ($search_montant_ttc != '') $param.='&search_montant_ttc='.urlencode($search_montant_ttc); |
|
312 | - if ($search_payment_mode != '') $param.='&search_payment_mode='.urlencode($search_payment_mode); |
|
313 | - if ($search_payment_type != '') $param.='&search_payment_type='.urlencode($search_payment_type); |
|
314 | - if ($search_recurring != '' && $search_recurrning != '-1') $param.='&search_recurring=' .urlencode($search_recurring); |
|
315 | - if ($search_frequency > 0) $param.='&search_frequency=' .urlencode($search_frequency); |
|
316 | - if ($search_unit_frequency != '') $param.='&search_unit_frequency='.urlencode($search_unit_frequency); |
|
317 | - if ($search_status != '') $param.='&search_status='.urlencode($search_status); |
|
318 | - if ($option) $param.="&option=".urlencode($option); |
|
319 | - if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss); |
|
344 | + if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { |
|
345 | + $param.='&contextpage='.urlencode($contextpage); |
|
346 | + } |
|
347 | + if ($limit > 0 && $limit != $conf->liste_limit) { |
|
348 | + $param.='&limit='.urlencode($limit); |
|
349 | + } |
|
350 | + if ($socid) { |
|
351 | + $param.='&socid='.urlencode($socid); |
|
352 | + } |
|
353 | + if ($search_day) { |
|
354 | + $param.='&search_day='.urlencode($search_day); |
|
355 | + } |
|
356 | + if ($search_month) { |
|
357 | + $param.='&search_month='.urlencode($search_month); |
|
358 | + } |
|
359 | + if ($search_year) { |
|
360 | + $param.='&search_year=' .urlencode($search_year); |
|
361 | + } |
|
362 | + if ($search_day_date_when) { |
|
363 | + $param.='&search_day_date_when='.urlencode($search_day_date_when); |
|
364 | + } |
|
365 | + if ($search_month_date_when) { |
|
366 | + $param.='&search_month_date_when='.urlencode($search_month_date_when); |
|
367 | + } |
|
368 | + if ($search_year_date_when) { |
|
369 | + $param.='&search_year_date_when=' .urlencode($search_year_date_when); |
|
370 | + } |
|
371 | + if ($search_ref) { |
|
372 | + $param.='&search_ref=' .urlencode($search_ref); |
|
373 | + } |
|
374 | + if ($search_societe) { |
|
375 | + $param.='&search_societe=' .urlencode($search_societe); |
|
376 | + } |
|
377 | + if ($search_montant_ht != '') { |
|
378 | + $param.='&search_montant_ht=' .urlencode($search_montant_ht); |
|
379 | + } |
|
380 | + if ($search_montant_vat != '') { |
|
381 | + $param.='&search_montant_vat='.urlencode($search_montant_vat); |
|
382 | + } |
|
383 | + if ($search_montant_ttc != '') { |
|
384 | + $param.='&search_montant_ttc='.urlencode($search_montant_ttc); |
|
385 | + } |
|
386 | + if ($search_payment_mode != '') { |
|
387 | + $param.='&search_payment_mode='.urlencode($search_payment_mode); |
|
388 | + } |
|
389 | + if ($search_payment_type != '') { |
|
390 | + $param.='&search_payment_type='.urlencode($search_payment_type); |
|
391 | + } |
|
392 | + if ($search_recurring != '' && $search_recurrning != '-1') { |
|
393 | + $param.='&search_recurring=' .urlencode($search_recurring); |
|
394 | + } |
|
395 | + if ($search_frequency > 0) { |
|
396 | + $param.='&search_frequency=' .urlencode($search_frequency); |
|
397 | + } |
|
398 | + if ($search_unit_frequency != '') { |
|
399 | + $param.='&search_unit_frequency='.urlencode($search_unit_frequency); |
|
400 | + } |
|
401 | + if ($search_status != '') { |
|
402 | + $param.='&search_status='.urlencode($search_status); |
|
403 | + } |
|
404 | + if ($option) { |
|
405 | + $param.="&option=".urlencode($option); |
|
406 | + } |
|
407 | + if ($optioncss != '') { |
|
408 | + $param.='&optioncss='.urlencode($optioncss); |
|
409 | + } |
|
320 | 410 | // Add $param from extra fields |
321 | 411 | include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; |
322 | 412 | |
@@ -327,7 +417,9 @@ discard block |
||
327 | 417 | //$selectedfields.=$form->showCheckAddButtons('checkforselect', 1); |
328 | 418 | |
329 | 419 | print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'; |
330 | - if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">'; |
|
420 | + if ($optioncss != '') { |
|
421 | + print '<input type="hidden" name="optioncss" value="'.$optioncss.'">'; |
|
422 | + } |
|
331 | 423 | print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
332 | 424 | print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">'; |
333 | 425 | print '<input type="hidden" name="action" value="list">'; |
@@ -426,7 +518,9 @@ discard block |
||
426 | 518 | if (! empty($arrayfields['f.date_last_gen']['checked'])) |
427 | 519 | { |
428 | 520 | print '<td class="liste_titre nowraponall" align="center">'; |
429 | - if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print '<input class="flat valignmiddle" type="text" size="1" maxlength="2" name="search_day" value="'.$search_day.'">'; |
|
521 | + if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) { |
|
522 | + print '<input class="flat valignmiddle" type="text" size="1" maxlength="2" name="search_day" value="'.$search_day.'">'; |
|
523 | + } |
|
430 | 524 | print '<input class="flat valignmiddle width25" type="text" size="1" maxlength="2" name="search_month" value="'.$search_month.'">'; |
431 | 525 | $formother->select_year($search_year?$search_year:-1,'search_year',1, 20, 5, 0, 0, '', 'witdhauto valignmiddle'); |
432 | 526 | print '</td>'; |
@@ -435,7 +529,9 @@ discard block |
||
435 | 529 | if (! empty($arrayfields['f.date_when']['checked'])) |
436 | 530 | { |
437 | 531 | print '<td class="liste_titre nowraponall" align="center">'; |
438 | - if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print '<input class="flat valignmiddle" type="text" size="1" maxlength="2" name="search_day_date_when" value="'.$search_day_date_when.'">'; |
|
532 | + if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) { |
|
533 | + print '<input class="flat valignmiddle" type="text" size="1" maxlength="2" name="search_day_date_when" value="'.$search_day_date_when.'">'; |
|
534 | + } |
|
439 | 535 | print '<input class="flat valignmiddle width25" type="text" size="1" maxlength="2" name="search_month_date_when" value="'.$search_month_date_when.'">'; |
440 | 536 | $formother->select_year($search_year_date_when?$search_year_date_when:-1,'search_year_date_when',1, 20, 5, 0, 0, '', 'witdhauto valignmiddle'); |
441 | 537 | print '</td>'; |
@@ -480,22 +576,54 @@ discard block |
||
480 | 576 | |
481 | 577 | |
482 | 578 | print '<tr class="liste_titre">'; |
483 | - if (! empty($arrayfields['f.titre']['checked'])) print_liste_field_titre($arrayfields['f.titre']['label'],$_SERVER['PHP_SELF'],"f.titre","",$param,"",$sortfield,$sortorder); |
|
484 | - if (! empty($arrayfields['s.nom']['checked'])) print_liste_field_titre($arrayfields['s.nom']['label'],$_SERVER['PHP_SELF'],"s.nom","",$param,"",$sortfield,$sortorder); |
|
485 | - if (! empty($arrayfields['f.total']['checked'])) print_liste_field_titre($arrayfields['f.total']['label'],$_SERVER['PHP_SELF'],"f.total","",$param,'align="right"',$sortfield,$sortorder); |
|
486 | - if (! empty($arrayfields['f.tva']['checked'])) print_liste_field_titre($arrayfields['f.tva']['label'],$_SERVER['PHP_SELF'],"f.tva","",$param,'align="right"',$sortfield,$sortorder); |
|
487 | - if (! empty($arrayfields['f.total_ttc']['checked'])) print_liste_field_titre($arrayfields['f.total_ttc']['label'],$_SERVER['PHP_SELF'],"f.total_ttc","",$param,'align="right"',$sortfield,$sortorder); |
|
488 | - if (! empty($arrayfields['f.fk_cond_reglement']['checked'])) print_liste_field_titre($arrayfields['f.fk_cond_reglement']['label'],$_SERVER['PHP_SELF'],"f.fk_cond_reglement","",$param,'',$sortfield,$sortorder); |
|
489 | - if (! empty($arrayfields['f.fk_mode_reglement']['checked'])) print_liste_field_titre($arrayfields['f.fk_mode_reglement']['label'],$_SERVER['PHP_SELF'],"f.fk_mode_reglement","",$param,'',$sortfield,$sortorder); |
|
490 | - if (! empty($arrayfields['recurring']['checked'])) print_liste_field_titre($arrayfields['recurring']['label'],$_SERVER['PHP_SELF'],"recurring","",$param,'align="center"',$sortfield,$sortorder); |
|
491 | - if (! empty($arrayfields['f.frequency']['checked'])) print_liste_field_titre($arrayfields['f.frequency']['label'],$_SERVER['PHP_SELF'],"f.frequency","",$param,'align="center"',$sortfield,$sortorder); |
|
492 | - if (! empty($arrayfields['f.unit_frequency']['checked'])) print_liste_field_titre($arrayfields['f.unit_frequency']['label'],$_SERVER['PHP_SELF'],"f.unit_frequency","",$param,'align="center"',$sortfield,$sortorder); |
|
493 | - if (! empty($arrayfields['f.nb_gen_done']['checked'])) print_liste_field_titre($arrayfields['f.nb_gen_done']['label'],$_SERVER['PHP_SELF'],"f.nb_gen_done","",$param,'align="center"',$sortfield,$sortorder); |
|
494 | - if (! empty($arrayfields['f.date_last_gen']['checked'])) print_liste_field_titre($arrayfields['f.date_last_gen']['label'],$_SERVER['PHP_SELF'],"f.date_last_gen","",$param,'align="center"',$sortfield,$sortorder); |
|
495 | - if (! empty($arrayfields['f.date_when']['checked'])) print_liste_field_titre($arrayfields['f.date_when']['label'],$_SERVER['PHP_SELF'],"f.date_when","",$param,'align="center"',$sortfield,$sortorder); |
|
496 | - if (! empty($arrayfields['f.datec']['checked'])) print_liste_field_titre($arrayfields['f.datec']['label'],$_SERVER['PHP_SELF'],"f.datec","",$param,'align="center"',$sortfield,$sortorder); |
|
497 | - if (! empty($arrayfields['f.tms']['checked'])) print_liste_field_titre($arrayfields['f.tms']['label'],$_SERVER['PHP_SELF'],"f.tms","",$param,'align="center"',$sortfield,$sortorder); |
|
498 | - if (! empty($arrayfields['status']['checked'])) print_liste_field_titre($arrayfields['status']['label'],$_SERVER['PHP_SELF'],"f.suspended,f.frequency","",$param,'align="center"',$sortfield,$sortorder); |
|
579 | + if (! empty($arrayfields['f.titre']['checked'])) { |
|
580 | + print_liste_field_titre($arrayfields['f.titre']['label'],$_SERVER['PHP_SELF'],"f.titre","",$param,"",$sortfield,$sortorder); |
|
581 | + } |
|
582 | + if (! empty($arrayfields['s.nom']['checked'])) { |
|
583 | + print_liste_field_titre($arrayfields['s.nom']['label'],$_SERVER['PHP_SELF'],"s.nom","",$param,"",$sortfield,$sortorder); |
|
584 | + } |
|
585 | + if (! empty($arrayfields['f.total']['checked'])) { |
|
586 | + print_liste_field_titre($arrayfields['f.total']['label'],$_SERVER['PHP_SELF'],"f.total","",$param,'align="right"',$sortfield,$sortorder); |
|
587 | + } |
|
588 | + if (! empty($arrayfields['f.tva']['checked'])) { |
|
589 | + print_liste_field_titre($arrayfields['f.tva']['label'],$_SERVER['PHP_SELF'],"f.tva","",$param,'align="right"',$sortfield,$sortorder); |
|
590 | + } |
|
591 | + if (! empty($arrayfields['f.total_ttc']['checked'])) { |
|
592 | + print_liste_field_titre($arrayfields['f.total_ttc']['label'],$_SERVER['PHP_SELF'],"f.total_ttc","",$param,'align="right"',$sortfield,$sortorder); |
|
593 | + } |
|
594 | + if (! empty($arrayfields['f.fk_cond_reglement']['checked'])) { |
|
595 | + print_liste_field_titre($arrayfields['f.fk_cond_reglement']['label'],$_SERVER['PHP_SELF'],"f.fk_cond_reglement","",$param,'',$sortfield,$sortorder); |
|
596 | + } |
|
597 | + if (! empty($arrayfields['f.fk_mode_reglement']['checked'])) { |
|
598 | + print_liste_field_titre($arrayfields['f.fk_mode_reglement']['label'],$_SERVER['PHP_SELF'],"f.fk_mode_reglement","",$param,'',$sortfield,$sortorder); |
|
599 | + } |
|
600 | + if (! empty($arrayfields['recurring']['checked'])) { |
|
601 | + print_liste_field_titre($arrayfields['recurring']['label'],$_SERVER['PHP_SELF'],"recurring","",$param,'align="center"',$sortfield,$sortorder); |
|
602 | + } |
|
603 | + if (! empty($arrayfields['f.frequency']['checked'])) { |
|
604 | + print_liste_field_titre($arrayfields['f.frequency']['label'],$_SERVER['PHP_SELF'],"f.frequency","",$param,'align="center"',$sortfield,$sortorder); |
|
605 | + } |
|
606 | + if (! empty($arrayfields['f.unit_frequency']['checked'])) { |
|
607 | + print_liste_field_titre($arrayfields['f.unit_frequency']['label'],$_SERVER['PHP_SELF'],"f.unit_frequency","",$param,'align="center"',$sortfield,$sortorder); |
|
608 | + } |
|
609 | + if (! empty($arrayfields['f.nb_gen_done']['checked'])) { |
|
610 | + print_liste_field_titre($arrayfields['f.nb_gen_done']['label'],$_SERVER['PHP_SELF'],"f.nb_gen_done","",$param,'align="center"',$sortfield,$sortorder); |
|
611 | + } |
|
612 | + if (! empty($arrayfields['f.date_last_gen']['checked'])) { |
|
613 | + print_liste_field_titre($arrayfields['f.date_last_gen']['label'],$_SERVER['PHP_SELF'],"f.date_last_gen","",$param,'align="center"',$sortfield,$sortorder); |
|
614 | + } |
|
615 | + if (! empty($arrayfields['f.date_when']['checked'])) { |
|
616 | + print_liste_field_titre($arrayfields['f.date_when']['label'],$_SERVER['PHP_SELF'],"f.date_when","",$param,'align="center"',$sortfield,$sortorder); |
|
617 | + } |
|
618 | + if (! empty($arrayfields['f.datec']['checked'])) { |
|
619 | + print_liste_field_titre($arrayfields['f.datec']['label'],$_SERVER['PHP_SELF'],"f.datec","",$param,'align="center"',$sortfield,$sortorder); |
|
620 | + } |
|
621 | + if (! empty($arrayfields['f.tms']['checked'])) { |
|
622 | + print_liste_field_titre($arrayfields['f.tms']['label'],$_SERVER['PHP_SELF'],"f.tms","",$param,'align="center"',$sortfield,$sortorder); |
|
623 | + } |
|
624 | + if (! empty($arrayfields['status']['checked'])) { |
|
625 | + print_liste_field_titre($arrayfields['status']['label'],$_SERVER['PHP_SELF'],"f.suspended,f.frequency","",$param,'align="center"',$sortfield,$sortorder); |
|
626 | + } |
|
499 | 627 | print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"],"",'','','align="center"',$sortfield,$sortorder,'nomaxwidthsearch ')."\n"; |
500 | 628 | print "</tr>\n"; |
501 | 629 | |
@@ -506,7 +634,9 @@ discard block |
||
506 | 634 | while ($i < min($num,$limit)) |
507 | 635 | { |
508 | 636 | $objp = $db->fetch_object($resql); |
509 | - if (empty($objp)) break; |
|
637 | + if (empty($objp)) { |
|
638 | + break; |
|
639 | + } |
|
510 | 640 | |
511 | 641 | $companystatic->id=$objp->socid; |
512 | 642 | $companystatic->name=$objp->name; |
@@ -527,32 +657,48 @@ discard block |
||
527 | 657 | print $invoicerectmp->getNomUrl(1); |
528 | 658 | print "</a>"; |
529 | 659 | print "</td>\n"; |
530 | - if (! $i) $totalarray['nbfield']++; |
|
660 | + if (! $i) { |
|
661 | + $totalarray['nbfield']++; |
|
662 | + } |
|
531 | 663 | } |
532 | 664 | if (! empty($arrayfields['s.nom']['checked'])) |
533 | 665 | { |
534 | 666 | print '<td class="tdoverflowmax200">'.$companystatic->getNomUrl(1,'customer').'</td>'; |
535 | - if (! $i) $totalarray['nbfield']++; |
|
667 | + if (! $i) { |
|
668 | + $totalarray['nbfield']++; |
|
669 | + } |
|
536 | 670 | } |
537 | 671 | if (! empty($arrayfields['f.total']['checked'])) |
538 | 672 | { |
539 | 673 | print '<td align="right">'.price($objp->total).'</td>'."\n"; |
540 | - if (! $i) $totalarray['nbfield']++; |
|
541 | - if (! $i) $totalarray['pos'][$totalarray['nbfield']]='f.total'; |
|
674 | + if (! $i) { |
|
675 | + $totalarray['nbfield']++; |
|
676 | + } |
|
677 | + if (! $i) { |
|
678 | + $totalarray['pos'][$totalarray['nbfield']]='f.total'; |
|
679 | + } |
|
542 | 680 | $totalarray['val']['f.total'] += $objp->total; |
543 | 681 | } |
544 | 682 | if (! empty($arrayfields['f.tva']['checked'])) |
545 | 683 | { |
546 | 684 | print '<td align="right">'.price($objp->total_vat).'</td>'."\n"; |
547 | - if (! $i) $totalarray['nbfield']++; |
|
548 | - if (! $i) $totalarray['pos'][$totalarray['nbfield']]='f.tva'; |
|
685 | + if (! $i) { |
|
686 | + $totalarray['nbfield']++; |
|
687 | + } |
|
688 | + if (! $i) { |
|
689 | + $totalarray['pos'][$totalarray['nbfield']]='f.tva'; |
|
690 | + } |
|
549 | 691 | $totalarray['val']['f.tva'] += $objp->total_vat; |
550 | 692 | } |
551 | 693 | if (! empty($arrayfields['f.total_ttc']['checked'])) |
552 | 694 | { |
553 | 695 | print '<td align="right">'.price($objp->total_ttc).'</td>'."\n"; |
554 | - if (! $i) $totalarray['nbfield']++; |
|
555 | - if (! $i) $totalarray['pos'][$totalarray['nbfield']]='f.total_ttc'; |
|
696 | + if (! $i) { |
|
697 | + $totalarray['nbfield']++; |
|
698 | + } |
|
699 | + if (! $i) { |
|
700 | + $totalarray['pos'][$totalarray['nbfield']]='f.total_ttc'; |
|
701 | + } |
|
556 | 702 | $totalarray['val']['f.total_ttc'] += $objp->total_ttc; |
557 | 703 | } |
558 | 704 | // Payment term |
@@ -561,7 +707,9 @@ discard block |
||
561 | 707 | print '<td align="right">'; |
562 | 708 | print $form->form_conditions_reglement('', $objp->fk_cond_reglement, 'none'); |
563 | 709 | print '</td>'."\n"; |
564 | - if (! $i) $totalarray['nbfield']++; |
|
710 | + if (! $i) { |
|
711 | + $totalarray['nbfield']++; |
|
712 | + } |
|
565 | 713 | } |
566 | 714 | // Payment mode |
567 | 715 | if (! empty($arrayfields['f.fk_mode_reglement']['checked'])) |
@@ -569,29 +717,39 @@ discard block |
||
569 | 717 | print '<td align="right">'; |
570 | 718 | print $form->form_modes_reglement('', $objp->fk_mode_reglement, 'none'); |
571 | 719 | print '</td>'."\n"; |
572 | - if (! $i) $totalarray['nbfield']++; |
|
720 | + if (! $i) { |
|
721 | + $totalarray['nbfield']++; |
|
722 | + } |
|
573 | 723 | } |
574 | 724 | if (! empty($arrayfields['recurring']['checked'])) |
575 | 725 | { |
576 | 726 | print '<td align="center">'.yn($objp->frequency?1:0).'</td>'; |
577 | - if (! $i) $totalarray['nbfield']++; |
|
727 | + if (! $i) { |
|
728 | + $totalarray['nbfield']++; |
|
729 | + } |
|
578 | 730 | } |
579 | 731 | if (! empty($arrayfields['f.frequency']['checked'])) |
580 | 732 | { |
581 | 733 | print '<td align="center">'.($objp->frequency > 0 ? $objp->frequency : '').'</td>'; |
582 | - if (! $i) $totalarray['nbfield']++; |
|
734 | + if (! $i) { |
|
735 | + $totalarray['nbfield']++; |
|
736 | + } |
|
583 | 737 | } |
584 | 738 | if (! empty($arrayfields['f.unit_frequency']['checked'])) |
585 | 739 | { |
586 | 740 | print '<td align="center">'.($objp->frequency > 0 ? $objp->unit_frequency : '').'</td>'; |
587 | - if (! $i) $totalarray['nbfield']++; |
|
741 | + if (! $i) { |
|
742 | + $totalarray['nbfield']++; |
|
743 | + } |
|
588 | 744 | } |
589 | 745 | if (! empty($arrayfields['f.nb_gen_done']['checked'])) |
590 | 746 | { |
591 | 747 | print '<td align="center">'; |
592 | 748 | print ($objp->frequency > 0 ? $objp->nb_gen_done.($objp->nb_gen_max>0?' / '. $objp->nb_gen_max:'') : '<span class="opacitymedium">'.$langs->trans('NA').'</span>'); |
593 | 749 | print '</td>'; |
594 | - if (! $i) $totalarray['nbfield']++; |
|
750 | + if (! $i) { |
|
751 | + $totalarray['nbfield']++; |
|
752 | + } |
|
595 | 753 | } |
596 | 754 | // Date last generation |
597 | 755 | if (! empty($arrayfields['f.date_last_gen']['checked'])) |
@@ -599,7 +757,9 @@ discard block |
||
599 | 757 | print '<td align="center">'; |
600 | 758 | print ($objp->frequency > 0 ? dol_print_date($db->jdate($objp->date_last_gen),'day') : '<span class="opacitymedium">'.$langs->trans('NA').'</span>'); |
601 | 759 | print '</td>'; |
602 | - if (! $i) $totalarray['nbfield']++; |
|
760 | + if (! $i) { |
|
761 | + $totalarray['nbfield']++; |
|
762 | + } |
|
603 | 763 | } |
604 | 764 | // Date next generation |
605 | 765 | if (! empty($arrayfields['f.date_when']['checked'])) |
@@ -609,36 +769,45 @@ discard block |
||
609 | 769 | print ($objp->frequency ? ($invoicerectmp->isMaxNbGenReached()?'<strike>':'').dol_print_date($db->jdate($objp->date_when),'day').($invoicerectmp->isMaxNbGenReached()?'</strike>':'') : '<span class="opacitymedium">'.$langs->trans('NA').'</span>'); |
610 | 770 | if (! $invoicerectmp->isMaxNbGenReached()) |
611 | 771 | { |
612 | - if (! $objp->suspended && $objp->frequency > 0 && $db->jdate($objp->date_when) && $db->jdate($objp->date_when) < $now) print img_warning($langs->trans("Late")); |
|
613 | - } |
|
614 | - else |
|
772 | + if (! $objp->suspended && $objp->frequency > 0 && $db->jdate($objp->date_when) && $db->jdate($objp->date_when) < $now) { |
|
773 | + print img_warning($langs->trans("Late")); |
|
774 | + } |
|
775 | + } else |
|
615 | 776 | { |
616 | 777 | print img_info($langs->trans("MaxNumberOfGenerationReached")); |
617 | 778 | } |
618 | 779 | print '</div>'; |
619 | 780 | print '</td>'; |
620 | - if (! $i) $totalarray['nbfield']++; |
|
781 | + if (! $i) { |
|
782 | + $totalarray['nbfield']++; |
|
783 | + } |
|
621 | 784 | } |
622 | 785 | if (! empty($arrayfields['f.datec']['checked'])) |
623 | 786 | { |
624 | 787 | print '<td align="center">'; |
625 | 788 | print dol_print_date($db->jdate($objp->datec),'dayhour'); |
626 | 789 | print '</td>'; |
627 | - if (! $i) $totalarray['nbfield']++; |
|
790 | + if (! $i) { |
|
791 | + $totalarray['nbfield']++; |
|
792 | + } |
|
628 | 793 | } |
629 | 794 | if (! empty($arrayfields['f.tms']['checked'])) |
630 | 795 | { |
631 | 796 | print '<td align="center">'; |
632 | 797 | print dol_print_date($db->jdate($objp->tms),'dayhour'); |
633 | 798 | print '</td>'; |
634 | - if (! $i) $totalarray['nbfield']++; |
|
799 | + if (! $i) { |
|
800 | + $totalarray['nbfield']++; |
|
801 | + } |
|
635 | 802 | } |
636 | 803 | if (! empty($arrayfields['status']['checked'])) |
637 | 804 | { |
638 | 805 | print '<td align="center">'; |
639 | 806 | print $invoicerectmp->getLibStatut(3,0); |
640 | 807 | print '</td>'; |
641 | - if (! $i) $totalarray['nbfield']++; |
|
808 | + if (! $i) { |
|
809 | + $totalarray['nbfield']++; |
|
810 | + } |
|
642 | 811 | } |
643 | 812 | // Action column |
644 | 813 | print '<td align="center">'; |
@@ -647,33 +816,34 @@ discard block |
||
647 | 816 | if ($invoicerectmp->isMaxNbGenReached()) |
648 | 817 | { |
649 | 818 | print $langs->trans("MaxNumberOfGenerationReached"); |
650 | - } |
|
651 | - elseif (empty($objp->frequency) || $db->jdate($objp->date_when) <= $today) |
|
819 | + } elseif (empty($objp->frequency) || $db->jdate($objp->date_when) <= $today) |
|
652 | 820 | { |
653 | 821 | print '<a href="' . BASE_URI . '?controller=compta/facture&method=card&action=create&socid=' . $objp->socid . '&fac_rec=' . $objp->facid . '">'; |
654 | 822 | print $langs->trans("CreateBill").'</a>'; |
655 | - } |
|
656 | - else |
|
823 | + } else |
|
657 | 824 | { |
658 | 825 | print $form->textwithpicto('', $langs->trans("DateIsNotEnough")); |
659 | 826 | } |
660 | - } |
|
661 | - else |
|
827 | + } else |
|
662 | 828 | { |
663 | 829 | print " "; |
664 | 830 | } |
665 | - if (! $i) $totalarray['nbfield']++; |
|
831 | + if (! $i) { |
|
832 | + $totalarray['nbfield']++; |
|
833 | + } |
|
666 | 834 | print "</td>"; |
667 | 835 | |
668 | 836 | print "</tr>\n"; |
669 | 837 | |
670 | 838 | $i++; |
671 | 839 | } |
672 | - } |
|
673 | - else |
|
840 | + } else |
|
674 | 841 | { |
675 | 842 | $colspan=1; |
676 | - foreach($arrayfields as $key => $val) { if (! empty($val['checked'])) $colspan++; } |
|
843 | + foreach($arrayfields as $key => $val) { if (! empty($val['checked'])) { |
|
844 | + $colspan++; |
|
845 | + } |
|
846 | + } |
|
677 | 847 | print '<tr><td colspan="'.$colspan.'" class="opacitymedium">'.$langs->trans("NoRecordFound").'</td></tr>'; |
678 | 848 | } |
679 | 849 | |
@@ -686,15 +856,20 @@ discard block |
||
686 | 856 | while ($i < $totalarray['nbfield']) |
687 | 857 | { |
688 | 858 | $i++; |
689 | - if (! empty($totalarray['pos'][$i])) print '<td align="right">'.price($totalarray['val'][$totalarray['pos'][$i]]).'</td>'; |
|
690 | - else |
|
859 | + if (! empty($totalarray['pos'][$i])) { |
|
860 | + print '<td align="right">'.price($totalarray['val'][$totalarray['pos'][$i]]).'</td>'; |
|
861 | + } else |
|
691 | 862 | { |
692 | 863 | if ($i == 1) |
693 | 864 | { |
694 | - if ($num < $limit) print '<td align="left">'.$langs->trans("Total").'</td>'; |
|
695 | - else print '<td align="left">'.$langs->trans("Totalforthispage").'</td>'; |
|
865 | + if ($num < $limit) { |
|
866 | + print '<td align="left">'.$langs->trans("Total").'</td>'; |
|
867 | + } else { |
|
868 | + print '<td align="left">'.$langs->trans("Totalforthispage").'</td>'; |
|
869 | + } |
|
870 | + } else { |
|
871 | + print '<td></td>'; |
|
696 | 872 | } |
697 | - else print '<td></td>'; |
|
698 | 873 | } |
699 | 874 | } |
700 | 875 | print '</tr>'; |
@@ -705,8 +880,7 @@ discard block |
||
705 | 880 | print "</form>"; |
706 | 881 | |
707 | 882 | $db->free($resql); |
708 | -} |
|
709 | -else |
|
883 | +} else |
|
710 | 884 | { |
711 | 885 | dol_print_error($db); |
712 | 886 | } |
@@ -38,8 +38,8 @@ discard block |
||
38 | 38 | require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; |
39 | 39 | require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; |
40 | 40 | if (! empty($conf->projet->enabled)) { |
41 | - include_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php'; |
|
42 | - //include_once DOL_DOCUMENT_ROOT . '/core/class/html.formprojet.class.php'; |
|
41 | + include_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php'; |
|
42 | + //include_once DOL_DOCUMENT_ROOT . '/core/class/html.formprojet.class.php'; |
|
43 | 43 | } |
44 | 44 | require_once DOL_DOCUMENT_ROOT . '/core/class/html.formprojet.class.php'; |
45 | 45 | require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php'; |
@@ -84,11 +84,11 @@ discard block |
||
84 | 84 | $object = new FactureRec($db); |
85 | 85 | if (($id > 0 || $ref) && $action != 'create' && $action != 'add') |
86 | 86 | { |
87 | - $ret = $object->fetch($id, $ref); |
|
88 | - if (!$ret) |
|
89 | - { |
|
90 | - setEventMessages($langs->trans("ErrorRecordNotFound"), null, 'errors'); |
|
91 | - } |
|
87 | + $ret = $object->fetch($id, $ref); |
|
88 | + if (!$ret) |
|
89 | + { |
|
90 | + setEventMessages($langs->trans("ErrorRecordNotFound"), null, 'errors'); |
|
91 | + } |
|
92 | 92 | } |
93 | 93 | |
94 | 94 | // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context |
@@ -119,564 +119,564 @@ discard block |
||
119 | 119 | |
120 | 120 | if (empty($reshook)) |
121 | 121 | { |
122 | - if (GETPOST('cancel','alpha')) $action=''; |
|
122 | + if (GETPOST('cancel','alpha')) $action=''; |
|
123 | 123 | |
124 | - // Selection of new fields |
|
125 | - include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; |
|
124 | + // Selection of new fields |
|
125 | + include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; |
|
126 | 126 | |
127 | - // Set note |
|
128 | - include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not include_once |
|
127 | + // Set note |
|
128 | + include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not include_once |
|
129 | 129 | |
130 | - include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php'; // Must be include, not include_once |
|
130 | + include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php'; // Must be include, not include_once |
|
131 | 131 | |
132 | - include DOL_DOCUMENT_ROOT.'/core/actions_lineupdown.inc.php'; // Must be include, not include_once |
|
132 | + include DOL_DOCUMENT_ROOT.'/core/actions_lineupdown.inc.php'; // Must be include, not include_once |
|
133 | 133 | |
134 | - // Mass actions |
|
135 | - /*$objectclass='MyObject'; |
|
134 | + // Mass actions |
|
135 | + /*$objectclass='MyObject'; |
|
136 | 136 | $objectlabel='MyObject'; |
137 | 137 | $permtoread = $user->rights->mymodule->read; |
138 | 138 | $permtodelete = $user->rights->mymodule->delete; |
139 | 139 | $uploaddir = $conf->mymodule->dir_output; |
140 | 140 | include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';*/ |
141 | 141 | |
142 | - // Create predefined invoice |
|
143 | - if ($action == 'add') |
|
144 | - { |
|
145 | - if (! GETPOST('titre')) |
|
146 | - { |
|
147 | - setEventMessages($langs->transnoentities("ErrorFieldRequired",$langs->trans("Title")), null, 'errors'); |
|
148 | - $action = "create"; |
|
149 | - $error++; |
|
150 | - } |
|
151 | - |
|
152 | - $frequency=GETPOST('frequency', 'int'); |
|
153 | - $reyear=GETPOST('reyear'); |
|
154 | - $remonth=GETPOST('remonth'); |
|
155 | - $reday=GETPOST('reday'); |
|
156 | - $rehour=GETPOST('rehour'); |
|
157 | - $remin=GETPOST('remin'); |
|
158 | - $nb_gen_max=GETPOST('nb_gen_max', 'int'); |
|
159 | - //if (empty($nb_gen_max)) $nb_gen_max =0; |
|
160 | - |
|
161 | - if (GETPOST('frequency')) |
|
162 | - { |
|
163 | - if (empty($reyear) || empty($remonth) || empty($reday)) |
|
164 | - { |
|
165 | - setEventMessages($langs->transnoentities("ErrorFieldRequired",$langs->trans("Date")), null, 'errors'); |
|
166 | - $action = "create"; |
|
167 | - $error++; |
|
168 | - } |
|
169 | - if ($nb_gen_max === '') |
|
170 | - { |
|
171 | - setEventMessages($langs->transnoentities("ErrorFieldRequired",$langs->trans("MaxPeriodNumber")), null, 'errors'); |
|
172 | - $action = "create"; |
|
173 | - $error++; |
|
174 | - } |
|
175 | - } |
|
176 | - |
|
177 | - if (! $error) |
|
178 | - { |
|
179 | - $object->titre = GETPOST('titre', 'alpha'); |
|
180 | - $object->note_private = GETPOST('note_private','none'); |
|
142 | + // Create predefined invoice |
|
143 | + if ($action == 'add') |
|
144 | + { |
|
145 | + if (! GETPOST('titre')) |
|
146 | + { |
|
147 | + setEventMessages($langs->transnoentities("ErrorFieldRequired",$langs->trans("Title")), null, 'errors'); |
|
148 | + $action = "create"; |
|
149 | + $error++; |
|
150 | + } |
|
151 | + |
|
152 | + $frequency=GETPOST('frequency', 'int'); |
|
153 | + $reyear=GETPOST('reyear'); |
|
154 | + $remonth=GETPOST('remonth'); |
|
155 | + $reday=GETPOST('reday'); |
|
156 | + $rehour=GETPOST('rehour'); |
|
157 | + $remin=GETPOST('remin'); |
|
158 | + $nb_gen_max=GETPOST('nb_gen_max', 'int'); |
|
159 | + //if (empty($nb_gen_max)) $nb_gen_max =0; |
|
160 | + |
|
161 | + if (GETPOST('frequency')) |
|
162 | + { |
|
163 | + if (empty($reyear) || empty($remonth) || empty($reday)) |
|
164 | + { |
|
165 | + setEventMessages($langs->transnoentities("ErrorFieldRequired",$langs->trans("Date")), null, 'errors'); |
|
166 | + $action = "create"; |
|
167 | + $error++; |
|
168 | + } |
|
169 | + if ($nb_gen_max === '') |
|
170 | + { |
|
171 | + setEventMessages($langs->transnoentities("ErrorFieldRequired",$langs->trans("MaxPeriodNumber")), null, 'errors'); |
|
172 | + $action = "create"; |
|
173 | + $error++; |
|
174 | + } |
|
175 | + } |
|
176 | + |
|
177 | + if (! $error) |
|
178 | + { |
|
179 | + $object->titre = GETPOST('titre', 'alpha'); |
|
180 | + $object->note_private = GETPOST('note_private','none'); |
|
181 | 181 | $object->note_public = GETPOST('note_public','none'); |
182 | 182 | $object->modelpdf = GETPOST('modelpdf', 'alpha'); |
183 | - $object->usenewprice = GETPOST('usenewprice'); |
|
183 | + $object->usenewprice = GETPOST('usenewprice'); |
|
184 | 184 | |
185 | - $object->frequency = $frequency; |
|
186 | - $object->unit_frequency = GETPOST('unit_frequency', 'alpha'); |
|
187 | - $object->nb_gen_max = $nb_gen_max; |
|
188 | - $object->auto_validate = GETPOST('auto_validate', 'int'); |
|
185 | + $object->frequency = $frequency; |
|
186 | + $object->unit_frequency = GETPOST('unit_frequency', 'alpha'); |
|
187 | + $object->nb_gen_max = $nb_gen_max; |
|
188 | + $object->auto_validate = GETPOST('auto_validate', 'int'); |
|
189 | 189 | $object->generate_pdf = GETPOST('generate_pdf', 'int'); |
190 | - $object->fk_project = $projectid; |
|
191 | - |
|
192 | - $date_next_execution = dol_mktime($rehour, $remin, 0, $remonth, $reday, $reyear); |
|
193 | - $object->date_when = $date_next_execution; |
|
194 | - |
|
195 | - // Get first contract linked to invoice used to generate template (facid is id of source invoice) |
|
196 | - if (GETPOST('facid','int') > 0) |
|
197 | - { |
|
198 | - $srcObject = new Facture($db); |
|
199 | - $srcObject->fetch(GETPOST('facid','int')); |
|
200 | - |
|
201 | - $srcObject->fetchObjectLinked(); |
|
202 | - |
|
203 | - if (! empty($srcObject->linkedObjectsIds['contrat'])) |
|
204 | - { |
|
205 | - $contractidid = reset($srcObject->linkedObjectsIds['contrat']); |
|
206 | - |
|
207 | - $object->origin = 'contrat'; |
|
208 | - $object->origin_id = $contractidid; |
|
209 | - $object->linked_objects[$object->origin] = $object->origin_id; |
|
210 | - } |
|
211 | - } |
|
212 | - |
|
213 | - $db->begin(); |
|
214 | - |
|
215 | - $oldinvoice = new Facture($db); |
|
216 | - $oldinvoice->fetch(GETPOST('facid','int')); |
|
217 | - |
|
218 | - $result = $object->create($user, $oldinvoice->id); |
|
219 | - if ($result > 0) |
|
220 | - { |
|
221 | - $result=$oldinvoice->delete($user, 1); |
|
222 | - if ($result < 0) |
|
223 | - { |
|
224 | - $error++; |
|
225 | - setEventMessages($oldinvoice->error, $oldinvoice->errors, 'errors'); |
|
226 | - $action = "create"; |
|
227 | - } |
|
228 | - } |
|
229 | - else |
|
230 | - { |
|
231 | - $error++; |
|
232 | - setEventMessages($object->error, $object->errors, 'errors'); |
|
233 | - $action = "create"; |
|
234 | - } |
|
235 | - |
|
236 | - if (! $error) |
|
237 | - { |
|
238 | - $db->commit(); |
|
239 | - |
|
240 | - header("Location: " . $_SERVER['PHP_SELF'] . '?facid=' . $object->id); |
|
241 | - exit; |
|
242 | - } |
|
243 | - else |
|
244 | - { |
|
245 | - $db->rollback(); |
|
246 | - |
|
247 | - $error++; |
|
248 | - setEventMessages($object->error, $object->errors, 'errors'); |
|
249 | - $action = "create"; |
|
250 | - } |
|
251 | - } |
|
252 | - } |
|
253 | - |
|
254 | - // Delete |
|
255 | - if ($action == 'confirm_deleteinvoice' && $confirm == 'yes' && $user->rights->facture->supprimer) |
|
256 | - { |
|
257 | - $object->delete($user); |
|
190 | + $object->fk_project = $projectid; |
|
191 | + |
|
192 | + $date_next_execution = dol_mktime($rehour, $remin, 0, $remonth, $reday, $reyear); |
|
193 | + $object->date_when = $date_next_execution; |
|
194 | + |
|
195 | + // Get first contract linked to invoice used to generate template (facid is id of source invoice) |
|
196 | + if (GETPOST('facid','int') > 0) |
|
197 | + { |
|
198 | + $srcObject = new Facture($db); |
|
199 | + $srcObject->fetch(GETPOST('facid','int')); |
|
200 | + |
|
201 | + $srcObject->fetchObjectLinked(); |
|
202 | + |
|
203 | + if (! empty($srcObject->linkedObjectsIds['contrat'])) |
|
204 | + { |
|
205 | + $contractidid = reset($srcObject->linkedObjectsIds['contrat']); |
|
206 | + |
|
207 | + $object->origin = 'contrat'; |
|
208 | + $object->origin_id = $contractidid; |
|
209 | + $object->linked_objects[$object->origin] = $object->origin_id; |
|
210 | + } |
|
211 | + } |
|
212 | + |
|
213 | + $db->begin(); |
|
214 | + |
|
215 | + $oldinvoice = new Facture($db); |
|
216 | + $oldinvoice->fetch(GETPOST('facid','int')); |
|
217 | + |
|
218 | + $result = $object->create($user, $oldinvoice->id); |
|
219 | + if ($result > 0) |
|
220 | + { |
|
221 | + $result=$oldinvoice->delete($user, 1); |
|
222 | + if ($result < 0) |
|
223 | + { |
|
224 | + $error++; |
|
225 | + setEventMessages($oldinvoice->error, $oldinvoice->errors, 'errors'); |
|
226 | + $action = "create"; |
|
227 | + } |
|
228 | + } |
|
229 | + else |
|
230 | + { |
|
231 | + $error++; |
|
232 | + setEventMessages($object->error, $object->errors, 'errors'); |
|
233 | + $action = "create"; |
|
234 | + } |
|
235 | + |
|
236 | + if (! $error) |
|
237 | + { |
|
238 | + $db->commit(); |
|
239 | + |
|
240 | + header("Location: " . $_SERVER['PHP_SELF'] . '?facid=' . $object->id); |
|
241 | + exit; |
|
242 | + } |
|
243 | + else |
|
244 | + { |
|
245 | + $db->rollback(); |
|
246 | + |
|
247 | + $error++; |
|
248 | + setEventMessages($object->error, $object->errors, 'errors'); |
|
249 | + $action = "create"; |
|
250 | + } |
|
251 | + } |
|
252 | + } |
|
253 | + |
|
254 | + // Delete |
|
255 | + if ($action == 'confirm_deleteinvoice' && $confirm == 'yes' && $user->rights->facture->supprimer) |
|
256 | + { |
|
257 | + $object->delete($user); |
|
258 | 258 | |
259 | 259 | header("Location: " . BASE_URI . 'controller=compta/facture&method=invoicetemplate_list'); |
260 | - exit; |
|
261 | - } |
|
262 | - |
|
263 | - |
|
264 | - // Update field |
|
265 | - // Set condition |
|
266 | - if ($action == 'setconditions' && $user->rights->facture->creer) |
|
267 | - { |
|
268 | - $result=$object->setPaymentTerms(GETPOST('cond_reglement_id', 'int')); |
|
269 | - } |
|
270 | - // Set mode |
|
271 | - elseif ($action == 'setmode' && $user->rights->facture->creer) |
|
272 | - { |
|
273 | - $result=$object->setPaymentMethods(GETPOST('mode_reglement_id', 'int')); |
|
274 | - } |
|
275 | - // Set project |
|
276 | - elseif ($action == 'classin' && $user->rights->facture->creer) |
|
277 | - { |
|
278 | - $object->setProject(GETPOST('projectid', 'int')); |
|
279 | - } |
|
280 | - // Set bank account |
|
281 | - elseif ($action == 'setref' && $user->rights->facture->creer) |
|
282 | - { |
|
283 | - //var_dump(GETPOST('ref', 'alpha'));exit; |
|
284 | - $result=$object->setValueFrom('titre', GETPOST('ref', 'alpha'), '', null, 'text', '', $user, 'BILLREC_MODIFY'); |
|
285 | - if ($result > 0) |
|
286 | - { |
|
287 | - $object->titre = GETPOST('ref', 'alpha'); |
|
288 | - $object->ref = $object->titre; |
|
289 | - } |
|
290 | - else dol_print_error($db, $object->error, $object->errors); |
|
291 | - } |
|
292 | - // Set bank account |
|
293 | - elseif ($action == 'setbankaccount' && $user->rights->facture->creer) |
|
294 | - { |
|
295 | - $result=$object->setBankAccount(GETPOST('fk_account', 'int')); |
|
296 | - } |
|
297 | - // Set frequency and unit frequency |
|
298 | - elseif ($action == 'setfrequency' && $user->rights->facture->creer) |
|
299 | - { |
|
300 | - $object->setFrequencyAndUnit(GETPOST('frequency', 'int'), GETPOST('unit_frequency', 'alpha')); |
|
301 | - } |
|
302 | - // Set next date of execution |
|
303 | - elseif ($action == 'setdate_when' && $user->rights->facture->creer) |
|
304 | - { |
|
305 | - $date = dol_mktime(GETPOST('date_whenhour'), GETPOST('date_whenmin'), 0, GETPOST('date_whenmonth'), GETPOST('date_whenday'), GETPOST('date_whenyear')); |
|
306 | - if (!empty($date)) $object->setNextDate($date); |
|
307 | - } |
|
308 | - // Set max period |
|
309 | - elseif ($action == 'setnb_gen_max' && $user->rights->facture->creer) |
|
310 | - { |
|
311 | - $object->setMaxPeriod(GETPOST('nb_gen_max', 'int')); |
|
312 | - } |
|
313 | - // Set auto validate |
|
314 | - elseif ($action == 'setauto_validate' && $user->rights->facture->creer) |
|
315 | - { |
|
316 | - $object->setAutoValidate(GETPOST('auto_validate', 'int')); |
|
260 | + exit; |
|
261 | + } |
|
262 | + |
|
263 | + |
|
264 | + // Update field |
|
265 | + // Set condition |
|
266 | + if ($action == 'setconditions' && $user->rights->facture->creer) |
|
267 | + { |
|
268 | + $result=$object->setPaymentTerms(GETPOST('cond_reglement_id', 'int')); |
|
269 | + } |
|
270 | + // Set mode |
|
271 | + elseif ($action == 'setmode' && $user->rights->facture->creer) |
|
272 | + { |
|
273 | + $result=$object->setPaymentMethods(GETPOST('mode_reglement_id', 'int')); |
|
274 | + } |
|
275 | + // Set project |
|
276 | + elseif ($action == 'classin' && $user->rights->facture->creer) |
|
277 | + { |
|
278 | + $object->setProject(GETPOST('projectid', 'int')); |
|
279 | + } |
|
280 | + // Set bank account |
|
281 | + elseif ($action == 'setref' && $user->rights->facture->creer) |
|
282 | + { |
|
283 | + //var_dump(GETPOST('ref', 'alpha'));exit; |
|
284 | + $result=$object->setValueFrom('titre', GETPOST('ref', 'alpha'), '', null, 'text', '', $user, 'BILLREC_MODIFY'); |
|
285 | + if ($result > 0) |
|
286 | + { |
|
287 | + $object->titre = GETPOST('ref', 'alpha'); |
|
288 | + $object->ref = $object->titre; |
|
289 | + } |
|
290 | + else dol_print_error($db, $object->error, $object->errors); |
|
291 | + } |
|
292 | + // Set bank account |
|
293 | + elseif ($action == 'setbankaccount' && $user->rights->facture->creer) |
|
294 | + { |
|
295 | + $result=$object->setBankAccount(GETPOST('fk_account', 'int')); |
|
296 | + } |
|
297 | + // Set frequency and unit frequency |
|
298 | + elseif ($action == 'setfrequency' && $user->rights->facture->creer) |
|
299 | + { |
|
300 | + $object->setFrequencyAndUnit(GETPOST('frequency', 'int'), GETPOST('unit_frequency', 'alpha')); |
|
301 | + } |
|
302 | + // Set next date of execution |
|
303 | + elseif ($action == 'setdate_when' && $user->rights->facture->creer) |
|
304 | + { |
|
305 | + $date = dol_mktime(GETPOST('date_whenhour'), GETPOST('date_whenmin'), 0, GETPOST('date_whenmonth'), GETPOST('date_whenday'), GETPOST('date_whenyear')); |
|
306 | + if (!empty($date)) $object->setNextDate($date); |
|
307 | + } |
|
308 | + // Set max period |
|
309 | + elseif ($action == 'setnb_gen_max' && $user->rights->facture->creer) |
|
310 | + { |
|
311 | + $object->setMaxPeriod(GETPOST('nb_gen_max', 'int')); |
|
312 | + } |
|
313 | + // Set auto validate |
|
314 | + elseif ($action == 'setauto_validate' && $user->rights->facture->creer) |
|
315 | + { |
|
316 | + $object->setAutoValidate(GETPOST('auto_validate', 'int')); |
|
317 | 317 | } |
318 | 318 | // Set generate pdf |
319 | - elseif ($action == 'setgenerate_pdf' && $user->rights->facture->creer) |
|
320 | - { |
|
321 | - $object->setGeneratepdf(GETPOST('generate_pdf', 'int')); |
|
322 | - } |
|
319 | + elseif ($action == 'setgenerate_pdf' && $user->rights->facture->creer) |
|
320 | + { |
|
321 | + $object->setGeneratepdf(GETPOST('generate_pdf', 'int')); |
|
322 | + } |
|
323 | 323 | // Set model pdf |
324 | - elseif ($action == 'setmodelpdf' && $user->rights->facture->creer) |
|
325 | - { |
|
326 | - $object->setModelpdf(GETPOST('modelpdf', 'alpha')); |
|
327 | - } |
|
328 | - |
|
329 | - // Set status disabled |
|
330 | - elseif ($action == 'disable' && $user->rights->facture->creer) |
|
331 | - { |
|
332 | - $db->begin(); |
|
333 | - |
|
334 | - $object->fetch($id); |
|
335 | - |
|
336 | - $res = $object->setValueFrom('suspended', 1); |
|
337 | - if ($res <= 0) |
|
338 | - { |
|
339 | - $error++; |
|
340 | - } |
|
341 | - |
|
342 | - if (! $error) |
|
343 | - { |
|
344 | - $db->commit(); |
|
345 | - } |
|
346 | - else |
|
347 | - { |
|
348 | - $db->rollback(); |
|
349 | - setEventMessages($object->error, $object->errors, 'errors'); |
|
350 | - } |
|
351 | - } |
|
352 | - |
|
353 | - // Set status enabled |
|
354 | - elseif ($action == 'enable' && $user->rights->facture->creer) |
|
355 | - { |
|
356 | - $db->begin(); |
|
357 | - |
|
358 | - $object->fetch($id); |
|
359 | - |
|
360 | - $res = $object->setValueFrom('suspended', 0); |
|
361 | - if ($res <= 0) |
|
362 | - { |
|
363 | - $error++; |
|
364 | - } |
|
365 | - |
|
366 | - if (! $error) |
|
367 | - { |
|
368 | - $db->commit(); |
|
369 | - } |
|
370 | - else |
|
371 | - { |
|
372 | - $db->rollback(); |
|
373 | - setEventMessages($object->error, $object->errors, 'errors'); |
|
374 | - } |
|
375 | - } |
|
376 | - |
|
377 | - // Delete line |
|
378 | - if ($action == 'confirm_deleteline' && $confirm == 'yes' && $user->rights->facture->creer) |
|
379 | - { |
|
380 | - $object->fetch($id); |
|
381 | - $object->fetch_thirdparty(); |
|
382 | - |
|
383 | - $db->begin(); |
|
384 | - |
|
385 | - $line=new FactureLigneRec($db); |
|
386 | - |
|
387 | - // For triggers |
|
388 | - $line->id = $lineid; |
|
389 | - |
|
390 | - if ($line->delete($user) > 0) |
|
391 | - { |
|
392 | - $result=$object->update_price(1); |
|
393 | - |
|
394 | - if ($result > 0) |
|
395 | - { |
|
396 | - $db->commit(); |
|
397 | - $object->fetch($object->id); // Reload lines |
|
398 | - } |
|
399 | - else |
|
400 | - { |
|
401 | - $db->rollback(); |
|
402 | - setEventMessages($db->lasterror(), null, 'errors'); |
|
403 | - } |
|
404 | - } |
|
405 | - else |
|
406 | - { |
|
407 | - $db->rollback(); |
|
408 | - setEventMessages($line->error, $line->errors, 'errors'); |
|
409 | - } |
|
410 | - } |
|
411 | - else if ($action == 'update_extras') |
|
412 | - { |
|
413 | - $object->oldcopy = dol_clone($object); |
|
414 | - |
|
415 | - // Fill array 'array_options' with data from update form |
|
416 | - $extralabels = $extrafields->fetch_name_optionals_label($object->table_element); |
|
417 | - $ret = $extrafields->setOptionalsFromPost($extralabels, $object, GETPOST('attribute','none')); |
|
418 | - if ($ret < 0) $error++; |
|
419 | - |
|
420 | - if (! $error) |
|
421 | - { |
|
422 | - $result = $object->insertExtraFields('BILLREC_MODIFY'); |
|
423 | - if ($result < 0) |
|
424 | - { |
|
425 | - setEventMessages($object->error, $object->errors, 'errors'); |
|
426 | - $error++; |
|
427 | - } |
|
428 | - } |
|
429 | - } |
|
430 | - |
|
431 | - // Add a new line |
|
432 | - if ($action == 'addline' && $user->rights->facture->creer) |
|
433 | - { |
|
434 | - $langs->load('errors'); |
|
435 | - $error = 0; |
|
436 | - |
|
437 | - // Set if we used free entry or predefined product |
|
438 | - $predef=''; |
|
439 | - $product_desc=(GETPOST('dp_desc')?GETPOST('dp_desc'):''); |
|
440 | - $price_ht = GETPOST('price_ht'); |
|
441 | - if (GETPOST('prod_entry_mode') == 'free') |
|
442 | - { |
|
443 | - $idprod=0; |
|
444 | - $tva_tx = (GETPOST('tva_tx') ? GETPOST('tva_tx') : 0); |
|
445 | - } |
|
446 | - else |
|
447 | - { |
|
448 | - $idprod=GETPOST('idprod', 'int'); |
|
449 | - $tva_tx = ''; |
|
450 | - } |
|
451 | - |
|
452 | - $qty = GETPOST('qty' . $predef); |
|
453 | - $remise_percent = GETPOST('remise_percent' . $predef); |
|
454 | - |
|
455 | - // Extrafields |
|
456 | - $extrafieldsline = new ExtraFields($db); |
|
457 | - $extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line); |
|
458 | - $array_options = $extrafieldsline->getOptionalsFromPost($extralabelsline, $predef); |
|
459 | - // Unset extrafield |
|
460 | - if (is_array($extralabelsline)) |
|
461 | - { |
|
462 | - // Get extra fields |
|
463 | - foreach ($extralabelsline as $key => $value) { |
|
464 | - unset($_POST["options_" . $key . $predef]); |
|
465 | - } |
|
466 | - } |
|
467 | - |
|
468 | - if (empty($idprod) && ($price_ht < 0) && ($qty < 0)) { |
|
469 | - setEventMessages($langs->trans('ErrorBothFieldCantBeNegative', $langs->transnoentitiesnoconv('UnitPriceHT'), $langs->transnoentitiesnoconv('Qty')), null, 'errors'); |
|
470 | - $error ++; |
|
471 | - } |
|
472 | - if (GETPOST('prod_entry_mode') == 'free' && empty($idprod) && GETPOST('type') < 0) { |
|
473 | - setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Type')), null, 'errors'); |
|
474 | - $error ++; |
|
475 | - } |
|
476 | - if (GETPOST('prod_entry_mode') == 'free' && empty($idprod) && (! ($price_ht >= 0) || $price_ht == '')) // Unit price can be 0 but not '' |
|
477 | - { |
|
478 | - setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("UnitPriceHT")), null, 'errors'); |
|
479 | - $error ++; |
|
480 | - } |
|
481 | - if ($qty == '') { |
|
482 | - setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Qty')), null, 'errors'); |
|
483 | - $error ++; |
|
484 | - } |
|
485 | - if (GETPOST('prod_entry_mode') == 'free' && empty($idprod) && empty($product_desc)) { |
|
486 | - setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Description')), null, 'errors'); |
|
487 | - $error ++; |
|
488 | - } |
|
489 | - if ($qty < 0) { |
|
490 | - $langs->load("errors"); |
|
491 | - setEventMessages($langs->trans('ErrorQtyForCustomerInvoiceCantBeNegative'), null, 'errors'); |
|
492 | - $error ++; |
|
493 | - } |
|
494 | - |
|
495 | - if (! $error && ($qty >= 0) && (! empty($product_desc) || ! empty($idprod))) |
|
496 | - { |
|
497 | - $ret = $object->fetch($id); |
|
498 | - if ($ret < 0) { |
|
499 | - dol_print_error($db, $object->error); |
|
500 | - exit(); |
|
501 | - } |
|
502 | - $ret = $object->fetch_thirdparty(); |
|
503 | - |
|
504 | - // Clean parameters |
|
505 | - $date_start = dol_mktime(GETPOST('date_start' . $predef . 'hour'), GETPOST('date_start' . $predef . 'min'), GETPOST('date_start' . $predef . 'sec'), GETPOST('date_start' . $predef . 'month'), GETPOST('date_start' . $predef . 'day'), GETPOST('date_start' . $predef . 'year')); |
|
506 | - $date_end = dol_mktime(GETPOST('date_end' . $predef . 'hour'), GETPOST('date_end' . $predef . 'min'), GETPOST('date_end' . $predef . 'sec'), GETPOST('date_end' . $predef . 'month'), GETPOST('date_end' . $predef . 'day'), GETPOST('date_end' . $predef . 'year')); |
|
507 | - $price_base_type = (GETPOST('price_base_type', 'alpha') ? GETPOST('price_base_type', 'alpha') : 'HT'); |
|
508 | - |
|
509 | - // Define special_code for special lines |
|
510 | - $special_code = 0; |
|
511 | - // if (empty($_POST['qty'])) $special_code=3; // Options should not exists on invoices |
|
512 | - |
|
513 | - // Ecrase $pu par celui du produit |
|
514 | - // Ecrase $desc par celui du produit |
|
515 | - // Ecrase $tva_tx par celui du produit |
|
516 | - // Ecrase $base_price_type par celui du produit |
|
517 | - // Replaces $fk_unit with the product's |
|
518 | - if (! empty($idprod)) |
|
519 | - { |
|
520 | - $prod = new Product($db); |
|
521 | - $prod->fetch($idprod); |
|
522 | - |
|
523 | - $label = ((GETPOST('product_label') && GETPOST('product_label') != $prod->label) ? GETPOST('product_label') : ''); |
|
524 | - |
|
525 | - // Update if prices fields are defined |
|
526 | - $tva_tx = get_default_tva($mysoc, $object->thirdparty, $prod->id); |
|
527 | - $tva_npr = get_default_npr($mysoc, $object->thirdparty, $prod->id); |
|
528 | - if (empty($tva_tx)) $tva_npr=0; |
|
529 | - |
|
530 | - $pu_ht = $prod->price; |
|
531 | - $pu_ttc = $prod->price_ttc; |
|
532 | - $price_min = $prod->price_min; |
|
533 | - $price_base_type = $prod->price_base_type; |
|
534 | - |
|
535 | - // We define price for product |
|
536 | - if (! empty($conf->global->PRODUIT_MULTIPRICES) && ! empty($object->thirdparty->price_level)) |
|
537 | - { |
|
538 | - $pu_ht = $prod->multiprices[$object->thirdparty->price_level]; |
|
539 | - $pu_ttc = $prod->multiprices_ttc[$object->thirdparty->price_level]; |
|
540 | - $price_min = $prod->multiprices_min[$object->thirdparty->price_level]; |
|
541 | - $price_base_type = $prod->multiprices_base_type[$object->thirdparty->price_level]; |
|
542 | - if (! empty($conf->global->PRODUIT_MULTIPRICES_USE_VAT_PER_LEVEL)) // using this option is a bug. kept for backward compatibility |
|
543 | - { |
|
544 | - if (isset($prod->multiprices_tva_tx[$object->thirdparty->price_level])) $tva_tx=$prod->multiprices_tva_tx[$object->thirdparty->price_level]; |
|
545 | - if (isset($prod->multiprices_recuperableonly[$object->thirdparty->price_level])) $tva_npr=$prod->multiprices_recuperableonly[$object->thirdparty->price_level]; |
|
546 | - if (empty($tva_tx)) $tva_npr=0; |
|
547 | - } |
|
548 | - } |
|
549 | - elseif (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) |
|
550 | - { |
|
551 | - include_once DOL_DOCUMENT_ROOT . '/product/class/productcustomerprice.class.php'; |
|
552 | - |
|
553 | - $prodcustprice = new Productcustomerprice($db); |
|
554 | - |
|
555 | - $filter = array('t.fk_product' => $prod->id,'t.fk_soc' => $object->thirdparty->id); |
|
556 | - |
|
557 | - $result = $prodcustprice->fetch_all('', '', 0, 0, $filter); |
|
558 | - if ($result) |
|
559 | - { |
|
560 | - if (count($prodcustprice->lines) > 0) |
|
561 | - { |
|
562 | - $pu_ht = price($prodcustprice->lines[0]->price); |
|
563 | - $pu_ttc = price($prodcustprice->lines[0]->price_ttc); |
|
564 | - $price_base_type = $prodcustprice->lines[0]->price_base_type; |
|
565 | - $tva_tx = $prodcustprice->lines[0]->tva_tx; |
|
566 | - if ($prodcustprice->lines[0]->default_vat_code && ! preg_match('/\(.*\)/', $tva_tx)) $tva_tx.= ' ('.$prodcustprice->lines[0]->default_vat_code.')'; |
|
567 | - $tva_npr = $prodcustprice->lines[0]->recuperableonly; |
|
568 | - if (empty($tva_tx)) $tva_npr=0; |
|
569 | - } |
|
570 | - } |
|
571 | - } |
|
572 | - |
|
573 | - $tmpvat = price2num(preg_replace('/\s*\(.*\)/', '', $tva_tx)); |
|
574 | - $tmpprodvat = price2num(preg_replace('/\s*\(.*\)/', '', $prod->tva_tx)); |
|
575 | - |
|
576 | - // if price ht was forced (ie: from gui when calculated by margin rate and cost price). TODO Why this ? |
|
577 | - if (! empty($price_ht)) |
|
578 | - { |
|
579 | - $pu_ht = price2num($price_ht, 'MU'); |
|
580 | - $pu_ttc = price2num($pu_ht * (1 + ($tmpvat / 100)), 'MU'); |
|
581 | - } |
|
582 | - // On reevalue prix selon taux tva car taux tva transaction peut etre different |
|
583 | - // de ceux du produit par defaut (par exemple si pays different entre vendeur et acheteur). |
|
584 | - elseif ($tmpvat != $tmpprodvat) |
|
585 | - { |
|
586 | - if ($price_base_type != 'HT') |
|
587 | - { |
|
588 | - $pu_ht = price2num($pu_ttc / (1 + ($tmpvat / 100)), 'MU'); |
|
589 | - } |
|
590 | - else |
|
591 | - { |
|
592 | - $pu_ttc = price2num($pu_ht * (1 + ($tmpvat / 100)), 'MU'); |
|
593 | - } |
|
594 | - } |
|
595 | - |
|
596 | - $desc = ''; |
|
597 | - |
|
598 | - // Define output language |
|
599 | - if (! empty($conf->global->MAIN_MULTILANGS) && ! empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) |
|
600 | - { |
|
601 | - $outputlangs = $langs; |
|
602 | - $newlang = ''; |
|
603 | - if (empty($newlang) && GETPOST('lang_id','aZ09')) |
|
604 | - $newlang = GETPOST('lang_id','aZ09'); |
|
605 | - if (empty($newlang)) |
|
606 | - $newlang = $object->thirdparty->default_lang; |
|
607 | - if (! empty($newlang)) |
|
608 | - { |
|
609 | - $outputlangs = new Translate("", $conf); |
|
610 | - $outputlangs->setDefaultLang($newlang); |
|
611 | - } |
|
612 | - |
|
613 | - $desc = (! empty($prod->multilangs [$outputlangs->defaultlang] ["description"])) ? $prod->multilangs [$outputlangs->defaultlang] ["description"] : $prod->description; |
|
614 | - } |
|
615 | - else |
|
616 | - { |
|
617 | - $desc = $prod->description; |
|
618 | - } |
|
619 | - |
|
620 | - $desc = dol_concatdesc($desc, $product_desc); |
|
621 | - |
|
622 | - // Add custom code and origin country into description |
|
623 | - if (empty($conf->global->MAIN_PRODUCT_DISABLE_CUSTOMCOUNTRYCODE) && (! empty($prod->customcode) || ! empty($prod->country_code))) |
|
624 | - { |
|
625 | - $tmptxt = '('; |
|
626 | - if (! empty($prod->customcode)) |
|
627 | - $tmptxt .= $langs->transnoentitiesnoconv("CustomCode") . ': ' . $prod->customcode; |
|
628 | - if (! empty($prod->customcode) && ! empty($prod->country_code)) |
|
629 | - $tmptxt .= ' - '; |
|
630 | - if (! empty($prod->country_code)) |
|
631 | - $tmptxt .= $langs->transnoentitiesnoconv("CountryOrigin") . ': ' . getCountry($prod->country_code, 0, $db, $langs, 0); |
|
632 | - $tmptxt .= ')'; |
|
633 | - $desc = dol_concatdesc($desc, $tmptxt); |
|
634 | - } |
|
635 | - |
|
636 | - $type = $prod->type; |
|
637 | - $fk_unit = $prod->fk_unit; |
|
638 | - } |
|
639 | - else |
|
640 | - { |
|
641 | - $pu_ht = price2num($price_ht, 'MU'); |
|
642 | - $pu_ttc = price2num(GETPOST('price_ttc'), 'MU'); |
|
643 | - $tva_npr = (preg_match('/\*/', $tva_tx) ? 1 : 0); |
|
644 | - $tva_tx = str_replace('*', '', $tva_tx); |
|
645 | - if (empty($tva_tx)) $tva_npr=0; |
|
646 | - $label = (GETPOST('product_label') ? GETPOST('product_label') : ''); |
|
647 | - $desc = $product_desc; |
|
648 | - $type = GETPOST('type'); |
|
649 | - $fk_unit= GETPOST('units', 'alpha'); |
|
650 | - } |
|
651 | - |
|
652 | - $date_start_fill = GETPOST('date_start_fill','int'); |
|
653 | - $date_end_fill = GETPOST('date_end_fill','int'); |
|
654 | - |
|
655 | - // Margin |
|
656 | - $fournprice = price2num(GETPOST('fournprice' . $predef) ? GETPOST('fournprice' . $predef) : ''); |
|
657 | - $buyingprice = price2num(GETPOST('buying_price' . $predef) != '' ? GETPOST('buying_price' . $predef) : ''); // If buying_price is '0', we must keep this value |
|
658 | - |
|
659 | - // Local Taxes |
|
660 | - $localtax1_tx = get_localtax($tva_tx, 1, $object->thirdparty, $mysoc, $tva_npr); |
|
661 | - $localtax2_tx = get_localtax($tva_tx, 2, $object->thirdparty, $mysoc, $tva_npr); |
|
662 | - |
|
663 | - $info_bits = 0; |
|
664 | - if ($tva_npr) |
|
665 | - $info_bits |= 0x01; |
|
666 | - |
|
667 | - if (((!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->produit->ignore_price_min_advance)) || empty($conf->global->MAIN_USE_ADVANCED_PERMS) )&& (! empty($price_min) && (price2num($pu_ht) * (1 - price2num($remise_percent) / 100) < price2num($price_min)))) |
|
668 | - { |
|
669 | - $mesg = $langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, - 1, $conf->currency)); |
|
670 | - setEventMessages($mesg, null, 'errors'); |
|
671 | - } |
|
672 | - else |
|
673 | - { |
|
674 | - // Insert line |
|
675 | - $result = $object->addline($desc, $pu_ht, $qty, $tva_tx,$localtax1_tx, $localtax2_tx, $idprod, $remise_percent, $price_base_type, $info_bits, '', $pu_ttc, $type, - 1, $special_code, $label, $fk_unit, 0, $date_start_fill, $date_end_fill); |
|
676 | - |
|
677 | - if ($result > 0) |
|
678 | - { |
|
679 | - /*if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) |
|
324 | + elseif ($action == 'setmodelpdf' && $user->rights->facture->creer) |
|
325 | + { |
|
326 | + $object->setModelpdf(GETPOST('modelpdf', 'alpha')); |
|
327 | + } |
|
328 | + |
|
329 | + // Set status disabled |
|
330 | + elseif ($action == 'disable' && $user->rights->facture->creer) |
|
331 | + { |
|
332 | + $db->begin(); |
|
333 | + |
|
334 | + $object->fetch($id); |
|
335 | + |
|
336 | + $res = $object->setValueFrom('suspended', 1); |
|
337 | + if ($res <= 0) |
|
338 | + { |
|
339 | + $error++; |
|
340 | + } |
|
341 | + |
|
342 | + if (! $error) |
|
343 | + { |
|
344 | + $db->commit(); |
|
345 | + } |
|
346 | + else |
|
347 | + { |
|
348 | + $db->rollback(); |
|
349 | + setEventMessages($object->error, $object->errors, 'errors'); |
|
350 | + } |
|
351 | + } |
|
352 | + |
|
353 | + // Set status enabled |
|
354 | + elseif ($action == 'enable' && $user->rights->facture->creer) |
|
355 | + { |
|
356 | + $db->begin(); |
|
357 | + |
|
358 | + $object->fetch($id); |
|
359 | + |
|
360 | + $res = $object->setValueFrom('suspended', 0); |
|
361 | + if ($res <= 0) |
|
362 | + { |
|
363 | + $error++; |
|
364 | + } |
|
365 | + |
|
366 | + if (! $error) |
|
367 | + { |
|
368 | + $db->commit(); |
|
369 | + } |
|
370 | + else |
|
371 | + { |
|
372 | + $db->rollback(); |
|
373 | + setEventMessages($object->error, $object->errors, 'errors'); |
|
374 | + } |
|
375 | + } |
|
376 | + |
|
377 | + // Delete line |
|
378 | + if ($action == 'confirm_deleteline' && $confirm == 'yes' && $user->rights->facture->creer) |
|
379 | + { |
|
380 | + $object->fetch($id); |
|
381 | + $object->fetch_thirdparty(); |
|
382 | + |
|
383 | + $db->begin(); |
|
384 | + |
|
385 | + $line=new FactureLigneRec($db); |
|
386 | + |
|
387 | + // For triggers |
|
388 | + $line->id = $lineid; |
|
389 | + |
|
390 | + if ($line->delete($user) > 0) |
|
391 | + { |
|
392 | + $result=$object->update_price(1); |
|
393 | + |
|
394 | + if ($result > 0) |
|
395 | + { |
|
396 | + $db->commit(); |
|
397 | + $object->fetch($object->id); // Reload lines |
|
398 | + } |
|
399 | + else |
|
400 | + { |
|
401 | + $db->rollback(); |
|
402 | + setEventMessages($db->lasterror(), null, 'errors'); |
|
403 | + } |
|
404 | + } |
|
405 | + else |
|
406 | + { |
|
407 | + $db->rollback(); |
|
408 | + setEventMessages($line->error, $line->errors, 'errors'); |
|
409 | + } |
|
410 | + } |
|
411 | + else if ($action == 'update_extras') |
|
412 | + { |
|
413 | + $object->oldcopy = dol_clone($object); |
|
414 | + |
|
415 | + // Fill array 'array_options' with data from update form |
|
416 | + $extralabels = $extrafields->fetch_name_optionals_label($object->table_element); |
|
417 | + $ret = $extrafields->setOptionalsFromPost($extralabels, $object, GETPOST('attribute','none')); |
|
418 | + if ($ret < 0) $error++; |
|
419 | + |
|
420 | + if (! $error) |
|
421 | + { |
|
422 | + $result = $object->insertExtraFields('BILLREC_MODIFY'); |
|
423 | + if ($result < 0) |
|
424 | + { |
|
425 | + setEventMessages($object->error, $object->errors, 'errors'); |
|
426 | + $error++; |
|
427 | + } |
|
428 | + } |
|
429 | + } |
|
430 | + |
|
431 | + // Add a new line |
|
432 | + if ($action == 'addline' && $user->rights->facture->creer) |
|
433 | + { |
|
434 | + $langs->load('errors'); |
|
435 | + $error = 0; |
|
436 | + |
|
437 | + // Set if we used free entry or predefined product |
|
438 | + $predef=''; |
|
439 | + $product_desc=(GETPOST('dp_desc')?GETPOST('dp_desc'):''); |
|
440 | + $price_ht = GETPOST('price_ht'); |
|
441 | + if (GETPOST('prod_entry_mode') == 'free') |
|
442 | + { |
|
443 | + $idprod=0; |
|
444 | + $tva_tx = (GETPOST('tva_tx') ? GETPOST('tva_tx') : 0); |
|
445 | + } |
|
446 | + else |
|
447 | + { |
|
448 | + $idprod=GETPOST('idprod', 'int'); |
|
449 | + $tva_tx = ''; |
|
450 | + } |
|
451 | + |
|
452 | + $qty = GETPOST('qty' . $predef); |
|
453 | + $remise_percent = GETPOST('remise_percent' . $predef); |
|
454 | + |
|
455 | + // Extrafields |
|
456 | + $extrafieldsline = new ExtraFields($db); |
|
457 | + $extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line); |
|
458 | + $array_options = $extrafieldsline->getOptionalsFromPost($extralabelsline, $predef); |
|
459 | + // Unset extrafield |
|
460 | + if (is_array($extralabelsline)) |
|
461 | + { |
|
462 | + // Get extra fields |
|
463 | + foreach ($extralabelsline as $key => $value) { |
|
464 | + unset($_POST["options_" . $key . $predef]); |
|
465 | + } |
|
466 | + } |
|
467 | + |
|
468 | + if (empty($idprod) && ($price_ht < 0) && ($qty < 0)) { |
|
469 | + setEventMessages($langs->trans('ErrorBothFieldCantBeNegative', $langs->transnoentitiesnoconv('UnitPriceHT'), $langs->transnoentitiesnoconv('Qty')), null, 'errors'); |
|
470 | + $error ++; |
|
471 | + } |
|
472 | + if (GETPOST('prod_entry_mode') == 'free' && empty($idprod) && GETPOST('type') < 0) { |
|
473 | + setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Type')), null, 'errors'); |
|
474 | + $error ++; |
|
475 | + } |
|
476 | + if (GETPOST('prod_entry_mode') == 'free' && empty($idprod) && (! ($price_ht >= 0) || $price_ht == '')) // Unit price can be 0 but not '' |
|
477 | + { |
|
478 | + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("UnitPriceHT")), null, 'errors'); |
|
479 | + $error ++; |
|
480 | + } |
|
481 | + if ($qty == '') { |
|
482 | + setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Qty')), null, 'errors'); |
|
483 | + $error ++; |
|
484 | + } |
|
485 | + if (GETPOST('prod_entry_mode') == 'free' && empty($idprod) && empty($product_desc)) { |
|
486 | + setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Description')), null, 'errors'); |
|
487 | + $error ++; |
|
488 | + } |
|
489 | + if ($qty < 0) { |
|
490 | + $langs->load("errors"); |
|
491 | + setEventMessages($langs->trans('ErrorQtyForCustomerInvoiceCantBeNegative'), null, 'errors'); |
|
492 | + $error ++; |
|
493 | + } |
|
494 | + |
|
495 | + if (! $error && ($qty >= 0) && (! empty($product_desc) || ! empty($idprod))) |
|
496 | + { |
|
497 | + $ret = $object->fetch($id); |
|
498 | + if ($ret < 0) { |
|
499 | + dol_print_error($db, $object->error); |
|
500 | + exit(); |
|
501 | + } |
|
502 | + $ret = $object->fetch_thirdparty(); |
|
503 | + |
|
504 | + // Clean parameters |
|
505 | + $date_start = dol_mktime(GETPOST('date_start' . $predef . 'hour'), GETPOST('date_start' . $predef . 'min'), GETPOST('date_start' . $predef . 'sec'), GETPOST('date_start' . $predef . 'month'), GETPOST('date_start' . $predef . 'day'), GETPOST('date_start' . $predef . 'year')); |
|
506 | + $date_end = dol_mktime(GETPOST('date_end' . $predef . 'hour'), GETPOST('date_end' . $predef . 'min'), GETPOST('date_end' . $predef . 'sec'), GETPOST('date_end' . $predef . 'month'), GETPOST('date_end' . $predef . 'day'), GETPOST('date_end' . $predef . 'year')); |
|
507 | + $price_base_type = (GETPOST('price_base_type', 'alpha') ? GETPOST('price_base_type', 'alpha') : 'HT'); |
|
508 | + |
|
509 | + // Define special_code for special lines |
|
510 | + $special_code = 0; |
|
511 | + // if (empty($_POST['qty'])) $special_code=3; // Options should not exists on invoices |
|
512 | + |
|
513 | + // Ecrase $pu par celui du produit |
|
514 | + // Ecrase $desc par celui du produit |
|
515 | + // Ecrase $tva_tx par celui du produit |
|
516 | + // Ecrase $base_price_type par celui du produit |
|
517 | + // Replaces $fk_unit with the product's |
|
518 | + if (! empty($idprod)) |
|
519 | + { |
|
520 | + $prod = new Product($db); |
|
521 | + $prod->fetch($idprod); |
|
522 | + |
|
523 | + $label = ((GETPOST('product_label') && GETPOST('product_label') != $prod->label) ? GETPOST('product_label') : ''); |
|
524 | + |
|
525 | + // Update if prices fields are defined |
|
526 | + $tva_tx = get_default_tva($mysoc, $object->thirdparty, $prod->id); |
|
527 | + $tva_npr = get_default_npr($mysoc, $object->thirdparty, $prod->id); |
|
528 | + if (empty($tva_tx)) $tva_npr=0; |
|
529 | + |
|
530 | + $pu_ht = $prod->price; |
|
531 | + $pu_ttc = $prod->price_ttc; |
|
532 | + $price_min = $prod->price_min; |
|
533 | + $price_base_type = $prod->price_base_type; |
|
534 | + |
|
535 | + // We define price for product |
|
536 | + if (! empty($conf->global->PRODUIT_MULTIPRICES) && ! empty($object->thirdparty->price_level)) |
|
537 | + { |
|
538 | + $pu_ht = $prod->multiprices[$object->thirdparty->price_level]; |
|
539 | + $pu_ttc = $prod->multiprices_ttc[$object->thirdparty->price_level]; |
|
540 | + $price_min = $prod->multiprices_min[$object->thirdparty->price_level]; |
|
541 | + $price_base_type = $prod->multiprices_base_type[$object->thirdparty->price_level]; |
|
542 | + if (! empty($conf->global->PRODUIT_MULTIPRICES_USE_VAT_PER_LEVEL)) // using this option is a bug. kept for backward compatibility |
|
543 | + { |
|
544 | + if (isset($prod->multiprices_tva_tx[$object->thirdparty->price_level])) $tva_tx=$prod->multiprices_tva_tx[$object->thirdparty->price_level]; |
|
545 | + if (isset($prod->multiprices_recuperableonly[$object->thirdparty->price_level])) $tva_npr=$prod->multiprices_recuperableonly[$object->thirdparty->price_level]; |
|
546 | + if (empty($tva_tx)) $tva_npr=0; |
|
547 | + } |
|
548 | + } |
|
549 | + elseif (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) |
|
550 | + { |
|
551 | + include_once DOL_DOCUMENT_ROOT . '/product/class/productcustomerprice.class.php'; |
|
552 | + |
|
553 | + $prodcustprice = new Productcustomerprice($db); |
|
554 | + |
|
555 | + $filter = array('t.fk_product' => $prod->id,'t.fk_soc' => $object->thirdparty->id); |
|
556 | + |
|
557 | + $result = $prodcustprice->fetch_all('', '', 0, 0, $filter); |
|
558 | + if ($result) |
|
559 | + { |
|
560 | + if (count($prodcustprice->lines) > 0) |
|
561 | + { |
|
562 | + $pu_ht = price($prodcustprice->lines[0]->price); |
|
563 | + $pu_ttc = price($prodcustprice->lines[0]->price_ttc); |
|
564 | + $price_base_type = $prodcustprice->lines[0]->price_base_type; |
|
565 | + $tva_tx = $prodcustprice->lines[0]->tva_tx; |
|
566 | + if ($prodcustprice->lines[0]->default_vat_code && ! preg_match('/\(.*\)/', $tva_tx)) $tva_tx.= ' ('.$prodcustprice->lines[0]->default_vat_code.')'; |
|
567 | + $tva_npr = $prodcustprice->lines[0]->recuperableonly; |
|
568 | + if (empty($tva_tx)) $tva_npr=0; |
|
569 | + } |
|
570 | + } |
|
571 | + } |
|
572 | + |
|
573 | + $tmpvat = price2num(preg_replace('/\s*\(.*\)/', '', $tva_tx)); |
|
574 | + $tmpprodvat = price2num(preg_replace('/\s*\(.*\)/', '', $prod->tva_tx)); |
|
575 | + |
|
576 | + // if price ht was forced (ie: from gui when calculated by margin rate and cost price). TODO Why this ? |
|
577 | + if (! empty($price_ht)) |
|
578 | + { |
|
579 | + $pu_ht = price2num($price_ht, 'MU'); |
|
580 | + $pu_ttc = price2num($pu_ht * (1 + ($tmpvat / 100)), 'MU'); |
|
581 | + } |
|
582 | + // On reevalue prix selon taux tva car taux tva transaction peut etre different |
|
583 | + // de ceux du produit par defaut (par exemple si pays different entre vendeur et acheteur). |
|
584 | + elseif ($tmpvat != $tmpprodvat) |
|
585 | + { |
|
586 | + if ($price_base_type != 'HT') |
|
587 | + { |
|
588 | + $pu_ht = price2num($pu_ttc / (1 + ($tmpvat / 100)), 'MU'); |
|
589 | + } |
|
590 | + else |
|
591 | + { |
|
592 | + $pu_ttc = price2num($pu_ht * (1 + ($tmpvat / 100)), 'MU'); |
|
593 | + } |
|
594 | + } |
|
595 | + |
|
596 | + $desc = ''; |
|
597 | + |
|
598 | + // Define output language |
|
599 | + if (! empty($conf->global->MAIN_MULTILANGS) && ! empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) |
|
600 | + { |
|
601 | + $outputlangs = $langs; |
|
602 | + $newlang = ''; |
|
603 | + if (empty($newlang) && GETPOST('lang_id','aZ09')) |
|
604 | + $newlang = GETPOST('lang_id','aZ09'); |
|
605 | + if (empty($newlang)) |
|
606 | + $newlang = $object->thirdparty->default_lang; |
|
607 | + if (! empty($newlang)) |
|
608 | + { |
|
609 | + $outputlangs = new Translate("", $conf); |
|
610 | + $outputlangs->setDefaultLang($newlang); |
|
611 | + } |
|
612 | + |
|
613 | + $desc = (! empty($prod->multilangs [$outputlangs->defaultlang] ["description"])) ? $prod->multilangs [$outputlangs->defaultlang] ["description"] : $prod->description; |
|
614 | + } |
|
615 | + else |
|
616 | + { |
|
617 | + $desc = $prod->description; |
|
618 | + } |
|
619 | + |
|
620 | + $desc = dol_concatdesc($desc, $product_desc); |
|
621 | + |
|
622 | + // Add custom code and origin country into description |
|
623 | + if (empty($conf->global->MAIN_PRODUCT_DISABLE_CUSTOMCOUNTRYCODE) && (! empty($prod->customcode) || ! empty($prod->country_code))) |
|
624 | + { |
|
625 | + $tmptxt = '('; |
|
626 | + if (! empty($prod->customcode)) |
|
627 | + $tmptxt .= $langs->transnoentitiesnoconv("CustomCode") . ': ' . $prod->customcode; |
|
628 | + if (! empty($prod->customcode) && ! empty($prod->country_code)) |
|
629 | + $tmptxt .= ' - '; |
|
630 | + if (! empty($prod->country_code)) |
|
631 | + $tmptxt .= $langs->transnoentitiesnoconv("CountryOrigin") . ': ' . getCountry($prod->country_code, 0, $db, $langs, 0); |
|
632 | + $tmptxt .= ')'; |
|
633 | + $desc = dol_concatdesc($desc, $tmptxt); |
|
634 | + } |
|
635 | + |
|
636 | + $type = $prod->type; |
|
637 | + $fk_unit = $prod->fk_unit; |
|
638 | + } |
|
639 | + else |
|
640 | + { |
|
641 | + $pu_ht = price2num($price_ht, 'MU'); |
|
642 | + $pu_ttc = price2num(GETPOST('price_ttc'), 'MU'); |
|
643 | + $tva_npr = (preg_match('/\*/', $tva_tx) ? 1 : 0); |
|
644 | + $tva_tx = str_replace('*', '', $tva_tx); |
|
645 | + if (empty($tva_tx)) $tva_npr=0; |
|
646 | + $label = (GETPOST('product_label') ? GETPOST('product_label') : ''); |
|
647 | + $desc = $product_desc; |
|
648 | + $type = GETPOST('type'); |
|
649 | + $fk_unit= GETPOST('units', 'alpha'); |
|
650 | + } |
|
651 | + |
|
652 | + $date_start_fill = GETPOST('date_start_fill','int'); |
|
653 | + $date_end_fill = GETPOST('date_end_fill','int'); |
|
654 | + |
|
655 | + // Margin |
|
656 | + $fournprice = price2num(GETPOST('fournprice' . $predef) ? GETPOST('fournprice' . $predef) : ''); |
|
657 | + $buyingprice = price2num(GETPOST('buying_price' . $predef) != '' ? GETPOST('buying_price' . $predef) : ''); // If buying_price is '0', we must keep this value |
|
658 | + |
|
659 | + // Local Taxes |
|
660 | + $localtax1_tx = get_localtax($tva_tx, 1, $object->thirdparty, $mysoc, $tva_npr); |
|
661 | + $localtax2_tx = get_localtax($tva_tx, 2, $object->thirdparty, $mysoc, $tva_npr); |
|
662 | + |
|
663 | + $info_bits = 0; |
|
664 | + if ($tva_npr) |
|
665 | + $info_bits |= 0x01; |
|
666 | + |
|
667 | + if (((!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->produit->ignore_price_min_advance)) || empty($conf->global->MAIN_USE_ADVANCED_PERMS) )&& (! empty($price_min) && (price2num($pu_ht) * (1 - price2num($remise_percent) / 100) < price2num($price_min)))) |
|
668 | + { |
|
669 | + $mesg = $langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, - 1, $conf->currency)); |
|
670 | + setEventMessages($mesg, null, 'errors'); |
|
671 | + } |
|
672 | + else |
|
673 | + { |
|
674 | + // Insert line |
|
675 | + $result = $object->addline($desc, $pu_ht, $qty, $tva_tx,$localtax1_tx, $localtax2_tx, $idprod, $remise_percent, $price_base_type, $info_bits, '', $pu_ttc, $type, - 1, $special_code, $label, $fk_unit, 0, $date_start_fill, $date_end_fill); |
|
676 | + |
|
677 | + if ($result > 0) |
|
678 | + { |
|
679 | + /*if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) |
|
680 | 680 | { |
681 | 681 | // Define output language |
682 | 682 | $outputlangs = $langs; |
@@ -693,117 +693,117 @@ discard block |
||
693 | 693 | $result = $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); |
694 | 694 | if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); |
695 | 695 | }*/ |
696 | - $object->fetch($object->id); // Reload lines |
|
697 | - |
|
698 | - unset($_POST['prod_entry_mode']); |
|
699 | - |
|
700 | - unset($_POST['qty']); |
|
701 | - unset($_POST['type']); |
|
702 | - unset($_POST['remise_percent']); |
|
703 | - unset($_POST['price_ht']); |
|
704 | - unset($_POST['multicurrency_price_ht']); |
|
705 | - unset($_POST['price_ttc']); |
|
706 | - unset($_POST['tva_tx']); |
|
707 | - unset($_POST['product_ref']); |
|
708 | - unset($_POST['product_label']); |
|
709 | - unset($_POST['product_desc']); |
|
710 | - unset($_POST['fournprice']); |
|
711 | - unset($_POST['buying_price']); |
|
712 | - unset($_POST['np_marginRate']); |
|
713 | - unset($_POST['np_markRate']); |
|
714 | - unset($_POST['dp_desc']); |
|
715 | - unset($_POST['idprod']); |
|
716 | - unset($_POST['units']); |
|
717 | - |
|
718 | - unset($_POST['date_starthour']); |
|
719 | - unset($_POST['date_startmin']); |
|
720 | - unset($_POST['date_startsec']); |
|
721 | - unset($_POST['date_startday']); |
|
722 | - unset($_POST['date_startmonth']); |
|
723 | - unset($_POST['date_startyear']); |
|
724 | - unset($_POST['date_endhour']); |
|
725 | - unset($_POST['date_endmin']); |
|
726 | - unset($_POST['date_endsec']); |
|
727 | - unset($_POST['date_endday']); |
|
728 | - unset($_POST['date_endmonth']); |
|
729 | - unset($_POST['date_endyear']); |
|
730 | - |
|
731 | - unset($_POST['date_start_fill']); |
|
732 | - unset($_POST['date_end_fill']); |
|
733 | - |
|
734 | - unset($_POST['situations']); |
|
735 | - unset($_POST['progress']); |
|
736 | - } |
|
737 | - else |
|
738 | - { |
|
739 | - setEventMessages($object->error, $object->errors, 'errors'); |
|
740 | - } |
|
741 | - |
|
742 | - $action = ''; |
|
743 | - } |
|
744 | - } |
|
745 | - } |
|
746 | - |
|
747 | - elseif ($action == 'updateline' && $user->rights->facture->creer && ! GETPOST('cancel','alpha')) |
|
748 | - { |
|
749 | - if (! $object->fetch($id) > 0) dol_print_error($db); |
|
750 | - $object->fetch_thirdparty(); |
|
751 | - |
|
752 | - // Clean parameters |
|
753 | - $date_start = ''; |
|
754 | - $date_end = ''; |
|
755 | - //$date_start = dol_mktime(GETPOST('date_starthour'), GETPOST('date_startmin'), GETPOST('date_startsec'), GETPOST('date_startmonth'), GETPOST('date_startday'), GETPOST('date_startyear')); |
|
756 | - //$date_end = dol_mktime(GETPOST('date_endhour'), GETPOST('date_endmin'), GETPOST('date_endsec'), GETPOST('date_endmonth'), GETPOST('date_endday'), GETPOST('date_endyear')); |
|
757 | - $description = dol_htmlcleanlastbr(GETPOST('product_desc','none') ? GETPOST('product_desc','none') : GETPOST('desc','none')); |
|
758 | - $pu_ht = GETPOST('price_ht'); |
|
759 | - $vat_rate = (GETPOST('tva_tx') ? GETPOST('tva_tx') : 0); |
|
760 | - $qty = GETPOST('qty'); |
|
761 | - $pu_ht_devise = GETPOST('multicurrency_subprice'); |
|
762 | - |
|
763 | - // Define info_bits |
|
764 | - $info_bits = 0; |
|
765 | - if (preg_match('/\*/', $vat_rate)) $info_bits |= 0x01; |
|
766 | - |
|
767 | - // Define vat_rate |
|
768 | - $vat_rate = str_replace('*', '', $vat_rate); |
|
769 | - $localtax1_rate = get_localtax($vat_rate, 1, $object->thirdparty); |
|
770 | - $localtax2_rate = get_localtax($vat_rate, 2, $object->thirdparty); |
|
771 | - |
|
772 | - // Add buying price |
|
773 | - $fournprice = price2num(GETPOST('fournprice') ? GETPOST('fournprice') : ''); |
|
774 | - $buyingprice = price2num(GETPOST('buying_price') != '' ? GETPOST('buying_price') : ''); // If buying_price is '0', we muste keep this value |
|
775 | - |
|
776 | - // Extrafields |
|
777 | - $extrafieldsline = new ExtraFields($db); |
|
778 | - $extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line); |
|
779 | - $array_options = $extrafieldsline->getOptionalsFromPost($extralabelsline); |
|
780 | - |
|
781 | - $objectline = new FactureLigneRec($db); |
|
782 | - if ($objectline->fetch(GETPOST('lineid'))) |
|
783 | - { |
|
784 | - $objectline->array_options=$array_options; |
|
785 | - $result=$objectline->insertExtraFields(); |
|
786 | - if ($result < 0) |
|
787 | - { |
|
788 | - setEventMessages($langs->trans('Error').$result, null, 'errors'); |
|
789 | - } |
|
790 | - } |
|
791 | - |
|
792 | - // Unset extrafield |
|
793 | - if (is_array($extralabelsline)) |
|
794 | - { |
|
795 | - // Get extra fields |
|
796 | - foreach ($extralabelsline as $key => $value) |
|
797 | - { |
|
798 | - unset($_POST["options_" . $key]); |
|
799 | - } |
|
800 | - } |
|
801 | - |
|
802 | - // Define special_code for special lines |
|
803 | - $special_code=GETPOST('special_code'); |
|
804 | - if (! GETPOST('qty')) $special_code=3; |
|
805 | - |
|
806 | - /*$line = new FactureLigne($db); |
|
696 | + $object->fetch($object->id); // Reload lines |
|
697 | + |
|
698 | + unset($_POST['prod_entry_mode']); |
|
699 | + |
|
700 | + unset($_POST['qty']); |
|
701 | + unset($_POST['type']); |
|
702 | + unset($_POST['remise_percent']); |
|
703 | + unset($_POST['price_ht']); |
|
704 | + unset($_POST['multicurrency_price_ht']); |
|
705 | + unset($_POST['price_ttc']); |
|
706 | + unset($_POST['tva_tx']); |
|
707 | + unset($_POST['product_ref']); |
|
708 | + unset($_POST['product_label']); |
|
709 | + unset($_POST['product_desc']); |
|
710 | + unset($_POST['fournprice']); |
|
711 | + unset($_POST['buying_price']); |
|
712 | + unset($_POST['np_marginRate']); |
|
713 | + unset($_POST['np_markRate']); |
|
714 | + unset($_POST['dp_desc']); |
|
715 | + unset($_POST['idprod']); |
|
716 | + unset($_POST['units']); |
|
717 | + |
|
718 | + unset($_POST['date_starthour']); |
|
719 | + unset($_POST['date_startmin']); |
|
720 | + unset($_POST['date_startsec']); |
|
721 | + unset($_POST['date_startday']); |
|
722 | + unset($_POST['date_startmonth']); |
|
723 | + unset($_POST['date_startyear']); |
|
724 | + unset($_POST['date_endhour']); |
|
725 | + unset($_POST['date_endmin']); |
|
726 | + unset($_POST['date_endsec']); |
|
727 | + unset($_POST['date_endday']); |
|
728 | + unset($_POST['date_endmonth']); |
|
729 | + unset($_POST['date_endyear']); |
|
730 | + |
|
731 | + unset($_POST['date_start_fill']); |
|
732 | + unset($_POST['date_end_fill']); |
|
733 | + |
|
734 | + unset($_POST['situations']); |
|
735 | + unset($_POST['progress']); |
|
736 | + } |
|
737 | + else |
|
738 | + { |
|
739 | + setEventMessages($object->error, $object->errors, 'errors'); |
|
740 | + } |
|
741 | + |
|
742 | + $action = ''; |
|
743 | + } |
|
744 | + } |
|
745 | + } |
|
746 | + |
|
747 | + elseif ($action == 'updateline' && $user->rights->facture->creer && ! GETPOST('cancel','alpha')) |
|
748 | + { |
|
749 | + if (! $object->fetch($id) > 0) dol_print_error($db); |
|
750 | + $object->fetch_thirdparty(); |
|
751 | + |
|
752 | + // Clean parameters |
|
753 | + $date_start = ''; |
|
754 | + $date_end = ''; |
|
755 | + //$date_start = dol_mktime(GETPOST('date_starthour'), GETPOST('date_startmin'), GETPOST('date_startsec'), GETPOST('date_startmonth'), GETPOST('date_startday'), GETPOST('date_startyear')); |
|
756 | + //$date_end = dol_mktime(GETPOST('date_endhour'), GETPOST('date_endmin'), GETPOST('date_endsec'), GETPOST('date_endmonth'), GETPOST('date_endday'), GETPOST('date_endyear')); |
|
757 | + $description = dol_htmlcleanlastbr(GETPOST('product_desc','none') ? GETPOST('product_desc','none') : GETPOST('desc','none')); |
|
758 | + $pu_ht = GETPOST('price_ht'); |
|
759 | + $vat_rate = (GETPOST('tva_tx') ? GETPOST('tva_tx') : 0); |
|
760 | + $qty = GETPOST('qty'); |
|
761 | + $pu_ht_devise = GETPOST('multicurrency_subprice'); |
|
762 | + |
|
763 | + // Define info_bits |
|
764 | + $info_bits = 0; |
|
765 | + if (preg_match('/\*/', $vat_rate)) $info_bits |= 0x01; |
|
766 | + |
|
767 | + // Define vat_rate |
|
768 | + $vat_rate = str_replace('*', '', $vat_rate); |
|
769 | + $localtax1_rate = get_localtax($vat_rate, 1, $object->thirdparty); |
|
770 | + $localtax2_rate = get_localtax($vat_rate, 2, $object->thirdparty); |
|
771 | + |
|
772 | + // Add buying price |
|
773 | + $fournprice = price2num(GETPOST('fournprice') ? GETPOST('fournprice') : ''); |
|
774 | + $buyingprice = price2num(GETPOST('buying_price') != '' ? GETPOST('buying_price') : ''); // If buying_price is '0', we muste keep this value |
|
775 | + |
|
776 | + // Extrafields |
|
777 | + $extrafieldsline = new ExtraFields($db); |
|
778 | + $extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line); |
|
779 | + $array_options = $extrafieldsline->getOptionalsFromPost($extralabelsline); |
|
780 | + |
|
781 | + $objectline = new FactureLigneRec($db); |
|
782 | + if ($objectline->fetch(GETPOST('lineid'))) |
|
783 | + { |
|
784 | + $objectline->array_options=$array_options; |
|
785 | + $result=$objectline->insertExtraFields(); |
|
786 | + if ($result < 0) |
|
787 | + { |
|
788 | + setEventMessages($langs->trans('Error').$result, null, 'errors'); |
|
789 | + } |
|
790 | + } |
|
791 | + |
|
792 | + // Unset extrafield |
|
793 | + if (is_array($extralabelsline)) |
|
794 | + { |
|
795 | + // Get extra fields |
|
796 | + foreach ($extralabelsline as $key => $value) |
|
797 | + { |
|
798 | + unset($_POST["options_" . $key]); |
|
799 | + } |
|
800 | + } |
|
801 | + |
|
802 | + // Define special_code for special lines |
|
803 | + $special_code=GETPOST('special_code'); |
|
804 | + if (! GETPOST('qty')) $special_code=3; |
|
805 | + |
|
806 | + /*$line = new FactureLigne($db); |
|
807 | 807 | $line->fetch(GETPOST('lineid')); |
808 | 808 | $percent = $line->get_prev_progress($object->id); |
809 | 809 | |
@@ -815,77 +815,77 @@ discard block |
||
815 | 815 | $result = -1; |
816 | 816 | }*/ |
817 | 817 | |
818 | - // Check minimum price |
|
819 | - $productid = GETPOST('productid', 'int'); |
|
820 | - if (! empty($productid)) |
|
821 | - { |
|
822 | - $product = new Product($db); |
|
823 | - $product->fetch($productid); |
|
824 | - |
|
825 | - $type = $product->type; |
|
826 | - |
|
827 | - $price_min = $product->price_min; |
|
828 | - if (! empty($conf->global->PRODUIT_MULTIPRICES) && ! empty($object->thirdparty->price_level)) |
|
829 | - $price_min = $product->multiprices_min[$object->thirdparty->price_level]; |
|
830 | - |
|
831 | - $label = ((GETPOST('update_label') && GETPOST('product_label')) ? GETPOST('product_label') : ''); |
|
832 | - |
|
833 | - // Check price is not lower than minimum (check is done only for standard or replacement invoices) |
|
834 | - if (((!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->produit->ignore_price_min_advance)) || empty($conf->global->MAIN_USE_ADVANCED_PERMS) )&& (($object->type == Facture::TYPE_STANDARD || $object->type == Facture::TYPE_REPLACEMENT) && $price_min && (price2num($pu_ht) * (1 - price2num(GETPOST('remise_percent')) / 100) < price2num($price_min)))) |
|
835 | - { |
|
836 | - setEventMessages($langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, - 1, $conf->currency)), null, 'errors'); |
|
837 | - $error ++; |
|
838 | - } |
|
839 | - } else { |
|
840 | - $type = GETPOST('type'); |
|
841 | - $label = (GETPOST('product_label') ? GETPOST('product_label') : ''); |
|
842 | - |
|
843 | - // Check parameters |
|
844 | - if (GETPOST('type') < 0) { |
|
845 | - setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")), null, 'errors'); |
|
846 | - $error ++; |
|
847 | - } |
|
848 | - } |
|
849 | - if ($qty < 0) { |
|
850 | - $langs->load("errors"); |
|
851 | - setEventMessages($langs->trans('ErrorQtyForCustomerInvoiceCantBeNegative'), null, 'errors'); |
|
852 | - $error ++; |
|
853 | - } |
|
854 | - |
|
855 | - $date_start_fill = GETPOST('date_start_fill','int'); |
|
856 | - $date_end_fill = GETPOST('date_end_fill','int'); |
|
857 | - |
|
858 | - // Update line |
|
859 | - if (! $error) |
|
860 | - { |
|
861 | - $result = $object->updateline( |
|
862 | - GETPOST('lineid'), |
|
863 | - $description, |
|
864 | - $pu_ht, |
|
865 | - $qty, |
|
866 | - $vat_rate, |
|
867 | - $localtax1_rate, |
|
868 | - $localtax1_rate, |
|
869 | - GETPOST('productid'), |
|
870 | - GETPOST('remise_percent'), |
|
871 | - 'HT', |
|
872 | - $info_bits, |
|
873 | - 0, |
|
874 | - 0, |
|
875 | - $type, |
|
876 | - 0, |
|
877 | - $special_code, |
|
878 | - $label, |
|
879 | - GETPOST('units'), |
|
880 | - $pu_ht_devise, |
|
881 | - 0, |
|
882 | - $date_start_fill, |
|
883 | - $date_end_fill |
|
884 | - ); |
|
885 | - |
|
886 | - if ($result >= 0) |
|
887 | - { |
|
888 | - /*if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { |
|
818 | + // Check minimum price |
|
819 | + $productid = GETPOST('productid', 'int'); |
|
820 | + if (! empty($productid)) |
|
821 | + { |
|
822 | + $product = new Product($db); |
|
823 | + $product->fetch($productid); |
|
824 | + |
|
825 | + $type = $product->type; |
|
826 | + |
|
827 | + $price_min = $product->price_min; |
|
828 | + if (! empty($conf->global->PRODUIT_MULTIPRICES) && ! empty($object->thirdparty->price_level)) |
|
829 | + $price_min = $product->multiprices_min[$object->thirdparty->price_level]; |
|
830 | + |
|
831 | + $label = ((GETPOST('update_label') && GETPOST('product_label')) ? GETPOST('product_label') : ''); |
|
832 | + |
|
833 | + // Check price is not lower than minimum (check is done only for standard or replacement invoices) |
|
834 | + if (((!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->produit->ignore_price_min_advance)) || empty($conf->global->MAIN_USE_ADVANCED_PERMS) )&& (($object->type == Facture::TYPE_STANDARD || $object->type == Facture::TYPE_REPLACEMENT) && $price_min && (price2num($pu_ht) * (1 - price2num(GETPOST('remise_percent')) / 100) < price2num($price_min)))) |
|
835 | + { |
|
836 | + setEventMessages($langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, - 1, $conf->currency)), null, 'errors'); |
|
837 | + $error ++; |
|
838 | + } |
|
839 | + } else { |
|
840 | + $type = GETPOST('type'); |
|
841 | + $label = (GETPOST('product_label') ? GETPOST('product_label') : ''); |
|
842 | + |
|
843 | + // Check parameters |
|
844 | + if (GETPOST('type') < 0) { |
|
845 | + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")), null, 'errors'); |
|
846 | + $error ++; |
|
847 | + } |
|
848 | + } |
|
849 | + if ($qty < 0) { |
|
850 | + $langs->load("errors"); |
|
851 | + setEventMessages($langs->trans('ErrorQtyForCustomerInvoiceCantBeNegative'), null, 'errors'); |
|
852 | + $error ++; |
|
853 | + } |
|
854 | + |
|
855 | + $date_start_fill = GETPOST('date_start_fill','int'); |
|
856 | + $date_end_fill = GETPOST('date_end_fill','int'); |
|
857 | + |
|
858 | + // Update line |
|
859 | + if (! $error) |
|
860 | + { |
|
861 | + $result = $object->updateline( |
|
862 | + GETPOST('lineid'), |
|
863 | + $description, |
|
864 | + $pu_ht, |
|
865 | + $qty, |
|
866 | + $vat_rate, |
|
867 | + $localtax1_rate, |
|
868 | + $localtax1_rate, |
|
869 | + GETPOST('productid'), |
|
870 | + GETPOST('remise_percent'), |
|
871 | + 'HT', |
|
872 | + $info_bits, |
|
873 | + 0, |
|
874 | + 0, |
|
875 | + $type, |
|
876 | + 0, |
|
877 | + $special_code, |
|
878 | + $label, |
|
879 | + GETPOST('units'), |
|
880 | + $pu_ht_devise, |
|
881 | + 0, |
|
882 | + $date_start_fill, |
|
883 | + $date_end_fill |
|
884 | + ); |
|
885 | + |
|
886 | + if ($result >= 0) |
|
887 | + { |
|
888 | + /*if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { |
|
889 | 889 | // Define output language |
890 | 890 | $outputlangs = $langs; |
891 | 891 | $newlang = ''; |
@@ -902,50 +902,50 @@ discard block |
||
902 | 902 | $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); |
903 | 903 | }*/ |
904 | 904 | |
905 | - $object->fetch($object->id); // Reload lines |
|
906 | - |
|
907 | - unset($_POST['qty']); |
|
908 | - unset($_POST['type']); |
|
909 | - unset($_POST['productid']); |
|
910 | - unset($_POST['remise_percent']); |
|
911 | - unset($_POST['price_ht']); |
|
912 | - unset($_POST['multicurrency_price_ht']); |
|
913 | - unset($_POST['price_ttc']); |
|
914 | - unset($_POST['tva_tx']); |
|
915 | - unset($_POST['product_ref']); |
|
916 | - unset($_POST['product_label']); |
|
917 | - unset($_POST['product_desc']); |
|
918 | - unset($_POST['fournprice']); |
|
919 | - unset($_POST['buying_price']); |
|
920 | - unset($_POST['np_marginRate']); |
|
921 | - unset($_POST['np_markRate']); |
|
922 | - |
|
923 | - unset($_POST['dp_desc']); |
|
924 | - unset($_POST['idprod']); |
|
925 | - unset($_POST['units']); |
|
926 | - |
|
927 | - unset($_POST['date_starthour']); |
|
928 | - unset($_POST['date_startmin']); |
|
929 | - unset($_POST['date_startsec']); |
|
930 | - unset($_POST['date_startday']); |
|
931 | - unset($_POST['date_startmonth']); |
|
932 | - unset($_POST['date_startyear']); |
|
933 | - unset($_POST['date_endhour']); |
|
934 | - unset($_POST['date_endmin']); |
|
935 | - unset($_POST['date_endsec']); |
|
936 | - unset($_POST['date_endday']); |
|
937 | - unset($_POST['date_endmonth']); |
|
938 | - unset($_POST['date_endyear']); |
|
939 | - |
|
940 | - unset($_POST['situations']); |
|
941 | - unset($_POST['progress']); |
|
942 | - } |
|
943 | - else |
|
944 | - { |
|
945 | - setEventMessages($object->error, $object->errors, 'errors'); |
|
946 | - } |
|
947 | - } |
|
948 | - } |
|
905 | + $object->fetch($object->id); // Reload lines |
|
906 | + |
|
907 | + unset($_POST['qty']); |
|
908 | + unset($_POST['type']); |
|
909 | + unset($_POST['productid']); |
|
910 | + unset($_POST['remise_percent']); |
|
911 | + unset($_POST['price_ht']); |
|
912 | + unset($_POST['multicurrency_price_ht']); |
|
913 | + unset($_POST['price_ttc']); |
|
914 | + unset($_POST['tva_tx']); |
|
915 | + unset($_POST['product_ref']); |
|
916 | + unset($_POST['product_label']); |
|
917 | + unset($_POST['product_desc']); |
|
918 | + unset($_POST['fournprice']); |
|
919 | + unset($_POST['buying_price']); |
|
920 | + unset($_POST['np_marginRate']); |
|
921 | + unset($_POST['np_markRate']); |
|
922 | + |
|
923 | + unset($_POST['dp_desc']); |
|
924 | + unset($_POST['idprod']); |
|
925 | + unset($_POST['units']); |
|
926 | + |
|
927 | + unset($_POST['date_starthour']); |
|
928 | + unset($_POST['date_startmin']); |
|
929 | + unset($_POST['date_startsec']); |
|
930 | + unset($_POST['date_startday']); |
|
931 | + unset($_POST['date_startmonth']); |
|
932 | + unset($_POST['date_startyear']); |
|
933 | + unset($_POST['date_endhour']); |
|
934 | + unset($_POST['date_endmin']); |
|
935 | + unset($_POST['date_endsec']); |
|
936 | + unset($_POST['date_endday']); |
|
937 | + unset($_POST['date_endmonth']); |
|
938 | + unset($_POST['date_endyear']); |
|
939 | + |
|
940 | + unset($_POST['situations']); |
|
941 | + unset($_POST['progress']); |
|
942 | + } |
|
943 | + else |
|
944 | + { |
|
945 | + setEventMessages($object->error, $object->errors, 'errors'); |
|
946 | + } |
|
947 | + } |
|
948 | + } |
|
949 | 949 | } |
950 | 950 | |
951 | 951 | |
@@ -971,119 +971,119 @@ discard block |
||
971 | 971 | */ |
972 | 972 | if ($action == 'create') |
973 | 973 | { |
974 | - print load_fiche_titre($langs->trans("CreateRepeatableInvoice"),'','title_accountancy.png'); |
|
975 | - |
|
976 | - $object = new Facture($db); // Source invoice |
|
977 | - $product_static = new Product($db); |
|
978 | - |
|
979 | - if ($object->fetch($id, $ref) > 0) |
|
980 | - { |
|
981 | - $result = $object->getLinesArray(); |
|
982 | - |
|
983 | - print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">'; |
|
984 | - print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
985 | - print '<input type="hidden" name="action" value="add">'; |
|
986 | - print '<input type="hidden" name="facid" value="'.$object->id.'">'; |
|
987 | - |
|
988 | - dol_fiche_head(null, '', '', 0); |
|
989 | - |
|
990 | - $rowspan=4; |
|
991 | - if (! empty($conf->projet->enabled)) $rowspan++; |
|
992 | - if ($object->fk_account > 0) $rowspan++; |
|
993 | - |
|
994 | - print '<table class="border" width="100%">'; |
|
995 | - |
|
996 | - $object->fetch_thirdparty(); |
|
997 | - |
|
998 | - // Title |
|
999 | - print '<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans("Title").'</td><td>'; |
|
1000 | - print '<input class="flat quatrevingtpercent" type="text" name="titre" value="'.$_POST["titre"].'">'; |
|
1001 | - print '</td></tr>'; |
|
1002 | - |
|
1003 | - // Third party |
|
1004 | - print '<tr><td class="titlefieldcreate">'.$langs->trans("Customer").'</td><td>'.$object->thirdparty->getNomUrl(1,'customer').'</td>'; |
|
1005 | - print '</tr>'; |
|
1006 | - |
|
1007 | - $note_public=GETPOST('note_public','none')?GETPOST('note_public','none'):$object->note_public; |
|
1008 | - $note_private=GETPOST('note_private','none')?GETPOST('note_private','none'):$object->note_private; |
|
1009 | - |
|
1010 | - // Help of substitution key |
|
1011 | - $substitutionarray = getCommonSubstitutionArray($langs, 2, null, $object); |
|
1012 | - |
|
1013 | - $substitutionarray['__INVOICE_PREVIOUS_MONTH__'] = $langs->trans("PreviousMonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($object->date, -1, 'm'),'%m').')'; |
|
1014 | - $substitutionarray['__INVOICE_MONTH__'] = $langs->trans("MonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date($object->date,'%m').')'; |
|
1015 | - $substitutionarray['__INVOICE_NEXT_MONTH__'] = $langs->trans("NextMonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($object->date, 1, 'm'),'%m').')'; |
|
1016 | - $substitutionarray['__INVOICE_PREVIOUS_MONTH_TEXT__'] = $langs->trans("TextPreviousMonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($object->date, -1, 'm'),'%B').')'; |
|
1017 | - $substitutionarray['__INVOICE_MONTH_TEXT__'] = $langs->trans("TextMonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date($object->date,'%B').')'; |
|
1018 | - $substitutionarray['__INVOICE_NEXT_MONTH_TEXT__'] = $langs->trans("TextNextMonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($object->date, 1, 'm'), '%B').')'; |
|
1019 | - $substitutionarray['__INVOICE_PREVIOUS_YEAR__'] = $langs->trans("YearOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($object->date, -1, 'y'),'%Y').')'; |
|
1020 | - $substitutionarray['__INVOICE_YEAR__'] = $langs->trans("PreviousYearOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date($object->date,'%Y').')'; |
|
1021 | - $substitutionarray['__INVOICE_NEXT_YEAR__'] = $langs->trans("NextYearOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($object->date, 1, 'y'),'%Y').')'; |
|
1022 | - // Only on template invoices |
|
1023 | - $substitutionarray['__INVOICE_DATE_NEXT_INVOICE_BEFORE_GEN__'] = $langs->trans("DateNextInvoiceBeforeGen").' ('.$langs->trans("Example").': '.dol_print_date($object->date_when, 'dayhour').')'; |
|
1024 | - $substitutionarray['__INVOICE_DATE_NEXT_INVOICE_AFTER_GEN__'] = $langs->trans("DateNextInvoiceAfterGen").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($object->date_when, $object->frequency, $object->unit_frequency),'dayhour').')'; |
|
1025 | - |
|
1026 | - $htmltext = '<i>'.$langs->trans("FollowingConstantsWillBeSubstituted").':<br>'; |
|
1027 | - foreach($substitutionarray as $key => $val) |
|
1028 | - { |
|
1029 | - $htmltext.=$key.' = '.$langs->trans($val).'<br>'; |
|
1030 | - } |
|
1031 | - $htmltext.='</i>'; |
|
1032 | - |
|
1033 | - // Public note |
|
1034 | - print '<tr>'; |
|
1035 | - print '<td class="tdtop">'; |
|
1036 | - print $form->textwithpicto($langs->trans('NotePublic'), $htmltext, 1, 'help', '', 0, 2, 'notepublic'); |
|
1037 | - print '</td>'; |
|
1038 | - print '<td>'; |
|
1039 | - $doleditor = new DolEditor('note_public', $note_public, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%'); |
|
1040 | - print $doleditor->Create(1); |
|
1041 | - |
|
1042 | - // Private note |
|
1043 | - if (empty($user->societe_id)) |
|
1044 | - { |
|
1045 | - print '<tr>'; |
|
1046 | - print '<td class="tdtop">'; |
|
1047 | - print $form->textwithpicto($langs->trans('NotePrivate'), $htmltext, 1, 'help', '', 0, 2, 'noteprivate'); |
|
1048 | - print '</td>'; |
|
1049 | - print '<td>'; |
|
1050 | - $doleditor = new DolEditor('note_private', $note_private, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%'); |
|
1051 | - print $doleditor->Create(1); |
|
1052 | - // print '<textarea name="note_private" wrap="soft" cols="70" rows="'.ROWS_3.'">'.$note_private.'.</textarea> |
|
1053 | - print '</td></tr>'; |
|
1054 | - } |
|
1055 | - |
|
1056 | - // Author |
|
1057 | - print "<tr><td>".$langs->trans("Author")."</td><td>".$user->getFullName($langs)."</td></tr>"; |
|
1058 | - |
|
1059 | - // Payment term |
|
1060 | - print "<tr><td>".$langs->trans("PaymentConditions")."</td><td>"; |
|
1061 | - $form->form_conditions_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->cond_reglement_id, 'none'); |
|
1062 | - print "</td></tr>"; |
|
1063 | - |
|
1064 | - // Payment mode |
|
1065 | - print "<tr><td>".$langs->trans("PaymentMode")."</td><td>"; |
|
1066 | - $form->form_modes_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->mode_reglement_id, 'none', '', 1); |
|
1067 | - print "</td></tr>"; |
|
1068 | - |
|
1069 | - // Project |
|
1070 | - if (! empty($conf->projet->enabled) && is_object($object->thirdparty) && $object->thirdparty->id > 0) |
|
1071 | - { |
|
1072 | - $projectid = GETPOST('projectid')?GETPOST('projectid'):$object->fk_project; |
|
1073 | - $langs->load('projects'); |
|
1074 | - print '<tr><td>' . $langs->trans('Project') . '</td><td>'; |
|
1075 | - $numprojet = $formproject->select_projects($object->thirdparty->id, $projectid, 'projectid', 0, 0, 1, 0, 0, 0, 0, '', 0, 0, ''); |
|
974 | + print load_fiche_titre($langs->trans("CreateRepeatableInvoice"),'','title_accountancy.png'); |
|
975 | + |
|
976 | + $object = new Facture($db); // Source invoice |
|
977 | + $product_static = new Product($db); |
|
978 | + |
|
979 | + if ($object->fetch($id, $ref) > 0) |
|
980 | + { |
|
981 | + $result = $object->getLinesArray(); |
|
982 | + |
|
983 | + print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">'; |
|
984 | + print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
985 | + print '<input type="hidden" name="action" value="add">'; |
|
986 | + print '<input type="hidden" name="facid" value="'.$object->id.'">'; |
|
987 | + |
|
988 | + dol_fiche_head(null, '', '', 0); |
|
989 | + |
|
990 | + $rowspan=4; |
|
991 | + if (! empty($conf->projet->enabled)) $rowspan++; |
|
992 | + if ($object->fk_account > 0) $rowspan++; |
|
993 | + |
|
994 | + print '<table class="border" width="100%">'; |
|
995 | + |
|
996 | + $object->fetch_thirdparty(); |
|
997 | + |
|
998 | + // Title |
|
999 | + print '<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans("Title").'</td><td>'; |
|
1000 | + print '<input class="flat quatrevingtpercent" type="text" name="titre" value="'.$_POST["titre"].'">'; |
|
1001 | + print '</td></tr>'; |
|
1002 | + |
|
1003 | + // Third party |
|
1004 | + print '<tr><td class="titlefieldcreate">'.$langs->trans("Customer").'</td><td>'.$object->thirdparty->getNomUrl(1,'customer').'</td>'; |
|
1005 | + print '</tr>'; |
|
1006 | + |
|
1007 | + $note_public=GETPOST('note_public','none')?GETPOST('note_public','none'):$object->note_public; |
|
1008 | + $note_private=GETPOST('note_private','none')?GETPOST('note_private','none'):$object->note_private; |
|
1009 | + |
|
1010 | + // Help of substitution key |
|
1011 | + $substitutionarray = getCommonSubstitutionArray($langs, 2, null, $object); |
|
1012 | + |
|
1013 | + $substitutionarray['__INVOICE_PREVIOUS_MONTH__'] = $langs->trans("PreviousMonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($object->date, -1, 'm'),'%m').')'; |
|
1014 | + $substitutionarray['__INVOICE_MONTH__'] = $langs->trans("MonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date($object->date,'%m').')'; |
|
1015 | + $substitutionarray['__INVOICE_NEXT_MONTH__'] = $langs->trans("NextMonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($object->date, 1, 'm'),'%m').')'; |
|
1016 | + $substitutionarray['__INVOICE_PREVIOUS_MONTH_TEXT__'] = $langs->trans("TextPreviousMonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($object->date, -1, 'm'),'%B').')'; |
|
1017 | + $substitutionarray['__INVOICE_MONTH_TEXT__'] = $langs->trans("TextMonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date($object->date,'%B').')'; |
|
1018 | + $substitutionarray['__INVOICE_NEXT_MONTH_TEXT__'] = $langs->trans("TextNextMonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($object->date, 1, 'm'), '%B').')'; |
|
1019 | + $substitutionarray['__INVOICE_PREVIOUS_YEAR__'] = $langs->trans("YearOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($object->date, -1, 'y'),'%Y').')'; |
|
1020 | + $substitutionarray['__INVOICE_YEAR__'] = $langs->trans("PreviousYearOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date($object->date,'%Y').')'; |
|
1021 | + $substitutionarray['__INVOICE_NEXT_YEAR__'] = $langs->trans("NextYearOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($object->date, 1, 'y'),'%Y').')'; |
|
1022 | + // Only on template invoices |
|
1023 | + $substitutionarray['__INVOICE_DATE_NEXT_INVOICE_BEFORE_GEN__'] = $langs->trans("DateNextInvoiceBeforeGen").' ('.$langs->trans("Example").': '.dol_print_date($object->date_when, 'dayhour').')'; |
|
1024 | + $substitutionarray['__INVOICE_DATE_NEXT_INVOICE_AFTER_GEN__'] = $langs->trans("DateNextInvoiceAfterGen").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($object->date_when, $object->frequency, $object->unit_frequency),'dayhour').')'; |
|
1025 | + |
|
1026 | + $htmltext = '<i>'.$langs->trans("FollowingConstantsWillBeSubstituted").':<br>'; |
|
1027 | + foreach($substitutionarray as $key => $val) |
|
1028 | + { |
|
1029 | + $htmltext.=$key.' = '.$langs->trans($val).'<br>'; |
|
1030 | + } |
|
1031 | + $htmltext.='</i>'; |
|
1032 | + |
|
1033 | + // Public note |
|
1034 | + print '<tr>'; |
|
1035 | + print '<td class="tdtop">'; |
|
1036 | + print $form->textwithpicto($langs->trans('NotePublic'), $htmltext, 1, 'help', '', 0, 2, 'notepublic'); |
|
1037 | + print '</td>'; |
|
1038 | + print '<td>'; |
|
1039 | + $doleditor = new DolEditor('note_public', $note_public, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%'); |
|
1040 | + print $doleditor->Create(1); |
|
1041 | + |
|
1042 | + // Private note |
|
1043 | + if (empty($user->societe_id)) |
|
1044 | + { |
|
1045 | + print '<tr>'; |
|
1046 | + print '<td class="tdtop">'; |
|
1047 | + print $form->textwithpicto($langs->trans('NotePrivate'), $htmltext, 1, 'help', '', 0, 2, 'noteprivate'); |
|
1048 | + print '</td>'; |
|
1049 | + print '<td>'; |
|
1050 | + $doleditor = new DolEditor('note_private', $note_private, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%'); |
|
1051 | + print $doleditor->Create(1); |
|
1052 | + // print '<textarea name="note_private" wrap="soft" cols="70" rows="'.ROWS_3.'">'.$note_private.'.</textarea> |
|
1053 | + print '</td></tr>'; |
|
1054 | + } |
|
1055 | + |
|
1056 | + // Author |
|
1057 | + print "<tr><td>".$langs->trans("Author")."</td><td>".$user->getFullName($langs)."</td></tr>"; |
|
1058 | + |
|
1059 | + // Payment term |
|
1060 | + print "<tr><td>".$langs->trans("PaymentConditions")."</td><td>"; |
|
1061 | + $form->form_conditions_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->cond_reglement_id, 'none'); |
|
1062 | + print "</td></tr>"; |
|
1063 | + |
|
1064 | + // Payment mode |
|
1065 | + print "<tr><td>".$langs->trans("PaymentMode")."</td><td>"; |
|
1066 | + $form->form_modes_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->mode_reglement_id, 'none', '', 1); |
|
1067 | + print "</td></tr>"; |
|
1068 | + |
|
1069 | + // Project |
|
1070 | + if (! empty($conf->projet->enabled) && is_object($object->thirdparty) && $object->thirdparty->id > 0) |
|
1071 | + { |
|
1072 | + $projectid = GETPOST('projectid')?GETPOST('projectid'):$object->fk_project; |
|
1073 | + $langs->load('projects'); |
|
1074 | + print '<tr><td>' . $langs->trans('Project') . '</td><td>'; |
|
1075 | + $numprojet = $formproject->select_projects($object->thirdparty->id, $projectid, 'projectid', 0, 0, 1, 0, 0, 0, 0, '', 0, 0, ''); |
|
1076 | 1076 | print ' <a href="' . BASE_URI . '?controller=projet&method=card&socid=' . $object->thirdparty->id . '&action=create&status=1&backtopage=' . urlencode($_SERVER["PHP_SELF"] . '?action=create&socid=' . $object->thirdparty->id . (!empty($id) ? '&id=' . $id : '')) . '">' . $langs->trans("AddProject") . '</a>'; |
1077 | - print '</td></tr>'; |
|
1078 | - } |
|
1077 | + print '</td></tr>'; |
|
1078 | + } |
|
1079 | 1079 | |
1080 | - // Bank account |
|
1081 | - if ($object->fk_account > 0) |
|
1082 | - { |
|
1083 | - print "<tr><td>".$langs->trans('BankAccount')."</td><td>"; |
|
1084 | - $form->formSelectAccount($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_account, 'none'); |
|
1085 | - print "</td></tr>"; |
|
1086 | - } |
|
1080 | + // Bank account |
|
1081 | + if ($object->fk_account > 0) |
|
1082 | + { |
|
1083 | + print "<tr><td>".$langs->trans('BankAccount')."</td><td>"; |
|
1084 | + $form->formSelectAccount($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_account, 'none'); |
|
1085 | + print "</td></tr>"; |
|
1086 | + } |
|
1087 | 1087 | |
1088 | 1088 | // Model pdf |
1089 | 1089 | print "<tr><td>".$langs->trans('Model')."</td><td>"; |
@@ -1092,323 +1092,323 @@ discard block |
||
1092 | 1092 | print $form->selectarray('modelpdf', $list, $conf->global->FACTURE_ADDON_PDF); |
1093 | 1093 | print "</td></tr>"; |
1094 | 1094 | |
1095 | - print "</table>"; |
|
1095 | + print "</table>"; |
|
1096 | 1096 | |
1097 | - dol_fiche_end(); |
|
1097 | + dol_fiche_end(); |
|
1098 | 1098 | |
1099 | 1099 | |
1100 | - // Autogeneration |
|
1101 | - $title = $langs->trans("Recurrence"); |
|
1102 | - print load_fiche_titre('<span class="fa fa-calendar"></span> '.$title, '', ''); |
|
1100 | + // Autogeneration |
|
1101 | + $title = $langs->trans("Recurrence"); |
|
1102 | + print load_fiche_titre('<span class="fa fa-calendar"></span> '.$title, '', ''); |
|
1103 | 1103 | |
1104 | - dol_fiche_head(null, '', '', 0); |
|
1104 | + dol_fiche_head(null, '', '', 0); |
|
1105 | 1105 | |
1106 | - print '<table class="border" width="100%">'; |
|
1106 | + print '<table class="border" width="100%">'; |
|
1107 | 1107 | |
1108 | - // Frequency + unit |
|
1109 | - print '<tr><td class="titlefieldcreate">'.$form->textwithpicto($langs->trans("Frequency"), $langs->transnoentitiesnoconv('toolTipFrequency'))."</td><td>"; |
|
1110 | - print "<input type='text' name='frequency' value='".GETPOST('frequency', 'int')."' size='4' /> ".$form->selectarray('unit_frequency', array('d'=>$langs->trans('Day'), 'm'=>$langs->trans('Month'), 'y'=>$langs->trans('Year')), (GETPOST('unit_frequency')?GETPOST('unit_frequency'):'m')); |
|
1111 | - print "</td></tr>"; |
|
1108 | + // Frequency + unit |
|
1109 | + print '<tr><td class="titlefieldcreate">'.$form->textwithpicto($langs->trans("Frequency"), $langs->transnoentitiesnoconv('toolTipFrequency'))."</td><td>"; |
|
1110 | + print "<input type='text' name='frequency' value='".GETPOST('frequency', 'int')."' size='4' /> ".$form->selectarray('unit_frequency', array('d'=>$langs->trans('Day'), 'm'=>$langs->trans('Month'), 'y'=>$langs->trans('Year')), (GETPOST('unit_frequency')?GETPOST('unit_frequency'):'m')); |
|
1111 | + print "</td></tr>"; |
|
1112 | 1112 | |
1113 | - // Date next run |
|
1114 | - print "<tr><td>".$langs->trans('NextDateToExecution')."</td><td>"; |
|
1115 | - $date_next_execution = isset($date_next_execution) ? $date_next_execution : (GETPOST('remonth') ? dol_mktime(12, 0, 0, GETPOST('remonth'), GETPOST('reday'), GETPOST('reyear')) : -1); |
|
1116 | - print $form->selectDate($date_next_execution, '', 1, 1, '', "add", 1, 1); |
|
1117 | - print "</td></tr>"; |
|
1113 | + // Date next run |
|
1114 | + print "<tr><td>".$langs->trans('NextDateToExecution')."</td><td>"; |
|
1115 | + $date_next_execution = isset($date_next_execution) ? $date_next_execution : (GETPOST('remonth') ? dol_mktime(12, 0, 0, GETPOST('remonth'), GETPOST('reday'), GETPOST('reyear')) : -1); |
|
1116 | + print $form->selectDate($date_next_execution, '', 1, 1, '', "add", 1, 1); |
|
1117 | + print "</td></tr>"; |
|
1118 | 1118 | |
1119 | - // Number max of generation |
|
1120 | - print "<tr><td>".$langs->trans("MaxPeriodNumber")."</td><td>"; |
|
1121 | - print '<input type="text" name="nb_gen_max" value="'.GETPOST('nb_gen_max').'" size="5" />'; |
|
1122 | - print "</td></tr>"; |
|
1119 | + // Number max of generation |
|
1120 | + print "<tr><td>".$langs->trans("MaxPeriodNumber")."</td><td>"; |
|
1121 | + print '<input type="text" name="nb_gen_max" value="'.GETPOST('nb_gen_max').'" size="5" />'; |
|
1122 | + print "</td></tr>"; |
|
1123 | 1123 | |
1124 | - // Auto validate the invoice |
|
1125 | - print "<tr><td>".$langs->trans("StatusOfGeneratedInvoices")."</td><td>"; |
|
1126 | - $select = array('0'=>$langs->trans('BillStatusDraft'),'1'=>$langs->trans('BillStatusValidated')); |
|
1127 | - print $form->selectarray('auto_validate', $select, GETPOST('auto_validate')); |
|
1128 | - print "</td></tr>"; |
|
1124 | + // Auto validate the invoice |
|
1125 | + print "<tr><td>".$langs->trans("StatusOfGeneratedInvoices")."</td><td>"; |
|
1126 | + $select = array('0'=>$langs->trans('BillStatusDraft'),'1'=>$langs->trans('BillStatusValidated')); |
|
1127 | + print $form->selectarray('auto_validate', $select, GETPOST('auto_validate')); |
|
1128 | + print "</td></tr>"; |
|
1129 | 1129 | |
1130 | - // Auto generate document |
|
1131 | - if (! empty($conf->global->INVOICE_REC_CAN_DISABLE_DOCUMENT_FILE_GENERATION)) |
|
1132 | - { |
|
1133 | - print "<tr><td>".$langs->trans("StatusOfGeneratedDocuments")."</td><td>"; |
|
1134 | - $select = array('0'=>$langs->trans('DoNotGenerateDoc'),'1'=>$langs->trans('AutoGenerateDoc')); |
|
1135 | - print $form->selectarray('generate_pdf', $select, GETPOST('generate_pdf')); |
|
1136 | - print "</td></tr>"; |
|
1137 | - } |
|
1138 | - else |
|
1139 | - { |
|
1140 | - print '<input type="hidden" name="generate_pdf" value="1">'; |
|
1141 | - } |
|
1130 | + // Auto generate document |
|
1131 | + if (! empty($conf->global->INVOICE_REC_CAN_DISABLE_DOCUMENT_FILE_GENERATION)) |
|
1132 | + { |
|
1133 | + print "<tr><td>".$langs->trans("StatusOfGeneratedDocuments")."</td><td>"; |
|
1134 | + $select = array('0'=>$langs->trans('DoNotGenerateDoc'),'1'=>$langs->trans('AutoGenerateDoc')); |
|
1135 | + print $form->selectarray('generate_pdf', $select, GETPOST('generate_pdf')); |
|
1136 | + print "</td></tr>"; |
|
1137 | + } |
|
1138 | + else |
|
1139 | + { |
|
1140 | + print '<input type="hidden" name="generate_pdf" value="1">'; |
|
1141 | + } |
|
1142 | 1142 | |
1143 | - print "</table>"; |
|
1143 | + print "</table>"; |
|
1144 | 1144 | |
1145 | - dol_fiche_end(); |
|
1145 | + dol_fiche_end(); |
|
1146 | 1146 | |
1147 | 1147 | |
1148 | - $title = $langs->trans("ProductsAndServices"); |
|
1149 | - if (empty($conf->service->enabled)) |
|
1150 | - $title = $langs->trans("Products"); |
|
1151 | - else if (empty($conf->product->enabled)) |
|
1152 | - $title = $langs->trans("Services"); |
|
1148 | + $title = $langs->trans("ProductsAndServices"); |
|
1149 | + if (empty($conf->service->enabled)) |
|
1150 | + $title = $langs->trans("Products"); |
|
1151 | + else if (empty($conf->product->enabled)) |
|
1152 | + $title = $langs->trans("Services"); |
|
1153 | 1153 | |
1154 | - print load_fiche_titre($title, '', ''); |
|
1154 | + print load_fiche_titre($title, '', ''); |
|
1155 | 1155 | |
1156 | - /* |
|
1156 | + /* |
|
1157 | 1157 | * Invoice lines |
1158 | 1158 | */ |
1159 | - print '<div class="div-table-responsive-no-min">'; |
|
1160 | - print '<table id="tablelines" class="noborder noshadow" width="100%">'; |
|
1161 | - // Show object lines |
|
1162 | - if (! empty($object->lines)) |
|
1163 | - { |
|
1164 | - $disableedit=1; |
|
1165 | - $disablemove=1; |
|
1166 | - $disableremove=1; |
|
1167 | - $object->printObjectLines('', $mysoc, $object->thirdparty, $lineid, 0); // No date selector for template invoice |
|
1168 | - } |
|
1169 | - |
|
1170 | - print "</table>\n"; |
|
1171 | - print '<div>'; |
|
1172 | - |
|
1173 | - print '</td></tr>'; |
|
1174 | - |
|
1175 | - if ($flag_price_may_change) |
|
1176 | - { |
|
1177 | - print '<tr><td colspan="3" align="left">'; |
|
1178 | - print '<select name="usenewprice" class="flat">'; |
|
1179 | - print '<option value="0">'.$langs->trans("AlwaysUseFixedPrice").'</option>'; |
|
1180 | - print '<option value="1" disabled>'.$langs->trans("AlwaysUseNewPrice").'</option>'; |
|
1181 | - print '</select>'; |
|
1182 | - print '</td></tr>'; |
|
1183 | - } |
|
1184 | - print "</table>\n"; |
|
1185 | - |
|
1186 | - print '<div align="center"><input type="submit" class="button" value="'.$langs->trans("Create").'">'; |
|
1187 | - print ' '; |
|
1188 | - print '<input type="button" class="button" value="' . $langs->trans("Cancel") . '" onClick="javascript:history.go(-1)">'; |
|
1189 | - print '</div>'; |
|
1190 | - print "</form>\n"; |
|
1191 | - } |
|
1192 | - else |
|
1193 | - { |
|
1194 | - dol_print_error('',"Error, no invoice ".$object->id); |
|
1195 | - } |
|
1159 | + print '<div class="div-table-responsive-no-min">'; |
|
1160 | + print '<table id="tablelines" class="noborder noshadow" width="100%">'; |
|
1161 | + // Show object lines |
|
1162 | + if (! empty($object->lines)) |
|
1163 | + { |
|
1164 | + $disableedit=1; |
|
1165 | + $disablemove=1; |
|
1166 | + $disableremove=1; |
|
1167 | + $object->printObjectLines('', $mysoc, $object->thirdparty, $lineid, 0); // No date selector for template invoice |
|
1168 | + } |
|
1169 | + |
|
1170 | + print "</table>\n"; |
|
1171 | + print '<div>'; |
|
1172 | + |
|
1173 | + print '</td></tr>'; |
|
1174 | + |
|
1175 | + if ($flag_price_may_change) |
|
1176 | + { |
|
1177 | + print '<tr><td colspan="3" align="left">'; |
|
1178 | + print '<select name="usenewprice" class="flat">'; |
|
1179 | + print '<option value="0">'.$langs->trans("AlwaysUseFixedPrice").'</option>'; |
|
1180 | + print '<option value="1" disabled>'.$langs->trans("AlwaysUseNewPrice").'</option>'; |
|
1181 | + print '</select>'; |
|
1182 | + print '</td></tr>'; |
|
1183 | + } |
|
1184 | + print "</table>\n"; |
|
1185 | + |
|
1186 | + print '<div align="center"><input type="submit" class="button" value="'.$langs->trans("Create").'">'; |
|
1187 | + print ' '; |
|
1188 | + print '<input type="button" class="button" value="' . $langs->trans("Cancel") . '" onClick="javascript:history.go(-1)">'; |
|
1189 | + print '</div>'; |
|
1190 | + print "</form>\n"; |
|
1191 | + } |
|
1192 | + else |
|
1193 | + { |
|
1194 | + dol_print_error('',"Error, no invoice ".$object->id); |
|
1195 | + } |
|
1196 | 1196 | } |
1197 | 1197 | else |
1198 | 1198 | { |
1199 | - /* |
|
1199 | + /* |
|
1200 | 1200 | * View mode |
1201 | 1201 | */ |
1202 | - if ($object->id > 0) |
|
1203 | - { |
|
1204 | - $object->fetch_thirdparty(); |
|
1202 | + if ($object->id > 0) |
|
1203 | + { |
|
1204 | + $object->fetch_thirdparty(); |
|
1205 | 1205 | |
1206 | - // Confirmation de la suppression d'une ligne produit |
|
1207 | - if ($action == 'ask_deleteline') { |
|
1208 | - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id . '&lineid=' . $lineid, $langs->trans('DeleteProductLine'), $langs->trans('ConfirmDeleteProductLine'), 'confirm_deleteline', '', 'no', 1); |
|
1209 | - } |
|
1206 | + // Confirmation de la suppression d'une ligne produit |
|
1207 | + if ($action == 'ask_deleteline') { |
|
1208 | + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id . '&lineid=' . $lineid, $langs->trans('DeleteProductLine'), $langs->trans('ConfirmDeleteProductLine'), 'confirm_deleteline', '', 'no', 1); |
|
1209 | + } |
|
1210 | 1210 | |
1211 | - // Confirm delete of repeatable invoice |
|
1212 | - if ($action == 'ask_deleteinvoice') { |
|
1213 | - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('DeleteRepeatableInvoice'), $langs->trans('ConfirmDeleteRepeatableInvoice'), 'confirm_deleteinvoice', '', 'no', 1); |
|
1214 | - } |
|
1211 | + // Confirm delete of repeatable invoice |
|
1212 | + if ($action == 'ask_deleteinvoice') { |
|
1213 | + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('DeleteRepeatableInvoice'), $langs->trans('ConfirmDeleteRepeatableInvoice'), 'confirm_deleteinvoice', '', 'no', 1); |
|
1214 | + } |
|
1215 | 1215 | |
1216 | - print $formconfirm; |
|
1216 | + print $formconfirm; |
|
1217 | 1217 | |
1218 | - $author = new User($db); |
|
1219 | - $author->fetch($object->user_author); |
|
1218 | + $author = new User($db); |
|
1219 | + $author->fetch($object->user_author); |
|
1220 | 1220 | |
1221 | - $head=invoice_rec_prepare_head($object); |
|
1221 | + $head=invoice_rec_prepare_head($object); |
|
1222 | 1222 | |
1223 | - dol_fiche_head($head, 'card', $langs->trans("RepeatableInvoice"), -1, 'bill'); // Add a div |
|
1223 | + dol_fiche_head($head, 'card', $langs->trans("RepeatableInvoice"), -1, 'bill'); // Add a div |
|
1224 | 1224 | |
1225 | - // Recurring invoice content |
|
1225 | + // Recurring invoice content |
|
1226 | 1226 | |
1227 | 1227 | $linkback = '<a href="' . BASE_URI . '?controller=compta/facture&method=invoicetemplate_list&restore_lastsearch_values=1' . (!empty($socid) ? '&socid=' . $socid : '') . '">' . $langs->trans("BackToList") . '</a>'; |
1228 | 1228 | |
1229 | - $morehtmlref=''; |
|
1230 | - if ($action != 'editref') $morehtmlref.=$form->editfieldkey($object->ref, 'ref', $object->ref, $object, $user->rights->facture->creer, '', '', 0, 2); |
|
1231 | - else $morehtmlref.= $form->editfieldval('', 'ref', $object->ref, $object, $user->rights->facture->creer, 'string'); |
|
1232 | - |
|
1233 | - $morehtmlref.='<div class="refidno">'; |
|
1234 | - // Ref customer |
|
1235 | - //$morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, $user->rights->facture->creer, 'string', '', 0, 1); |
|
1236 | - //$morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, $user->rights->facture->creer, 'string', '', null, null, '', 1); |
|
1237 | - // Thirdparty |
|
1238 | - $morehtmlref.=$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1); |
|
1239 | - // Project |
|
1240 | - if (! empty($conf->projet->enabled)) |
|
1241 | - { |
|
1242 | - $langs->load("projects"); |
|
1243 | - $morehtmlref.='<br>'.$langs->trans('Project') . ' '; |
|
1244 | - if ($user->rights->facture->creer) |
|
1245 | - { |
|
1246 | - if ($action != 'classify') |
|
1247 | - $morehtmlref.='<a href="' . $_SERVER['PHP_SELF'] . '?action=classify&id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : '; |
|
1248 | - if ($action == 'classify') { |
|
1249 | - //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); |
|
1250 | - $morehtmlref.='<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">'; |
|
1251 | - $morehtmlref.='<input type="hidden" name="action" value="classin">'; |
|
1252 | - $morehtmlref.='<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
1253 | - $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); |
|
1254 | - $morehtmlref.='<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">'; |
|
1255 | - $morehtmlref.='</form>'; |
|
1256 | - } else { |
|
1257 | - $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); |
|
1258 | - } |
|
1259 | - } else { |
|
1260 | - if (! empty($object->fk_project)) { |
|
1261 | - $proj = new Project($db); |
|
1262 | - $proj->fetch($object->fk_project); |
|
1229 | + $morehtmlref=''; |
|
1230 | + if ($action != 'editref') $morehtmlref.=$form->editfieldkey($object->ref, 'ref', $object->ref, $object, $user->rights->facture->creer, '', '', 0, 2); |
|
1231 | + else $morehtmlref.= $form->editfieldval('', 'ref', $object->ref, $object, $user->rights->facture->creer, 'string'); |
|
1232 | + |
|
1233 | + $morehtmlref.='<div class="refidno">'; |
|
1234 | + // Ref customer |
|
1235 | + //$morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, $user->rights->facture->creer, 'string', '', 0, 1); |
|
1236 | + //$morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, $user->rights->facture->creer, 'string', '', null, null, '', 1); |
|
1237 | + // Thirdparty |
|
1238 | + $morehtmlref.=$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1); |
|
1239 | + // Project |
|
1240 | + if (! empty($conf->projet->enabled)) |
|
1241 | + { |
|
1242 | + $langs->load("projects"); |
|
1243 | + $morehtmlref.='<br>'.$langs->trans('Project') . ' '; |
|
1244 | + if ($user->rights->facture->creer) |
|
1245 | + { |
|
1246 | + if ($action != 'classify') |
|
1247 | + $morehtmlref.='<a href="' . $_SERVER['PHP_SELF'] . '?action=classify&id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : '; |
|
1248 | + if ($action == 'classify') { |
|
1249 | + //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); |
|
1250 | + $morehtmlref.='<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">'; |
|
1251 | + $morehtmlref.='<input type="hidden" name="action" value="classin">'; |
|
1252 | + $morehtmlref.='<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
1253 | + $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); |
|
1254 | + $morehtmlref.='<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">'; |
|
1255 | + $morehtmlref.='</form>'; |
|
1256 | + } else { |
|
1257 | + $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); |
|
1258 | + } |
|
1259 | + } else { |
|
1260 | + if (! empty($object->fk_project)) { |
|
1261 | + $proj = new Project($db); |
|
1262 | + $proj->fetch($object->fk_project); |
|
1263 | 1263 | $morehtmlref .= '<a href="' . BASE_URI . '&controller=projet&method=card&id=' . $object->fk_project . '" title="' . $langs->trans('ShowProject') . '">'; |
1264 | - $morehtmlref.=$proj->ref; |
|
1265 | - $morehtmlref.='</a>'; |
|
1266 | - } else { |
|
1267 | - $morehtmlref.=''; |
|
1268 | - } |
|
1269 | - } |
|
1270 | - } |
|
1271 | - $morehtmlref.='</div>'; |
|
1272 | - |
|
1273 | - dol_banner_tab($object, 'ref', $linkback, 1, 'titre', 'none', $morehtmlref, '', 0, '', $morehtmlright); |
|
1274 | - |
|
1275 | - print '<div class="fichecenter">'; |
|
1276 | - print '<div class="fichehalfleft">'; |
|
1277 | - print '<div class="underbanner clearboth"></div>'; |
|
1278 | - |
|
1279 | - print '<table class="border" width="100%">'; |
|
1280 | - |
|
1281 | - print '<tr><td class="titlefield">'.$langs->trans("Author").'</td><td>'.$author->getFullName($langs)."</td></tr>"; |
|
1282 | - |
|
1283 | - print '<tr><td>'.$langs->trans("AmountHT").'</td>'; |
|
1284 | - print '<td>'.price($object->total_ht,'',$langs,1,-1,-1,$conf->currency).'</td>'; |
|
1285 | - print '</tr>'; |
|
1286 | - |
|
1287 | - print '<tr><td>'.$langs->trans("AmountVAT").'</td><td>'.price($object->total_tva,'',$langs,1,-1,-1,$conf->currency).'</td>'; |
|
1288 | - print '</tr>'; |
|
1289 | - |
|
1290 | - // Amount Local Taxes |
|
1291 | - if (($mysoc->localtax1_assuj == "1" && $mysoc->useLocalTax(1)) || $object->total_localtax1 != 0) // Localtax1 |
|
1292 | - { |
|
1293 | - print '<tr><td>' . $langs->transcountry("AmountLT1", $mysoc->country_code) . '</td>'; |
|
1294 | - print '<td class="nowrap">' . price($object->total_localtax1, 1, '', 1, - 1, - 1, $conf->currency) . '</td></tr>'; |
|
1295 | - } |
|
1296 | - if (($mysoc->localtax2_assuj == "1" && $mysoc->useLocalTax(2)) || $object->total_localtax2 != 0) // Localtax2 |
|
1297 | - { |
|
1298 | - print '<tr><td>' . $langs->transcountry("AmountLT2", $mysoc->country_code) . '</td>'; |
|
1299 | - print '<td class=nowrap">' . price($object->total_localtax2, 1, '', 1, - 1, - 1, $conf->currency) . '</td></tr>'; |
|
1300 | - } |
|
1301 | - |
|
1302 | - print '<tr><td>'.$langs->trans("AmountTTC").'</td><td colspan="3">'.price($object->total_ttc,'',$langs,1,-1,-1,$conf->currency).'</td>'; |
|
1303 | - print '</tr>'; |
|
1304 | - |
|
1305 | - |
|
1306 | - // Payment term |
|
1307 | - print '<tr><td>'; |
|
1308 | - print '<table class="nobordernopadding" width="100%"><tr><td>'; |
|
1309 | - print $langs->trans('PaymentConditionsShort'); |
|
1310 | - print '</td>'; |
|
1311 | - if ($object->type != Facture::TYPE_CREDIT_NOTE && $action != 'editconditions' && ! empty($object->brouillon) && $user->rights->facture->creer) |
|
1312 | - print '<td align="right"><a href="' . $_SERVER["PHP_SELF"] . '?action=editconditions&facid=' . $object->id . '">' . img_edit($langs->trans('SetConditions'), 1) . '</a></td>'; |
|
1313 | - print '</tr></table>'; |
|
1314 | - print '</td><td>'; |
|
1315 | - if ($object->type != Facture::TYPE_CREDIT_NOTE) |
|
1316 | - { |
|
1317 | - if ($action == 'editconditions') |
|
1318 | - { |
|
1319 | - $form->form_conditions_reglement($_SERVER['PHP_SELF'] . '?facid=' . $object->id, $object->cond_reglement_id, 'cond_reglement_id'); |
|
1320 | - } |
|
1321 | - else |
|
1322 | - { |
|
1323 | - $form->form_conditions_reglement($_SERVER['PHP_SELF'] . '?facid=' . $object->id, $object->cond_reglement_id, 'none'); |
|
1324 | - } |
|
1325 | - } else { |
|
1326 | - print ' '; |
|
1327 | - } |
|
1328 | - print '</td></tr>'; |
|
1329 | - |
|
1330 | - // Payment mode |
|
1331 | - print '<tr><td>'; |
|
1332 | - print '<table class="nobordernopadding" width="100%"><tr><td>'; |
|
1333 | - print $langs->trans('PaymentMode'); |
|
1334 | - print '</td>'; |
|
1335 | - if ($action != 'editmode' && ! empty($object->brouillon) && $user->rights->facture->creer) |
|
1336 | - print '<td align="right"><a href="' . $_SERVER["PHP_SELF"] . '?action=editmode&facid=' . $object->id . '">' . img_edit($langs->trans('SetMode'), 1) . '</a></td>'; |
|
1337 | - print '</tr></table>'; |
|
1338 | - print '</td><td>'; |
|
1339 | - if ($action == 'editmode') |
|
1340 | - { |
|
1341 | - $form->form_modes_reglement($_SERVER['PHP_SELF'].'?facid='.$object->id, $object->mode_reglement_id, 'mode_reglement_id', 'CRDT'); |
|
1342 | - } |
|
1343 | - else |
|
1344 | - { |
|
1345 | - $form->form_modes_reglement($_SERVER['PHP_SELF'].'?facid='.$object->id, $object->mode_reglement_id, 'none', 'CRDT'); |
|
1346 | - } |
|
1347 | - print '</td></tr>'; |
|
1348 | - |
|
1349 | - // Help of substitution key |
|
1350 | - $dateexample=dol_now(); |
|
1351 | - if (! empty($object->frequency) && ! empty($object->date_when)) $dateexample=$object->date_when; |
|
1352 | - |
|
1353 | - $substitutionarray = getCommonSubstitutionArray($langs, 2, null, $object); |
|
1354 | - |
|
1355 | - $substitutionarray['__INVOICE_PREVIOUS_MONTH__'] = $langs->trans("PreviousMonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($dateexample, -1, 'm'),'%m').')'; |
|
1356 | - $substitutionarray['__INVOICE_MONTH__'] = $langs->trans("MonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date($dateexample,'%m').')'; |
|
1357 | - $substitutionarray['__INVOICE_NEXT_MONTH__'] = $langs->trans("NextMonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($dateexample, 1, 'm'),'%m').')'; |
|
1358 | - $substitutionarray['__INVOICE_PREVIOUS_MONTH_TEXT__'] = $langs->trans("TextPreviousMonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($dateexample, -1, 'm'),'%B').')'; |
|
1359 | - $substitutionarray['__INVOICE_MONTH_TEXT__'] = $langs->trans("TextMonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date($dateexample,'%B').')'; |
|
1360 | - $substitutionarray['__INVOICE_NEXT_MONTH_TEXT__'] = $langs->trans("TextNextMonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($dateexample, 1, 'm'), '%B').')'; |
|
1361 | - $substitutionarray['__INVOICE_PREVIOUS_YEAR__'] = $langs->trans("YearOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($dateexample, -1, 'y'),'%Y').')'; |
|
1362 | - $substitutionarray['__INVOICE_YEAR__'] = $langs->trans("PreviousYearOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date($dateexample,'%Y').')'; |
|
1363 | - $substitutionarray['__INVOICE_NEXT_YEAR__'] = $langs->trans("NextYearOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($dateexample, 1, 'y'),'%Y').')'; |
|
1364 | - // Only on template invoices |
|
1365 | - $substitutionarray['__INVOICE_DATE_NEXT_INVOICE_BEFORE_GEN__'] = $langs->trans("DateNextInvoiceBeforeGen").' ('.$langs->trans("Example").': '.dol_print_date(($object->date_when?$object->date_when:dol_now()), 'dayhour').')'; |
|
1366 | - $substitutionarray['__INVOICE_DATE_NEXT_INVOICE_AFTER_GEN__'] = $langs->trans("DateNextInvoiceAfterGen").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree(($object->date_when?$object->date_when:dol_now()), $object->frequency, $object->unit_frequency),'dayhour').')'; |
|
1367 | - |
|
1368 | - $htmltext = '<i>'.$langs->trans("FollowingConstantsWillBeSubstituted").':<br>'; |
|
1369 | - foreach($substitutionarray as $key => $val) |
|
1370 | - { |
|
1371 | - $htmltext.=$key.' = '.$langs->trans($val).'<br>'; |
|
1372 | - } |
|
1373 | - $htmltext.='</i>'; |
|
1374 | - |
|
1375 | - // Note public |
|
1376 | - print '<tr><td>'; |
|
1377 | - print $form->editfieldkey($form->textwithpicto($langs->trans('NotePublic'), $htmltext, 1, 'help', '', 0, 2, 'notepublic'), 'note_public', $object->note_public, $object, $user->rights->facture->creer); |
|
1378 | - print '</td><td class="wordbreak">'; |
|
1379 | - print $form->editfieldval($langs->trans("NotePublic"), 'note_public', $object->note_public, $object, $user->rights->facture->creer, 'textarea:'.ROWS_4.':90%', '', null, null, '', 1); |
|
1380 | - print '</td>'; |
|
1381 | - print '</tr>'; |
|
1382 | - |
|
1383 | - // Note private |
|
1384 | - print '<tr><td>'; |
|
1385 | - print $form->editfieldkey($form->textwithpicto($langs->trans("NotePrivate"), $htmltext, 1, 'help', '', 0, 2, 'noteprivate'), 'note_private', $object->note_private, $object, $user->rights->facture->creer); |
|
1386 | - print '</td><td class="wordbreak">'; |
|
1387 | - print $form->editfieldval($langs->trans("NotePrivate"), 'note_private', $object->note_private, $object, $user->rights->facture->creer, 'textarea:'.ROWS_4.':90%', '', null, null, '', 1); |
|
1388 | - print '</td>'; |
|
1389 | - print '</tr>'; |
|
1390 | - |
|
1391 | - // Bank Account |
|
1392 | - $langs->load('banks'); |
|
1393 | - |
|
1394 | - print '<tr><td class="nowrap">'; |
|
1395 | - print '<table width="100%" class="nobordernopadding"><tr><td class="nowrap">'; |
|
1396 | - print $langs->trans('RIB'); |
|
1397 | - print '<td>'; |
|
1398 | - if (($action != 'editbankaccount') && $user->rights->facture->creer && ! empty($object->brouillon)) |
|
1399 | - print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editbankaccount&id='.$object->id.'">'.img_edit($langs->trans('SetBankAccount'),1).'</a></td>'; |
|
1400 | - print '</tr></table>'; |
|
1401 | - print '</td><td>'; |
|
1402 | - if ($action == 'editbankaccount') |
|
1403 | - { |
|
1404 | - $form->formSelectAccount($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_account, 'fk_account', 1); |
|
1405 | - } |
|
1406 | - else |
|
1407 | - { |
|
1408 | - $form->formSelectAccount($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_account, 'none'); |
|
1409 | - } |
|
1410 | - print "</td>"; |
|
1411 | - print '</tr>'; |
|
1264 | + $morehtmlref.=$proj->ref; |
|
1265 | + $morehtmlref.='</a>'; |
|
1266 | + } else { |
|
1267 | + $morehtmlref.=''; |
|
1268 | + } |
|
1269 | + } |
|
1270 | + } |
|
1271 | + $morehtmlref.='</div>'; |
|
1272 | + |
|
1273 | + dol_banner_tab($object, 'ref', $linkback, 1, 'titre', 'none', $morehtmlref, '', 0, '', $morehtmlright); |
|
1274 | + |
|
1275 | + print '<div class="fichecenter">'; |
|
1276 | + print '<div class="fichehalfleft">'; |
|
1277 | + print '<div class="underbanner clearboth"></div>'; |
|
1278 | + |
|
1279 | + print '<table class="border" width="100%">'; |
|
1280 | + |
|
1281 | + print '<tr><td class="titlefield">'.$langs->trans("Author").'</td><td>'.$author->getFullName($langs)."</td></tr>"; |
|
1282 | + |
|
1283 | + print '<tr><td>'.$langs->trans("AmountHT").'</td>'; |
|
1284 | + print '<td>'.price($object->total_ht,'',$langs,1,-1,-1,$conf->currency).'</td>'; |
|
1285 | + print '</tr>'; |
|
1286 | + |
|
1287 | + print '<tr><td>'.$langs->trans("AmountVAT").'</td><td>'.price($object->total_tva,'',$langs,1,-1,-1,$conf->currency).'</td>'; |
|
1288 | + print '</tr>'; |
|
1289 | + |
|
1290 | + // Amount Local Taxes |
|
1291 | + if (($mysoc->localtax1_assuj == "1" && $mysoc->useLocalTax(1)) || $object->total_localtax1 != 0) // Localtax1 |
|
1292 | + { |
|
1293 | + print '<tr><td>' . $langs->transcountry("AmountLT1", $mysoc->country_code) . '</td>'; |
|
1294 | + print '<td class="nowrap">' . price($object->total_localtax1, 1, '', 1, - 1, - 1, $conf->currency) . '</td></tr>'; |
|
1295 | + } |
|
1296 | + if (($mysoc->localtax2_assuj == "1" && $mysoc->useLocalTax(2)) || $object->total_localtax2 != 0) // Localtax2 |
|
1297 | + { |
|
1298 | + print '<tr><td>' . $langs->transcountry("AmountLT2", $mysoc->country_code) . '</td>'; |
|
1299 | + print '<td class=nowrap">' . price($object->total_localtax2, 1, '', 1, - 1, - 1, $conf->currency) . '</td></tr>'; |
|
1300 | + } |
|
1301 | + |
|
1302 | + print '<tr><td>'.$langs->trans("AmountTTC").'</td><td colspan="3">'.price($object->total_ttc,'',$langs,1,-1,-1,$conf->currency).'</td>'; |
|
1303 | + print '</tr>'; |
|
1304 | + |
|
1305 | + |
|
1306 | + // Payment term |
|
1307 | + print '<tr><td>'; |
|
1308 | + print '<table class="nobordernopadding" width="100%"><tr><td>'; |
|
1309 | + print $langs->trans('PaymentConditionsShort'); |
|
1310 | + print '</td>'; |
|
1311 | + if ($object->type != Facture::TYPE_CREDIT_NOTE && $action != 'editconditions' && ! empty($object->brouillon) && $user->rights->facture->creer) |
|
1312 | + print '<td align="right"><a href="' . $_SERVER["PHP_SELF"] . '?action=editconditions&facid=' . $object->id . '">' . img_edit($langs->trans('SetConditions'), 1) . '</a></td>'; |
|
1313 | + print '</tr></table>'; |
|
1314 | + print '</td><td>'; |
|
1315 | + if ($object->type != Facture::TYPE_CREDIT_NOTE) |
|
1316 | + { |
|
1317 | + if ($action == 'editconditions') |
|
1318 | + { |
|
1319 | + $form->form_conditions_reglement($_SERVER['PHP_SELF'] . '?facid=' . $object->id, $object->cond_reglement_id, 'cond_reglement_id'); |
|
1320 | + } |
|
1321 | + else |
|
1322 | + { |
|
1323 | + $form->form_conditions_reglement($_SERVER['PHP_SELF'] . '?facid=' . $object->id, $object->cond_reglement_id, 'none'); |
|
1324 | + } |
|
1325 | + } else { |
|
1326 | + print ' '; |
|
1327 | + } |
|
1328 | + print '</td></tr>'; |
|
1329 | + |
|
1330 | + // Payment mode |
|
1331 | + print '<tr><td>'; |
|
1332 | + print '<table class="nobordernopadding" width="100%"><tr><td>'; |
|
1333 | + print $langs->trans('PaymentMode'); |
|
1334 | + print '</td>'; |
|
1335 | + if ($action != 'editmode' && ! empty($object->brouillon) && $user->rights->facture->creer) |
|
1336 | + print '<td align="right"><a href="' . $_SERVER["PHP_SELF"] . '?action=editmode&facid=' . $object->id . '">' . img_edit($langs->trans('SetMode'), 1) . '</a></td>'; |
|
1337 | + print '</tr></table>'; |
|
1338 | + print '</td><td>'; |
|
1339 | + if ($action == 'editmode') |
|
1340 | + { |
|
1341 | + $form->form_modes_reglement($_SERVER['PHP_SELF'].'?facid='.$object->id, $object->mode_reglement_id, 'mode_reglement_id', 'CRDT'); |
|
1342 | + } |
|
1343 | + else |
|
1344 | + { |
|
1345 | + $form->form_modes_reglement($_SERVER['PHP_SELF'].'?facid='.$object->id, $object->mode_reglement_id, 'none', 'CRDT'); |
|
1346 | + } |
|
1347 | + print '</td></tr>'; |
|
1348 | + |
|
1349 | + // Help of substitution key |
|
1350 | + $dateexample=dol_now(); |
|
1351 | + if (! empty($object->frequency) && ! empty($object->date_when)) $dateexample=$object->date_when; |
|
1352 | + |
|
1353 | + $substitutionarray = getCommonSubstitutionArray($langs, 2, null, $object); |
|
1354 | + |
|
1355 | + $substitutionarray['__INVOICE_PREVIOUS_MONTH__'] = $langs->trans("PreviousMonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($dateexample, -1, 'm'),'%m').')'; |
|
1356 | + $substitutionarray['__INVOICE_MONTH__'] = $langs->trans("MonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date($dateexample,'%m').')'; |
|
1357 | + $substitutionarray['__INVOICE_NEXT_MONTH__'] = $langs->trans("NextMonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($dateexample, 1, 'm'),'%m').')'; |
|
1358 | + $substitutionarray['__INVOICE_PREVIOUS_MONTH_TEXT__'] = $langs->trans("TextPreviousMonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($dateexample, -1, 'm'),'%B').')'; |
|
1359 | + $substitutionarray['__INVOICE_MONTH_TEXT__'] = $langs->trans("TextMonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date($dateexample,'%B').')'; |
|
1360 | + $substitutionarray['__INVOICE_NEXT_MONTH_TEXT__'] = $langs->trans("TextNextMonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($dateexample, 1, 'm'), '%B').')'; |
|
1361 | + $substitutionarray['__INVOICE_PREVIOUS_YEAR__'] = $langs->trans("YearOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($dateexample, -1, 'y'),'%Y').')'; |
|
1362 | + $substitutionarray['__INVOICE_YEAR__'] = $langs->trans("PreviousYearOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date($dateexample,'%Y').')'; |
|
1363 | + $substitutionarray['__INVOICE_NEXT_YEAR__'] = $langs->trans("NextYearOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($dateexample, 1, 'y'),'%Y').')'; |
|
1364 | + // Only on template invoices |
|
1365 | + $substitutionarray['__INVOICE_DATE_NEXT_INVOICE_BEFORE_GEN__'] = $langs->trans("DateNextInvoiceBeforeGen").' ('.$langs->trans("Example").': '.dol_print_date(($object->date_when?$object->date_when:dol_now()), 'dayhour').')'; |
|
1366 | + $substitutionarray['__INVOICE_DATE_NEXT_INVOICE_AFTER_GEN__'] = $langs->trans("DateNextInvoiceAfterGen").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree(($object->date_when?$object->date_when:dol_now()), $object->frequency, $object->unit_frequency),'dayhour').')'; |
|
1367 | + |
|
1368 | + $htmltext = '<i>'.$langs->trans("FollowingConstantsWillBeSubstituted").':<br>'; |
|
1369 | + foreach($substitutionarray as $key => $val) |
|
1370 | + { |
|
1371 | + $htmltext.=$key.' = '.$langs->trans($val).'<br>'; |
|
1372 | + } |
|
1373 | + $htmltext.='</i>'; |
|
1374 | + |
|
1375 | + // Note public |
|
1376 | + print '<tr><td>'; |
|
1377 | + print $form->editfieldkey($form->textwithpicto($langs->trans('NotePublic'), $htmltext, 1, 'help', '', 0, 2, 'notepublic'), 'note_public', $object->note_public, $object, $user->rights->facture->creer); |
|
1378 | + print '</td><td class="wordbreak">'; |
|
1379 | + print $form->editfieldval($langs->trans("NotePublic"), 'note_public', $object->note_public, $object, $user->rights->facture->creer, 'textarea:'.ROWS_4.':90%', '', null, null, '', 1); |
|
1380 | + print '</td>'; |
|
1381 | + print '</tr>'; |
|
1382 | + |
|
1383 | + // Note private |
|
1384 | + print '<tr><td>'; |
|
1385 | + print $form->editfieldkey($form->textwithpicto($langs->trans("NotePrivate"), $htmltext, 1, 'help', '', 0, 2, 'noteprivate'), 'note_private', $object->note_private, $object, $user->rights->facture->creer); |
|
1386 | + print '</td><td class="wordbreak">'; |
|
1387 | + print $form->editfieldval($langs->trans("NotePrivate"), 'note_private', $object->note_private, $object, $user->rights->facture->creer, 'textarea:'.ROWS_4.':90%', '', null, null, '', 1); |
|
1388 | + print '</td>'; |
|
1389 | + print '</tr>'; |
|
1390 | + |
|
1391 | + // Bank Account |
|
1392 | + $langs->load('banks'); |
|
1393 | + |
|
1394 | + print '<tr><td class="nowrap">'; |
|
1395 | + print '<table width="100%" class="nobordernopadding"><tr><td class="nowrap">'; |
|
1396 | + print $langs->trans('RIB'); |
|
1397 | + print '<td>'; |
|
1398 | + if (($action != 'editbankaccount') && $user->rights->facture->creer && ! empty($object->brouillon)) |
|
1399 | + print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editbankaccount&id='.$object->id.'">'.img_edit($langs->trans('SetBankAccount'),1).'</a></td>'; |
|
1400 | + print '</tr></table>'; |
|
1401 | + print '</td><td>'; |
|
1402 | + if ($action == 'editbankaccount') |
|
1403 | + { |
|
1404 | + $form->formSelectAccount($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_account, 'fk_account', 1); |
|
1405 | + } |
|
1406 | + else |
|
1407 | + { |
|
1408 | + $form->formSelectAccount($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_account, 'none'); |
|
1409 | + } |
|
1410 | + print "</td>"; |
|
1411 | + print '</tr>'; |
|
1412 | 1412 | |
1413 | 1413 | // Model pdf |
1414 | 1414 | $langs->load('banks'); |
@@ -1439,298 +1439,298 @@ discard block |
||
1439 | 1439 | print "</td>"; |
1440 | 1440 | print '</tr>'; |
1441 | 1441 | |
1442 | - // Other attributes |
|
1443 | - $cols = 2; |
|
1444 | - include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; |
|
1442 | + // Other attributes |
|
1443 | + $cols = 2; |
|
1444 | + include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; |
|
1445 | 1445 | |
1446 | - print '</table>'; |
|
1446 | + print '</table>'; |
|
1447 | 1447 | |
1448 | - print '</div>'; |
|
1449 | - print '<div class="fichehalfright">'; |
|
1450 | - print '<div class="ficheaddleft">'; |
|
1451 | - print '<div class="underbanner clearboth"></div>'; |
|
1448 | + print '</div>'; |
|
1449 | + print '<div class="fichehalfright">'; |
|
1450 | + print '<div class="ficheaddleft">'; |
|
1451 | + print '<div class="underbanner clearboth"></div>'; |
|
1452 | 1452 | |
1453 | 1453 | |
1454 | - /* |
|
1454 | + /* |
|
1455 | 1455 | * Recurrence |
1456 | 1456 | */ |
1457 | - $title = $langs->trans("Recurrence"); |
|
1458 | - //print load_fiche_titre($title, '', 'calendar'); |
|
1459 | - |
|
1460 | - print '<table class="border" width="100%">'; |
|
1461 | - |
|
1462 | - print '<tr><td colspan="2"><span class="fa fa-calendar"></span> '.$title.'</td></tr>'; |
|
1463 | - |
|
1464 | - // if "frequency" is empty or = 0, the reccurence is disabled |
|
1465 | - print '<tr><td style="width: 50%">'; |
|
1466 | - print '<table class="nobordernopadding" width="100%"><tr><td>'; |
|
1467 | - print $langs->trans('Frequency'); |
|
1468 | - print '</td>'; |
|
1469 | - if ($action != 'editfrequency' && ! empty($object->brouillon) && $user->rights->facture->creer) |
|
1470 | - print '<td align="right"><a href="' . $_SERVER["PHP_SELF"] . '?action=editfrequency&facid=' . $object->id . '">' . img_edit($langs->trans('Edit'), 1) . '</a></td>'; |
|
1471 | - print '</tr></table>'; |
|
1472 | - print '</td><td>'; |
|
1473 | - if ($action == 'editfrequency') |
|
1474 | - { |
|
1475 | - print '<form method="post" action="'.$_SERVER["PHP_SELF"] . '?facid=' . $object->id.'">'; |
|
1476 | - print '<input type="hidden" name="action" value="setfrequency">'; |
|
1477 | - print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
1478 | - print '<table class="nobordernopadding" cellpadding="0" cellspacing="0">'; |
|
1479 | - print '<tr><td>'; |
|
1480 | - print "<input type='text' name='frequency' value='".$object->frequency."' size='5' /> ".$form->selectarray('unit_frequency', array('d'=>$langs->trans('Day'), 'm'=>$langs->trans('Month'), 'y'=>$langs->trans('Year')), ($object->unit_frequency?$object->unit_frequency:'m')); |
|
1481 | - print '</td>'; |
|
1482 | - print '<td align="left"><input type="submit" class="button" value="'.$langs->trans("Modify").'"></td>'; |
|
1483 | - print '</tr></table></form>'; |
|
1484 | - } |
|
1485 | - else |
|
1486 | - { |
|
1487 | - if ($object->frequency > 0) |
|
1488 | - { |
|
1489 | - print $langs->trans('FrequencyPer_'.$object->unit_frequency, $object->frequency); |
|
1490 | - } |
|
1491 | - else |
|
1492 | - { |
|
1493 | - print $langs->trans("NotARecurringInvoiceTemplate"); |
|
1494 | - } |
|
1495 | - } |
|
1496 | - print '</td></tr>'; |
|
1497 | - |
|
1498 | - // Date when (next invoice generation) |
|
1499 | - print '<tr><td>'; |
|
1500 | - if ($action == 'date_when' || $object->frequency > 0) |
|
1501 | - { |
|
1502 | - print $form->editfieldkey($langs->trans("NextDateToExecution"), 'date_when', $object->date_when, $object, $user->rights->facture->creer, 'day'); |
|
1503 | - } |
|
1504 | - else |
|
1505 | - { |
|
1506 | - print $langs->trans("NextDateToExecution"); |
|
1507 | - } |
|
1508 | - print '</td><td>'; |
|
1509 | - if ($action == 'date_when' || $object->frequency > 0) |
|
1510 | - { |
|
1511 | - print $form->editfieldval($langs->trans("NextDateToExecution"), 'date_when', $object->date_when, $object, $user->rights->facture->creer, 'day', $object->date_when, null, '', '', 0, 'strikeIfMaxNbGenReached'); |
|
1512 | - } |
|
1513 | - //var_dump(dol_print_date($object->date_when+60, 'dayhour').' - '.dol_print_date($now, 'dayhour')); |
|
1514 | - if (! $object->isMaxNbGenReached()) |
|
1515 | - { |
|
1516 | - if (! $object->suspended && $action != 'editdate_when' && $object->frequency > 0 && $object->date_when && $object->date_when < $now) print img_warning($langs->trans("Late")); |
|
1517 | - } |
|
1518 | - else |
|
1519 | - { |
|
1520 | - print img_info($langs->trans("MaxNumberOfGenerationReached")); |
|
1521 | - } |
|
1522 | - print '</td>'; |
|
1523 | - print '</tr>'; |
|
1524 | - |
|
1525 | - // Max period / Rest period |
|
1526 | - print '<tr><td>'; |
|
1527 | - if ($action == 'nb_gen_max' || $object->frequency > 0) |
|
1528 | - { |
|
1529 | - print $form->editfieldkey($langs->trans("MaxPeriodNumber"), 'nb_gen_max', $object->nb_gen_max, $object, $user->rights->facture->creer); |
|
1530 | - } |
|
1531 | - else |
|
1532 | - { |
|
1533 | - print $langs->trans("MaxPeriodNumber"); |
|
1534 | - } |
|
1535 | - print '</td><td>'; |
|
1536 | - if ($action == 'nb_gen_max' || $object->frequency > 0) |
|
1537 | - { |
|
1538 | - print $form->editfieldval($langs->trans("MaxPeriodNumber"), 'nb_gen_max', $object->nb_gen_max?$object->nb_gen_max:'', $object, $user->rights->facture->creer); |
|
1539 | - } |
|
1540 | - else |
|
1541 | - { |
|
1542 | - print ''; |
|
1543 | - } |
|
1544 | - print '</td>'; |
|
1545 | - print '</tr>'; |
|
1546 | - |
|
1547 | - // Status of generated invoices |
|
1548 | - print '<tr><td>'; |
|
1549 | - if ($action == 'auto_validate' || $object->frequency > 0) |
|
1550 | - print $form->editfieldkey($langs->trans("StatusOfGeneratedInvoices"), 'auto_validate', $object->auto_validate, $object, $user->rights->facture->creer); |
|
1551 | - else |
|
1552 | - print $langs->trans("StatusOfGeneratedInvoices"); |
|
1553 | - print '</td><td>'; |
|
1554 | - $select = 'select;0:'.$langs->trans('BillStatusDraft').',1:'.$langs->trans('BillStatusValidated'); |
|
1555 | - if ($action == 'auto_validate' || $object->frequency > 0) |
|
1556 | - { |
|
1557 | - print $form->editfieldval($langs->trans("StatusOfGeneratedInvoices"), 'auto_validate', $object->auto_validate, $object, $user->rights->facture->creer, $select); |
|
1558 | - } |
|
1559 | - print '</td>'; |
|
1560 | - // Auto generate documents |
|
1561 | - if (! empty($conf->global->INVOICE_REC_CAN_DISABLE_DOCUMENT_FILE_GENERATION)) |
|
1562 | - { |
|
1563 | - print '<tr>'; |
|
1564 | - print '<td>'; |
|
1565 | - if ($action == 'generate_pdf' || $object->frequency > 0) |
|
1566 | - print $form->editfieldkey($langs->trans("StatusOfGeneratedDocuments"), 'generate_pdf', $object->generate_pdf, $object, $user->rights->facture->creer); |
|
1567 | - else |
|
1568 | - print $langs->trans("StatusOfGeneratedDocuments"); |
|
1569 | - print '</td>'; |
|
1570 | - print '<td>'; |
|
1571 | - $select = 'select;0:'.$langs->trans('DoNotGenerateDoc').',1:'.$langs->trans('AutogenerateDoc'); |
|
1572 | - if ($action == 'generate_pdf' || $object->frequency > 0) |
|
1573 | - { |
|
1574 | - print $form->editfieldval($langs->trans("StatusOfGeneratedDocuments"), 'generate_pdf', $object->generate_pdf, $object, $user->rights->facture->creer, $select); |
|
1575 | - } |
|
1576 | - print '</td>'; |
|
1577 | - print '</tr>'; |
|
1578 | - } |
|
1579 | - else |
|
1580 | - { |
|
1581 | - print '<input type="hidden" name="generate_pdf" value="1">'; |
|
1582 | - } |
|
1583 | - |
|
1584 | - print '</table>'; |
|
1585 | - |
|
1586 | - // Frequencry/Recurring section |
|
1587 | - if ($object->frequency > 0) |
|
1588 | - { |
|
1589 | - print '<br>'; |
|
1590 | - |
|
1591 | - if (empty($conf->cron->enabled)) |
|
1592 | - { |
|
1593 | - print info_admin($langs->trans("EnableAndSetupModuleCron", $langs->transnoentitiesnoconv("Module2300Name"))); |
|
1594 | - } |
|
1595 | - |
|
1596 | - print '<div class="underbanner clearboth"></div>'; |
|
1597 | - print '<table class="border centpercent">'; |
|
1598 | - |
|
1599 | - // Nb of generation already done |
|
1600 | - print '<tr><td style="width: 50%">'.$langs->trans("NbOfGenerationDone").'</td>'; |
|
1601 | - print '<td>'; |
|
1602 | - print $object->nb_gen_done?$object->nb_gen_done:'0'; |
|
1603 | - print '</td>'; |
|
1604 | - print '</tr>'; |
|
1605 | - |
|
1606 | - // Date last |
|
1607 | - print '<tr><td>'; |
|
1608 | - print $langs->trans("DateLastGeneration"); |
|
1609 | - print '</td><td>'; |
|
1610 | - print dol_print_date($object->date_last_gen, 'dayhour'); |
|
1611 | - print '</td>'; |
|
1612 | - print '</tr>'; |
|
1613 | - |
|
1614 | - print '</table>'; |
|
1615 | - |
|
1616 | - print '<br>'; |
|
1617 | - } |
|
1618 | - |
|
1619 | - print '</div>'; |
|
1620 | - print '</div>'; |
|
1621 | - print '</div>'; |
|
1622 | - |
|
1623 | - print '<div class="clearboth"></div><br>'; |
|
1624 | - |
|
1625 | - |
|
1626 | - // Lines |
|
1627 | - print ' <form name="addproduct" id="addproduct" action="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . (($action != 'editline') ? '#add' : '#line_' . GETPOST('lineid')) . '" method="POST"> |
|
1457 | + $title = $langs->trans("Recurrence"); |
|
1458 | + //print load_fiche_titre($title, '', 'calendar'); |
|
1459 | + |
|
1460 | + print '<table class="border" width="100%">'; |
|
1461 | + |
|
1462 | + print '<tr><td colspan="2"><span class="fa fa-calendar"></span> '.$title.'</td></tr>'; |
|
1463 | + |
|
1464 | + // if "frequency" is empty or = 0, the reccurence is disabled |
|
1465 | + print '<tr><td style="width: 50%">'; |
|
1466 | + print '<table class="nobordernopadding" width="100%"><tr><td>'; |
|
1467 | + print $langs->trans('Frequency'); |
|
1468 | + print '</td>'; |
|
1469 | + if ($action != 'editfrequency' && ! empty($object->brouillon) && $user->rights->facture->creer) |
|
1470 | + print '<td align="right"><a href="' . $_SERVER["PHP_SELF"] . '?action=editfrequency&facid=' . $object->id . '">' . img_edit($langs->trans('Edit'), 1) . '</a></td>'; |
|
1471 | + print '</tr></table>'; |
|
1472 | + print '</td><td>'; |
|
1473 | + if ($action == 'editfrequency') |
|
1474 | + { |
|
1475 | + print '<form method="post" action="'.$_SERVER["PHP_SELF"] . '?facid=' . $object->id.'">'; |
|
1476 | + print '<input type="hidden" name="action" value="setfrequency">'; |
|
1477 | + print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
1478 | + print '<table class="nobordernopadding" cellpadding="0" cellspacing="0">'; |
|
1479 | + print '<tr><td>'; |
|
1480 | + print "<input type='text' name='frequency' value='".$object->frequency."' size='5' /> ".$form->selectarray('unit_frequency', array('d'=>$langs->trans('Day'), 'm'=>$langs->trans('Month'), 'y'=>$langs->trans('Year')), ($object->unit_frequency?$object->unit_frequency:'m')); |
|
1481 | + print '</td>'; |
|
1482 | + print '<td align="left"><input type="submit" class="button" value="'.$langs->trans("Modify").'"></td>'; |
|
1483 | + print '</tr></table></form>'; |
|
1484 | + } |
|
1485 | + else |
|
1486 | + { |
|
1487 | + if ($object->frequency > 0) |
|
1488 | + { |
|
1489 | + print $langs->trans('FrequencyPer_'.$object->unit_frequency, $object->frequency); |
|
1490 | + } |
|
1491 | + else |
|
1492 | + { |
|
1493 | + print $langs->trans("NotARecurringInvoiceTemplate"); |
|
1494 | + } |
|
1495 | + } |
|
1496 | + print '</td></tr>'; |
|
1497 | + |
|
1498 | + // Date when (next invoice generation) |
|
1499 | + print '<tr><td>'; |
|
1500 | + if ($action == 'date_when' || $object->frequency > 0) |
|
1501 | + { |
|
1502 | + print $form->editfieldkey($langs->trans("NextDateToExecution"), 'date_when', $object->date_when, $object, $user->rights->facture->creer, 'day'); |
|
1503 | + } |
|
1504 | + else |
|
1505 | + { |
|
1506 | + print $langs->trans("NextDateToExecution"); |
|
1507 | + } |
|
1508 | + print '</td><td>'; |
|
1509 | + if ($action == 'date_when' || $object->frequency > 0) |
|
1510 | + { |
|
1511 | + print $form->editfieldval($langs->trans("NextDateToExecution"), 'date_when', $object->date_when, $object, $user->rights->facture->creer, 'day', $object->date_when, null, '', '', 0, 'strikeIfMaxNbGenReached'); |
|
1512 | + } |
|
1513 | + //var_dump(dol_print_date($object->date_when+60, 'dayhour').' - '.dol_print_date($now, 'dayhour')); |
|
1514 | + if (! $object->isMaxNbGenReached()) |
|
1515 | + { |
|
1516 | + if (! $object->suspended && $action != 'editdate_when' && $object->frequency > 0 && $object->date_when && $object->date_when < $now) print img_warning($langs->trans("Late")); |
|
1517 | + } |
|
1518 | + else |
|
1519 | + { |
|
1520 | + print img_info($langs->trans("MaxNumberOfGenerationReached")); |
|
1521 | + } |
|
1522 | + print '</td>'; |
|
1523 | + print '</tr>'; |
|
1524 | + |
|
1525 | + // Max period / Rest period |
|
1526 | + print '<tr><td>'; |
|
1527 | + if ($action == 'nb_gen_max' || $object->frequency > 0) |
|
1528 | + { |
|
1529 | + print $form->editfieldkey($langs->trans("MaxPeriodNumber"), 'nb_gen_max', $object->nb_gen_max, $object, $user->rights->facture->creer); |
|
1530 | + } |
|
1531 | + else |
|
1532 | + { |
|
1533 | + print $langs->trans("MaxPeriodNumber"); |
|
1534 | + } |
|
1535 | + print '</td><td>'; |
|
1536 | + if ($action == 'nb_gen_max' || $object->frequency > 0) |
|
1537 | + { |
|
1538 | + print $form->editfieldval($langs->trans("MaxPeriodNumber"), 'nb_gen_max', $object->nb_gen_max?$object->nb_gen_max:'', $object, $user->rights->facture->creer); |
|
1539 | + } |
|
1540 | + else |
|
1541 | + { |
|
1542 | + print ''; |
|
1543 | + } |
|
1544 | + print '</td>'; |
|
1545 | + print '</tr>'; |
|
1546 | + |
|
1547 | + // Status of generated invoices |
|
1548 | + print '<tr><td>'; |
|
1549 | + if ($action == 'auto_validate' || $object->frequency > 0) |
|
1550 | + print $form->editfieldkey($langs->trans("StatusOfGeneratedInvoices"), 'auto_validate', $object->auto_validate, $object, $user->rights->facture->creer); |
|
1551 | + else |
|
1552 | + print $langs->trans("StatusOfGeneratedInvoices"); |
|
1553 | + print '</td><td>'; |
|
1554 | + $select = 'select;0:'.$langs->trans('BillStatusDraft').',1:'.$langs->trans('BillStatusValidated'); |
|
1555 | + if ($action == 'auto_validate' || $object->frequency > 0) |
|
1556 | + { |
|
1557 | + print $form->editfieldval($langs->trans("StatusOfGeneratedInvoices"), 'auto_validate', $object->auto_validate, $object, $user->rights->facture->creer, $select); |
|
1558 | + } |
|
1559 | + print '</td>'; |
|
1560 | + // Auto generate documents |
|
1561 | + if (! empty($conf->global->INVOICE_REC_CAN_DISABLE_DOCUMENT_FILE_GENERATION)) |
|
1562 | + { |
|
1563 | + print '<tr>'; |
|
1564 | + print '<td>'; |
|
1565 | + if ($action == 'generate_pdf' || $object->frequency > 0) |
|
1566 | + print $form->editfieldkey($langs->trans("StatusOfGeneratedDocuments"), 'generate_pdf', $object->generate_pdf, $object, $user->rights->facture->creer); |
|
1567 | + else |
|
1568 | + print $langs->trans("StatusOfGeneratedDocuments"); |
|
1569 | + print '</td>'; |
|
1570 | + print '<td>'; |
|
1571 | + $select = 'select;0:'.$langs->trans('DoNotGenerateDoc').',1:'.$langs->trans('AutogenerateDoc'); |
|
1572 | + if ($action == 'generate_pdf' || $object->frequency > 0) |
|
1573 | + { |
|
1574 | + print $form->editfieldval($langs->trans("StatusOfGeneratedDocuments"), 'generate_pdf', $object->generate_pdf, $object, $user->rights->facture->creer, $select); |
|
1575 | + } |
|
1576 | + print '</td>'; |
|
1577 | + print '</tr>'; |
|
1578 | + } |
|
1579 | + else |
|
1580 | + { |
|
1581 | + print '<input type="hidden" name="generate_pdf" value="1">'; |
|
1582 | + } |
|
1583 | + |
|
1584 | + print '</table>'; |
|
1585 | + |
|
1586 | + // Frequencry/Recurring section |
|
1587 | + if ($object->frequency > 0) |
|
1588 | + { |
|
1589 | + print '<br>'; |
|
1590 | + |
|
1591 | + if (empty($conf->cron->enabled)) |
|
1592 | + { |
|
1593 | + print info_admin($langs->trans("EnableAndSetupModuleCron", $langs->transnoentitiesnoconv("Module2300Name"))); |
|
1594 | + } |
|
1595 | + |
|
1596 | + print '<div class="underbanner clearboth"></div>'; |
|
1597 | + print '<table class="border centpercent">'; |
|
1598 | + |
|
1599 | + // Nb of generation already done |
|
1600 | + print '<tr><td style="width: 50%">'.$langs->trans("NbOfGenerationDone").'</td>'; |
|
1601 | + print '<td>'; |
|
1602 | + print $object->nb_gen_done?$object->nb_gen_done:'0'; |
|
1603 | + print '</td>'; |
|
1604 | + print '</tr>'; |
|
1605 | + |
|
1606 | + // Date last |
|
1607 | + print '<tr><td>'; |
|
1608 | + print $langs->trans("DateLastGeneration"); |
|
1609 | + print '</td><td>'; |
|
1610 | + print dol_print_date($object->date_last_gen, 'dayhour'); |
|
1611 | + print '</td>'; |
|
1612 | + print '</tr>'; |
|
1613 | + |
|
1614 | + print '</table>'; |
|
1615 | + |
|
1616 | + print '<br>'; |
|
1617 | + } |
|
1618 | + |
|
1619 | + print '</div>'; |
|
1620 | + print '</div>'; |
|
1621 | + print '</div>'; |
|
1622 | + |
|
1623 | + print '<div class="clearboth"></div><br>'; |
|
1624 | + |
|
1625 | + |
|
1626 | + // Lines |
|
1627 | + print ' <form name="addproduct" id="addproduct" action="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . (($action != 'editline') ? '#add' : '#line_' . GETPOST('lineid')) . '" method="POST"> |
|
1628 | 1628 | <input type="hidden" name="token" value="' . $_SESSION ['newtoken'] . '"> |
1629 | 1629 | <input type="hidden" name="action" value="' . (($action != 'editline') ? 'addline' : 'updateline') . '"> |
1630 | 1630 | <input type="hidden" name="mode" value=""> |
1631 | 1631 | <input type="hidden" name="id" value="' . $object->id . '"> |
1632 | 1632 | '; |
1633 | 1633 | |
1634 | - if (! empty($conf->use_javascript_ajax) && $object->statut == 0) { |
|
1635 | - include DOL_DOCUMENT_ROOT . '/core/tpl/ajaxrow.tpl.php'; |
|
1636 | - } |
|
1634 | + if (! empty($conf->use_javascript_ajax) && $object->statut == 0) { |
|
1635 | + include DOL_DOCUMENT_ROOT . '/core/tpl/ajaxrow.tpl.php'; |
|
1636 | + } |
|
1637 | 1637 | |
1638 | - print '<div class="div-table-responsive-no-min">'; |
|
1639 | - print '<table id="tablelines" class="noborder noshadow" width="100%">'; |
|
1640 | - // Show object lines |
|
1641 | - if (! empty($object->lines)) |
|
1642 | - { |
|
1643 | - //$disableedit=1; |
|
1644 | - //$disablemove=1; |
|
1645 | - $ret = $object->printObjectLines($action, $mysoc, $object->thirdparty, $lineid, 0); // No date selector for template invoice |
|
1646 | - } |
|
1638 | + print '<div class="div-table-responsive-no-min">'; |
|
1639 | + print '<table id="tablelines" class="noborder noshadow" width="100%">'; |
|
1640 | + // Show object lines |
|
1641 | + if (! empty($object->lines)) |
|
1642 | + { |
|
1643 | + //$disableedit=1; |
|
1644 | + //$disablemove=1; |
|
1645 | + $ret = $object->printObjectLines($action, $mysoc, $object->thirdparty, $lineid, 0); // No date selector for template invoice |
|
1646 | + } |
|
1647 | 1647 | |
1648 | - // Form to add new line |
|
1649 | - if ($object->statut == 0 && $user->rights->facture->creer && $action != 'valid' && $action != 'editline') |
|
1650 | - { |
|
1651 | - if ($action != 'editline') |
|
1652 | - { |
|
1653 | - // Add free products/services |
|
1654 | - $object->formAddObjectLine(0, $mysoc, $object->thirdparty); // No date selector for template invoice |
|
1648 | + // Form to add new line |
|
1649 | + if ($object->statut == 0 && $user->rights->facture->creer && $action != 'valid' && $action != 'editline') |
|
1650 | + { |
|
1651 | + if ($action != 'editline') |
|
1652 | + { |
|
1653 | + // Add free products/services |
|
1654 | + $object->formAddObjectLine(0, $mysoc, $object->thirdparty); // No date selector for template invoice |
|
1655 | 1655 | |
1656 | - $parameters = array(); |
|
1657 | - $reshook = $hookmanager->executeHooks('formAddObjectLine', $parameters, $object, $action); // Note that $action and $object may have been modified by hook |
|
1658 | - } |
|
1659 | - } |
|
1656 | + $parameters = array(); |
|
1657 | + $reshook = $hookmanager->executeHooks('formAddObjectLine', $parameters, $object, $action); // Note that $action and $object may have been modified by hook |
|
1658 | + } |
|
1659 | + } |
|
1660 | 1660 | |
1661 | - print "</table>\n"; |
|
1662 | - print '</div>'; |
|
1661 | + print "</table>\n"; |
|
1662 | + print '</div>'; |
|
1663 | 1663 | |
1664 | - print "</form>\n"; |
|
1664 | + print "</form>\n"; |
|
1665 | 1665 | |
1666 | - dol_fiche_end(); |
|
1666 | + dol_fiche_end(); |
|
1667 | 1667 | |
1668 | 1668 | |
1669 | - /** |
|
1670 | - * Barre d'actions |
|
1671 | - */ |
|
1672 | - print '<div class="tabsAction">'; |
|
1673 | - |
|
1674 | - if (empty($object->suspended)) |
|
1675 | - { |
|
1676 | - if ($user->rights->facture->creer) |
|
1677 | - { |
|
1678 | - if (! empty($object->frequency) && $object->nb_gen_max > 0 && ($object->nb_gen_done >= $object->nb_gen_max)) |
|
1679 | - { |
|
1680 | - print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("MaxGenerationReached")).'">'.$langs->trans("CreateBill").'</a></div>'; |
|
1681 | - } |
|
1682 | - else |
|
1683 | - { |
|
1684 | - if (empty($object->frequency) || $object->date_when <= $today) |
|
1685 | - { |
|
1669 | + /** |
|
1670 | + * Barre d'actions |
|
1671 | + */ |
|
1672 | + print '<div class="tabsAction">'; |
|
1673 | + |
|
1674 | + if (empty($object->suspended)) |
|
1675 | + { |
|
1676 | + if ($user->rights->facture->creer) |
|
1677 | + { |
|
1678 | + if (! empty($object->frequency) && $object->nb_gen_max > 0 && ($object->nb_gen_done >= $object->nb_gen_max)) |
|
1679 | + { |
|
1680 | + print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("MaxGenerationReached")).'">'.$langs->trans("CreateBill").'</a></div>'; |
|
1681 | + } |
|
1682 | + else |
|
1683 | + { |
|
1684 | + if (empty($object->frequency) || $object->date_when <= $today) |
|
1685 | + { |
|
1686 | 1686 | print '<div class="inline-block divButAction"><a class="butAction" href="' . BASE_URI . '?controller=compta/facture&method=card&action=create&socid=' . $object->thirdparty->id . '&fac_rec=' . $object->id . '">' . $langs->trans("CreateBill") . '</a></div>'; |
1687 | - } |
|
1688 | - else |
|
1689 | - { |
|
1690 | - print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("DateIsNotEnough")).'">'.$langs->trans("CreateBill").'</a></div>'; |
|
1691 | - } |
|
1692 | - } |
|
1693 | - } |
|
1694 | - else |
|
1695 | - { |
|
1696 | - print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#">'.$langs->trans("CreateBill").'</a></div>'; |
|
1697 | - } |
|
1698 | - } |
|
1699 | - |
|
1700 | - if ($user->rights->facture->creer) |
|
1701 | - { |
|
1702 | - if (empty($object->suspended)) |
|
1703 | - { |
|
1687 | + } |
|
1688 | + else |
|
1689 | + { |
|
1690 | + print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("DateIsNotEnough")).'">'.$langs->trans("CreateBill").'</a></div>'; |
|
1691 | + } |
|
1692 | + } |
|
1693 | + } |
|
1694 | + else |
|
1695 | + { |
|
1696 | + print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#">'.$langs->trans("CreateBill").'</a></div>'; |
|
1697 | + } |
|
1698 | + } |
|
1699 | + |
|
1700 | + if ($user->rights->facture->creer) |
|
1701 | + { |
|
1702 | + if (empty($object->suspended)) |
|
1703 | + { |
|
1704 | 1704 | print '<div class="inline-block divButAction"><a class="butActionDelete" href="' . BASE_URI . '?controller=compta/facture&method=fiche-rec&action=disable&id=' . $object->id . '">' . $langs->trans("Disable") . '</a></div>'; |
1705 | - } |
|
1706 | - else |
|
1707 | - { |
|
1705 | + } |
|
1706 | + else |
|
1707 | + { |
|
1708 | 1708 | print '<div class="inline-block divButAction"><a class="butAction" href="' . BASE_URI . '?controller=compta/facture&method=fiche-rec&action=enable&id=' . $object->id . '">' . $langs->trans("Enable") . '</a></div>'; |
1709 | - } |
|
1710 | - } |
|
1709 | + } |
|
1710 | + } |
|
1711 | 1711 | |
1712 | - //if ($object->statut == Facture::STATUS_DRAFT && $user->rights->facture->supprimer) |
|
1713 | - if ($user->rights->facture->supprimer) |
|
1714 | - { |
|
1715 | - print '<div class="inline-block divButAction"><a class="butActionDelete" href="'.$_SERVER['PHP_SELF'].'?action=ask_deleteinvoice&id='.$object->id.'">'.$langs->trans('Delete').'</a></div>'; |
|
1716 | - } |
|
1712 | + //if ($object->statut == Facture::STATUS_DRAFT && $user->rights->facture->supprimer) |
|
1713 | + if ($user->rights->facture->supprimer) |
|
1714 | + { |
|
1715 | + print '<div class="inline-block divButAction"><a class="butActionDelete" href="'.$_SERVER['PHP_SELF'].'?action=ask_deleteinvoice&id='.$object->id.'">'.$langs->trans('Delete').'</a></div>'; |
|
1716 | + } |
|
1717 | 1717 | |
1718 | - print '</div>'; |
|
1718 | + print '</div>'; |
|
1719 | 1719 | |
1720 | 1720 | |
1721 | 1721 | |
1722 | - print '<div class="fichecenter"><div class="fichehalfleft">'; |
|
1723 | - print '<a name="builddoc"></a>'; // ancre |
|
1722 | + print '<div class="fichecenter"><div class="fichehalfleft">'; |
|
1723 | + print '<a name="builddoc"></a>'; // ancre |
|
1724 | 1724 | |
1725 | 1725 | |
1726 | - // Show links to link elements |
|
1727 | - $linktoelem = $form->showLinkToObjectBlock($object, null, array('invoice')); |
|
1726 | + // Show links to link elements |
|
1727 | + $linktoelem = $form->showLinkToObjectBlock($object, null, array('invoice')); |
|
1728 | 1728 | |
1729 | - $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem); |
|
1729 | + $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem); |
|
1730 | 1730 | |
1731 | 1731 | |
1732 | - print '</div></div>'; |
|
1733 | - } |
|
1732 | + print '</div></div>'; |
|
1733 | + } |
|
1734 | 1734 | } |
1735 | 1735 | |
1736 | 1736 | // End of page |
@@ -33,51 +33,51 @@ discard block |
||
33 | 33 | |
34 | 34 | // Copyright (C) 2018 Alxarafe/Alixar <[email protected]> |
35 | 35 | defined('BASE_PATH') or die('Single entry point through the index.php of the main folder'); |
36 | -require DOL_BASE_PATH . '/main.inc.php'; |
|
36 | +require DOL_BASE_PATH.'/main.inc.php'; |
|
37 | 37 | require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture-rec.class.php'; |
38 | 38 | require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; |
39 | 39 | require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; |
40 | -if (! empty($conf->projet->enabled)) { |
|
41 | - include_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php'; |
|
40 | +if (!empty($conf->projet->enabled)) { |
|
41 | + include_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; |
|
42 | 42 | //include_once DOL_DOCUMENT_ROOT . '/core/class/html.formprojet.class.php'; |
43 | 43 | } |
44 | -require_once DOL_DOCUMENT_ROOT . '/core/class/html.formprojet.class.php'; |
|
45 | -require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php'; |
|
46 | -require_once DOL_DOCUMENT_ROOT . '/core/lib/invoice.lib.php'; |
|
47 | -require_once DOL_DOCUMENT_ROOT . '/core/class/extrafields.class.php'; |
|
44 | +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; |
|
45 | +require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; |
|
46 | +require_once DOL_DOCUMENT_ROOT.'/core/lib/invoice.lib.php'; |
|
47 | +require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; |
|
48 | 48 | |
49 | 49 | // Load translation files required by the page |
50 | 50 | $langs->loadLangs(array('bills', 'compta', 'admin', 'other', 'products')); |
51 | 51 | |
52 | -$action = GETPOST('action','alpha'); |
|
53 | -$massaction = GETPOST('massaction','alpha'); |
|
54 | -$show_files = GETPOST('show_files','int'); |
|
55 | -$confirm = GETPOST('confirm','alpha'); |
|
52 | +$action = GETPOST('action', 'alpha'); |
|
53 | +$massaction = GETPOST('massaction', 'alpha'); |
|
54 | +$show_files = GETPOST('show_files', 'int'); |
|
55 | +$confirm = GETPOST('confirm', 'alpha'); |
|
56 | 56 | $cancel = GETPOST('cancel', 'alpha'); |
57 | 57 | $toselect = GETPOST('toselect', 'array'); |
58 | -$contextpage= GETPOST('contextpage','aZ')?GETPOST('contextpage','aZ'):'invoicetemplatelist'; // To manage different context of search |
|
58 | +$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'invoicetemplatelist'; // To manage different context of search |
|
59 | 59 | |
60 | 60 | // Security check |
61 | -$id=(GETPOST('facid','int')?GETPOST('facid','int'):GETPOST('id','int')); |
|
62 | -$lineid=GETPOST('lineid','int'); |
|
63 | -$ref=GETPOST('ref','alpha'); |
|
64 | -if ($user->societe_id) $socid=$user->societe_id; |
|
61 | +$id = (GETPOST('facid', 'int') ?GETPOST('facid', 'int') : GETPOST('id', 'int')); |
|
62 | +$lineid = GETPOST('lineid', 'int'); |
|
63 | +$ref = GETPOST('ref', 'alpha'); |
|
64 | +if ($user->societe_id) $socid = $user->societe_id; |
|
65 | 65 | $objecttype = 'facture_rec'; |
66 | 66 | if ($action == "create" || $action == "add") $objecttype = ''; |
67 | 67 | $result = restrictedArea($user, 'facture', $id, $objecttype); |
68 | -$projectid = GETPOST('projectid','int'); |
|
68 | +$projectid = GETPOST('projectid', 'int'); |
|
69 | 69 | |
70 | -$year_date_when=GETPOST('year_date_when'); |
|
71 | -$month_date_when=GETPOST('month_date_when'); |
|
70 | +$year_date_when = GETPOST('year_date_when'); |
|
71 | +$month_date_when = GETPOST('month_date_when'); |
|
72 | 72 | |
73 | -$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; |
|
74 | -$sortfield = GETPOST("sortfield",'alpha'); |
|
75 | -$sortorder = GETPOST("sortorder",'alpha'); |
|
76 | -$page = GETPOST("page",'int'); |
|
73 | +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; |
|
74 | +$sortfield = GETPOST("sortfield", 'alpha'); |
|
75 | +$sortorder = GETPOST("sortorder", 'alpha'); |
|
76 | +$page = GETPOST("page", 'int'); |
|
77 | 77 | if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 |
78 | 78 | $offset = $limit * $page; |
79 | -if (! $sortorder) $sortorder='DESC'; |
|
80 | -if (! $sortfield) $sortfield='f.titre'; |
|
79 | +if (!$sortorder) $sortorder = 'DESC'; |
|
80 | +if (!$sortfield) $sortfield = 'f.titre'; |
|
81 | 81 | $pageprev = $page - 1; |
82 | 82 | $pagenext = $page + 1; |
83 | 83 | |
@@ -92,15 +92,15 @@ discard block |
||
92 | 92 | } |
93 | 93 | |
94 | 94 | // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context |
95 | -$hookmanager->initHooks(array('invoicereccard','globalcard')); |
|
95 | +$hookmanager->initHooks(array('invoicereccard', 'globalcard')); |
|
96 | 96 | $extrafields = new ExtraFields($db); |
97 | 97 | |
98 | 98 | // fetch optionals attributes and labels |
99 | 99 | $extralabels = $extrafields->fetch_name_optionals_label('facture_rec'); |
100 | -$search_array_options=$extrafields->getOptionalsFromPost($object->table_element,'','search_'); |
|
100 | +$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); |
|
101 | 101 | |
102 | 102 | $permissionnote = $user->rights->facture->creer; // Used by the include of actions_setnotes.inc.php |
103 | -$permissiondellink=$user->rights->facture->creer; // Used by the include of actions_dellink.inc.php |
|
103 | +$permissiondellink = $user->rights->facture->creer; // Used by the include of actions_dellink.inc.php |
|
104 | 104 | $permissiontoedit = $user->rights->facture->creer; // Used by the include of actions_lineupdonw.inc.php |
105 | 105 | |
106 | 106 | $now = dol_now(); |
@@ -110,8 +110,8 @@ discard block |
||
110 | 110 | * Actions |
111 | 111 | */ |
112 | 112 | |
113 | -if (GETPOST('cancel','alpha')) { $action='list'; $massaction=''; } |
|
114 | -if (! GETPOST('confirmmassaction','alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction=''; } |
|
113 | +if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; } |
|
114 | +if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; } |
|
115 | 115 | |
116 | 116 | $parameters = array('socid' => $socid); |
117 | 117 | $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks |
@@ -119,17 +119,17 @@ discard block |
||
119 | 119 | |
120 | 120 | if (empty($reshook)) |
121 | 121 | { |
122 | - if (GETPOST('cancel','alpha')) $action=''; |
|
122 | + if (GETPOST('cancel', 'alpha')) $action = ''; |
|
123 | 123 | |
124 | 124 | // Selection of new fields |
125 | 125 | include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; |
126 | 126 | |
127 | 127 | // Set note |
128 | - include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not include_once |
|
128 | + include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not include_once |
|
129 | 129 | |
130 | - include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php'; // Must be include, not include_once |
|
130 | + include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php'; // Must be include, not include_once |
|
131 | 131 | |
132 | - include DOL_DOCUMENT_ROOT.'/core/actions_lineupdown.inc.php'; // Must be include, not include_once |
|
132 | + include DOL_DOCUMENT_ROOT.'/core/actions_lineupdown.inc.php'; // Must be include, not include_once |
|
133 | 133 | |
134 | 134 | // Mass actions |
135 | 135 | /*$objectclass='MyObject'; |
@@ -142,43 +142,43 @@ discard block |
||
142 | 142 | // Create predefined invoice |
143 | 143 | if ($action == 'add') |
144 | 144 | { |
145 | - if (! GETPOST('titre')) |
|
145 | + if (!GETPOST('titre')) |
|
146 | 146 | { |
147 | - setEventMessages($langs->transnoentities("ErrorFieldRequired",$langs->trans("Title")), null, 'errors'); |
|
147 | + setEventMessages($langs->transnoentities("ErrorFieldRequired", $langs->trans("Title")), null, 'errors'); |
|
148 | 148 | $action = "create"; |
149 | 149 | $error++; |
150 | 150 | } |
151 | 151 | |
152 | - $frequency=GETPOST('frequency', 'int'); |
|
153 | - $reyear=GETPOST('reyear'); |
|
154 | - $remonth=GETPOST('remonth'); |
|
155 | - $reday=GETPOST('reday'); |
|
156 | - $rehour=GETPOST('rehour'); |
|
157 | - $remin=GETPOST('remin'); |
|
158 | - $nb_gen_max=GETPOST('nb_gen_max', 'int'); |
|
152 | + $frequency = GETPOST('frequency', 'int'); |
|
153 | + $reyear = GETPOST('reyear'); |
|
154 | + $remonth = GETPOST('remonth'); |
|
155 | + $reday = GETPOST('reday'); |
|
156 | + $rehour = GETPOST('rehour'); |
|
157 | + $remin = GETPOST('remin'); |
|
158 | + $nb_gen_max = GETPOST('nb_gen_max', 'int'); |
|
159 | 159 | //if (empty($nb_gen_max)) $nb_gen_max =0; |
160 | 160 | |
161 | 161 | if (GETPOST('frequency')) |
162 | 162 | { |
163 | 163 | if (empty($reyear) || empty($remonth) || empty($reday)) |
164 | 164 | { |
165 | - setEventMessages($langs->transnoentities("ErrorFieldRequired",$langs->trans("Date")), null, 'errors'); |
|
165 | + setEventMessages($langs->transnoentities("ErrorFieldRequired", $langs->trans("Date")), null, 'errors'); |
|
166 | 166 | $action = "create"; |
167 | 167 | $error++; |
168 | 168 | } |
169 | 169 | if ($nb_gen_max === '') |
170 | 170 | { |
171 | - setEventMessages($langs->transnoentities("ErrorFieldRequired",$langs->trans("MaxPeriodNumber")), null, 'errors'); |
|
171 | + setEventMessages($langs->transnoentities("ErrorFieldRequired", $langs->trans("MaxPeriodNumber")), null, 'errors'); |
|
172 | 172 | $action = "create"; |
173 | 173 | $error++; |
174 | 174 | } |
175 | 175 | } |
176 | 176 | |
177 | - if (! $error) |
|
177 | + if (!$error) |
|
178 | 178 | { |
179 | 179 | $object->titre = GETPOST('titre', 'alpha'); |
180 | - $object->note_private = GETPOST('note_private','none'); |
|
181 | - $object->note_public = GETPOST('note_public','none'); |
|
180 | + $object->note_private = GETPOST('note_private', 'none'); |
|
181 | + $object->note_public = GETPOST('note_public', 'none'); |
|
182 | 182 | $object->modelpdf = GETPOST('modelpdf', 'alpha'); |
183 | 183 | $object->usenewprice = GETPOST('usenewprice'); |
184 | 184 | |
@@ -193,14 +193,14 @@ discard block |
||
193 | 193 | $object->date_when = $date_next_execution; |
194 | 194 | |
195 | 195 | // Get first contract linked to invoice used to generate template (facid is id of source invoice) |
196 | - if (GETPOST('facid','int') > 0) |
|
196 | + if (GETPOST('facid', 'int') > 0) |
|
197 | 197 | { |
198 | 198 | $srcObject = new Facture($db); |
199 | - $srcObject->fetch(GETPOST('facid','int')); |
|
199 | + $srcObject->fetch(GETPOST('facid', 'int')); |
|
200 | 200 | |
201 | 201 | $srcObject->fetchObjectLinked(); |
202 | 202 | |
203 | - if (! empty($srcObject->linkedObjectsIds['contrat'])) |
|
203 | + if (!empty($srcObject->linkedObjectsIds['contrat'])) |
|
204 | 204 | { |
205 | 205 | $contractidid = reset($srcObject->linkedObjectsIds['contrat']); |
206 | 206 | |
@@ -213,12 +213,12 @@ discard block |
||
213 | 213 | $db->begin(); |
214 | 214 | |
215 | 215 | $oldinvoice = new Facture($db); |
216 | - $oldinvoice->fetch(GETPOST('facid','int')); |
|
216 | + $oldinvoice->fetch(GETPOST('facid', 'int')); |
|
217 | 217 | |
218 | 218 | $result = $object->create($user, $oldinvoice->id); |
219 | 219 | if ($result > 0) |
220 | 220 | { |
221 | - $result=$oldinvoice->delete($user, 1); |
|
221 | + $result = $oldinvoice->delete($user, 1); |
|
222 | 222 | if ($result < 0) |
223 | 223 | { |
224 | 224 | $error++; |
@@ -233,11 +233,11 @@ discard block |
||
233 | 233 | $action = "create"; |
234 | 234 | } |
235 | 235 | |
236 | - if (! $error) |
|
236 | + if (!$error) |
|
237 | 237 | { |
238 | 238 | $db->commit(); |
239 | 239 | |
240 | - header("Location: " . $_SERVER['PHP_SELF'] . '?facid=' . $object->id); |
|
240 | + header("Location: ".$_SERVER['PHP_SELF'].'?facid='.$object->id); |
|
241 | 241 | exit; |
242 | 242 | } |
243 | 243 | else |
@@ -256,7 +256,7 @@ discard block |
||
256 | 256 | { |
257 | 257 | $object->delete($user); |
258 | 258 | |
259 | - header("Location: " . BASE_URI . 'controller=compta/facture&method=invoicetemplate_list'); |
|
259 | + header("Location: ".BASE_URI.'controller=compta/facture&method=invoicetemplate_list'); |
|
260 | 260 | exit; |
261 | 261 | } |
262 | 262 | |
@@ -265,12 +265,12 @@ discard block |
||
265 | 265 | // Set condition |
266 | 266 | if ($action == 'setconditions' && $user->rights->facture->creer) |
267 | 267 | { |
268 | - $result=$object->setPaymentTerms(GETPOST('cond_reglement_id', 'int')); |
|
268 | + $result = $object->setPaymentTerms(GETPOST('cond_reglement_id', 'int')); |
|
269 | 269 | } |
270 | 270 | // Set mode |
271 | 271 | elseif ($action == 'setmode' && $user->rights->facture->creer) |
272 | 272 | { |
273 | - $result=$object->setPaymentMethods(GETPOST('mode_reglement_id', 'int')); |
|
273 | + $result = $object->setPaymentMethods(GETPOST('mode_reglement_id', 'int')); |
|
274 | 274 | } |
275 | 275 | // Set project |
276 | 276 | elseif ($action == 'classin' && $user->rights->facture->creer) |
@@ -281,7 +281,7 @@ discard block |
||
281 | 281 | elseif ($action == 'setref' && $user->rights->facture->creer) |
282 | 282 | { |
283 | 283 | //var_dump(GETPOST('ref', 'alpha'));exit; |
284 | - $result=$object->setValueFrom('titre', GETPOST('ref', 'alpha'), '', null, 'text', '', $user, 'BILLREC_MODIFY'); |
|
284 | + $result = $object->setValueFrom('titre', GETPOST('ref', 'alpha'), '', null, 'text', '', $user, 'BILLREC_MODIFY'); |
|
285 | 285 | if ($result > 0) |
286 | 286 | { |
287 | 287 | $object->titre = GETPOST('ref', 'alpha'); |
@@ -292,7 +292,7 @@ discard block |
||
292 | 292 | // Set bank account |
293 | 293 | elseif ($action == 'setbankaccount' && $user->rights->facture->creer) |
294 | 294 | { |
295 | - $result=$object->setBankAccount(GETPOST('fk_account', 'int')); |
|
295 | + $result = $object->setBankAccount(GETPOST('fk_account', 'int')); |
|
296 | 296 | } |
297 | 297 | // Set frequency and unit frequency |
298 | 298 | elseif ($action == 'setfrequency' && $user->rights->facture->creer) |
@@ -339,7 +339,7 @@ discard block |
||
339 | 339 | $error++; |
340 | 340 | } |
341 | 341 | |
342 | - if (! $error) |
|
342 | + if (!$error) |
|
343 | 343 | { |
344 | 344 | $db->commit(); |
345 | 345 | } |
@@ -363,7 +363,7 @@ discard block |
||
363 | 363 | $error++; |
364 | 364 | } |
365 | 365 | |
366 | - if (! $error) |
|
366 | + if (!$error) |
|
367 | 367 | { |
368 | 368 | $db->commit(); |
369 | 369 | } |
@@ -382,19 +382,19 @@ discard block |
||
382 | 382 | |
383 | 383 | $db->begin(); |
384 | 384 | |
385 | - $line=new FactureLigneRec($db); |
|
385 | + $line = new FactureLigneRec($db); |
|
386 | 386 | |
387 | 387 | // For triggers |
388 | 388 | $line->id = $lineid; |
389 | 389 | |
390 | 390 | if ($line->delete($user) > 0) |
391 | 391 | { |
392 | - $result=$object->update_price(1); |
|
392 | + $result = $object->update_price(1); |
|
393 | 393 | |
394 | 394 | if ($result > 0) |
395 | 395 | { |
396 | 396 | $db->commit(); |
397 | - $object->fetch($object->id); // Reload lines |
|
397 | + $object->fetch($object->id); // Reload lines |
|
398 | 398 | } |
399 | 399 | else |
400 | 400 | { |
@@ -414,10 +414,10 @@ discard block |
||
414 | 414 | |
415 | 415 | // Fill array 'array_options' with data from update form |
416 | 416 | $extralabels = $extrafields->fetch_name_optionals_label($object->table_element); |
417 | - $ret = $extrafields->setOptionalsFromPost($extralabels, $object, GETPOST('attribute','none')); |
|
417 | + $ret = $extrafields->setOptionalsFromPost($extralabels, $object, GETPOST('attribute', 'none')); |
|
418 | 418 | if ($ret < 0) $error++; |
419 | 419 | |
420 | - if (! $error) |
|
420 | + if (!$error) |
|
421 | 421 | { |
422 | 422 | $result = $object->insertExtraFields('BILLREC_MODIFY'); |
423 | 423 | if ($result < 0) |
@@ -435,22 +435,22 @@ discard block |
||
435 | 435 | $error = 0; |
436 | 436 | |
437 | 437 | // Set if we used free entry or predefined product |
438 | - $predef=''; |
|
439 | - $product_desc=(GETPOST('dp_desc')?GETPOST('dp_desc'):''); |
|
438 | + $predef = ''; |
|
439 | + $product_desc = (GETPOST('dp_desc') ?GETPOST('dp_desc') : ''); |
|
440 | 440 | $price_ht = GETPOST('price_ht'); |
441 | 441 | if (GETPOST('prod_entry_mode') == 'free') |
442 | 442 | { |
443 | - $idprod=0; |
|
443 | + $idprod = 0; |
|
444 | 444 | $tva_tx = (GETPOST('tva_tx') ? GETPOST('tva_tx') : 0); |
445 | 445 | } |
446 | 446 | else |
447 | 447 | { |
448 | - $idprod=GETPOST('idprod', 'int'); |
|
448 | + $idprod = GETPOST('idprod', 'int'); |
|
449 | 449 | $tva_tx = ''; |
450 | 450 | } |
451 | 451 | |
452 | - $qty = GETPOST('qty' . $predef); |
|
453 | - $remise_percent = GETPOST('remise_percent' . $predef); |
|
452 | + $qty = GETPOST('qty'.$predef); |
|
453 | + $remise_percent = GETPOST('remise_percent'.$predef); |
|
454 | 454 | |
455 | 455 | // Extrafields |
456 | 456 | $extrafieldsline = new ExtraFields($db); |
@@ -461,38 +461,38 @@ discard block |
||
461 | 461 | { |
462 | 462 | // Get extra fields |
463 | 463 | foreach ($extralabelsline as $key => $value) { |
464 | - unset($_POST["options_" . $key . $predef]); |
|
464 | + unset($_POST["options_".$key.$predef]); |
|
465 | 465 | } |
466 | 466 | } |
467 | 467 | |
468 | 468 | if (empty($idprod) && ($price_ht < 0) && ($qty < 0)) { |
469 | 469 | setEventMessages($langs->trans('ErrorBothFieldCantBeNegative', $langs->transnoentitiesnoconv('UnitPriceHT'), $langs->transnoentitiesnoconv('Qty')), null, 'errors'); |
470 | - $error ++; |
|
470 | + $error++; |
|
471 | 471 | } |
472 | 472 | if (GETPOST('prod_entry_mode') == 'free' && empty($idprod) && GETPOST('type') < 0) { |
473 | 473 | setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Type')), null, 'errors'); |
474 | - $error ++; |
|
474 | + $error++; |
|
475 | 475 | } |
476 | - if (GETPOST('prod_entry_mode') == 'free' && empty($idprod) && (! ($price_ht >= 0) || $price_ht == '')) // Unit price can be 0 but not '' |
|
476 | + if (GETPOST('prod_entry_mode') == 'free' && empty($idprod) && (!($price_ht >= 0) || $price_ht == '')) // Unit price can be 0 but not '' |
|
477 | 477 | { |
478 | 478 | setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("UnitPriceHT")), null, 'errors'); |
479 | - $error ++; |
|
479 | + $error++; |
|
480 | 480 | } |
481 | 481 | if ($qty == '') { |
482 | 482 | setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Qty')), null, 'errors'); |
483 | - $error ++; |
|
483 | + $error++; |
|
484 | 484 | } |
485 | 485 | if (GETPOST('prod_entry_mode') == 'free' && empty($idprod) && empty($product_desc)) { |
486 | 486 | setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Description')), null, 'errors'); |
487 | - $error ++; |
|
487 | + $error++; |
|
488 | 488 | } |
489 | 489 | if ($qty < 0) { |
490 | 490 | $langs->load("errors"); |
491 | 491 | setEventMessages($langs->trans('ErrorQtyForCustomerInvoiceCantBeNegative'), null, 'errors'); |
492 | - $error ++; |
|
492 | + $error++; |
|
493 | 493 | } |
494 | 494 | |
495 | - if (! $error && ($qty >= 0) && (! empty($product_desc) || ! empty($idprod))) |
|
495 | + if (!$error && ($qty >= 0) && (!empty($product_desc) || !empty($idprod))) |
|
496 | 496 | { |
497 | 497 | $ret = $object->fetch($id); |
498 | 498 | if ($ret < 0) { |
@@ -502,8 +502,8 @@ discard block |
||
502 | 502 | $ret = $object->fetch_thirdparty(); |
503 | 503 | |
504 | 504 | // Clean parameters |
505 | - $date_start = dol_mktime(GETPOST('date_start' . $predef . 'hour'), GETPOST('date_start' . $predef . 'min'), GETPOST('date_start' . $predef . 'sec'), GETPOST('date_start' . $predef . 'month'), GETPOST('date_start' . $predef . 'day'), GETPOST('date_start' . $predef . 'year')); |
|
506 | - $date_end = dol_mktime(GETPOST('date_end' . $predef . 'hour'), GETPOST('date_end' . $predef . 'min'), GETPOST('date_end' . $predef . 'sec'), GETPOST('date_end' . $predef . 'month'), GETPOST('date_end' . $predef . 'day'), GETPOST('date_end' . $predef . 'year')); |
|
505 | + $date_start = dol_mktime(GETPOST('date_start'.$predef.'hour'), GETPOST('date_start'.$predef.'min'), GETPOST('date_start'.$predef.'sec'), GETPOST('date_start'.$predef.'month'), GETPOST('date_start'.$predef.'day'), GETPOST('date_start'.$predef.'year')); |
|
506 | + $date_end = dol_mktime(GETPOST('date_end'.$predef.'hour'), GETPOST('date_end'.$predef.'min'), GETPOST('date_end'.$predef.'sec'), GETPOST('date_end'.$predef.'month'), GETPOST('date_end'.$predef.'day'), GETPOST('date_end'.$predef.'year')); |
|
507 | 507 | $price_base_type = (GETPOST('price_base_type', 'alpha') ? GETPOST('price_base_type', 'alpha') : 'HT'); |
508 | 508 | |
509 | 509 | // Define special_code for special lines |
@@ -515,7 +515,7 @@ discard block |
||
515 | 515 | // Ecrase $tva_tx par celui du produit |
516 | 516 | // Ecrase $base_price_type par celui du produit |
517 | 517 | // Replaces $fk_unit with the product's |
518 | - if (! empty($idprod)) |
|
518 | + if (!empty($idprod)) |
|
519 | 519 | { |
520 | 520 | $prod = new Product($db); |
521 | 521 | $prod->fetch($idprod); |
@@ -525,7 +525,7 @@ discard block |
||
525 | 525 | // Update if prices fields are defined |
526 | 526 | $tva_tx = get_default_tva($mysoc, $object->thirdparty, $prod->id); |
527 | 527 | $tva_npr = get_default_npr($mysoc, $object->thirdparty, $prod->id); |
528 | - if (empty($tva_tx)) $tva_npr=0; |
|
528 | + if (empty($tva_tx)) $tva_npr = 0; |
|
529 | 529 | |
530 | 530 | $pu_ht = $prod->price; |
531 | 531 | $pu_ttc = $prod->price_ttc; |
@@ -533,26 +533,26 @@ discard block |
||
533 | 533 | $price_base_type = $prod->price_base_type; |
534 | 534 | |
535 | 535 | // We define price for product |
536 | - if (! empty($conf->global->PRODUIT_MULTIPRICES) && ! empty($object->thirdparty->price_level)) |
|
536 | + if (!empty($conf->global->PRODUIT_MULTIPRICES) && !empty($object->thirdparty->price_level)) |
|
537 | 537 | { |
538 | 538 | $pu_ht = $prod->multiprices[$object->thirdparty->price_level]; |
539 | 539 | $pu_ttc = $prod->multiprices_ttc[$object->thirdparty->price_level]; |
540 | 540 | $price_min = $prod->multiprices_min[$object->thirdparty->price_level]; |
541 | 541 | $price_base_type = $prod->multiprices_base_type[$object->thirdparty->price_level]; |
542 | - if (! empty($conf->global->PRODUIT_MULTIPRICES_USE_VAT_PER_LEVEL)) // using this option is a bug. kept for backward compatibility |
|
542 | + if (!empty($conf->global->PRODUIT_MULTIPRICES_USE_VAT_PER_LEVEL)) // using this option is a bug. kept for backward compatibility |
|
543 | 543 | { |
544 | - if (isset($prod->multiprices_tva_tx[$object->thirdparty->price_level])) $tva_tx=$prod->multiprices_tva_tx[$object->thirdparty->price_level]; |
|
545 | - if (isset($prod->multiprices_recuperableonly[$object->thirdparty->price_level])) $tva_npr=$prod->multiprices_recuperableonly[$object->thirdparty->price_level]; |
|
546 | - if (empty($tva_tx)) $tva_npr=0; |
|
544 | + if (isset($prod->multiprices_tva_tx[$object->thirdparty->price_level])) $tva_tx = $prod->multiprices_tva_tx[$object->thirdparty->price_level]; |
|
545 | + if (isset($prod->multiprices_recuperableonly[$object->thirdparty->price_level])) $tva_npr = $prod->multiprices_recuperableonly[$object->thirdparty->price_level]; |
|
546 | + if (empty($tva_tx)) $tva_npr = 0; |
|
547 | 547 | } |
548 | 548 | } |
549 | - elseif (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) |
|
549 | + elseif (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) |
|
550 | 550 | { |
551 | - include_once DOL_DOCUMENT_ROOT . '/product/class/productcustomerprice.class.php'; |
|
551 | + include_once DOL_DOCUMENT_ROOT.'/product/class/productcustomerprice.class.php'; |
|
552 | 552 | |
553 | 553 | $prodcustprice = new Productcustomerprice($db); |
554 | 554 | |
555 | - $filter = array('t.fk_product' => $prod->id,'t.fk_soc' => $object->thirdparty->id); |
|
555 | + $filter = array('t.fk_product' => $prod->id, 't.fk_soc' => $object->thirdparty->id); |
|
556 | 556 | |
557 | 557 | $result = $prodcustprice->fetch_all('', '', 0, 0, $filter); |
558 | 558 | if ($result) |
@@ -563,9 +563,9 @@ discard block |
||
563 | 563 | $pu_ttc = price($prodcustprice->lines[0]->price_ttc); |
564 | 564 | $price_base_type = $prodcustprice->lines[0]->price_base_type; |
565 | 565 | $tva_tx = $prodcustprice->lines[0]->tva_tx; |
566 | - if ($prodcustprice->lines[0]->default_vat_code && ! preg_match('/\(.*\)/', $tva_tx)) $tva_tx.= ' ('.$prodcustprice->lines[0]->default_vat_code.')'; |
|
566 | + if ($prodcustprice->lines[0]->default_vat_code && !preg_match('/\(.*\)/', $tva_tx)) $tva_tx .= ' ('.$prodcustprice->lines[0]->default_vat_code.')'; |
|
567 | 567 | $tva_npr = $prodcustprice->lines[0]->recuperableonly; |
568 | - if (empty($tva_tx)) $tva_npr=0; |
|
568 | + if (empty($tva_tx)) $tva_npr = 0; |
|
569 | 569 | } |
570 | 570 | } |
571 | 571 | } |
@@ -574,7 +574,7 @@ discard block |
||
574 | 574 | $tmpprodvat = price2num(preg_replace('/\s*\(.*\)/', '', $prod->tva_tx)); |
575 | 575 | |
576 | 576 | // if price ht was forced (ie: from gui when calculated by margin rate and cost price). TODO Why this ? |
577 | - if (! empty($price_ht)) |
|
577 | + if (!empty($price_ht)) |
|
578 | 578 | { |
579 | 579 | $pu_ht = price2num($price_ht, 'MU'); |
580 | 580 | $pu_ttc = price2num($pu_ht * (1 + ($tmpvat / 100)), 'MU'); |
@@ -596,21 +596,21 @@ discard block |
||
596 | 596 | $desc = ''; |
597 | 597 | |
598 | 598 | // Define output language |
599 | - if (! empty($conf->global->MAIN_MULTILANGS) && ! empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) |
|
599 | + if (!empty($conf->global->MAIN_MULTILANGS) && !empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) |
|
600 | 600 | { |
601 | 601 | $outputlangs = $langs; |
602 | 602 | $newlang = ''; |
603 | - if (empty($newlang) && GETPOST('lang_id','aZ09')) |
|
604 | - $newlang = GETPOST('lang_id','aZ09'); |
|
603 | + if (empty($newlang) && GETPOST('lang_id', 'aZ09')) |
|
604 | + $newlang = GETPOST('lang_id', 'aZ09'); |
|
605 | 605 | if (empty($newlang)) |
606 | 606 | $newlang = $object->thirdparty->default_lang; |
607 | - if (! empty($newlang)) |
|
607 | + if (!empty($newlang)) |
|
608 | 608 | { |
609 | 609 | $outputlangs = new Translate("", $conf); |
610 | 610 | $outputlangs->setDefaultLang($newlang); |
611 | 611 | } |
612 | 612 | |
613 | - $desc = (! empty($prod->multilangs [$outputlangs->defaultlang] ["description"])) ? $prod->multilangs [$outputlangs->defaultlang] ["description"] : $prod->description; |
|
613 | + $desc = (!empty($prod->multilangs [$outputlangs->defaultlang] ["description"])) ? $prod->multilangs [$outputlangs->defaultlang] ["description"] : $prod->description; |
|
614 | 614 | } |
615 | 615 | else |
616 | 616 | { |
@@ -620,15 +620,15 @@ discard block |
||
620 | 620 | $desc = dol_concatdesc($desc, $product_desc); |
621 | 621 | |
622 | 622 | // Add custom code and origin country into description |
623 | - if (empty($conf->global->MAIN_PRODUCT_DISABLE_CUSTOMCOUNTRYCODE) && (! empty($prod->customcode) || ! empty($prod->country_code))) |
|
623 | + if (empty($conf->global->MAIN_PRODUCT_DISABLE_CUSTOMCOUNTRYCODE) && (!empty($prod->customcode) || !empty($prod->country_code))) |
|
624 | 624 | { |
625 | 625 | $tmptxt = '('; |
626 | - if (! empty($prod->customcode)) |
|
627 | - $tmptxt .= $langs->transnoentitiesnoconv("CustomCode") . ': ' . $prod->customcode; |
|
628 | - if (! empty($prod->customcode) && ! empty($prod->country_code)) |
|
626 | + if (!empty($prod->customcode)) |
|
627 | + $tmptxt .= $langs->transnoentitiesnoconv("CustomCode").': '.$prod->customcode; |
|
628 | + if (!empty($prod->customcode) && !empty($prod->country_code)) |
|
629 | 629 | $tmptxt .= ' - '; |
630 | - if (! empty($prod->country_code)) |
|
631 | - $tmptxt .= $langs->transnoentitiesnoconv("CountryOrigin") . ': ' . getCountry($prod->country_code, 0, $db, $langs, 0); |
|
630 | + if (!empty($prod->country_code)) |
|
631 | + $tmptxt .= $langs->transnoentitiesnoconv("CountryOrigin").': '.getCountry($prod->country_code, 0, $db, $langs, 0); |
|
632 | 632 | $tmptxt .= ')'; |
633 | 633 | $desc = dol_concatdesc($desc, $tmptxt); |
634 | 634 | } |
@@ -642,19 +642,19 @@ discard block |
||
642 | 642 | $pu_ttc = price2num(GETPOST('price_ttc'), 'MU'); |
643 | 643 | $tva_npr = (preg_match('/\*/', $tva_tx) ? 1 : 0); |
644 | 644 | $tva_tx = str_replace('*', '', $tva_tx); |
645 | - if (empty($tva_tx)) $tva_npr=0; |
|
645 | + if (empty($tva_tx)) $tva_npr = 0; |
|
646 | 646 | $label = (GETPOST('product_label') ? GETPOST('product_label') : ''); |
647 | 647 | $desc = $product_desc; |
648 | 648 | $type = GETPOST('type'); |
649 | - $fk_unit= GETPOST('units', 'alpha'); |
|
649 | + $fk_unit = GETPOST('units', 'alpha'); |
|
650 | 650 | } |
651 | 651 | |
652 | - $date_start_fill = GETPOST('date_start_fill','int'); |
|
653 | - $date_end_fill = GETPOST('date_end_fill','int'); |
|
652 | + $date_start_fill = GETPOST('date_start_fill', 'int'); |
|
653 | + $date_end_fill = GETPOST('date_end_fill', 'int'); |
|
654 | 654 | |
655 | 655 | // Margin |
656 | - $fournprice = price2num(GETPOST('fournprice' . $predef) ? GETPOST('fournprice' . $predef) : ''); |
|
657 | - $buyingprice = price2num(GETPOST('buying_price' . $predef) != '' ? GETPOST('buying_price' . $predef) : ''); // If buying_price is '0', we must keep this value |
|
656 | + $fournprice = price2num(GETPOST('fournprice'.$predef) ? GETPOST('fournprice'.$predef) : ''); |
|
657 | + $buyingprice = price2num(GETPOST('buying_price'.$predef) != '' ? GETPOST('buying_price'.$predef) : ''); // If buying_price is '0', we must keep this value |
|
658 | 658 | |
659 | 659 | // Local Taxes |
660 | 660 | $localtax1_tx = get_localtax($tva_tx, 1, $object->thirdparty, $mysoc, $tva_npr); |
@@ -664,7 +664,7 @@ discard block |
||
664 | 664 | if ($tva_npr) |
665 | 665 | $info_bits |= 0x01; |
666 | 666 | |
667 | - if (((!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->produit->ignore_price_min_advance)) || empty($conf->global->MAIN_USE_ADVANCED_PERMS) )&& (! empty($price_min) && (price2num($pu_ht) * (1 - price2num($remise_percent) / 100) < price2num($price_min)))) |
|
667 | + if (((!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->produit->ignore_price_min_advance)) || empty($conf->global->MAIN_USE_ADVANCED_PERMS)) && (!empty($price_min) && (price2num($pu_ht) * (1 - price2num($remise_percent) / 100) < price2num($price_min)))) |
|
668 | 668 | { |
669 | 669 | $mesg = $langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, - 1, $conf->currency)); |
670 | 670 | setEventMessages($mesg, null, 'errors'); |
@@ -672,7 +672,7 @@ discard block |
||
672 | 672 | else |
673 | 673 | { |
674 | 674 | // Insert line |
675 | - $result = $object->addline($desc, $pu_ht, $qty, $tva_tx,$localtax1_tx, $localtax2_tx, $idprod, $remise_percent, $price_base_type, $info_bits, '', $pu_ttc, $type, - 1, $special_code, $label, $fk_unit, 0, $date_start_fill, $date_end_fill); |
|
675 | + $result = $object->addline($desc, $pu_ht, $qty, $tva_tx, $localtax1_tx, $localtax2_tx, $idprod, $remise_percent, $price_base_type, $info_bits, '', $pu_ttc, $type, - 1, $special_code, $label, $fk_unit, 0, $date_start_fill, $date_end_fill); |
|
676 | 676 | |
677 | 677 | if ($result > 0) |
678 | 678 | { |
@@ -693,7 +693,7 @@ discard block |
||
693 | 693 | $result = $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); |
694 | 694 | if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); |
695 | 695 | }*/ |
696 | - $object->fetch($object->id); // Reload lines |
|
696 | + $object->fetch($object->id); // Reload lines |
|
697 | 697 | |
698 | 698 | unset($_POST['prod_entry_mode']); |
699 | 699 | |
@@ -744,9 +744,9 @@ discard block |
||
744 | 744 | } |
745 | 745 | } |
746 | 746 | |
747 | - elseif ($action == 'updateline' && $user->rights->facture->creer && ! GETPOST('cancel','alpha')) |
|
747 | + elseif ($action == 'updateline' && $user->rights->facture->creer && !GETPOST('cancel', 'alpha')) |
|
748 | 748 | { |
749 | - if (! $object->fetch($id) > 0) dol_print_error($db); |
|
749 | + if (!$object->fetch($id) > 0) dol_print_error($db); |
|
750 | 750 | $object->fetch_thirdparty(); |
751 | 751 | |
752 | 752 | // Clean parameters |
@@ -754,7 +754,7 @@ discard block |
||
754 | 754 | $date_end = ''; |
755 | 755 | //$date_start = dol_mktime(GETPOST('date_starthour'), GETPOST('date_startmin'), GETPOST('date_startsec'), GETPOST('date_startmonth'), GETPOST('date_startday'), GETPOST('date_startyear')); |
756 | 756 | //$date_end = dol_mktime(GETPOST('date_endhour'), GETPOST('date_endmin'), GETPOST('date_endsec'), GETPOST('date_endmonth'), GETPOST('date_endday'), GETPOST('date_endyear')); |
757 | - $description = dol_htmlcleanlastbr(GETPOST('product_desc','none') ? GETPOST('product_desc','none') : GETPOST('desc','none')); |
|
757 | + $description = dol_htmlcleanlastbr(GETPOST('product_desc', 'none') ? GETPOST('product_desc', 'none') : GETPOST('desc', 'none')); |
|
758 | 758 | $pu_ht = GETPOST('price_ht'); |
759 | 759 | $vat_rate = (GETPOST('tva_tx') ? GETPOST('tva_tx') : 0); |
760 | 760 | $qty = GETPOST('qty'); |
@@ -771,7 +771,7 @@ discard block |
||
771 | 771 | |
772 | 772 | // Add buying price |
773 | 773 | $fournprice = price2num(GETPOST('fournprice') ? GETPOST('fournprice') : ''); |
774 | - $buyingprice = price2num(GETPOST('buying_price') != '' ? GETPOST('buying_price') : ''); // If buying_price is '0', we muste keep this value |
|
774 | + $buyingprice = price2num(GETPOST('buying_price') != '' ? GETPOST('buying_price') : ''); // If buying_price is '0', we muste keep this value |
|
775 | 775 | |
776 | 776 | // Extrafields |
777 | 777 | $extrafieldsline = new ExtraFields($db); |
@@ -781,8 +781,8 @@ discard block |
||
781 | 781 | $objectline = new FactureLigneRec($db); |
782 | 782 | if ($objectline->fetch(GETPOST('lineid'))) |
783 | 783 | { |
784 | - $objectline->array_options=$array_options; |
|
785 | - $result=$objectline->insertExtraFields(); |
|
784 | + $objectline->array_options = $array_options; |
|
785 | + $result = $objectline->insertExtraFields(); |
|
786 | 786 | if ($result < 0) |
787 | 787 | { |
788 | 788 | setEventMessages($langs->trans('Error').$result, null, 'errors'); |
@@ -795,13 +795,13 @@ discard block |
||
795 | 795 | // Get extra fields |
796 | 796 | foreach ($extralabelsline as $key => $value) |
797 | 797 | { |
798 | - unset($_POST["options_" . $key]); |
|
798 | + unset($_POST["options_".$key]); |
|
799 | 799 | } |
800 | 800 | } |
801 | 801 | |
802 | 802 | // Define special_code for special lines |
803 | - $special_code=GETPOST('special_code'); |
|
804 | - if (! GETPOST('qty')) $special_code=3; |
|
803 | + $special_code = GETPOST('special_code'); |
|
804 | + if (!GETPOST('qty')) $special_code = 3; |
|
805 | 805 | |
806 | 806 | /*$line = new FactureLigne($db); |
807 | 807 | $line->fetch(GETPOST('lineid')); |
@@ -817,7 +817,7 @@ discard block |
||
817 | 817 | |
818 | 818 | // Check minimum price |
819 | 819 | $productid = GETPOST('productid', 'int'); |
820 | - if (! empty($productid)) |
|
820 | + if (!empty($productid)) |
|
821 | 821 | { |
822 | 822 | $product = new Product($db); |
823 | 823 | $product->fetch($productid); |
@@ -825,16 +825,16 @@ discard block |
||
825 | 825 | $type = $product->type; |
826 | 826 | |
827 | 827 | $price_min = $product->price_min; |
828 | - if (! empty($conf->global->PRODUIT_MULTIPRICES) && ! empty($object->thirdparty->price_level)) |
|
828 | + if (!empty($conf->global->PRODUIT_MULTIPRICES) && !empty($object->thirdparty->price_level)) |
|
829 | 829 | $price_min = $product->multiprices_min[$object->thirdparty->price_level]; |
830 | 830 | |
831 | 831 | $label = ((GETPOST('update_label') && GETPOST('product_label')) ? GETPOST('product_label') : ''); |
832 | 832 | |
833 | 833 | // Check price is not lower than minimum (check is done only for standard or replacement invoices) |
834 | - if (((!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->produit->ignore_price_min_advance)) || empty($conf->global->MAIN_USE_ADVANCED_PERMS) )&& (($object->type == Facture::TYPE_STANDARD || $object->type == Facture::TYPE_REPLACEMENT) && $price_min && (price2num($pu_ht) * (1 - price2num(GETPOST('remise_percent')) / 100) < price2num($price_min)))) |
|
834 | + if (((!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->produit->ignore_price_min_advance)) || empty($conf->global->MAIN_USE_ADVANCED_PERMS)) && (($object->type == Facture::TYPE_STANDARD || $object->type == Facture::TYPE_REPLACEMENT) && $price_min && (price2num($pu_ht) * (1 - price2num(GETPOST('remise_percent')) / 100) < price2num($price_min)))) |
|
835 | 835 | { |
836 | 836 | setEventMessages($langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, - 1, $conf->currency)), null, 'errors'); |
837 | - $error ++; |
|
837 | + $error++; |
|
838 | 838 | } |
839 | 839 | } else { |
840 | 840 | $type = GETPOST('type'); |
@@ -843,20 +843,20 @@ discard block |
||
843 | 843 | // Check parameters |
844 | 844 | if (GETPOST('type') < 0) { |
845 | 845 | setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")), null, 'errors'); |
846 | - $error ++; |
|
846 | + $error++; |
|
847 | 847 | } |
848 | 848 | } |
849 | 849 | if ($qty < 0) { |
850 | 850 | $langs->load("errors"); |
851 | 851 | setEventMessages($langs->trans('ErrorQtyForCustomerInvoiceCantBeNegative'), null, 'errors'); |
852 | - $error ++; |
|
852 | + $error++; |
|
853 | 853 | } |
854 | 854 | |
855 | - $date_start_fill = GETPOST('date_start_fill','int'); |
|
856 | - $date_end_fill = GETPOST('date_end_fill','int'); |
|
855 | + $date_start_fill = GETPOST('date_start_fill', 'int'); |
|
856 | + $date_end_fill = GETPOST('date_end_fill', 'int'); |
|
857 | 857 | |
858 | 858 | // Update line |
859 | - if (! $error) |
|
859 | + if (!$error) |
|
860 | 860 | { |
861 | 861 | $result = $object->updateline( |
862 | 862 | GETPOST('lineid'), |
@@ -902,7 +902,7 @@ discard block |
||
902 | 902 | $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); |
903 | 903 | }*/ |
904 | 904 | |
905 | - $object->fetch($object->id); // Reload lines |
|
905 | + $object->fetch($object->id); // Reload lines |
|
906 | 906 | |
907 | 907 | unset($_POST['qty']); |
908 | 908 | unset($_POST['type']); |
@@ -953,17 +953,17 @@ discard block |
||
953 | 953 | * View |
954 | 954 | */ |
955 | 955 | |
956 | -llxHeader('',$langs->trans("RepeatableInvoices"),'ch-facture.html#s-fac-facture-rec'); |
|
956 | +llxHeader('', $langs->trans("RepeatableInvoices"), 'ch-facture.html#s-fac-facture-rec'); |
|
957 | 957 | |
958 | 958 | $form = new Form($db); |
959 | 959 | $formother = new FormOther($db); |
960 | -if (! empty($conf->projet->enabled)) { $formproject = new FormProjets($db); } |
|
960 | +if (!empty($conf->projet->enabled)) { $formproject = new FormProjets($db); } |
|
961 | 961 | $companystatic = new Societe($db); |
962 | 962 | $invoicerectmp = new FactureRec($db); |
963 | 963 | |
964 | 964 | $now = dol_now(); |
965 | -$tmparray=dol_getdate($now); |
|
966 | -$today = dol_mktime(23,59,59,$tmparray['mon'],$tmparray['mday'],$tmparray['year']); // Today is last second of current day |
|
965 | +$tmparray = dol_getdate($now); |
|
966 | +$today = dol_mktime(23, 59, 59, $tmparray['mon'], $tmparray['mday'], $tmparray['year']); // Today is last second of current day |
|
967 | 967 | |
968 | 968 | |
969 | 969 | /* |
@@ -971,9 +971,9 @@ discard block |
||
971 | 971 | */ |
972 | 972 | if ($action == 'create') |
973 | 973 | { |
974 | - print load_fiche_titre($langs->trans("CreateRepeatableInvoice"),'','title_accountancy.png'); |
|
974 | + print load_fiche_titre($langs->trans("CreateRepeatableInvoice"), '', 'title_accountancy.png'); |
|
975 | 975 | |
976 | - $object = new Facture($db); // Source invoice |
|
976 | + $object = new Facture($db); // Source invoice |
|
977 | 977 | $product_static = new Product($db); |
978 | 978 | |
979 | 979 | if ($object->fetch($id, $ref) > 0) |
@@ -987,8 +987,8 @@ discard block |
||
987 | 987 | |
988 | 988 | dol_fiche_head(null, '', '', 0); |
989 | 989 | |
990 | - $rowspan=4; |
|
991 | - if (! empty($conf->projet->enabled)) $rowspan++; |
|
990 | + $rowspan = 4; |
|
991 | + if (!empty($conf->projet->enabled)) $rowspan++; |
|
992 | 992 | if ($object->fk_account > 0) $rowspan++; |
993 | 993 | |
994 | 994 | print '<table class="border" width="100%">'; |
@@ -1001,34 +1001,34 @@ discard block |
||
1001 | 1001 | print '</td></tr>'; |
1002 | 1002 | |
1003 | 1003 | // Third party |
1004 | - print '<tr><td class="titlefieldcreate">'.$langs->trans("Customer").'</td><td>'.$object->thirdparty->getNomUrl(1,'customer').'</td>'; |
|
1004 | + print '<tr><td class="titlefieldcreate">'.$langs->trans("Customer").'</td><td>'.$object->thirdparty->getNomUrl(1, 'customer').'</td>'; |
|
1005 | 1005 | print '</tr>'; |
1006 | 1006 | |
1007 | - $note_public=GETPOST('note_public','none')?GETPOST('note_public','none'):$object->note_public; |
|
1008 | - $note_private=GETPOST('note_private','none')?GETPOST('note_private','none'):$object->note_private; |
|
1007 | + $note_public = GETPOST('note_public', 'none') ?GETPOST('note_public', 'none') : $object->note_public; |
|
1008 | + $note_private = GETPOST('note_private', 'none') ?GETPOST('note_private', 'none') : $object->note_private; |
|
1009 | 1009 | |
1010 | 1010 | // Help of substitution key |
1011 | 1011 | $substitutionarray = getCommonSubstitutionArray($langs, 2, null, $object); |
1012 | 1012 | |
1013 | - $substitutionarray['__INVOICE_PREVIOUS_MONTH__'] = $langs->trans("PreviousMonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($object->date, -1, 'm'),'%m').')'; |
|
1014 | - $substitutionarray['__INVOICE_MONTH__'] = $langs->trans("MonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date($object->date,'%m').')'; |
|
1015 | - $substitutionarray['__INVOICE_NEXT_MONTH__'] = $langs->trans("NextMonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($object->date, 1, 'm'),'%m').')'; |
|
1016 | - $substitutionarray['__INVOICE_PREVIOUS_MONTH_TEXT__'] = $langs->trans("TextPreviousMonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($object->date, -1, 'm'),'%B').')'; |
|
1017 | - $substitutionarray['__INVOICE_MONTH_TEXT__'] = $langs->trans("TextMonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date($object->date,'%B').')'; |
|
1013 | + $substitutionarray['__INVOICE_PREVIOUS_MONTH__'] = $langs->trans("PreviousMonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($object->date, -1, 'm'), '%m').')'; |
|
1014 | + $substitutionarray['__INVOICE_MONTH__'] = $langs->trans("MonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date($object->date, '%m').')'; |
|
1015 | + $substitutionarray['__INVOICE_NEXT_MONTH__'] = $langs->trans("NextMonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($object->date, 1, 'm'), '%m').')'; |
|
1016 | + $substitutionarray['__INVOICE_PREVIOUS_MONTH_TEXT__'] = $langs->trans("TextPreviousMonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($object->date, -1, 'm'), '%B').')'; |
|
1017 | + $substitutionarray['__INVOICE_MONTH_TEXT__'] = $langs->trans("TextMonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date($object->date, '%B').')'; |
|
1018 | 1018 | $substitutionarray['__INVOICE_NEXT_MONTH_TEXT__'] = $langs->trans("TextNextMonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($object->date, 1, 'm'), '%B').')'; |
1019 | - $substitutionarray['__INVOICE_PREVIOUS_YEAR__'] = $langs->trans("YearOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($object->date, -1, 'y'),'%Y').')'; |
|
1020 | - $substitutionarray['__INVOICE_YEAR__'] = $langs->trans("PreviousYearOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date($object->date,'%Y').')'; |
|
1021 | - $substitutionarray['__INVOICE_NEXT_YEAR__'] = $langs->trans("NextYearOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($object->date, 1, 'y'),'%Y').')'; |
|
1019 | + $substitutionarray['__INVOICE_PREVIOUS_YEAR__'] = $langs->trans("YearOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($object->date, -1, 'y'), '%Y').')'; |
|
1020 | + $substitutionarray['__INVOICE_YEAR__'] = $langs->trans("PreviousYearOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date($object->date, '%Y').')'; |
|
1021 | + $substitutionarray['__INVOICE_NEXT_YEAR__'] = $langs->trans("NextYearOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($object->date, 1, 'y'), '%Y').')'; |
|
1022 | 1022 | // Only on template invoices |
1023 | 1023 | $substitutionarray['__INVOICE_DATE_NEXT_INVOICE_BEFORE_GEN__'] = $langs->trans("DateNextInvoiceBeforeGen").' ('.$langs->trans("Example").': '.dol_print_date($object->date_when, 'dayhour').')'; |
1024 | - $substitutionarray['__INVOICE_DATE_NEXT_INVOICE_AFTER_GEN__'] = $langs->trans("DateNextInvoiceAfterGen").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($object->date_when, $object->frequency, $object->unit_frequency),'dayhour').')'; |
|
1024 | + $substitutionarray['__INVOICE_DATE_NEXT_INVOICE_AFTER_GEN__'] = $langs->trans("DateNextInvoiceAfterGen").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($object->date_when, $object->frequency, $object->unit_frequency), 'dayhour').')'; |
|
1025 | 1025 | |
1026 | 1026 | $htmltext = '<i>'.$langs->trans("FollowingConstantsWillBeSubstituted").':<br>'; |
1027 | - foreach($substitutionarray as $key => $val) |
|
1027 | + foreach ($substitutionarray as $key => $val) |
|
1028 | 1028 | { |
1029 | - $htmltext.=$key.' = '.$langs->trans($val).'<br>'; |
|
1029 | + $htmltext .= $key.' = '.$langs->trans($val).'<br>'; |
|
1030 | 1030 | } |
1031 | - $htmltext.='</i>'; |
|
1031 | + $htmltext .= '</i>'; |
|
1032 | 1032 | |
1033 | 1033 | // Public note |
1034 | 1034 | print '<tr>'; |
@@ -1067,13 +1067,13 @@ discard block |
||
1067 | 1067 | print "</td></tr>"; |
1068 | 1068 | |
1069 | 1069 | // Project |
1070 | - if (! empty($conf->projet->enabled) && is_object($object->thirdparty) && $object->thirdparty->id > 0) |
|
1070 | + if (!empty($conf->projet->enabled) && is_object($object->thirdparty) && $object->thirdparty->id > 0) |
|
1071 | 1071 | { |
1072 | - $projectid = GETPOST('projectid')?GETPOST('projectid'):$object->fk_project; |
|
1072 | + $projectid = GETPOST('projectid') ?GETPOST('projectid') : $object->fk_project; |
|
1073 | 1073 | $langs->load('projects'); |
1074 | - print '<tr><td>' . $langs->trans('Project') . '</td><td>'; |
|
1074 | + print '<tr><td>'.$langs->trans('Project').'</td><td>'; |
|
1075 | 1075 | $numprojet = $formproject->select_projects($object->thirdparty->id, $projectid, 'projectid', 0, 0, 1, 0, 0, 0, 0, '', 0, 0, ''); |
1076 | - print ' <a href="' . BASE_URI . '?controller=projet&method=card&socid=' . $object->thirdparty->id . '&action=create&status=1&backtopage=' . urlencode($_SERVER["PHP_SELF"] . '?action=create&socid=' . $object->thirdparty->id . (!empty($id) ? '&id=' . $id : '')) . '">' . $langs->trans("AddProject") . '</a>'; |
|
1076 | + print ' <a href="'.BASE_URI.'?controller=projet&method=card&socid='.$object->thirdparty->id.'&action=create&status=1&backtopage='.urlencode($_SERVER["PHP_SELF"].'?action=create&socid='.$object->thirdparty->id.(!empty($id) ? '&id='.$id : '')).'">'.$langs->trans("AddProject").'</a>'; |
|
1077 | 1077 | print '</td></tr>'; |
1078 | 1078 | } |
1079 | 1079 | |
@@ -1087,7 +1087,7 @@ discard block |
||
1087 | 1087 | |
1088 | 1088 | // Model pdf |
1089 | 1089 | print "<tr><td>".$langs->trans('Model')."</td><td>"; |
1090 | - include_once DOL_DOCUMENT_ROOT . '/core/modules/facture/modules_facture.php'; |
|
1090 | + include_once DOL_DOCUMENT_ROOT.'/core/modules/facture/modules_facture.php'; |
|
1091 | 1091 | $list = ModelePDFFactures::liste_modeles($db); |
1092 | 1092 | print $form->selectarray('modelpdf', $list, $conf->global->FACTURE_ADDON_PDF); |
1093 | 1093 | print "</td></tr>"; |
@@ -1107,7 +1107,7 @@ discard block |
||
1107 | 1107 | |
1108 | 1108 | // Frequency + unit |
1109 | 1109 | print '<tr><td class="titlefieldcreate">'.$form->textwithpicto($langs->trans("Frequency"), $langs->transnoentitiesnoconv('toolTipFrequency'))."</td><td>"; |
1110 | - print "<input type='text' name='frequency' value='".GETPOST('frequency', 'int')."' size='4' /> ".$form->selectarray('unit_frequency', array('d'=>$langs->trans('Day'), 'm'=>$langs->trans('Month'), 'y'=>$langs->trans('Year')), (GETPOST('unit_frequency')?GETPOST('unit_frequency'):'m')); |
|
1110 | + print "<input type='text' name='frequency' value='".GETPOST('frequency', 'int')."' size='4' /> ".$form->selectarray('unit_frequency', array('d'=>$langs->trans('Day'), 'm'=>$langs->trans('Month'), 'y'=>$langs->trans('Year')), (GETPOST('unit_frequency') ?GETPOST('unit_frequency') : 'm')); |
|
1111 | 1111 | print "</td></tr>"; |
1112 | 1112 | |
1113 | 1113 | // Date next run |
@@ -1123,15 +1123,15 @@ discard block |
||
1123 | 1123 | |
1124 | 1124 | // Auto validate the invoice |
1125 | 1125 | print "<tr><td>".$langs->trans("StatusOfGeneratedInvoices")."</td><td>"; |
1126 | - $select = array('0'=>$langs->trans('BillStatusDraft'),'1'=>$langs->trans('BillStatusValidated')); |
|
1126 | + $select = array('0'=>$langs->trans('BillStatusDraft'), '1'=>$langs->trans('BillStatusValidated')); |
|
1127 | 1127 | print $form->selectarray('auto_validate', $select, GETPOST('auto_validate')); |
1128 | 1128 | print "</td></tr>"; |
1129 | 1129 | |
1130 | 1130 | // Auto generate document |
1131 | - if (! empty($conf->global->INVOICE_REC_CAN_DISABLE_DOCUMENT_FILE_GENERATION)) |
|
1131 | + if (!empty($conf->global->INVOICE_REC_CAN_DISABLE_DOCUMENT_FILE_GENERATION)) |
|
1132 | 1132 | { |
1133 | 1133 | print "<tr><td>".$langs->trans("StatusOfGeneratedDocuments")."</td><td>"; |
1134 | - $select = array('0'=>$langs->trans('DoNotGenerateDoc'),'1'=>$langs->trans('AutoGenerateDoc')); |
|
1134 | + $select = array('0'=>$langs->trans('DoNotGenerateDoc'), '1'=>$langs->trans('AutoGenerateDoc')); |
|
1135 | 1135 | print $form->selectarray('generate_pdf', $select, GETPOST('generate_pdf')); |
1136 | 1136 | print "</td></tr>"; |
1137 | 1137 | } |
@@ -1159,12 +1159,12 @@ discard block |
||
1159 | 1159 | print '<div class="div-table-responsive-no-min">'; |
1160 | 1160 | print '<table id="tablelines" class="noborder noshadow" width="100%">'; |
1161 | 1161 | // Show object lines |
1162 | - if (! empty($object->lines)) |
|
1162 | + if (!empty($object->lines)) |
|
1163 | 1163 | { |
1164 | - $disableedit=1; |
|
1165 | - $disablemove=1; |
|
1166 | - $disableremove=1; |
|
1167 | - $object->printObjectLines('', $mysoc, $object->thirdparty, $lineid, 0); // No date selector for template invoice |
|
1164 | + $disableedit = 1; |
|
1165 | + $disablemove = 1; |
|
1166 | + $disableremove = 1; |
|
1167 | + $object->printObjectLines('', $mysoc, $object->thirdparty, $lineid, 0); // No date selector for template invoice |
|
1168 | 1168 | } |
1169 | 1169 | |
1170 | 1170 | print "</table>\n"; |
@@ -1185,13 +1185,13 @@ discard block |
||
1185 | 1185 | |
1186 | 1186 | print '<div align="center"><input type="submit" class="button" value="'.$langs->trans("Create").'">'; |
1187 | 1187 | print ' '; |
1188 | - print '<input type="button" class="button" value="' . $langs->trans("Cancel") . '" onClick="javascript:history.go(-1)">'; |
|
1188 | + print '<input type="button" class="button" value="'.$langs->trans("Cancel").'" onClick="javascript:history.go(-1)">'; |
|
1189 | 1189 | print '</div>'; |
1190 | 1190 | print "</form>\n"; |
1191 | 1191 | } |
1192 | 1192 | else |
1193 | 1193 | { |
1194 | - dol_print_error('',"Error, no invoice ".$object->id); |
|
1194 | + dol_print_error('', "Error, no invoice ".$object->id); |
|
1195 | 1195 | } |
1196 | 1196 | } |
1197 | 1197 | else |
@@ -1205,12 +1205,12 @@ discard block |
||
1205 | 1205 | |
1206 | 1206 | // Confirmation de la suppression d'une ligne produit |
1207 | 1207 | if ($action == 'ask_deleteline') { |
1208 | - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id . '&lineid=' . $lineid, $langs->trans('DeleteProductLine'), $langs->trans('ConfirmDeleteProductLine'), 'confirm_deleteline', '', 'no', 1); |
|
1208 | + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&lineid='.$lineid, $langs->trans('DeleteProductLine'), $langs->trans('ConfirmDeleteProductLine'), 'confirm_deleteline', '', 'no', 1); |
|
1209 | 1209 | } |
1210 | 1210 | |
1211 | 1211 | // Confirm delete of repeatable invoice |
1212 | 1212 | if ($action == 'ask_deleteinvoice') { |
1213 | - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('DeleteRepeatableInvoice'), $langs->trans('ConfirmDeleteRepeatableInvoice'), 'confirm_deleteinvoice', '', 'no', 1); |
|
1213 | + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DeleteRepeatableInvoice'), $langs->trans('ConfirmDeleteRepeatableInvoice'), 'confirm_deleteinvoice', '', 'no', 1); |
|
1214 | 1214 | } |
1215 | 1215 | |
1216 | 1216 | print $formconfirm; |
@@ -1218,57 +1218,57 @@ discard block |
||
1218 | 1218 | $author = new User($db); |
1219 | 1219 | $author->fetch($object->user_author); |
1220 | 1220 | |
1221 | - $head=invoice_rec_prepare_head($object); |
|
1221 | + $head = invoice_rec_prepare_head($object); |
|
1222 | 1222 | |
1223 | - dol_fiche_head($head, 'card', $langs->trans("RepeatableInvoice"), -1, 'bill'); // Add a div |
|
1223 | + dol_fiche_head($head, 'card', $langs->trans("RepeatableInvoice"), -1, 'bill'); // Add a div |
|
1224 | 1224 | |
1225 | 1225 | // Recurring invoice content |
1226 | 1226 | |
1227 | - $linkback = '<a href="' . BASE_URI . '?controller=compta/facture&method=invoicetemplate_list&restore_lastsearch_values=1' . (!empty($socid) ? '&socid=' . $socid : '') . '">' . $langs->trans("BackToList") . '</a>'; |
|
1227 | + $linkback = '<a href="'.BASE_URI.'?controller=compta/facture&method=invoicetemplate_list&restore_lastsearch_values=1'.(!empty($socid) ? '&socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>'; |
|
1228 | 1228 | |
1229 | - $morehtmlref=''; |
|
1230 | - if ($action != 'editref') $morehtmlref.=$form->editfieldkey($object->ref, 'ref', $object->ref, $object, $user->rights->facture->creer, '', '', 0, 2); |
|
1231 | - else $morehtmlref.= $form->editfieldval('', 'ref', $object->ref, $object, $user->rights->facture->creer, 'string'); |
|
1229 | + $morehtmlref = ''; |
|
1230 | + if ($action != 'editref') $morehtmlref .= $form->editfieldkey($object->ref, 'ref', $object->ref, $object, $user->rights->facture->creer, '', '', 0, 2); |
|
1231 | + else $morehtmlref .= $form->editfieldval('', 'ref', $object->ref, $object, $user->rights->facture->creer, 'string'); |
|
1232 | 1232 | |
1233 | - $morehtmlref.='<div class="refidno">'; |
|
1233 | + $morehtmlref .= '<div class="refidno">'; |
|
1234 | 1234 | // Ref customer |
1235 | 1235 | //$morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, $user->rights->facture->creer, 'string', '', 0, 1); |
1236 | 1236 | //$morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, $user->rights->facture->creer, 'string', '', null, null, '', 1); |
1237 | 1237 | // Thirdparty |
1238 | - $morehtmlref.=$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1); |
|
1238 | + $morehtmlref .= $langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1); |
|
1239 | 1239 | // Project |
1240 | - if (! empty($conf->projet->enabled)) |
|
1240 | + if (!empty($conf->projet->enabled)) |
|
1241 | 1241 | { |
1242 | 1242 | $langs->load("projects"); |
1243 | - $morehtmlref.='<br>'.$langs->trans('Project') . ' '; |
|
1243 | + $morehtmlref .= '<br>'.$langs->trans('Project').' '; |
|
1244 | 1244 | if ($user->rights->facture->creer) |
1245 | 1245 | { |
1246 | 1246 | if ($action != 'classify') |
1247 | - $morehtmlref.='<a href="' . $_SERVER['PHP_SELF'] . '?action=classify&id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : '; |
|
1247 | + $morehtmlref .= '<a href="'.$_SERVER['PHP_SELF'].'?action=classify&id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetProject')).'</a> : '; |
|
1248 | 1248 | if ($action == 'classify') { |
1249 | 1249 | //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); |
1250 | - $morehtmlref.='<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">'; |
|
1251 | - $morehtmlref.='<input type="hidden" name="action" value="classin">'; |
|
1252 | - $morehtmlref.='<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
1253 | - $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); |
|
1254 | - $morehtmlref.='<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">'; |
|
1255 | - $morehtmlref.='</form>'; |
|
1250 | + $morehtmlref .= '<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">'; |
|
1251 | + $morehtmlref .= '<input type="hidden" name="action" value="classin">'; |
|
1252 | + $morehtmlref .= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
1253 | + $morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); |
|
1254 | + $morehtmlref .= '<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">'; |
|
1255 | + $morehtmlref .= '</form>'; |
|
1256 | 1256 | } else { |
1257 | - $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); |
|
1257 | + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); |
|
1258 | 1258 | } |
1259 | 1259 | } else { |
1260 | - if (! empty($object->fk_project)) { |
|
1260 | + if (!empty($object->fk_project)) { |
|
1261 | 1261 | $proj = new Project($db); |
1262 | 1262 | $proj->fetch($object->fk_project); |
1263 | - $morehtmlref .= '<a href="' . BASE_URI . '&controller=projet&method=card&id=' . $object->fk_project . '" title="' . $langs->trans('ShowProject') . '">'; |
|
1264 | - $morehtmlref.=$proj->ref; |
|
1265 | - $morehtmlref.='</a>'; |
|
1263 | + $morehtmlref .= '<a href="'.BASE_URI.'&controller=projet&method=card&id='.$object->fk_project.'" title="'.$langs->trans('ShowProject').'">'; |
|
1264 | + $morehtmlref .= $proj->ref; |
|
1265 | + $morehtmlref .= '</a>'; |
|
1266 | 1266 | } else { |
1267 | - $morehtmlref.=''; |
|
1267 | + $morehtmlref .= ''; |
|
1268 | 1268 | } |
1269 | 1269 | } |
1270 | 1270 | } |
1271 | - $morehtmlref.='</div>'; |
|
1271 | + $morehtmlref .= '</div>'; |
|
1272 | 1272 | |
1273 | 1273 | dol_banner_tab($object, 'ref', $linkback, 1, 'titre', 'none', $morehtmlref, '', 0, '', $morehtmlright); |
1274 | 1274 | |
@@ -1281,25 +1281,25 @@ discard block |
||
1281 | 1281 | print '<tr><td class="titlefield">'.$langs->trans("Author").'</td><td>'.$author->getFullName($langs)."</td></tr>"; |
1282 | 1282 | |
1283 | 1283 | print '<tr><td>'.$langs->trans("AmountHT").'</td>'; |
1284 | - print '<td>'.price($object->total_ht,'',$langs,1,-1,-1,$conf->currency).'</td>'; |
|
1284 | + print '<td>'.price($object->total_ht, '', $langs, 1, -1, -1, $conf->currency).'</td>'; |
|
1285 | 1285 | print '</tr>'; |
1286 | 1286 | |
1287 | - print '<tr><td>'.$langs->trans("AmountVAT").'</td><td>'.price($object->total_tva,'',$langs,1,-1,-1,$conf->currency).'</td>'; |
|
1287 | + print '<tr><td>'.$langs->trans("AmountVAT").'</td><td>'.price($object->total_tva, '', $langs, 1, -1, -1, $conf->currency).'</td>'; |
|
1288 | 1288 | print '</tr>'; |
1289 | 1289 | |
1290 | 1290 | // Amount Local Taxes |
1291 | 1291 | if (($mysoc->localtax1_assuj == "1" && $mysoc->useLocalTax(1)) || $object->total_localtax1 != 0) // Localtax1 |
1292 | 1292 | { |
1293 | - print '<tr><td>' . $langs->transcountry("AmountLT1", $mysoc->country_code) . '</td>'; |
|
1294 | - print '<td class="nowrap">' . price($object->total_localtax1, 1, '', 1, - 1, - 1, $conf->currency) . '</td></tr>'; |
|
1293 | + print '<tr><td>'.$langs->transcountry("AmountLT1", $mysoc->country_code).'</td>'; |
|
1294 | + print '<td class="nowrap">'.price($object->total_localtax1, 1, '', 1, - 1, - 1, $conf->currency).'</td></tr>'; |
|
1295 | 1295 | } |
1296 | 1296 | if (($mysoc->localtax2_assuj == "1" && $mysoc->useLocalTax(2)) || $object->total_localtax2 != 0) // Localtax2 |
1297 | 1297 | { |
1298 | - print '<tr><td>' . $langs->transcountry("AmountLT2", $mysoc->country_code) . '</td>'; |
|
1299 | - print '<td class=nowrap">' . price($object->total_localtax2, 1, '', 1, - 1, - 1, $conf->currency) . '</td></tr>'; |
|
1298 | + print '<tr><td>'.$langs->transcountry("AmountLT2", $mysoc->country_code).'</td>'; |
|
1299 | + print '<td class=nowrap">'.price($object->total_localtax2, 1, '', 1, - 1, - 1, $conf->currency).'</td></tr>'; |
|
1300 | 1300 | } |
1301 | 1301 | |
1302 | - print '<tr><td>'.$langs->trans("AmountTTC").'</td><td colspan="3">'.price($object->total_ttc,'',$langs,1,-1,-1,$conf->currency).'</td>'; |
|
1302 | + print '<tr><td>'.$langs->trans("AmountTTC").'</td><td colspan="3">'.price($object->total_ttc, '', $langs, 1, -1, -1, $conf->currency).'</td>'; |
|
1303 | 1303 | print '</tr>'; |
1304 | 1304 | |
1305 | 1305 | |
@@ -1308,19 +1308,19 @@ discard block |
||
1308 | 1308 | print '<table class="nobordernopadding" width="100%"><tr><td>'; |
1309 | 1309 | print $langs->trans('PaymentConditionsShort'); |
1310 | 1310 | print '</td>'; |
1311 | - if ($object->type != Facture::TYPE_CREDIT_NOTE && $action != 'editconditions' && ! empty($object->brouillon) && $user->rights->facture->creer) |
|
1312 | - print '<td align="right"><a href="' . $_SERVER["PHP_SELF"] . '?action=editconditions&facid=' . $object->id . '">' . img_edit($langs->trans('SetConditions'), 1) . '</a></td>'; |
|
1311 | + if ($object->type != Facture::TYPE_CREDIT_NOTE && $action != 'editconditions' && !empty($object->brouillon) && $user->rights->facture->creer) |
|
1312 | + print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editconditions&facid='.$object->id.'">'.img_edit($langs->trans('SetConditions'), 1).'</a></td>'; |
|
1313 | 1313 | print '</tr></table>'; |
1314 | 1314 | print '</td><td>'; |
1315 | 1315 | if ($object->type != Facture::TYPE_CREDIT_NOTE) |
1316 | 1316 | { |
1317 | 1317 | if ($action == 'editconditions') |
1318 | 1318 | { |
1319 | - $form->form_conditions_reglement($_SERVER['PHP_SELF'] . '?facid=' . $object->id, $object->cond_reglement_id, 'cond_reglement_id'); |
|
1319 | + $form->form_conditions_reglement($_SERVER['PHP_SELF'].'?facid='.$object->id, $object->cond_reglement_id, 'cond_reglement_id'); |
|
1320 | 1320 | } |
1321 | 1321 | else |
1322 | 1322 | { |
1323 | - $form->form_conditions_reglement($_SERVER['PHP_SELF'] . '?facid=' . $object->id, $object->cond_reglement_id, 'none'); |
|
1323 | + $form->form_conditions_reglement($_SERVER['PHP_SELF'].'?facid='.$object->id, $object->cond_reglement_id, 'none'); |
|
1324 | 1324 | } |
1325 | 1325 | } else { |
1326 | 1326 | print ' '; |
@@ -1332,8 +1332,8 @@ discard block |
||
1332 | 1332 | print '<table class="nobordernopadding" width="100%"><tr><td>'; |
1333 | 1333 | print $langs->trans('PaymentMode'); |
1334 | 1334 | print '</td>'; |
1335 | - if ($action != 'editmode' && ! empty($object->brouillon) && $user->rights->facture->creer) |
|
1336 | - print '<td align="right"><a href="' . $_SERVER["PHP_SELF"] . '?action=editmode&facid=' . $object->id . '">' . img_edit($langs->trans('SetMode'), 1) . '</a></td>'; |
|
1335 | + if ($action != 'editmode' && !empty($object->brouillon) && $user->rights->facture->creer) |
|
1336 | + print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editmode&facid='.$object->id.'">'.img_edit($langs->trans('SetMode'), 1).'</a></td>'; |
|
1337 | 1337 | print '</tr></table>'; |
1338 | 1338 | print '</td><td>'; |
1339 | 1339 | if ($action == 'editmode') |
@@ -1347,30 +1347,30 @@ discard block |
||
1347 | 1347 | print '</td></tr>'; |
1348 | 1348 | |
1349 | 1349 | // Help of substitution key |
1350 | - $dateexample=dol_now(); |
|
1351 | - if (! empty($object->frequency) && ! empty($object->date_when)) $dateexample=$object->date_when; |
|
1350 | + $dateexample = dol_now(); |
|
1351 | + if (!empty($object->frequency) && !empty($object->date_when)) $dateexample = $object->date_when; |
|
1352 | 1352 | |
1353 | 1353 | $substitutionarray = getCommonSubstitutionArray($langs, 2, null, $object); |
1354 | 1354 | |
1355 | - $substitutionarray['__INVOICE_PREVIOUS_MONTH__'] = $langs->trans("PreviousMonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($dateexample, -1, 'm'),'%m').')'; |
|
1356 | - $substitutionarray['__INVOICE_MONTH__'] = $langs->trans("MonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date($dateexample,'%m').')'; |
|
1357 | - $substitutionarray['__INVOICE_NEXT_MONTH__'] = $langs->trans("NextMonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($dateexample, 1, 'm'),'%m').')'; |
|
1358 | - $substitutionarray['__INVOICE_PREVIOUS_MONTH_TEXT__'] = $langs->trans("TextPreviousMonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($dateexample, -1, 'm'),'%B').')'; |
|
1359 | - $substitutionarray['__INVOICE_MONTH_TEXT__'] = $langs->trans("TextMonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date($dateexample,'%B').')'; |
|
1355 | + $substitutionarray['__INVOICE_PREVIOUS_MONTH__'] = $langs->trans("PreviousMonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($dateexample, -1, 'm'), '%m').')'; |
|
1356 | + $substitutionarray['__INVOICE_MONTH__'] = $langs->trans("MonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date($dateexample, '%m').')'; |
|
1357 | + $substitutionarray['__INVOICE_NEXT_MONTH__'] = $langs->trans("NextMonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($dateexample, 1, 'm'), '%m').')'; |
|
1358 | + $substitutionarray['__INVOICE_PREVIOUS_MONTH_TEXT__'] = $langs->trans("TextPreviousMonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($dateexample, -1, 'm'), '%B').')'; |
|
1359 | + $substitutionarray['__INVOICE_MONTH_TEXT__'] = $langs->trans("TextMonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date($dateexample, '%B').')'; |
|
1360 | 1360 | $substitutionarray['__INVOICE_NEXT_MONTH_TEXT__'] = $langs->trans("TextNextMonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($dateexample, 1, 'm'), '%B').')'; |
1361 | - $substitutionarray['__INVOICE_PREVIOUS_YEAR__'] = $langs->trans("YearOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($dateexample, -1, 'y'),'%Y').')'; |
|
1362 | - $substitutionarray['__INVOICE_YEAR__'] = $langs->trans("PreviousYearOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date($dateexample,'%Y').')'; |
|
1363 | - $substitutionarray['__INVOICE_NEXT_YEAR__'] = $langs->trans("NextYearOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($dateexample, 1, 'y'),'%Y').')'; |
|
1361 | + $substitutionarray['__INVOICE_PREVIOUS_YEAR__'] = $langs->trans("YearOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($dateexample, -1, 'y'), '%Y').')'; |
|
1362 | + $substitutionarray['__INVOICE_YEAR__'] = $langs->trans("PreviousYearOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date($dateexample, '%Y').')'; |
|
1363 | + $substitutionarray['__INVOICE_NEXT_YEAR__'] = $langs->trans("NextYearOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($dateexample, 1, 'y'), '%Y').')'; |
|
1364 | 1364 | // Only on template invoices |
1365 | - $substitutionarray['__INVOICE_DATE_NEXT_INVOICE_BEFORE_GEN__'] = $langs->trans("DateNextInvoiceBeforeGen").' ('.$langs->trans("Example").': '.dol_print_date(($object->date_when?$object->date_when:dol_now()), 'dayhour').')'; |
|
1366 | - $substitutionarray['__INVOICE_DATE_NEXT_INVOICE_AFTER_GEN__'] = $langs->trans("DateNextInvoiceAfterGen").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree(($object->date_when?$object->date_when:dol_now()), $object->frequency, $object->unit_frequency),'dayhour').')'; |
|
1365 | + $substitutionarray['__INVOICE_DATE_NEXT_INVOICE_BEFORE_GEN__'] = $langs->trans("DateNextInvoiceBeforeGen").' ('.$langs->trans("Example").': '.dol_print_date(($object->date_when ? $object->date_when : dol_now()), 'dayhour').')'; |
|
1366 | + $substitutionarray['__INVOICE_DATE_NEXT_INVOICE_AFTER_GEN__'] = $langs->trans("DateNextInvoiceAfterGen").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree(($object->date_when ? $object->date_when : dol_now()), $object->frequency, $object->unit_frequency), 'dayhour').')'; |
|
1367 | 1367 | |
1368 | 1368 | $htmltext = '<i>'.$langs->trans("FollowingConstantsWillBeSubstituted").':<br>'; |
1369 | - foreach($substitutionarray as $key => $val) |
|
1369 | + foreach ($substitutionarray as $key => $val) |
|
1370 | 1370 | { |
1371 | - $htmltext.=$key.' = '.$langs->trans($val).'<br>'; |
|
1371 | + $htmltext .= $key.' = '.$langs->trans($val).'<br>'; |
|
1372 | 1372 | } |
1373 | - $htmltext.='</i>'; |
|
1373 | + $htmltext .= '</i>'; |
|
1374 | 1374 | |
1375 | 1375 | // Note public |
1376 | 1376 | print '<tr><td>'; |
@@ -1395,8 +1395,8 @@ discard block |
||
1395 | 1395 | print '<table width="100%" class="nobordernopadding"><tr><td class="nowrap">'; |
1396 | 1396 | print $langs->trans('RIB'); |
1397 | 1397 | print '<td>'; |
1398 | - if (($action != 'editbankaccount') && $user->rights->facture->creer && ! empty($object->brouillon)) |
|
1399 | - print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editbankaccount&id='.$object->id.'">'.img_edit($langs->trans('SetBankAccount'),1).'</a></td>'; |
|
1398 | + if (($action != 'editbankaccount') && $user->rights->facture->creer && !empty($object->brouillon)) |
|
1399 | + print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editbankaccount&id='.$object->id.'">'.img_edit($langs->trans('SetBankAccount'), 1).'</a></td>'; |
|
1400 | 1400 | print '</tr></table>'; |
1401 | 1401 | print '</td><td>'; |
1402 | 1402 | if ($action == 'editbankaccount') |
@@ -1417,17 +1417,17 @@ discard block |
||
1417 | 1417 | print '<table width="100%" class="nobordernopadding"><tr><td class="nowrap">'; |
1418 | 1418 | print $langs->trans('Model'); |
1419 | 1419 | print '<td>'; |
1420 | - if (($action != 'editmodelpdf') && $user->rights->facture->creer && ! empty($object->brouillon)) |
|
1421 | - print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editmodelpdf&id='.$object->id.'">'.img_edit($langs->trans('SetModel'),1).'</a></td>'; |
|
1420 | + if (($action != 'editmodelpdf') && $user->rights->facture->creer && !empty($object->brouillon)) |
|
1421 | + print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editmodelpdf&id='.$object->id.'">'.img_edit($langs->trans('SetModel'), 1).'</a></td>'; |
|
1422 | 1422 | print '</tr></table>'; |
1423 | 1423 | print '</td><td>'; |
1424 | 1424 | if ($action == 'editmodelpdf') |
1425 | 1425 | { |
1426 | - include_once DOL_DOCUMENT_ROOT . '/core/modules/facture/modules_facture.php'; |
|
1426 | + include_once DOL_DOCUMENT_ROOT.'/core/modules/facture/modules_facture.php'; |
|
1427 | 1427 | $list = array(); |
1428 | 1428 | $models = ModelePDFFactures::liste_modeles($db); |
1429 | 1429 | foreach ($models as $model) { |
1430 | - $list[] = $model . ':' . $model; |
|
1430 | + $list[] = $model.':'.$model; |
|
1431 | 1431 | } |
1432 | 1432 | $select = 'select;'.implode(',', $list); |
1433 | 1433 | print $form->editfieldval($langs->trans("Model"), 'modelpdf', $object->modelpdf, $object, $user->rights->facture->creer, $select); |
@@ -1441,7 +1441,7 @@ discard block |
||
1441 | 1441 | |
1442 | 1442 | // Other attributes |
1443 | 1443 | $cols = 2; |
1444 | - include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; |
|
1444 | + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; |
|
1445 | 1445 | |
1446 | 1446 | print '</table>'; |
1447 | 1447 | |
@@ -1466,18 +1466,18 @@ discard block |
||
1466 | 1466 | print '<table class="nobordernopadding" width="100%"><tr><td>'; |
1467 | 1467 | print $langs->trans('Frequency'); |
1468 | 1468 | print '</td>'; |
1469 | - if ($action != 'editfrequency' && ! empty($object->brouillon) && $user->rights->facture->creer) |
|
1470 | - print '<td align="right"><a href="' . $_SERVER["PHP_SELF"] . '?action=editfrequency&facid=' . $object->id . '">' . img_edit($langs->trans('Edit'), 1) . '</a></td>'; |
|
1469 | + if ($action != 'editfrequency' && !empty($object->brouillon) && $user->rights->facture->creer) |
|
1470 | + print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editfrequency&facid='.$object->id.'">'.img_edit($langs->trans('Edit'), 1).'</a></td>'; |
|
1471 | 1471 | print '</tr></table>'; |
1472 | 1472 | print '</td><td>'; |
1473 | 1473 | if ($action == 'editfrequency') |
1474 | 1474 | { |
1475 | - print '<form method="post" action="'.$_SERVER["PHP_SELF"] . '?facid=' . $object->id.'">'; |
|
1475 | + print '<form method="post" action="'.$_SERVER["PHP_SELF"].'?facid='.$object->id.'">'; |
|
1476 | 1476 | print '<input type="hidden" name="action" value="setfrequency">'; |
1477 | 1477 | print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
1478 | 1478 | print '<table class="nobordernopadding" cellpadding="0" cellspacing="0">'; |
1479 | 1479 | print '<tr><td>'; |
1480 | - print "<input type='text' name='frequency' value='".$object->frequency."' size='5' /> ".$form->selectarray('unit_frequency', array('d'=>$langs->trans('Day'), 'm'=>$langs->trans('Month'), 'y'=>$langs->trans('Year')), ($object->unit_frequency?$object->unit_frequency:'m')); |
|
1480 | + print "<input type='text' name='frequency' value='".$object->frequency."' size='5' /> ".$form->selectarray('unit_frequency', array('d'=>$langs->trans('Day'), 'm'=>$langs->trans('Month'), 'y'=>$langs->trans('Year')), ($object->unit_frequency ? $object->unit_frequency : 'm')); |
|
1481 | 1481 | print '</td>'; |
1482 | 1482 | print '<td align="left"><input type="submit" class="button" value="'.$langs->trans("Modify").'"></td>'; |
1483 | 1483 | print '</tr></table></form>'; |
@@ -1511,9 +1511,9 @@ discard block |
||
1511 | 1511 | print $form->editfieldval($langs->trans("NextDateToExecution"), 'date_when', $object->date_when, $object, $user->rights->facture->creer, 'day', $object->date_when, null, '', '', 0, 'strikeIfMaxNbGenReached'); |
1512 | 1512 | } |
1513 | 1513 | //var_dump(dol_print_date($object->date_when+60, 'dayhour').' - '.dol_print_date($now, 'dayhour')); |
1514 | - if (! $object->isMaxNbGenReached()) |
|
1514 | + if (!$object->isMaxNbGenReached()) |
|
1515 | 1515 | { |
1516 | - if (! $object->suspended && $action != 'editdate_when' && $object->frequency > 0 && $object->date_when && $object->date_when < $now) print img_warning($langs->trans("Late")); |
|
1516 | + if (!$object->suspended && $action != 'editdate_when' && $object->frequency > 0 && $object->date_when && $object->date_when < $now) print img_warning($langs->trans("Late")); |
|
1517 | 1517 | } |
1518 | 1518 | else |
1519 | 1519 | { |
@@ -1535,7 +1535,7 @@ discard block |
||
1535 | 1535 | print '</td><td>'; |
1536 | 1536 | if ($action == 'nb_gen_max' || $object->frequency > 0) |
1537 | 1537 | { |
1538 | - print $form->editfieldval($langs->trans("MaxPeriodNumber"), 'nb_gen_max', $object->nb_gen_max?$object->nb_gen_max:'', $object, $user->rights->facture->creer); |
|
1538 | + print $form->editfieldval($langs->trans("MaxPeriodNumber"), 'nb_gen_max', $object->nb_gen_max ? $object->nb_gen_max : '', $object, $user->rights->facture->creer); |
|
1539 | 1539 | } |
1540 | 1540 | else |
1541 | 1541 | { |
@@ -1558,7 +1558,7 @@ discard block |
||
1558 | 1558 | } |
1559 | 1559 | print '</td>'; |
1560 | 1560 | // Auto generate documents |
1561 | - if (! empty($conf->global->INVOICE_REC_CAN_DISABLE_DOCUMENT_FILE_GENERATION)) |
|
1561 | + if (!empty($conf->global->INVOICE_REC_CAN_DISABLE_DOCUMENT_FILE_GENERATION)) |
|
1562 | 1562 | { |
1563 | 1563 | print '<tr>'; |
1564 | 1564 | print '<td>'; |
@@ -1599,7 +1599,7 @@ discard block |
||
1599 | 1599 | // Nb of generation already done |
1600 | 1600 | print '<tr><td style="width: 50%">'.$langs->trans("NbOfGenerationDone").'</td>'; |
1601 | 1601 | print '<td>'; |
1602 | - print $object->nb_gen_done?$object->nb_gen_done:'0'; |
|
1602 | + print $object->nb_gen_done ? $object->nb_gen_done : '0'; |
|
1603 | 1603 | print '</td>'; |
1604 | 1604 | print '</tr>'; |
1605 | 1605 | |
@@ -1624,25 +1624,25 @@ discard block |
||
1624 | 1624 | |
1625 | 1625 | |
1626 | 1626 | // Lines |
1627 | - print ' <form name="addproduct" id="addproduct" action="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . (($action != 'editline') ? '#add' : '#line_' . GETPOST('lineid')) . '" method="POST"> |
|
1628 | - <input type="hidden" name="token" value="' . $_SESSION ['newtoken'] . '"> |
|
1629 | - <input type="hidden" name="action" value="' . (($action != 'editline') ? 'addline' : 'updateline') . '"> |
|
1627 | + print ' <form name="addproduct" id="addproduct" action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.(($action != 'editline') ? '#add' : '#line_'.GETPOST('lineid')).'" method="POST"> |
|
1628 | + <input type="hidden" name="token" value="' . $_SESSION ['newtoken'].'"> |
|
1629 | + <input type="hidden" name="action" value="' . (($action != 'editline') ? 'addline' : 'updateline').'"> |
|
1630 | 1630 | <input type="hidden" name="mode" value=""> |
1631 | - <input type="hidden" name="id" value="' . $object->id . '"> |
|
1631 | + <input type="hidden" name="id" value="' . $object->id.'"> |
|
1632 | 1632 | '; |
1633 | 1633 | |
1634 | - if (! empty($conf->use_javascript_ajax) && $object->statut == 0) { |
|
1635 | - include DOL_DOCUMENT_ROOT . '/core/tpl/ajaxrow.tpl.php'; |
|
1634 | + if (!empty($conf->use_javascript_ajax) && $object->statut == 0) { |
|
1635 | + include DOL_DOCUMENT_ROOT.'/core/tpl/ajaxrow.tpl.php'; |
|
1636 | 1636 | } |
1637 | 1637 | |
1638 | 1638 | print '<div class="div-table-responsive-no-min">'; |
1639 | 1639 | print '<table id="tablelines" class="noborder noshadow" width="100%">'; |
1640 | 1640 | // Show object lines |
1641 | - if (! empty($object->lines)) |
|
1641 | + if (!empty($object->lines)) |
|
1642 | 1642 | { |
1643 | 1643 | //$disableedit=1; |
1644 | 1644 | //$disablemove=1; |
1645 | - $ret = $object->printObjectLines($action, $mysoc, $object->thirdparty, $lineid, 0); // No date selector for template invoice |
|
1645 | + $ret = $object->printObjectLines($action, $mysoc, $object->thirdparty, $lineid, 0); // No date selector for template invoice |
|
1646 | 1646 | } |
1647 | 1647 | |
1648 | 1648 | // Form to add new line |
@@ -1651,7 +1651,7 @@ discard block |
||
1651 | 1651 | if ($action != 'editline') |
1652 | 1652 | { |
1653 | 1653 | // Add free products/services |
1654 | - $object->formAddObjectLine(0, $mysoc, $object->thirdparty); // No date selector for template invoice |
|
1654 | + $object->formAddObjectLine(0, $mysoc, $object->thirdparty); // No date selector for template invoice |
|
1655 | 1655 | |
1656 | 1656 | $parameters = array(); |
1657 | 1657 | $reshook = $hookmanager->executeHooks('formAddObjectLine', $parameters, $object, $action); // Note that $action and $object may have been modified by hook |
@@ -1675,7 +1675,7 @@ discard block |
||
1675 | 1675 | { |
1676 | 1676 | if ($user->rights->facture->creer) |
1677 | 1677 | { |
1678 | - if (! empty($object->frequency) && $object->nb_gen_max > 0 && ($object->nb_gen_done >= $object->nb_gen_max)) |
|
1678 | + if (!empty($object->frequency) && $object->nb_gen_max > 0 && ($object->nb_gen_done >= $object->nb_gen_max)) |
|
1679 | 1679 | { |
1680 | 1680 | print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("MaxGenerationReached")).'">'.$langs->trans("CreateBill").'</a></div>'; |
1681 | 1681 | } |
@@ -1683,7 +1683,7 @@ discard block |
||
1683 | 1683 | { |
1684 | 1684 | if (empty($object->frequency) || $object->date_when <= $today) |
1685 | 1685 | { |
1686 | - print '<div class="inline-block divButAction"><a class="butAction" href="' . BASE_URI . '?controller=compta/facture&method=card&action=create&socid=' . $object->thirdparty->id . '&fac_rec=' . $object->id . '">' . $langs->trans("CreateBill") . '</a></div>'; |
|
1686 | + print '<div class="inline-block divButAction"><a class="butAction" href="'.BASE_URI.'?controller=compta/facture&method=card&action=create&socid='.$object->thirdparty->id.'&fac_rec='.$object->id.'">'.$langs->trans("CreateBill").'</a></div>'; |
|
1687 | 1687 | } |
1688 | 1688 | else |
1689 | 1689 | { |
@@ -1701,11 +1701,11 @@ discard block |
||
1701 | 1701 | { |
1702 | 1702 | if (empty($object->suspended)) |
1703 | 1703 | { |
1704 | - print '<div class="inline-block divButAction"><a class="butActionDelete" href="' . BASE_URI . '?controller=compta/facture&method=fiche-rec&action=disable&id=' . $object->id . '">' . $langs->trans("Disable") . '</a></div>'; |
|
1704 | + print '<div class="inline-block divButAction"><a class="butActionDelete" href="'.BASE_URI.'?controller=compta/facture&method=fiche-rec&action=disable&id='.$object->id.'">'.$langs->trans("Disable").'</a></div>'; |
|
1705 | 1705 | } |
1706 | 1706 | else |
1707 | 1707 | { |
1708 | - print '<div class="inline-block divButAction"><a class="butAction" href="' . BASE_URI . '?controller=compta/facture&method=fiche-rec&action=enable&id=' . $object->id . '">' . $langs->trans("Enable") . '</a></div>'; |
|
1708 | + print '<div class="inline-block divButAction"><a class="butAction" href="'.BASE_URI.'?controller=compta/facture&method=fiche-rec&action=enable&id='.$object->id.'">'.$langs->trans("Enable").'</a></div>'; |
|
1709 | 1709 | } |
1710 | 1710 | } |
1711 | 1711 |
@@ -61,9 +61,13 @@ discard block |
||
61 | 61 | $id=(GETPOST('facid','int')?GETPOST('facid','int'):GETPOST('id','int')); |
62 | 62 | $lineid=GETPOST('lineid','int'); |
63 | 63 | $ref=GETPOST('ref','alpha'); |
64 | -if ($user->societe_id) $socid=$user->societe_id; |
|
64 | +if ($user->societe_id) { |
|
65 | + $socid=$user->societe_id; |
|
66 | +} |
|
65 | 67 | $objecttype = 'facture_rec'; |
66 | -if ($action == "create" || $action == "add") $objecttype = ''; |
|
68 | +if ($action == "create" || $action == "add") { |
|
69 | + $objecttype = ''; |
|
70 | +} |
|
67 | 71 | $result = restrictedArea($user, 'facture', $id, $objecttype); |
68 | 72 | $projectid = GETPOST('projectid','int'); |
69 | 73 | |
@@ -76,8 +80,12 @@ discard block |
||
76 | 80 | $page = GETPOST("page",'int'); |
77 | 81 | if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 |
78 | 82 | $offset = $limit * $page; |
79 | -if (! $sortorder) $sortorder='DESC'; |
|
80 | -if (! $sortfield) $sortfield='f.titre'; |
|
83 | +if (! $sortorder) { |
|
84 | + $sortorder='DESC'; |
|
85 | +} |
|
86 | +if (! $sortfield) { |
|
87 | + $sortfield='f.titre'; |
|
88 | +} |
|
81 | 89 | $pageprev = $page - 1; |
82 | 90 | $pagenext = $page + 1; |
83 | 91 | |
@@ -115,11 +123,15 @@ discard block |
||
115 | 123 | |
116 | 124 | $parameters = array('socid' => $socid); |
117 | 125 | $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks |
118 | -if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); |
|
126 | +if ($reshook < 0) { |
|
127 | + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); |
|
128 | +} |
|
119 | 129 | |
120 | 130 | if (empty($reshook)) |
121 | 131 | { |
122 | - if (GETPOST('cancel','alpha')) $action=''; |
|
132 | + if (GETPOST('cancel','alpha')) { |
|
133 | + $action=''; |
|
134 | + } |
|
123 | 135 | |
124 | 136 | // Selection of new fields |
125 | 137 | include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; |
@@ -225,8 +237,7 @@ discard block |
||
225 | 237 | setEventMessages($oldinvoice->error, $oldinvoice->errors, 'errors'); |
226 | 238 | $action = "create"; |
227 | 239 | } |
228 | - } |
|
229 | - else |
|
240 | + } else |
|
230 | 241 | { |
231 | 242 | $error++; |
232 | 243 | setEventMessages($object->error, $object->errors, 'errors'); |
@@ -239,8 +250,7 @@ discard block |
||
239 | 250 | |
240 | 251 | header("Location: " . $_SERVER['PHP_SELF'] . '?facid=' . $object->id); |
241 | 252 | exit; |
242 | - } |
|
243 | - else |
|
253 | + } else |
|
244 | 254 | { |
245 | 255 | $db->rollback(); |
246 | 256 | |
@@ -286,8 +296,9 @@ discard block |
||
286 | 296 | { |
287 | 297 | $object->titre = GETPOST('ref', 'alpha'); |
288 | 298 | $object->ref = $object->titre; |
299 | + } else { |
|
300 | + dol_print_error($db, $object->error, $object->errors); |
|
289 | 301 | } |
290 | - else dol_print_error($db, $object->error, $object->errors); |
|
291 | 302 | } |
292 | 303 | // Set bank account |
293 | 304 | elseif ($action == 'setbankaccount' && $user->rights->facture->creer) |
@@ -303,7 +314,9 @@ discard block |
||
303 | 314 | elseif ($action == 'setdate_when' && $user->rights->facture->creer) |
304 | 315 | { |
305 | 316 | $date = dol_mktime(GETPOST('date_whenhour'), GETPOST('date_whenmin'), 0, GETPOST('date_whenmonth'), GETPOST('date_whenday'), GETPOST('date_whenyear')); |
306 | - if (!empty($date)) $object->setNextDate($date); |
|
317 | + if (!empty($date)) { |
|
318 | + $object->setNextDate($date); |
|
319 | + } |
|
307 | 320 | } |
308 | 321 | // Set max period |
309 | 322 | elseif ($action == 'setnb_gen_max' && $user->rights->facture->creer) |
@@ -342,8 +355,7 @@ discard block |
||
342 | 355 | if (! $error) |
343 | 356 | { |
344 | 357 | $db->commit(); |
345 | - } |
|
346 | - else |
|
358 | + } else |
|
347 | 359 | { |
348 | 360 | $db->rollback(); |
349 | 361 | setEventMessages($object->error, $object->errors, 'errors'); |
@@ -366,8 +378,7 @@ discard block |
||
366 | 378 | if (! $error) |
367 | 379 | { |
368 | 380 | $db->commit(); |
369 | - } |
|
370 | - else |
|
381 | + } else |
|
371 | 382 | { |
372 | 383 | $db->rollback(); |
373 | 384 | setEventMessages($object->error, $object->errors, 'errors'); |
@@ -395,27 +406,26 @@ discard block |
||
395 | 406 | { |
396 | 407 | $db->commit(); |
397 | 408 | $object->fetch($object->id); // Reload lines |
398 | - } |
|
399 | - else |
|
409 | + } else |
|
400 | 410 | { |
401 | 411 | $db->rollback(); |
402 | 412 | setEventMessages($db->lasterror(), null, 'errors'); |
403 | 413 | } |
404 | - } |
|
405 | - else |
|
414 | + } else |
|
406 | 415 | { |
407 | 416 | $db->rollback(); |
408 | 417 | setEventMessages($line->error, $line->errors, 'errors'); |
409 | 418 | } |
410 | - } |
|
411 | - else if ($action == 'update_extras') |
|
419 | + } else if ($action == 'update_extras') |
|
412 | 420 | { |
413 | 421 | $object->oldcopy = dol_clone($object); |
414 | 422 | |
415 | 423 | // Fill array 'array_options' with data from update form |
416 | 424 | $extralabels = $extrafields->fetch_name_optionals_label($object->table_element); |
417 | 425 | $ret = $extrafields->setOptionalsFromPost($extralabels, $object, GETPOST('attribute','none')); |
418 | - if ($ret < 0) $error++; |
|
426 | + if ($ret < 0) { |
|
427 | + $error++; |
|
428 | + } |
|
419 | 429 | |
420 | 430 | if (! $error) |
421 | 431 | { |
@@ -442,8 +452,7 @@ discard block |
||
442 | 452 | { |
443 | 453 | $idprod=0; |
444 | 454 | $tva_tx = (GETPOST('tva_tx') ? GETPOST('tva_tx') : 0); |
445 | - } |
|
446 | - else |
|
455 | + } else |
|
447 | 456 | { |
448 | 457 | $idprod=GETPOST('idprod', 'int'); |
449 | 458 | $tva_tx = ''; |
@@ -473,9 +482,11 @@ discard block |
||
473 | 482 | setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Type')), null, 'errors'); |
474 | 483 | $error ++; |
475 | 484 | } |
476 | - if (GETPOST('prod_entry_mode') == 'free' && empty($idprod) && (! ($price_ht >= 0) || $price_ht == '')) // Unit price can be 0 but not '' |
|
485 | + if (GETPOST('prod_entry_mode') == 'free' && empty($idprod) && (! ($price_ht >= 0) || $price_ht == '')) { |
|
486 | + // Unit price can be 0 but not '' |
|
477 | 487 | { |
478 | 488 | setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("UnitPriceHT")), null, 'errors'); |
489 | + } |
|
479 | 490 | $error ++; |
480 | 491 | } |
481 | 492 | if ($qty == '') { |
@@ -525,7 +536,9 @@ discard block |
||
525 | 536 | // Update if prices fields are defined |
526 | 537 | $tva_tx = get_default_tva($mysoc, $object->thirdparty, $prod->id); |
527 | 538 | $tva_npr = get_default_npr($mysoc, $object->thirdparty, $prod->id); |
528 | - if (empty($tva_tx)) $tva_npr=0; |
|
539 | + if (empty($tva_tx)) { |
|
540 | + $tva_npr=0; |
|
541 | + } |
|
529 | 542 | |
530 | 543 | $pu_ht = $prod->price; |
531 | 544 | $pu_ttc = $prod->price_ttc; |
@@ -539,14 +552,19 @@ discard block |
||
539 | 552 | $pu_ttc = $prod->multiprices_ttc[$object->thirdparty->price_level]; |
540 | 553 | $price_min = $prod->multiprices_min[$object->thirdparty->price_level]; |
541 | 554 | $price_base_type = $prod->multiprices_base_type[$object->thirdparty->price_level]; |
542 | - if (! empty($conf->global->PRODUIT_MULTIPRICES_USE_VAT_PER_LEVEL)) // using this option is a bug. kept for backward compatibility |
|
555 | + if (! empty($conf->global->PRODUIT_MULTIPRICES_USE_VAT_PER_LEVEL)) { |
|
556 | + // using this option is a bug. kept for backward compatibility |
|
543 | 557 | { |
544 | 558 | if (isset($prod->multiprices_tva_tx[$object->thirdparty->price_level])) $tva_tx=$prod->multiprices_tva_tx[$object->thirdparty->price_level]; |
545 | - if (isset($prod->multiprices_recuperableonly[$object->thirdparty->price_level])) $tva_npr=$prod->multiprices_recuperableonly[$object->thirdparty->price_level]; |
|
546 | - if (empty($tva_tx)) $tva_npr=0; |
|
547 | 559 | } |
548 | - } |
|
549 | - elseif (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) |
|
560 | + if (isset($prod->multiprices_recuperableonly[$object->thirdparty->price_level])) { |
|
561 | + $tva_npr=$prod->multiprices_recuperableonly[$object->thirdparty->price_level]; |
|
562 | + } |
|
563 | + if (empty($tva_tx)) { |
|
564 | + $tva_npr=0; |
|
565 | + } |
|
566 | + } |
|
567 | + } elseif (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) |
|
550 | 568 | { |
551 | 569 | include_once DOL_DOCUMENT_ROOT . '/product/class/productcustomerprice.class.php'; |
552 | 570 | |
@@ -563,9 +581,13 @@ discard block |
||
563 | 581 | $pu_ttc = price($prodcustprice->lines[0]->price_ttc); |
564 | 582 | $price_base_type = $prodcustprice->lines[0]->price_base_type; |
565 | 583 | $tva_tx = $prodcustprice->lines[0]->tva_tx; |
566 | - if ($prodcustprice->lines[0]->default_vat_code && ! preg_match('/\(.*\)/', $tva_tx)) $tva_tx.= ' ('.$prodcustprice->lines[0]->default_vat_code.')'; |
|
584 | + if ($prodcustprice->lines[0]->default_vat_code && ! preg_match('/\(.*\)/', $tva_tx)) { |
|
585 | + $tva_tx.= ' ('.$prodcustprice->lines[0]->default_vat_code.')'; |
|
586 | + } |
|
567 | 587 | $tva_npr = $prodcustprice->lines[0]->recuperableonly; |
568 | - if (empty($tva_tx)) $tva_npr=0; |
|
588 | + if (empty($tva_tx)) { |
|
589 | + $tva_npr=0; |
|
590 | + } |
|
569 | 591 | } |
570 | 592 | } |
571 | 593 | } |
@@ -586,8 +608,7 @@ discard block |
||
586 | 608 | if ($price_base_type != 'HT') |
587 | 609 | { |
588 | 610 | $pu_ht = price2num($pu_ttc / (1 + ($tmpvat / 100)), 'MU'); |
589 | - } |
|
590 | - else |
|
611 | + } else |
|
591 | 612 | { |
592 | 613 | $pu_ttc = price2num($pu_ht * (1 + ($tmpvat / 100)), 'MU'); |
593 | 614 | } |
@@ -600,10 +621,12 @@ discard block |
||
600 | 621 | { |
601 | 622 | $outputlangs = $langs; |
602 | 623 | $newlang = ''; |
603 | - if (empty($newlang) && GETPOST('lang_id','aZ09')) |
|
604 | - $newlang = GETPOST('lang_id','aZ09'); |
|
605 | - if (empty($newlang)) |
|
606 | - $newlang = $object->thirdparty->default_lang; |
|
624 | + if (empty($newlang) && GETPOST('lang_id','aZ09')) { |
|
625 | + $newlang = GETPOST('lang_id','aZ09'); |
|
626 | + } |
|
627 | + if (empty($newlang)) { |
|
628 | + $newlang = $object->thirdparty->default_lang; |
|
629 | + } |
|
607 | 630 | if (! empty($newlang)) |
608 | 631 | { |
609 | 632 | $outputlangs = new Translate("", $conf); |
@@ -611,8 +634,7 @@ discard block |
||
611 | 634 | } |
612 | 635 | |
613 | 636 | $desc = (! empty($prod->multilangs [$outputlangs->defaultlang] ["description"])) ? $prod->multilangs [$outputlangs->defaultlang] ["description"] : $prod->description; |
614 | - } |
|
615 | - else |
|
637 | + } else |
|
616 | 638 | { |
617 | 639 | $desc = $prod->description; |
618 | 640 | } |
@@ -623,26 +645,30 @@ discard block |
||
623 | 645 | if (empty($conf->global->MAIN_PRODUCT_DISABLE_CUSTOMCOUNTRYCODE) && (! empty($prod->customcode) || ! empty($prod->country_code))) |
624 | 646 | { |
625 | 647 | $tmptxt = '('; |
626 | - if (! empty($prod->customcode)) |
|
627 | - $tmptxt .= $langs->transnoentitiesnoconv("CustomCode") . ': ' . $prod->customcode; |
|
628 | - if (! empty($prod->customcode) && ! empty($prod->country_code)) |
|
629 | - $tmptxt .= ' - '; |
|
630 | - if (! empty($prod->country_code)) |
|
631 | - $tmptxt .= $langs->transnoentitiesnoconv("CountryOrigin") . ': ' . getCountry($prod->country_code, 0, $db, $langs, 0); |
|
648 | + if (! empty($prod->customcode)) { |
|
649 | + $tmptxt .= $langs->transnoentitiesnoconv("CustomCode") . ': ' . $prod->customcode; |
|
650 | + } |
|
651 | + if (! empty($prod->customcode) && ! empty($prod->country_code)) { |
|
652 | + $tmptxt .= ' - '; |
|
653 | + } |
|
654 | + if (! empty($prod->country_code)) { |
|
655 | + $tmptxt .= $langs->transnoentitiesnoconv("CountryOrigin") . ': ' . getCountry($prod->country_code, 0, $db, $langs, 0); |
|
656 | + } |
|
632 | 657 | $tmptxt .= ')'; |
633 | 658 | $desc = dol_concatdesc($desc, $tmptxt); |
634 | 659 | } |
635 | 660 | |
636 | 661 | $type = $prod->type; |
637 | 662 | $fk_unit = $prod->fk_unit; |
638 | - } |
|
639 | - else |
|
663 | + } else |
|
640 | 664 | { |
641 | 665 | $pu_ht = price2num($price_ht, 'MU'); |
642 | 666 | $pu_ttc = price2num(GETPOST('price_ttc'), 'MU'); |
643 | 667 | $tva_npr = (preg_match('/\*/', $tva_tx) ? 1 : 0); |
644 | 668 | $tva_tx = str_replace('*', '', $tva_tx); |
645 | - if (empty($tva_tx)) $tva_npr=0; |
|
669 | + if (empty($tva_tx)) { |
|
670 | + $tva_npr=0; |
|
671 | + } |
|
646 | 672 | $label = (GETPOST('product_label') ? GETPOST('product_label') : ''); |
647 | 673 | $desc = $product_desc; |
648 | 674 | $type = GETPOST('type'); |
@@ -661,15 +687,15 @@ discard block |
||
661 | 687 | $localtax2_tx = get_localtax($tva_tx, 2, $object->thirdparty, $mysoc, $tva_npr); |
662 | 688 | |
663 | 689 | $info_bits = 0; |
664 | - if ($tva_npr) |
|
665 | - $info_bits |= 0x01; |
|
690 | + if ($tva_npr) { |
|
691 | + $info_bits |= 0x01; |
|
692 | + } |
|
666 | 693 | |
667 | 694 | if (((!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->produit->ignore_price_min_advance)) || empty($conf->global->MAIN_USE_ADVANCED_PERMS) )&& (! empty($price_min) && (price2num($pu_ht) * (1 - price2num($remise_percent) / 100) < price2num($price_min)))) |
668 | 695 | { |
669 | 696 | $mesg = $langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, - 1, $conf->currency)); |
670 | 697 | setEventMessages($mesg, null, 'errors'); |
671 | - } |
|
672 | - else |
|
698 | + } else |
|
673 | 699 | { |
674 | 700 | // Insert line |
675 | 701 | $result = $object->addline($desc, $pu_ht, $qty, $tva_tx,$localtax1_tx, $localtax2_tx, $idprod, $remise_percent, $price_base_type, $info_bits, '', $pu_ttc, $type, - 1, $special_code, $label, $fk_unit, 0, $date_start_fill, $date_end_fill); |
@@ -733,8 +759,7 @@ discard block |
||
733 | 759 | |
734 | 760 | unset($_POST['situations']); |
735 | 761 | unset($_POST['progress']); |
736 | - } |
|
737 | - else |
|
762 | + } else |
|
738 | 763 | { |
739 | 764 | setEventMessages($object->error, $object->errors, 'errors'); |
740 | 765 | } |
@@ -742,11 +767,11 @@ discard block |
||
742 | 767 | $action = ''; |
743 | 768 | } |
744 | 769 | } |
745 | - } |
|
746 | - |
|
747 | - elseif ($action == 'updateline' && $user->rights->facture->creer && ! GETPOST('cancel','alpha')) |
|
770 | + } elseif ($action == 'updateline' && $user->rights->facture->creer && ! GETPOST('cancel','alpha')) |
|
748 | 771 | { |
749 | - if (! $object->fetch($id) > 0) dol_print_error($db); |
|
772 | + if (! $object->fetch($id) > 0) { |
|
773 | + dol_print_error($db); |
|
774 | + } |
|
750 | 775 | $object->fetch_thirdparty(); |
751 | 776 | |
752 | 777 | // Clean parameters |
@@ -762,7 +787,9 @@ discard block |
||
762 | 787 | |
763 | 788 | // Define info_bits |
764 | 789 | $info_bits = 0; |
765 | - if (preg_match('/\*/', $vat_rate)) $info_bits |= 0x01; |
|
790 | + if (preg_match('/\*/', $vat_rate)) { |
|
791 | + $info_bits |= 0x01; |
|
792 | + } |
|
766 | 793 | |
767 | 794 | // Define vat_rate |
768 | 795 | $vat_rate = str_replace('*', '', $vat_rate); |
@@ -801,7 +828,9 @@ discard block |
||
801 | 828 | |
802 | 829 | // Define special_code for special lines |
803 | 830 | $special_code=GETPOST('special_code'); |
804 | - if (! GETPOST('qty')) $special_code=3; |
|
831 | + if (! GETPOST('qty')) { |
|
832 | + $special_code=3; |
|
833 | + } |
|
805 | 834 | |
806 | 835 | /*$line = new FactureLigne($db); |
807 | 836 | $line->fetch(GETPOST('lineid')); |
@@ -825,8 +854,9 @@ discard block |
||
825 | 854 | $type = $product->type; |
826 | 855 | |
827 | 856 | $price_min = $product->price_min; |
828 | - if (! empty($conf->global->PRODUIT_MULTIPRICES) && ! empty($object->thirdparty->price_level)) |
|
829 | - $price_min = $product->multiprices_min[$object->thirdparty->price_level]; |
|
857 | + if (! empty($conf->global->PRODUIT_MULTIPRICES) && ! empty($object->thirdparty->price_level)) { |
|
858 | + $price_min = $product->multiprices_min[$object->thirdparty->price_level]; |
|
859 | + } |
|
830 | 860 | |
831 | 861 | $label = ((GETPOST('update_label') && GETPOST('product_label')) ? GETPOST('product_label') : ''); |
832 | 862 | |
@@ -939,8 +969,7 @@ discard block |
||
939 | 969 | |
940 | 970 | unset($_POST['situations']); |
941 | 971 | unset($_POST['progress']); |
942 | - } |
|
943 | - else |
|
972 | + } else |
|
944 | 973 | { |
945 | 974 | setEventMessages($object->error, $object->errors, 'errors'); |
946 | 975 | } |
@@ -988,8 +1017,12 @@ discard block |
||
988 | 1017 | dol_fiche_head(null, '', '', 0); |
989 | 1018 | |
990 | 1019 | $rowspan=4; |
991 | - if (! empty($conf->projet->enabled)) $rowspan++; |
|
992 | - if ($object->fk_account > 0) $rowspan++; |
|
1020 | + if (! empty($conf->projet->enabled)) { |
|
1021 | + $rowspan++; |
|
1022 | + } |
|
1023 | + if ($object->fk_account > 0) { |
|
1024 | + $rowspan++; |
|
1025 | + } |
|
993 | 1026 | |
994 | 1027 | print '<table class="border" width="100%">'; |
995 | 1028 | |
@@ -1134,8 +1167,7 @@ discard block |
||
1134 | 1167 | $select = array('0'=>$langs->trans('DoNotGenerateDoc'),'1'=>$langs->trans('AutoGenerateDoc')); |
1135 | 1168 | print $form->selectarray('generate_pdf', $select, GETPOST('generate_pdf')); |
1136 | 1169 | print "</td></tr>"; |
1137 | - } |
|
1138 | - else |
|
1170 | + } else |
|
1139 | 1171 | { |
1140 | 1172 | print '<input type="hidden" name="generate_pdf" value="1">'; |
1141 | 1173 | } |
@@ -1146,10 +1178,11 @@ discard block |
||
1146 | 1178 | |
1147 | 1179 | |
1148 | 1180 | $title = $langs->trans("ProductsAndServices"); |
1149 | - if (empty($conf->service->enabled)) |
|
1150 | - $title = $langs->trans("Products"); |
|
1151 | - else if (empty($conf->product->enabled)) |
|
1152 | - $title = $langs->trans("Services"); |
|
1181 | + if (empty($conf->service->enabled)) { |
|
1182 | + $title = $langs->trans("Products"); |
|
1183 | + } else if (empty($conf->product->enabled)) { |
|
1184 | + $title = $langs->trans("Services"); |
|
1185 | + } |
|
1153 | 1186 | |
1154 | 1187 | print load_fiche_titre($title, '', ''); |
1155 | 1188 | |
@@ -1188,13 +1221,11 @@ discard block |
||
1188 | 1221 | print '<input type="button" class="button" value="' . $langs->trans("Cancel") . '" onClick="javascript:history.go(-1)">'; |
1189 | 1222 | print '</div>'; |
1190 | 1223 | print "</form>\n"; |
1191 | - } |
|
1192 | - else |
|
1224 | + } else |
|
1193 | 1225 | { |
1194 | 1226 | dol_print_error('',"Error, no invoice ".$object->id); |
1195 | 1227 | } |
1196 | -} |
|
1197 | -else |
|
1228 | +} else |
|
1198 | 1229 | { |
1199 | 1230 | /* |
1200 | 1231 | * View mode |
@@ -1227,8 +1258,11 @@ discard block |
||
1227 | 1258 | $linkback = '<a href="' . BASE_URI . '?controller=compta/facture&method=invoicetemplate_list&restore_lastsearch_values=1' . (!empty($socid) ? '&socid=' . $socid : '') . '">' . $langs->trans("BackToList") . '</a>'; |
1228 | 1259 | |
1229 | 1260 | $morehtmlref=''; |
1230 | - if ($action != 'editref') $morehtmlref.=$form->editfieldkey($object->ref, 'ref', $object->ref, $object, $user->rights->facture->creer, '', '', 0, 2); |
|
1231 | - else $morehtmlref.= $form->editfieldval('', 'ref', $object->ref, $object, $user->rights->facture->creer, 'string'); |
|
1261 | + if ($action != 'editref') { |
|
1262 | + $morehtmlref.=$form->editfieldkey($object->ref, 'ref', $object->ref, $object, $user->rights->facture->creer, '', '', 0, 2); |
|
1263 | + } else { |
|
1264 | + $morehtmlref.= $form->editfieldval('', 'ref', $object->ref, $object, $user->rights->facture->creer, 'string'); |
|
1265 | + } |
|
1232 | 1266 | |
1233 | 1267 | $morehtmlref.='<div class="refidno">'; |
1234 | 1268 | // Ref customer |
@@ -1243,8 +1277,9 @@ discard block |
||
1243 | 1277 | $morehtmlref.='<br>'.$langs->trans('Project') . ' '; |
1244 | 1278 | if ($user->rights->facture->creer) |
1245 | 1279 | { |
1246 | - if ($action != 'classify') |
|
1247 | - $morehtmlref.='<a href="' . $_SERVER['PHP_SELF'] . '?action=classify&id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : '; |
|
1280 | + if ($action != 'classify') { |
|
1281 | + $morehtmlref.='<a href="' . $_SERVER['PHP_SELF'] . '?action=classify&id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : '; |
|
1282 | + } |
|
1248 | 1283 | if ($action == 'classify') { |
1249 | 1284 | //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); |
1250 | 1285 | $morehtmlref.='<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">'; |
@@ -1288,14 +1323,18 @@ discard block |
||
1288 | 1323 | print '</tr>'; |
1289 | 1324 | |
1290 | 1325 | // Amount Local Taxes |
1291 | - if (($mysoc->localtax1_assuj == "1" && $mysoc->useLocalTax(1)) || $object->total_localtax1 != 0) // Localtax1 |
|
1326 | + if (($mysoc->localtax1_assuj == "1" && $mysoc->useLocalTax(1)) || $object->total_localtax1 != 0) { |
|
1327 | + // Localtax1 |
|
1292 | 1328 | { |
1293 | 1329 | print '<tr><td>' . $langs->transcountry("AmountLT1", $mysoc->country_code) . '</td>'; |
1330 | + } |
|
1294 | 1331 | print '<td class="nowrap">' . price($object->total_localtax1, 1, '', 1, - 1, - 1, $conf->currency) . '</td></tr>'; |
1295 | 1332 | } |
1296 | - if (($mysoc->localtax2_assuj == "1" && $mysoc->useLocalTax(2)) || $object->total_localtax2 != 0) // Localtax2 |
|
1333 | + if (($mysoc->localtax2_assuj == "1" && $mysoc->useLocalTax(2)) || $object->total_localtax2 != 0) { |
|
1334 | + // Localtax2 |
|
1297 | 1335 | { |
1298 | 1336 | print '<tr><td>' . $langs->transcountry("AmountLT2", $mysoc->country_code) . '</td>'; |
1337 | + } |
|
1299 | 1338 | print '<td class=nowrap">' . price($object->total_localtax2, 1, '', 1, - 1, - 1, $conf->currency) . '</td></tr>'; |
1300 | 1339 | } |
1301 | 1340 | |
@@ -1308,8 +1347,9 @@ discard block |
||
1308 | 1347 | print '<table class="nobordernopadding" width="100%"><tr><td>'; |
1309 | 1348 | print $langs->trans('PaymentConditionsShort'); |
1310 | 1349 | print '</td>'; |
1311 | - if ($object->type != Facture::TYPE_CREDIT_NOTE && $action != 'editconditions' && ! empty($object->brouillon) && $user->rights->facture->creer) |
|
1312 | - print '<td align="right"><a href="' . $_SERVER["PHP_SELF"] . '?action=editconditions&facid=' . $object->id . '">' . img_edit($langs->trans('SetConditions'), 1) . '</a></td>'; |
|
1350 | + if ($object->type != Facture::TYPE_CREDIT_NOTE && $action != 'editconditions' && ! empty($object->brouillon) && $user->rights->facture->creer) { |
|
1351 | + print '<td align="right"><a href="' . $_SERVER["PHP_SELF"] . '?action=editconditions&facid=' . $object->id . '">' . img_edit($langs->trans('SetConditions'), 1) . '</a></td>'; |
|
1352 | + } |
|
1313 | 1353 | print '</tr></table>'; |
1314 | 1354 | print '</td><td>'; |
1315 | 1355 | if ($object->type != Facture::TYPE_CREDIT_NOTE) |
@@ -1317,8 +1357,7 @@ discard block |
||
1317 | 1357 | if ($action == 'editconditions') |
1318 | 1358 | { |
1319 | 1359 | $form->form_conditions_reglement($_SERVER['PHP_SELF'] . '?facid=' . $object->id, $object->cond_reglement_id, 'cond_reglement_id'); |
1320 | - } |
|
1321 | - else |
|
1360 | + } else |
|
1322 | 1361 | { |
1323 | 1362 | $form->form_conditions_reglement($_SERVER['PHP_SELF'] . '?facid=' . $object->id, $object->cond_reglement_id, 'none'); |
1324 | 1363 | } |
@@ -1332,15 +1371,15 @@ discard block |
||
1332 | 1371 | print '<table class="nobordernopadding" width="100%"><tr><td>'; |
1333 | 1372 | print $langs->trans('PaymentMode'); |
1334 | 1373 | print '</td>'; |
1335 | - if ($action != 'editmode' && ! empty($object->brouillon) && $user->rights->facture->creer) |
|
1336 | - print '<td align="right"><a href="' . $_SERVER["PHP_SELF"] . '?action=editmode&facid=' . $object->id . '">' . img_edit($langs->trans('SetMode'), 1) . '</a></td>'; |
|
1374 | + if ($action != 'editmode' && ! empty($object->brouillon) && $user->rights->facture->creer) { |
|
1375 | + print '<td align="right"><a href="' . $_SERVER["PHP_SELF"] . '?action=editmode&facid=' . $object->id . '">' . img_edit($langs->trans('SetMode'), 1) . '</a></td>'; |
|
1376 | + } |
|
1337 | 1377 | print '</tr></table>'; |
1338 | 1378 | print '</td><td>'; |
1339 | 1379 | if ($action == 'editmode') |
1340 | 1380 | { |
1341 | 1381 | $form->form_modes_reglement($_SERVER['PHP_SELF'].'?facid='.$object->id, $object->mode_reglement_id, 'mode_reglement_id', 'CRDT'); |
1342 | - } |
|
1343 | - else |
|
1382 | + } else |
|
1344 | 1383 | { |
1345 | 1384 | $form->form_modes_reglement($_SERVER['PHP_SELF'].'?facid='.$object->id, $object->mode_reglement_id, 'none', 'CRDT'); |
1346 | 1385 | } |
@@ -1348,7 +1387,9 @@ discard block |
||
1348 | 1387 | |
1349 | 1388 | // Help of substitution key |
1350 | 1389 | $dateexample=dol_now(); |
1351 | - if (! empty($object->frequency) && ! empty($object->date_when)) $dateexample=$object->date_when; |
|
1390 | + if (! empty($object->frequency) && ! empty($object->date_when)) { |
|
1391 | + $dateexample=$object->date_when; |
|
1392 | + } |
|
1352 | 1393 | |
1353 | 1394 | $substitutionarray = getCommonSubstitutionArray($langs, 2, null, $object); |
1354 | 1395 | |
@@ -1395,15 +1436,15 @@ discard block |
||
1395 | 1436 | print '<table width="100%" class="nobordernopadding"><tr><td class="nowrap">'; |
1396 | 1437 | print $langs->trans('RIB'); |
1397 | 1438 | print '<td>'; |
1398 | - if (($action != 'editbankaccount') && $user->rights->facture->creer && ! empty($object->brouillon)) |
|
1399 | - print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editbankaccount&id='.$object->id.'">'.img_edit($langs->trans('SetBankAccount'),1).'</a></td>'; |
|
1439 | + if (($action != 'editbankaccount') && $user->rights->facture->creer && ! empty($object->brouillon)) { |
|
1440 | + print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editbankaccount&id='.$object->id.'">'.img_edit($langs->trans('SetBankAccount'),1).'</a></td>'; |
|
1441 | + } |
|
1400 | 1442 | print '</tr></table>'; |
1401 | 1443 | print '</td><td>'; |
1402 | 1444 | if ($action == 'editbankaccount') |
1403 | 1445 | { |
1404 | 1446 | $form->formSelectAccount($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_account, 'fk_account', 1); |
1405 | - } |
|
1406 | - else |
|
1447 | + } else |
|
1407 | 1448 | { |
1408 | 1449 | $form->formSelectAccount($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_account, 'none'); |
1409 | 1450 | } |
@@ -1417,8 +1458,9 @@ discard block |
||
1417 | 1458 | print '<table width="100%" class="nobordernopadding"><tr><td class="nowrap">'; |
1418 | 1459 | print $langs->trans('Model'); |
1419 | 1460 | print '<td>'; |
1420 | - if (($action != 'editmodelpdf') && $user->rights->facture->creer && ! empty($object->brouillon)) |
|
1421 | - print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editmodelpdf&id='.$object->id.'">'.img_edit($langs->trans('SetModel'),1).'</a></td>'; |
|
1461 | + if (($action != 'editmodelpdf') && $user->rights->facture->creer && ! empty($object->brouillon)) { |
|
1462 | + print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editmodelpdf&id='.$object->id.'">'.img_edit($langs->trans('SetModel'),1).'</a></td>'; |
|
1463 | + } |
|
1422 | 1464 | print '</tr></table>'; |
1423 | 1465 | print '</td><td>'; |
1424 | 1466 | if ($action == 'editmodelpdf') |
@@ -1431,8 +1473,7 @@ discard block |
||
1431 | 1473 | } |
1432 | 1474 | $select = 'select;'.implode(',', $list); |
1433 | 1475 | print $form->editfieldval($langs->trans("Model"), 'modelpdf', $object->modelpdf, $object, $user->rights->facture->creer, $select); |
1434 | - } |
|
1435 | - else |
|
1476 | + } else |
|
1436 | 1477 | { |
1437 | 1478 | print $object->modelpdf; |
1438 | 1479 | } |
@@ -1466,8 +1507,9 @@ discard block |
||
1466 | 1507 | print '<table class="nobordernopadding" width="100%"><tr><td>'; |
1467 | 1508 | print $langs->trans('Frequency'); |
1468 | 1509 | print '</td>'; |
1469 | - if ($action != 'editfrequency' && ! empty($object->brouillon) && $user->rights->facture->creer) |
|
1470 | - print '<td align="right"><a href="' . $_SERVER["PHP_SELF"] . '?action=editfrequency&facid=' . $object->id . '">' . img_edit($langs->trans('Edit'), 1) . '</a></td>'; |
|
1510 | + if ($action != 'editfrequency' && ! empty($object->brouillon) && $user->rights->facture->creer) { |
|
1511 | + print '<td align="right"><a href="' . $_SERVER["PHP_SELF"] . '?action=editfrequency&facid=' . $object->id . '">' . img_edit($langs->trans('Edit'), 1) . '</a></td>'; |
|
1512 | + } |
|
1471 | 1513 | print '</tr></table>'; |
1472 | 1514 | print '</td><td>'; |
1473 | 1515 | if ($action == 'editfrequency') |
@@ -1481,14 +1523,12 @@ discard block |
||
1481 | 1523 | print '</td>'; |
1482 | 1524 | print '<td align="left"><input type="submit" class="button" value="'.$langs->trans("Modify").'"></td>'; |
1483 | 1525 | print '</tr></table></form>'; |
1484 | - } |
|
1485 | - else |
|
1526 | + } else |
|
1486 | 1527 | { |
1487 | 1528 | if ($object->frequency > 0) |
1488 | 1529 | { |
1489 | 1530 | print $langs->trans('FrequencyPer_'.$object->unit_frequency, $object->frequency); |
1490 | - } |
|
1491 | - else |
|
1531 | + } else |
|
1492 | 1532 | { |
1493 | 1533 | print $langs->trans("NotARecurringInvoiceTemplate"); |
1494 | 1534 | } |
@@ -1500,8 +1540,7 @@ discard block |
||
1500 | 1540 | if ($action == 'date_when' || $object->frequency > 0) |
1501 | 1541 | { |
1502 | 1542 | print $form->editfieldkey($langs->trans("NextDateToExecution"), 'date_when', $object->date_when, $object, $user->rights->facture->creer, 'day'); |
1503 | - } |
|
1504 | - else |
|
1543 | + } else |
|
1505 | 1544 | { |
1506 | 1545 | print $langs->trans("NextDateToExecution"); |
1507 | 1546 | } |
@@ -1513,9 +1552,10 @@ discard block |
||
1513 | 1552 | //var_dump(dol_print_date($object->date_when+60, 'dayhour').' - '.dol_print_date($now, 'dayhour')); |
1514 | 1553 | if (! $object->isMaxNbGenReached()) |
1515 | 1554 | { |
1516 | - if (! $object->suspended && $action != 'editdate_when' && $object->frequency > 0 && $object->date_when && $object->date_when < $now) print img_warning($langs->trans("Late")); |
|
1517 | - } |
|
1518 | - else |
|
1555 | + if (! $object->suspended && $action != 'editdate_when' && $object->frequency > 0 && $object->date_when && $object->date_when < $now) { |
|
1556 | + print img_warning($langs->trans("Late")); |
|
1557 | + } |
|
1558 | + } else |
|
1519 | 1559 | { |
1520 | 1560 | print img_info($langs->trans("MaxNumberOfGenerationReached")); |
1521 | 1561 | } |
@@ -1527,8 +1567,7 @@ discard block |
||
1527 | 1567 | if ($action == 'nb_gen_max' || $object->frequency > 0) |
1528 | 1568 | { |
1529 | 1569 | print $form->editfieldkey($langs->trans("MaxPeriodNumber"), 'nb_gen_max', $object->nb_gen_max, $object, $user->rights->facture->creer); |
1530 | - } |
|
1531 | - else |
|
1570 | + } else |
|
1532 | 1571 | { |
1533 | 1572 | print $langs->trans("MaxPeriodNumber"); |
1534 | 1573 | } |
@@ -1536,8 +1575,7 @@ discard block |
||
1536 | 1575 | if ($action == 'nb_gen_max' || $object->frequency > 0) |
1537 | 1576 | { |
1538 | 1577 | print $form->editfieldval($langs->trans("MaxPeriodNumber"), 'nb_gen_max', $object->nb_gen_max?$object->nb_gen_max:'', $object, $user->rights->facture->creer); |
1539 | - } |
|
1540 | - else |
|
1578 | + } else |
|
1541 | 1579 | { |
1542 | 1580 | print ''; |
1543 | 1581 | } |
@@ -1546,10 +1584,11 @@ discard block |
||
1546 | 1584 | |
1547 | 1585 | // Status of generated invoices |
1548 | 1586 | print '<tr><td>'; |
1549 | - if ($action == 'auto_validate' || $object->frequency > 0) |
|
1550 | - print $form->editfieldkey($langs->trans("StatusOfGeneratedInvoices"), 'auto_validate', $object->auto_validate, $object, $user->rights->facture->creer); |
|
1551 | - else |
|
1552 | - print $langs->trans("StatusOfGeneratedInvoices"); |
|
1587 | + if ($action == 'auto_validate' || $object->frequency > 0) { |
|
1588 | + print $form->editfieldkey($langs->trans("StatusOfGeneratedInvoices"), 'auto_validate', $object->auto_validate, $object, $user->rights->facture->creer); |
|
1589 | + } else { |
|
1590 | + print $langs->trans("StatusOfGeneratedInvoices"); |
|
1591 | + } |
|
1553 | 1592 | print '</td><td>'; |
1554 | 1593 | $select = 'select;0:'.$langs->trans('BillStatusDraft').',1:'.$langs->trans('BillStatusValidated'); |
1555 | 1594 | if ($action == 'auto_validate' || $object->frequency > 0) |
@@ -1562,10 +1601,11 @@ discard block |
||
1562 | 1601 | { |
1563 | 1602 | print '<tr>'; |
1564 | 1603 | print '<td>'; |
1565 | - if ($action == 'generate_pdf' || $object->frequency > 0) |
|
1566 | - print $form->editfieldkey($langs->trans("StatusOfGeneratedDocuments"), 'generate_pdf', $object->generate_pdf, $object, $user->rights->facture->creer); |
|
1567 | - else |
|
1568 | - print $langs->trans("StatusOfGeneratedDocuments"); |
|
1604 | + if ($action == 'generate_pdf' || $object->frequency > 0) { |
|
1605 | + print $form->editfieldkey($langs->trans("StatusOfGeneratedDocuments"), 'generate_pdf', $object->generate_pdf, $object, $user->rights->facture->creer); |
|
1606 | + } else { |
|
1607 | + print $langs->trans("StatusOfGeneratedDocuments"); |
|
1608 | + } |
|
1569 | 1609 | print '</td>'; |
1570 | 1610 | print '<td>'; |
1571 | 1611 | $select = 'select;0:'.$langs->trans('DoNotGenerateDoc').',1:'.$langs->trans('AutogenerateDoc'); |
@@ -1575,8 +1615,7 @@ discard block |
||
1575 | 1615 | } |
1576 | 1616 | print '</td>'; |
1577 | 1617 | print '</tr>'; |
1578 | - } |
|
1579 | - else |
|
1618 | + } else |
|
1580 | 1619 | { |
1581 | 1620 | print '<input type="hidden" name="generate_pdf" value="1">'; |
1582 | 1621 | } |
@@ -1678,20 +1717,17 @@ discard block |
||
1678 | 1717 | if (! empty($object->frequency) && $object->nb_gen_max > 0 && ($object->nb_gen_done >= $object->nb_gen_max)) |
1679 | 1718 | { |
1680 | 1719 | print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("MaxGenerationReached")).'">'.$langs->trans("CreateBill").'</a></div>'; |
1681 | - } |
|
1682 | - else |
|
1720 | + } else |
|
1683 | 1721 | { |
1684 | 1722 | if (empty($object->frequency) || $object->date_when <= $today) |
1685 | 1723 | { |
1686 | 1724 | print '<div class="inline-block divButAction"><a class="butAction" href="' . BASE_URI . '?controller=compta/facture&method=card&action=create&socid=' . $object->thirdparty->id . '&fac_rec=' . $object->id . '">' . $langs->trans("CreateBill") . '</a></div>'; |
1687 | - } |
|
1688 | - else |
|
1725 | + } else |
|
1689 | 1726 | { |
1690 | 1727 | print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("DateIsNotEnough")).'">'.$langs->trans("CreateBill").'</a></div>'; |
1691 | 1728 | } |
1692 | 1729 | } |
1693 | - } |
|
1694 | - else |
|
1730 | + } else |
|
1695 | 1731 | { |
1696 | 1732 | print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#">'.$langs->trans("CreateBill").'</a></div>'; |
1697 | 1733 | } |
@@ -1702,8 +1738,7 @@ discard block |
||
1702 | 1738 | if (empty($object->suspended)) |
1703 | 1739 | { |
1704 | 1740 | print '<div class="inline-block divButAction"><a class="butActionDelete" href="' . BASE_URI . '?controller=compta/facture&method=fiche-rec&action=disable&id=' . $object->id . '">' . $langs->trans("Disable") . '</a></div>'; |
1705 | - } |
|
1706 | - else |
|
1741 | + } else |
|
1707 | 1742 | { |
1708 | 1743 | print '<div class="inline-block divButAction"><a class="butAction" href="' . BASE_URI . '?controller=compta/facture&method=fiche-rec&action=enable&id=' . $object->id . '">' . $langs->trans("Enable") . '</a></div>'; |
1709 | 1744 | } |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | require_once DOL_DOCUMENT_ROOT.'/core/lib/invoice.lib.php'; |
36 | 36 | |
37 | 37 | if (! empty($conf->projet->enabled)) { |
38 | - require_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php'; |
|
38 | + require_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php'; |
|
39 | 39 | } |
40 | 40 | |
41 | 41 | // Load translation files required by the page |
@@ -75,10 +75,10 @@ discard block |
||
75 | 75 | |
76 | 76 | if ($id > 0 || ! empty($ref)) |
77 | 77 | { |
78 | - $object = new Facture($db); |
|
79 | - $object->fetch($id,$ref); |
|
78 | + $object = new Facture($db); |
|
79 | + $object->fetch($id,$ref); |
|
80 | 80 | |
81 | - $object->fetch_thirdparty(); |
|
81 | + $object->fetch_thirdparty(); |
|
82 | 82 | |
83 | 83 | $head = facture_prepare_head($object); |
84 | 84 | |
@@ -99,35 +99,35 @@ discard block |
||
99 | 99 | // Project |
100 | 100 | if (! empty($conf->projet->enabled)) |
101 | 101 | { |
102 | - $langs->load("projects"); |
|
103 | - $morehtmlref.='<br>'.$langs->trans('Project') . ' '; |
|
104 | - if ($user->rights->facture->creer) |
|
105 | - { |
|
106 | - if ($action != 'classify') |
|
107 | - //$morehtmlref.='<a href="' . $_SERVER['PHP_SELF'] . '?action=classify&id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : '; |
|
108 | - $morehtmlref.=' : '; |
|
109 | - if ($action == 'classify') { |
|
110 | - //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); |
|
111 | - $morehtmlref.='<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">'; |
|
112 | - $morehtmlref.='<input type="hidden" name="action" value="classin">'; |
|
113 | - $morehtmlref.='<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
114 | - $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); |
|
115 | - $morehtmlref.='<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">'; |
|
116 | - $morehtmlref.='</form>'; |
|
117 | - } else { |
|
118 | - $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); |
|
119 | - } |
|
120 | - } else { |
|
121 | - if (! empty($object->fk_project)) { |
|
122 | - $proj = new Project($db); |
|
123 | - $proj->fetch($object->fk_project); |
|
102 | + $langs->load("projects"); |
|
103 | + $morehtmlref.='<br>'.$langs->trans('Project') . ' '; |
|
104 | + if ($user->rights->facture->creer) |
|
105 | + { |
|
106 | + if ($action != 'classify') |
|
107 | + //$morehtmlref.='<a href="' . $_SERVER['PHP_SELF'] . '?action=classify&id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : '; |
|
108 | + $morehtmlref.=' : '; |
|
109 | + if ($action == 'classify') { |
|
110 | + //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); |
|
111 | + $morehtmlref.='<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">'; |
|
112 | + $morehtmlref.='<input type="hidden" name="action" value="classin">'; |
|
113 | + $morehtmlref.='<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
114 | + $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); |
|
115 | + $morehtmlref.='<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">'; |
|
116 | + $morehtmlref.='</form>'; |
|
117 | + } else { |
|
118 | + $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); |
|
119 | + } |
|
120 | + } else { |
|
121 | + if (! empty($object->fk_project)) { |
|
122 | + $proj = new Project($db); |
|
123 | + $proj->fetch($object->fk_project); |
|
124 | 124 | $morehtmlref .= '<a href="' . BASE_URI . '?controller=projet&method=card&id=' . $object->fk_project . '" title="' . $langs->trans('ShowProject') . '">'; |
125 | - $morehtmlref.=$proj->ref; |
|
126 | - $morehtmlref.='</a>'; |
|
127 | - } else { |
|
128 | - $morehtmlref.=''; |
|
129 | - } |
|
130 | - } |
|
125 | + $morehtmlref.=$proj->ref; |
|
126 | + $morehtmlref.='</a>'; |
|
127 | + } else { |
|
128 | + $morehtmlref.=''; |
|
129 | + } |
|
130 | + } |
|
131 | 131 | } |
132 | 132 | $morehtmlref.='</div>'; |
133 | 133 | |
@@ -135,14 +135,14 @@ discard block |
||
135 | 135 | |
136 | 136 | dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref, '', 0); |
137 | 137 | |
138 | - print '<div class="fichecenter">'; |
|
139 | - print '<div class="underbanner clearboth"></div>'; |
|
138 | + print '<div class="fichecenter">'; |
|
139 | + print '<div class="underbanner clearboth"></div>'; |
|
140 | 140 | |
141 | 141 | |
142 | - $cssclass="titlefield"; |
|
142 | + $cssclass="titlefield"; |
|
143 | 143 | include DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php'; |
144 | 144 | |
145 | - dol_fiche_end(); |
|
145 | + dol_fiche_end(); |
|
146 | 146 | } |
147 | 147 | |
148 | 148 | // End of page |
@@ -29,54 +29,54 @@ discard block |
||
29 | 29 | |
30 | 30 | defined('BASE_PATH') or die('Single entry point through the index.php of the main folder'); |
31 | 31 | |
32 | -require DOL_BASE_PATH . '/main.inc.php'; |
|
32 | +require DOL_BASE_PATH.'/main.inc.php'; |
|
33 | 33 | require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; |
34 | 34 | require_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php'; |
35 | 35 | require_once DOL_DOCUMENT_ROOT.'/core/lib/invoice.lib.php'; |
36 | 36 | |
37 | -if (! empty($conf->projet->enabled)) { |
|
38 | - require_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php'; |
|
37 | +if (!empty($conf->projet->enabled)) { |
|
38 | + require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; |
|
39 | 39 | } |
40 | 40 | |
41 | 41 | // Load translation files required by the page |
42 | 42 | $langs->loadLangs(array('companies', 'bills')); |
43 | 43 | |
44 | -$id=(GETPOST('id','int')?GETPOST('id','int'):GETPOST('facid','int')); // For backward compatibility |
|
45 | -$ref=GETPOST('ref','alpha'); |
|
46 | -$socid=GETPOST('socid','int'); |
|
47 | -$action=GETPOST('action','alpha'); |
|
44 | +$id = (GETPOST('id', 'int') ?GETPOST('id', 'int') : GETPOST('facid', 'int')); // For backward compatibility |
|
45 | +$ref = GETPOST('ref', 'alpha'); |
|
46 | +$socid = GETPOST('socid', 'int'); |
|
47 | +$action = GETPOST('action', 'alpha'); |
|
48 | 48 | |
49 | 49 | // Security check |
50 | -$socid=0; |
|
51 | -if ($user->societe_id) $socid=$user->societe_id; |
|
52 | -$result=restrictedArea($user,'facture',$id,''); |
|
50 | +$socid = 0; |
|
51 | +if ($user->societe_id) $socid = $user->societe_id; |
|
52 | +$result = restrictedArea($user, 'facture', $id, ''); |
|
53 | 53 | |
54 | 54 | $object = new Facture($db); |
55 | 55 | $object->fetch($id); |
56 | 56 | |
57 | -$permissionnote=$user->rights->facture->creer; // Used by the include of actions_setnotes.inc.php |
|
57 | +$permissionnote = $user->rights->facture->creer; // Used by the include of actions_setnotes.inc.php |
|
58 | 58 | |
59 | 59 | |
60 | 60 | /* |
61 | 61 | * Actions |
62 | 62 | */ |
63 | 63 | |
64 | -include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not includ_once |
|
64 | +include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not includ_once |
|
65 | 65 | |
66 | 66 | /* |
67 | 67 | * View |
68 | 68 | */ |
69 | 69 | |
70 | -$title = $langs->trans('InvoiceCustomer') . " - " . $langs->trans('Notes'); |
|
70 | +$title = $langs->trans('InvoiceCustomer')." - ".$langs->trans('Notes'); |
|
71 | 71 | $helpurl = "EN:Customers_Invoices|FR:Factures_Clients|ES:Facturas_a_clientes"; |
72 | 72 | llxHeader('', $title, $helpurl); |
73 | 73 | |
74 | 74 | $form = new Form($db); |
75 | 75 | |
76 | -if ($id > 0 || ! empty($ref)) |
|
76 | +if ($id > 0 || !empty($ref)) |
|
77 | 77 | { |
78 | 78 | $object = new Facture($db); |
79 | - $object->fetch($id,$ref); |
|
79 | + $object->fetch($id, $ref); |
|
80 | 80 | |
81 | 81 | $object->fetch_thirdparty(); |
82 | 82 | |
@@ -88,50 +88,50 @@ discard block |
||
88 | 88 | |
89 | 89 | // Invoice content |
90 | 90 | |
91 | - $linkback = '<a href="' . BASE_URI . '?controller=compta/facture&method=list&restore_lastsearch_values=1' . (!empty($socid) ? '&socid=' . $socid : '') . '">' . $langs->trans("BackToList") . '</a>'; |
|
91 | + $linkback = '<a href="'.BASE_URI.'?controller=compta/facture&method=list&restore_lastsearch_values=1'.(!empty($socid) ? '&socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>'; |
|
92 | 92 | |
93 | - $morehtmlref='<div class="refidno">'; |
|
93 | + $morehtmlref = '<div class="refidno">'; |
|
94 | 94 | // Ref customer |
95 | - $morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1); |
|
96 | - $morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', null, null, '', 1); |
|
95 | + $morehtmlref .= $form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1); |
|
96 | + $morehtmlref .= $form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', null, null, '', 1); |
|
97 | 97 | // Thirdparty |
98 | - $morehtmlref.='<br>'.$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1,'customer'); |
|
98 | + $morehtmlref .= '<br>'.$langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1, 'customer'); |
|
99 | 99 | // Project |
100 | - if (! empty($conf->projet->enabled)) |
|
100 | + if (!empty($conf->projet->enabled)) |
|
101 | 101 | { |
102 | 102 | $langs->load("projects"); |
103 | - $morehtmlref.='<br>'.$langs->trans('Project') . ' '; |
|
103 | + $morehtmlref .= '<br>'.$langs->trans('Project').' '; |
|
104 | 104 | if ($user->rights->facture->creer) |
105 | 105 | { |
106 | 106 | if ($action != 'classify') |
107 | 107 | //$morehtmlref.='<a href="' . $_SERVER['PHP_SELF'] . '?action=classify&id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : '; |
108 | - $morehtmlref.=' : '; |
|
108 | + $morehtmlref .= ' : '; |
|
109 | 109 | if ($action == 'classify') { |
110 | 110 | //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); |
111 | - $morehtmlref.='<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">'; |
|
112 | - $morehtmlref.='<input type="hidden" name="action" value="classin">'; |
|
113 | - $morehtmlref.='<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
114 | - $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); |
|
115 | - $morehtmlref.='<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">'; |
|
116 | - $morehtmlref.='</form>'; |
|
111 | + $morehtmlref .= '<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">'; |
|
112 | + $morehtmlref .= '<input type="hidden" name="action" value="classin">'; |
|
113 | + $morehtmlref .= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
114 | + $morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); |
|
115 | + $morehtmlref .= '<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">'; |
|
116 | + $morehtmlref .= '</form>'; |
|
117 | 117 | } else { |
118 | - $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); |
|
118 | + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); |
|
119 | 119 | } |
120 | 120 | } else { |
121 | - if (! empty($object->fk_project)) { |
|
121 | + if (!empty($object->fk_project)) { |
|
122 | 122 | $proj = new Project($db); |
123 | 123 | $proj->fetch($object->fk_project); |
124 | - $morehtmlref .= '<a href="' . BASE_URI . '?controller=projet&method=card&id=' . $object->fk_project . '" title="' . $langs->trans('ShowProject') . '">'; |
|
125 | - $morehtmlref.=$proj->ref; |
|
126 | - $morehtmlref.='</a>'; |
|
124 | + $morehtmlref .= '<a href="'.BASE_URI.'?controller=projet&method=card&id='.$object->fk_project.'" title="'.$langs->trans('ShowProject').'">'; |
|
125 | + $morehtmlref .= $proj->ref; |
|
126 | + $morehtmlref .= '</a>'; |
|
127 | 127 | } else { |
128 | - $morehtmlref.=''; |
|
128 | + $morehtmlref .= ''; |
|
129 | 129 | } |
130 | 130 | } |
131 | 131 | } |
132 | - $morehtmlref.='</div>'; |
|
132 | + $morehtmlref .= '</div>'; |
|
133 | 133 | |
134 | - $object->totalpaye = $totalpaye; // To give a chance to dol_banner_tab to use already paid amount to show correct status |
|
134 | + $object->totalpaye = $totalpaye; // To give a chance to dol_banner_tab to use already paid amount to show correct status |
|
135 | 135 | |
136 | 136 | dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref, '', 0); |
137 | 137 | |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | print '<div class="underbanner clearboth"></div>'; |
140 | 140 | |
141 | 141 | |
142 | - $cssclass="titlefield"; |
|
142 | + $cssclass = "titlefield"; |
|
143 | 143 | include DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php'; |
144 | 144 | |
145 | 145 | dol_fiche_end(); |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; |
34 | 34 | require_once DOL_DOCUMENT_ROOT.'/core/lib/invoice.lib.php'; |
35 | 35 | if (! empty($conf->projet->enabled)) { |
36 | - include_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php'; |
|
36 | + include_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php'; |
|
37 | 37 | } |
38 | 38 | |
39 | 39 | // Load translation files required by the page |
@@ -77,35 +77,35 @@ discard block |
||
77 | 77 | // Project |
78 | 78 | if (! empty($conf->projet->enabled)) |
79 | 79 | { |
80 | - $langs->load("projects"); |
|
81 | - $morehtmlref.='<br>'.$langs->trans('Project') . ' '; |
|
82 | - if ($user->rights->facture->creer) |
|
83 | - { |
|
84 | - if ($action != 'classify') |
|
85 | - //$morehtmlref.='<a href="' . $_SERVER['PHP_SELF'] . '?action=classify&id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : '; |
|
86 | - $morehtmlref.=' : '; |
|
87 | - if ($action == 'classify') { |
|
88 | - //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); |
|
89 | - $morehtmlref.='<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">'; |
|
90 | - $morehtmlref.='<input type="hidden" name="action" value="classin">'; |
|
91 | - $morehtmlref.='<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
92 | - $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); |
|
93 | - $morehtmlref.='<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">'; |
|
94 | - $morehtmlref.='</form>'; |
|
95 | - } else { |
|
96 | - $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); |
|
97 | - } |
|
98 | - } else { |
|
99 | - if (! empty($object->fk_project)) { |
|
100 | - $proj = new Project($db); |
|
101 | - $proj->fetch($object->fk_project); |
|
80 | + $langs->load("projects"); |
|
81 | + $morehtmlref.='<br>'.$langs->trans('Project') . ' '; |
|
82 | + if ($user->rights->facture->creer) |
|
83 | + { |
|
84 | + if ($action != 'classify') |
|
85 | + //$morehtmlref.='<a href="' . $_SERVER['PHP_SELF'] . '?action=classify&id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : '; |
|
86 | + $morehtmlref.=' : '; |
|
87 | + if ($action == 'classify') { |
|
88 | + //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); |
|
89 | + $morehtmlref.='<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">'; |
|
90 | + $morehtmlref.='<input type="hidden" name="action" value="classin">'; |
|
91 | + $morehtmlref.='<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
92 | + $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); |
|
93 | + $morehtmlref.='<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">'; |
|
94 | + $morehtmlref.='</form>'; |
|
95 | + } else { |
|
96 | + $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); |
|
97 | + } |
|
98 | + } else { |
|
99 | + if (! empty($object->fk_project)) { |
|
100 | + $proj = new Project($db); |
|
101 | + $proj->fetch($object->fk_project); |
|
102 | 102 | $morehtmlref .= '<a href="' . BASE_URI . '?controller=projet&method=card&id=' . $object->fk_project . '" title="' . $langs->trans('ShowProject') . '">'; |
103 | - $morehtmlref.=$proj->ref; |
|
104 | - $morehtmlref.='</a>'; |
|
105 | - } else { |
|
106 | - $morehtmlref.=''; |
|
107 | - } |
|
108 | - } |
|
103 | + $morehtmlref.=$proj->ref; |
|
104 | + $morehtmlref.='</a>'; |
|
105 | + } else { |
|
106 | + $morehtmlref.=''; |
|
107 | + } |
|
108 | + } |
|
109 | 109 | } |
110 | 110 | $morehtmlref.='</div>'; |
111 | 111 |
@@ -27,20 +27,20 @@ discard block |
||
27 | 27 | |
28 | 28 | defined('BASE_PATH') or die('Single entry point through the index.php of the main folder'); |
29 | 29 | |
30 | -require DOL_BASE_PATH . '/main.inc.php'; |
|
30 | +require DOL_BASE_PATH.'/main.inc.php'; |
|
31 | 31 | require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; |
32 | 32 | require_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php'; |
33 | 33 | require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; |
34 | 34 | require_once DOL_DOCUMENT_ROOT.'/core/lib/invoice.lib.php'; |
35 | -if (! empty($conf->projet->enabled)) { |
|
36 | - include_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php'; |
|
35 | +if (!empty($conf->projet->enabled)) { |
|
36 | + include_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; |
|
37 | 37 | } |
38 | 38 | |
39 | 39 | // Load translation files required by the page |
40 | 40 | $langs->loadLangs(array('companies', 'bills')); |
41 | 41 | |
42 | -$id = GETPOST("facid","int"); |
|
43 | -$ref=GETPOST("ref",'alpha'); |
|
42 | +$id = GETPOST("facid", "int"); |
|
43 | +$ref = GETPOST("ref", 'alpha'); |
|
44 | 44 | |
45 | 45 | |
46 | 46 | /* |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | |
50 | 50 | $form = new Form($db); |
51 | 51 | |
52 | -$title = $langs->trans('InvoiceCustomer') . " - " . $langs->trans('Info'); |
|
52 | +$title = $langs->trans('InvoiceCustomer')." - ".$langs->trans('Info'); |
|
53 | 53 | $helpurl = "EN:Customers_Invoices|FR:Factures_Clients|ES:Facturas_a_clientes"; |
54 | 54 | llxHeader('', $title, $helpurl); |
55 | 55 | |
@@ -66,50 +66,50 @@ discard block |
||
66 | 66 | |
67 | 67 | // Invoice content |
68 | 68 | |
69 | -$linkback = '<a href="' . BASE_URL . '?controller=compta/facture&method=list&restore_lastsearch_values=1' . (!empty($socid) ? '&socid=' . $socid : '') . '">' . $langs->trans("BackToList") . '</a>'; |
|
69 | +$linkback = '<a href="'.BASE_URL.'?controller=compta/facture&method=list&restore_lastsearch_values=1'.(!empty($socid) ? '&socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>'; |
|
70 | 70 | |
71 | -$morehtmlref='<div class="refidno">'; |
|
71 | +$morehtmlref = '<div class="refidno">'; |
|
72 | 72 | // Ref customer |
73 | -$morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1); |
|
74 | -$morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', null, null, '', 1); |
|
73 | +$morehtmlref .= $form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1); |
|
74 | +$morehtmlref .= $form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', null, null, '', 1); |
|
75 | 75 | // Thirdparty |
76 | -$morehtmlref.='<br>'.$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1,'customer'); |
|
76 | +$morehtmlref .= '<br>'.$langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1, 'customer'); |
|
77 | 77 | // Project |
78 | -if (! empty($conf->projet->enabled)) |
|
78 | +if (!empty($conf->projet->enabled)) |
|
79 | 79 | { |
80 | 80 | $langs->load("projects"); |
81 | - $morehtmlref.='<br>'.$langs->trans('Project') . ' '; |
|
81 | + $morehtmlref .= '<br>'.$langs->trans('Project').' '; |
|
82 | 82 | if ($user->rights->facture->creer) |
83 | 83 | { |
84 | 84 | if ($action != 'classify') |
85 | 85 | //$morehtmlref.='<a href="' . $_SERVER['PHP_SELF'] . '?action=classify&id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : '; |
86 | - $morehtmlref.=' : '; |
|
86 | + $morehtmlref .= ' : '; |
|
87 | 87 | if ($action == 'classify') { |
88 | 88 | //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); |
89 | - $morehtmlref.='<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">'; |
|
90 | - $morehtmlref.='<input type="hidden" name="action" value="classin">'; |
|
91 | - $morehtmlref.='<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
92 | - $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); |
|
93 | - $morehtmlref.='<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">'; |
|
94 | - $morehtmlref.='</form>'; |
|
89 | + $morehtmlref .= '<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">'; |
|
90 | + $morehtmlref .= '<input type="hidden" name="action" value="classin">'; |
|
91 | + $morehtmlref .= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
92 | + $morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); |
|
93 | + $morehtmlref .= '<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">'; |
|
94 | + $morehtmlref .= '</form>'; |
|
95 | 95 | } else { |
96 | - $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); |
|
96 | + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); |
|
97 | 97 | } |
98 | 98 | } else { |
99 | - if (! empty($object->fk_project)) { |
|
99 | + if (!empty($object->fk_project)) { |
|
100 | 100 | $proj = new Project($db); |
101 | 101 | $proj->fetch($object->fk_project); |
102 | - $morehtmlref .= '<a href="' . BASE_URI . '?controller=projet&method=card&id=' . $object->fk_project . '" title="' . $langs->trans('ShowProject') . '">'; |
|
103 | - $morehtmlref.=$proj->ref; |
|
104 | - $morehtmlref.='</a>'; |
|
102 | + $morehtmlref .= '<a href="'.BASE_URI.'?controller=projet&method=card&id='.$object->fk_project.'" title="'.$langs->trans('ShowProject').'">'; |
|
103 | + $morehtmlref .= $proj->ref; |
|
104 | + $morehtmlref .= '</a>'; |
|
105 | 105 | } else { |
106 | - $morehtmlref.=''; |
|
106 | + $morehtmlref .= ''; |
|
107 | 107 | } |
108 | 108 | } |
109 | 109 | } |
110 | -$morehtmlref.='</div>'; |
|
110 | +$morehtmlref .= '</div>'; |
|
111 | 111 | |
112 | -$object->totalpaye = $totalpaye; // To give a chance to dol_banner_tab to use already paid amount to show correct status |
|
112 | +$object->totalpaye = $totalpaye; // To give a chance to dol_banner_tab to use already paid amount to show correct status |
|
113 | 113 | |
114 | 114 | dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref, '', 0); |
115 | 115 |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | |
29 | 29 | // Copyright (C) 2018 Alxarafe/Alixar <[email protected]> |
30 | 30 | defined('BASE_PATH') or die('Single entry point through the index.php of the main folder'); |
31 | -require DOL_BASE_PATH . '/main.inc.php'; |
|
31 | +require DOL_BASE_PATH.'/main.inc.php'; |
|
32 | 32 | require_once DOL_DOCUMENT_ROOT.'/core/lib/invoice.lib.php'; |
33 | 33 | require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; |
34 | 34 | |
@@ -39,13 +39,13 @@ discard block |
||
39 | 39 | $form = new Form($db); |
40 | 40 | |
41 | 41 | // List of supported format |
42 | -$tmptype2label=ExtraFields::$type2label; |
|
43 | -$type2label=array(''); |
|
44 | -foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->transnoentitiesnoconv($val); |
|
42 | +$tmptype2label = ExtraFields::$type2label; |
|
43 | +$type2label = array(''); |
|
44 | +foreach ($tmptype2label as $key => $val) $type2label[$key] = $langs->transnoentitiesnoconv($val); |
|
45 | 45 | |
46 | -$action=GETPOST('action', 'alpha'); |
|
47 | -$attrname=GETPOST('attrname', 'alpha'); |
|
48 | -$elementtype='facture'; //Must be the $table_element of the class that manage extrafield |
|
46 | +$action = GETPOST('action', 'alpha'); |
|
47 | +$attrname = GETPOST('attrname', 'alpha'); |
|
48 | +$elementtype = 'facture'; //Must be the $table_element of the class that manage extrafield |
|
49 | 49 | |
50 | 50 | if (!$user->admin) accessforbidden(); |
51 | 51 | |
@@ -62,13 +62,13 @@ discard block |
||
62 | 62 | * View |
63 | 63 | */ |
64 | 64 | |
65 | -$textobject=strtolower($langs->transnoentitiesnoconv("BillsCustomers")); |
|
65 | +$textobject = strtolower($langs->transnoentitiesnoconv("BillsCustomers")); |
|
66 | 66 | |
67 | -llxHeader('',$langs->trans("BillsSetup")); |
|
67 | +llxHeader('', $langs->trans("BillsSetup")); |
|
68 | 68 | |
69 | -$linkback = '<a href="' . BASE_URI . '?controller=admin&method=modules&restore_lastsearch_values=1">' . $langs->trans("BackToModuleList") . '</a>'; |
|
69 | +$linkback = '<a href="'.BASE_URI.'?controller=admin&method=modules&restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>'; |
|
70 | 70 | |
71 | -print load_fiche_titre($langs->trans("BillsSetup"),$linkback,'title_setup'); |
|
71 | +print load_fiche_titre($langs->trans("BillsSetup"), $linkback, 'title_setup'); |
|
72 | 72 | |
73 | 73 | $head = invoice_admin_prepare_head(); |
74 | 74 | |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | /* Edition of an optional field */ |
108 | 108 | /* */ |
109 | 109 | /* ************************************************************************** */ |
110 | -if ($action == 'edit' && ! empty($attrname)) |
|
110 | +if ($action == 'edit' && !empty($attrname)) |
|
111 | 111 | { |
112 | 112 | $langs->load("members"); |
113 | 113 |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | |
30 | 30 | // Copyright (C) 2018 Alxarafe/Alixar <[email protected]> |
31 | 31 | defined('BASE_PATH') or die('Single entry point through the index.php of the main folder'); |
32 | -require DOL_BASE_PATH . '/main.inc.php'; |
|
32 | +require DOL_BASE_PATH.'/main.inc.php'; |
|
33 | 33 | require_once DOL_DOCUMENT_ROOT.'/core/lib/invoice.lib.php'; |
34 | 34 | require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; |
35 | 35 | |
@@ -40,13 +40,13 @@ discard block |
||
40 | 40 | $form = new Form($db); |
41 | 41 | |
42 | 42 | // List of supported format |
43 | -$tmptype2label=ExtraFields::$type2label; |
|
44 | -$type2label=array(''); |
|
45 | -foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->transnoentitiesnoconv($val); |
|
43 | +$tmptype2label = ExtraFields::$type2label; |
|
44 | +$type2label = array(''); |
|
45 | +foreach ($tmptype2label as $key => $val) $type2label[$key] = $langs->transnoentitiesnoconv($val); |
|
46 | 46 | |
47 | -$action=GETPOST('action', 'alpha'); |
|
48 | -$attrname=GETPOST('attrname', 'alpha'); |
|
49 | -$elementtype='facture_rec'; //Must be the $table_element of the class that manage extrafield |
|
47 | +$action = GETPOST('action', 'alpha'); |
|
48 | +$attrname = GETPOST('attrname', 'alpha'); |
|
49 | +$elementtype = 'facture_rec'; //Must be the $table_element of the class that manage extrafield |
|
50 | 50 | |
51 | 51 | if (!$user->admin) accessforbidden(); |
52 | 52 | |
@@ -63,13 +63,13 @@ discard block |
||
63 | 63 | * View |
64 | 64 | */ |
65 | 65 | |
66 | -$textobject=strtolower($langs->transnoentitiesnoconv("BillsCustomers")); |
|
66 | +$textobject = strtolower($langs->transnoentitiesnoconv("BillsCustomers")); |
|
67 | 67 | |
68 | -llxHeader('',$langs->trans("BillsSetup")); |
|
68 | +llxHeader('', $langs->trans("BillsSetup")); |
|
69 | 69 | |
70 | -$linkback = '<a href="' . BASE_URI . '?controller=admin&method=modules&restore_lastsearch_values=1">' . $langs->trans("BackToModuleList") . '</a>'; |
|
70 | +$linkback = '<a href="'.BASE_URI.'?controller=admin&method=modules&restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>'; |
|
71 | 71 | |
72 | -print load_fiche_titre($langs->trans("BillsSetup"),$linkback,'title_setup'); |
|
72 | +print load_fiche_titre($langs->trans("BillsSetup"), $linkback, 'title_setup'); |
|
73 | 73 | |
74 | 74 | $head = invoice_admin_prepare_head(); |
75 | 75 | |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | /* Edition of an optional field */ |
109 | 109 | /* */ |
110 | 110 | /* ************************************************************************** */ |
111 | -if ($action == 'edit' && ! empty($attrname)) |
|
111 | +if ($action == 'edit' && !empty($attrname)) |
|
112 | 112 | { |
113 | 113 | $langs->load("members"); |
114 | 114 |