28 if (!defined(
'NOSESSION')) {
29 define(
'NOSESSION',
'1');
34 require_once $path.
"../../htdocs/master.inc.php";
35 require_once DOL_DOCUMENT_ROOT.
'/core/lib/report.lib.php';
36 require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
38 $langs->loadLangs(array(
"companies",
"compta",
"main",
"accountancy"));
49 $month_current = strftime(
"%m",
dol_now());
50 $year_start = $year_current;
52 $year_current = $year;
53 $month_current = strftime(
"%m",
dol_now());
56 $date_start =
dol_mktime(0, 0, 0, $date_startmonth, $date_startday, $date_startyear);
57 $date_end =
dol_mktime(23, 59, 59, $date_endmonth, $date_endday, $date_endyear);
60 if (empty($date_start) || empty($date_end)) {
64 $year_end = $year_start;
65 $month_start =
GETPOST(
"month") ?
GETPOST(
"month") : ($conf->global->SOCIETE_FISCAL_MONTH_START ? ($conf->global->SOCIETE_FISCAL_MONTH_START) : 1);
67 if (!
GETPOST(
"year") && $month_start > $month_current) {
71 $month_end = $month_start - 1;
78 $month_end = $month_start;
113 $nom = $langs->trans(
"ReportThirdParty");
114 $period =
$form->selectDate($date_start,
'date_start', 0, 0, 0,
'', 1, 0).
' - '.
$form->selectDate($date_end,
'date_end', 0, 0, 0,
'', 1, 0);
115 $description = $langs->trans(
"DescThirdPartyReport");
118 $moreparam = array(
'action' =>
'');
119 report_header($nom, $nomlink, $period, $periodlink, $description, $builddate, $exportlink, $moreparam);
121 print
'<input type="button" class="button" style="float: right;" value="Export CSV" onclick="launch_export();" />';
124 <script type="text/javascript">
125 function launch_export()
127 $("div.fiche div.tabBar form input[name=\"action\"]").val("export_csv");
128 $("div.fiche div.tabBar form input[type=\"submit\"]").click();
129 $("div.fiche div.tabBar form input[name=\"action\"]").val();
133 $sql =
"(SELECT s.rowid, s.nom as name , s.address, s.zip , s.town";
134 if (!empty($conf->global->MAIN_COMPANY_PERENTITY_SHARED)) {
135 $sql .=
", spe.accountancy_code_customer as compta";
137 $sql .=
", s.code_compta";
139 $sql .=
", s.fk_forme_juridique , s.fk_pays , s.phone , s.fax , f.datec , f.fk_soc , cp.label as country ";
140 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s";
141 if (!empty($conf->global->MAIN_COMPANY_PERENTITY_SHARED)) {
142 $sql .=
" LEFT JOIN " . MAIN_DB_PREFIX .
"societe_perentity as spe ON spe.fk_soc = s.rowid AND spe.entity = " . ((int) $conf->entity);
144 $sql .=
", ".MAIN_DB_PREFIX.
"facture as f";
145 $sql .=
", ".MAIN_DB_PREFIX.
"c_country as cp";
146 $sql .=
" WHERE f.fk_soc = s.rowid";
147 $sql .=
" AND s.fk_pays = cp.rowid";
148 if (!empty($date_start) && !empty($date_end)) {
149 $sql .=
" AND f.datec >= '".$db->idate($date_start).
"' AND f.datec <= '".$db->idate($date_end).
"'";
151 $sql .=
" AND f.entity IN (".getEntity(
'invoice', 0).
")";
153 $sql .=
" AND f.fk_soc = ".((int) $socid);
155 $sql .=
" GROUP BY name";
157 $sql .=
"UNION (SELECT s.rowid, s.nom as name , s.address, s.zip , s.town, , ";
158 if (!empty($conf->global->MAIN_COMPANY_PERENTITY_SHARED)) {
159 $sql .=
", spe.accountancy_code_supplier as compta";
161 $sql .=
", s.code_compta_fournisseur as compta";
163 $sql .=
" s.fk_forme_juridique , s.fk_pays , s.phone , s.fax , ff.datec , ff.fk_soc , cp.label as country ";
164 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s";
165 if (!empty($conf->global->MAIN_COMPANY_PERENTITY_SHARED)) {
166 $sql .=
" LEFT JOIN " . MAIN_DB_PREFIX .
"societe_perentity as spe ON spe.fk_soc = s.rowid AND spe.entity = " . ((int) $conf->entity);
168 $sql .=
", ".MAIN_DB_PREFIX.
"facture_fourn as ff";
169 $sql .=
", ".MAIN_DB_PREFIX.
"c_country as cp";
170 $sql .=
" WHERE ff.fk_soc = s.rowid";
171 $sql .=
" AND s.fk_pays = cp.rowid";
172 if (!empty($date_start) && !empty($date_end)) {
173 $sql .=
" AND ff.datec >= '".$db->idate($date_start).
"' AND ff.datec <= '".$db->idate($date_end).
"'";
175 $sql .=
" AND ff.entity = ".$conf->entity;
177 $sql .=
" AND f.fk_soc = ".((int) $socid);
179 $sql .=
" GROUP BY name";
182 $sql .=
"ORDER BY name ASC";
184 dol_syslog(
'accountancy/admin/thirdpartyaccount.php:: $sql='.$sql);
185 $resql = $db->query($sql);
187 $num = $db->num_rows(
$resql);
191 if (
GETPOST(
'action',
'aZ09') ==
'export_csv') {
192 header(
'Content-Type: text/csv');
193 header(
'Content-Disposition: attachment;filename=export_csv.csv');
195 $obj = $db->fetch_object(
$resql);
197 print
'"'.$obj->compta.
'",';
198 print
'"'.$obj->address.
'",';
199 print
'"'.$obj->zip.
'",';
200 print
'"'.$obj->town.
'",';
201 print
'"'.$obj->country.
'",';
202 print
'"'.$obj->phone.
'",';
203 print
'"'.$obj->fax.
'",';
209 $thirdpartystatic =
new Societe($db);
213 print
'<table class="noborder centpercent">';
215 print
'</td><td valign="top" width="70%" class="notopnoleftnoright"></td>';
216 print
'</tr><tr><td colspan=2>';
217 print
'<table class="noborder centpercent">';
218 print
'<tr class="liste_titre"><td class="left">'.$langs->trans(
"ThirdParties").
'</td>';
219 print
'<td class="left">'.$langs->trans(
"AccountNumber").
'</td>';
220 print
'<td class="left">'.$langs->trans(
"RaisonSociale").
'</td>';
221 print
'<td class="left">'.$langs->trans(
"Address").
'</td>';
222 print
'<td class="left">'.$langs->trans(
"Zip").
'</td>';
223 print
'<td class="left">'.$langs->trans(
"Town").
'</td>';
224 print
'<td class="left">'.$langs->trans(
"Country").
'</td>';
225 print
'<td class="left">'.$langs->trans(
"Contact").
'</td>';
226 print
'<td class="left">'.$langs->trans(
"Phone").
'</td>';
227 print
'<td class="left">'.$langs->trans(
"Fax").
'</td></tr>';
229 while ($obj = $db->fetch_object(
$resql)) {
230 print
'<tr class="oddeven">';
232 $thirdpartystatic->id = $obj->rowid;
233 $thirdpartystatic->name = $obj->name;
234 $thirdpartystatic->client = $obj->client;
235 $thirdpartystatic->canvas = $obj->canvas;
236 $thirdpartystatic->status = $obj->status;
237 print $thirdpartystatic->getNomUrl(1);
239 print
'<td class="left">'.$obj->compta.
'</td>'.
"\n";
240 print
'<td class="left"></td>';
241 print
'<td class="left">'.$obj->address.
'</td>';
242 print
'<td class="left">'.$obj->zip.
'</td>';
243 print
'<td class="left">'.$obj->town.
'</td>';
244 print
'<td class="left">'.$obj->country.
'</td>';
245 print
'<td class="left"></td>';
246 print
'<td class="left">'.$obj->phone.
'</td>';
247 print
'<td class="left">'.$obj->fax.
'</td>';
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
Class to manage third parties objects (customers, suppliers, prospects...)
if(isModEnabled('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') &&!empty($user->rights->don->lire)) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
dol_get_first_day($year, $month=1, $gm=false)
Return GMT time for first day of a month or year.
dol_get_last_day($year, $month=12, $gm=false)
Return GMT time for last day of a month or year.
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_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dol_now($mode='auto')
Return date for now.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
report_header($reportname, $notused, $period, $periodlink, $description, $builddate, $exportlink='', $moreparam=array(), $calcmode='', $varlink='')
Show header of a report.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.