28 if (!defined(
'NOSESSION')) define(
'NOSESSION',
'1');
32 require_once $path.
"../../htdocs/master.inc.php";
33 require_once DOL_DOCUMENT_ROOT.
'/core/lib/report.lib.php';
34 require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
36 $langs->loadLangs(array(
"companies",
"compta",
"main",
"accountancy"));
45 $year_current = strftime(
"%Y",
dol_now());
46 $month_current = strftime(
"%m",
dol_now());
47 $year_start = $year_current;
49 $year_current = $year;
50 $month_current = strftime(
"%m",
dol_now());
53 $date_start =
dol_mktime(0, 0, 0, $date_startmonth, $date_startday, $date_startyear);
54 $date_end =
dol_mktime(23, 59, 59, $date_endmonth, $date_endday, $date_endyear);
57 if (empty($date_start) || empty($date_end))
62 $year_end = $year_start;
63 $month_start =
GETPOST(
"month") ?
GETPOST(
"month") : ($conf->global->SOCIETE_FISCAL_MONTH_START ? ($conf->global->SOCIETE_FISCAL_MONTH_START) : 1);
65 if (!
GETPOST(
"year") && $month_start > $month_current) {
69 $month_end = $month_start - 1;
73 }
else $month_end = $month_start;
98 $form =
new Form($db);
104 $nom = $langs->trans(
"ReportThirdParty");
105 $period = $form->selectDate($date_start,
'date_start', 0, 0, 0,
'', 1, 0).
' - '.$form->selectDate($date_end,
'date_end', 0, 0, 0,
'', 1, 0);
106 $description = $langs->trans(
"DescThirdPartyReport");
109 $moreparam = array(
'action' =>
'');
110 report_header($nom, $nomlink, $period, $periodlink, $description, $builddate, $exportlink, $moreparam);
112 print '<input type="button" class="button" style="float: right;" value="Export CSV" onclick="launch_export();" />';
115 <script type="text/javascript">
116 function launch_export()
118 $("div.fiche div.tabBar form input[name=\"action\"]").val("export_csv");
119 $("div.fiche div.tabBar form input[type=\"submit\"]").click();
120 $("div.fiche div.tabBar form input[name=\"action\"]").val();
124 $sql =
"(SELECT s.rowid, s.nom as name , s.address, s.zip , s.town, s.code_compta as compta , ";
125 $sql .=
" s.fk_forme_juridique , s.fk_pays , s.phone , s.fax , f.datec , f.fk_soc , cp.label as country ";
126 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s";
127 $sql .=
", ".MAIN_DB_PREFIX.
"facture as f";
128 $sql .=
", ".MAIN_DB_PREFIX.
"c_country as cp";
129 $sql .=
" WHERE f.fk_soc = s.rowid";
130 $sql .=
" AND s.fk_pays = cp.rowid";
131 if (!empty($date_start) && !empty($date_end))
132 $sql .=
" AND f.datec >= '".$db->idate($date_start).
"' AND f.datec <= '".$db->idate($date_end).
"'";
133 $sql .=
" AND f.entity IN (".getEntity(
'invoice', 0).
")";
135 $sql .=
" AND f.fk_soc = ".$socid;
136 $sql .=
" GROUP BY name";
138 $sql .=
"UNION (SELECT s.rowid, s.nom as name , s.address, s.zip , s.town, s.code_compta_fournisseur as compta , ";
139 $sql .=
" s.fk_forme_juridique , s.fk_pays , s.phone , s.fax , ff.datec , ff.fk_soc , cp.label as country ";
140 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s";
141 $sql .=
", ".MAIN_DB_PREFIX.
"facture_fourn as ff";
142 $sql .=
", ".MAIN_DB_PREFIX.
"c_country as cp";
143 $sql .=
" WHERE ff.fk_soc = s.rowid";
144 $sql .=
" AND s.fk_pays = cp.rowid";
145 if (!empty($date_start) && !empty($date_end))
146 $sql .=
" AND ff.datec >= '".$db->idate($date_start).
"' AND ff.datec <= '".$db->idate($date_end).
"'";
147 $sql .=
" AND ff.entity = ".$conf->entity;
149 $sql .=
" AND f.fk_soc = ".$socid;
150 $sql .=
" GROUP BY name";
153 $sql .=
"ORDER BY name ASC";
155 dol_syslog(
'accountancy/admin/thirdpartyaccount.php:: $sql='.$sql);
156 $resql = $db->query($sql);
158 $num = $db->num_rows(
$resql);
162 if (
GETPOST(
'action',
'aZ09') ==
'export_csv') {
163 header(
'Content-Type: text/csv');
164 header(
'Content-Disposition: attachment;filename=export_csv.csv');
166 $obj = $db->fetch_object(
$resql);
168 print '"'.$obj->compta.
'",';
169 print '"'.$obj->address.
'",';
170 print '"'.$obj->zip.
'",';
171 print '"'.$obj->town.
'",';
172 print '"'.$obj->country.
'",';
173 print '"'.$obj->phone.
'",';
174 print '"'.$obj->fax.
'",';
183 $thirdpartystatic =
new Societe($db);
187 print '<table class="noborder centpercent">';
189 print '</td><td valign="top" width="70%" class="notopnoleftnoright"></td>';
190 print '</tr><tr><td colspan=2>';
191 print '<table class="noborder centpercent">';
192 print '<tr class="liste_titre"><td class="left">'.$langs->trans(
"ThirdParties").
'</td>';
193 print '<td class="left">'.$langs->trans(
"AccountNumber").
'</td>';
194 print '<td class="left">'.$langs->trans(
"RaisonSociale").
'</td>';
195 print '<td class="left">'.$langs->trans(
"Address").
'</td>';
196 print '<td class="left">'.$langs->trans(
"Zip").
'</td>';
197 print '<td class="left">'.$langs->trans(
"Town").
'</td>';
198 print '<td class="left">'.$langs->trans(
"Country").
'</td>';
199 print '<td class="left">'.$langs->trans(
"Contact").
'</td>';
200 print '<td class="left">'.$langs->trans(
"Phone").
'</td>';
201 print '<td class="left">'.$langs->trans(
"Fax").
'</td></tr>';
203 while ($obj = $db->fetch_object(
$resql))
205 print '<tr class="oddeven">';
207 $thirdpartystatic->id = $obj->rowid;
208 $thirdpartystatic->name = $obj->name;
209 $thirdpartystatic->client = $obj->client;
210 $thirdpartystatic->canvas = $obj->canvas;
211 $thirdpartystatic->status = $obj->status;
212 print $thirdpartystatic->getNomUrl(1);
214 print '<td class="left">'.$obj->compta.
'</td>'.
"\n";
215 print '<td class="left"></td>';
216 print '<td class="left">'.$obj->address.
'</td>';
217 print '<td class="left">'.$obj->zip.
'</td>';
218 print '<td class="left">'.$obj->town.
'</td>';
219 print '<td class="left">'.$obj->country.
'</td>';
220 print '<td class="left"></td>';
221 print '<td class="left">'.$obj->phone.
'</td>';
222 print '<td class="left">'.$obj->fax.
'</td>';
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm= 'auto', $check=1)
Return a timestamp date built from detailed informations (by default a local PHP server timestamp) Re...
dol_now($mode= 'auto')
Return date for now.
report_header($reportname, $notused, $period, $periodlink, $description, $builddate, $exportlink= '', $moreparam=array(), $calcmode= '', $varlink= '')
Show header of a report.
dol_get_first_day($year, $month=1, $gm=false)
Return GMT time for first day of a month or year.
Class to manage third parties objects (customers, suppliers, prospects...)
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename= '', $restricttologhandler= '', $logcontext=null)
Write log message into outputs.
accessforbidden($message= '', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program Calling this function terminate execution ...
dol_get_last_day($year, $month=12, $gm=false)
Return GMT time for last day of a month or year.
print
Draft customers invoices.
if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) if(!empty($conf->don->enabled)&&$user->rights->don->lire) if(!empty($conf->tax->enabled)&&$user->rights->tax->charges->lire) if(!empty($conf->facture->enabled)&&!empty($conf->commande->enabled)&&$user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...