* Copyright (C) 2004-2015 Laurent Destailleur * Copyright (C) 2004 Eric Seigne * Copyright (C) 2006 Andre Cianfarani * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2008 Raphael Bertrand (Resultic) * Copyright (C) 2010-2014 Juanjo Menent * Copyright (C) 2013 Alexandre Spangaro * Copyright (C) 2015 Frederic France * Copyright (C) 2015 Marcos GarcĂ­a * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ /** * \file htdocs/comm/card.php * \ingroup commercial compta * \brief Page to show customer card of a third party */ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/societe/class/client.class.php'; require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php'; if (! empty($conf->facture->enabled)) require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; if (! empty($conf->propal->enabled)) require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; if (! empty($conf->commande->enabled)) require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; if (! empty($conf->expedition->enabled)) require_once DOL_DOCUMENT_ROOT.'/expedition/class/expedition.class.php'; if (! empty($conf->contrat->enabled)) require_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php'; if (! empty($conf->adherent->enabled)) require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; if (! empty($conf->ficheinter->enabled)) require_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php'; $langs->load("companies"); if (! empty($conf->contrat->enabled)) $langs->load("contracts"); if (! empty($conf->commande->enabled)) $langs->load("orders"); if (! empty($conf->expedition->enabled)) $langs->load("sendings"); if (! empty($conf->facture->enabled)) $langs->load("bills"); if (! empty($conf->projet->enabled)) $langs->load("projects"); if (! empty($conf->ficheinter->enabled)) $langs->load("interventions"); if (! empty($conf->notification->enabled)) $langs->load("mails"); // Security check $id = (GETPOST('socid','int') ? GETPOST('socid','int') : GETPOST('id','int')); if ($user->societe_id > 0) $id=$user->societe_id; $result = restrictedArea($user,'societe',$id,'&societe'); $action = GETPOST('action'); $mode = GETPOST("mode"); $modesearch = GETPOST("mode_search"); $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); $page = GETPOST("page",'int'); if ($page == -1) { $page = 0; } $offset = $conf->liste_limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; if (! $sortorder) $sortorder="ASC"; if (! $sortfield) $sortfield="nom"; $cancelbutton = GETPOST('cancel'); $object = new Client($db); $extrafields = new ExtraFields($db); // fetch optionals attributes and labels $extralabels=$extrafields->fetch_name_optionals_label($object->table_element); // Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array $hookmanager->initHooks(array('commcard','globalcard')); /* * Actions */ $parameters = array('socid' => $id); $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); if (empty($reshook)) { if ($cancelbutton) { $action=""; } // set accountancy code if ($action == 'setcustomeraccountancycode') { $result=$object->fetch($id); $object->code_compta=$_POST["customeraccountancycode"]; $result=$object->update($object->id,$user,1,1,0); if ($result < 0) setEventMessage($object->error,$object->errors,'errors'); } // conditions de reglement if ($action == 'setconditions' && $user->rights->societe->creer) { $object->fetch($id); $result=$object->setPaymentTerms(GETPOST('cond_reglement_id','int')); if ($result < 0) setEventMessage($object->error,$object->errors,'errors'); } // mode de reglement if ($action == 'setmode' && $user->rights->societe->creer) { $object->fetch($id); $result=$object->setPaymentMethods(GETPOST('mode_reglement_id','int')); if ($result < 0) setEventMessage($object->error,$object->errors,'errors'); } // assujetissement a la TVA if ($action == 'setassujtva' && $user->rights->societe->creer) { $object->fetch($id); $object->tva_assuj=$_POST['assujtva_value']; $result=$object->update($object->id); if ($result < 0) setEventMessage($object->error,$object->errors,'errors'); } // set prospect level if ($action == 'setprospectlevel' && $user->rights->societe->creer) { $object->fetch($id); $object->fk_prospectlevel=GETPOST('prospect_level_id','alpha'); $result=$object->set_prospect_level($user); if ($result < 0) setEventMessage($object->error,$object->errors,'errors'); } // set communication status if ($action == 'setstcomm') { $object->fetch($id); $object->stcomm_id=dol_getIdFromCode($db, GETPOST('stcomm','alpha'), 'c_stcomm'); $result=$object->set_commnucation_level($user); if ($result < 0) setEventMessages($object->error,$object->errors,'errors'); } // update outstandng limit if ($action == 'setoutstanding_limit') { $object->fetch($id); $object->outstanding_limit=GETPOST('outstanding_limit'); $result=$object->set_OutstandingBill($user); if ($result < 0) setEventMessage($object->error,$object->errors,'errors'); } } /* * View */ $contactstatic = new Contact($db); $userstatic=new User($db); $form = new Form($db); $formcompany=new FormCompany($db); if ($id > 0 && empty($object->id)) { // Load data of third party $res=$object->fetch($id); if ($object->id <= 0) dol_print_error($db,$object->error); } $title=$langs->trans("CustomerCard"); if (! empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/',$conf->global->MAIN_HTML_TITLE) && $object->name) $title=$object->name; $help_url='EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas'; llxHeader('',$title,$help_url); if ($mode == 'search') { if ($modesearch == 'soc') { // TODO move to DAO class $sql = "SELECT s.rowid"; if (!$user->rights->societe->client->voir && !$id) $sql .= ", sc.fk_soc, sc.fk_user "; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; if (!$user->rights->societe->client->voir && !$id) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql .= " WHERE lower(s.nom) like '%".strtolower($socname)."%'"; if (!$user->rights->societe->client->voir && !$id) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; } $resql=$db->query($sql); if ($resql) { if ( $db->num_rows($resql) == 1) { $obj = $db->fetch_object($resql); $id = $obj->rowid; } $db->free($resql); } } if ($id > 0) { $head = societe_prepare_head($object); dol_fiche_head($head, 'customer', $langs->trans("ThirdParty"),0,'company'); print '
'; print ''; print ''; // Alias name (commercial, trademark or alias name) print '"; // Prospect/Customer print ''; // Prefix if (! empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field { print ''; } if ($object->client) { $langs->load("compta"); print ''; print ''; print ''; print ''; } // Address print '"; // Zip / Town print ''; print '"; print ''; // Country print ''; // EMail print ''; // Web print ''; // Phone print ''; // Fax print ''; // Skype if (! empty($conf->skype->enabled)) { print ''; } // Assujeti a TVA ou pas print ''; print ''; print ''; // Local Taxes if ($mysoc->useLocalTax(1)) { print ''; } if ($mysoc->useLocalTax(2)) { print ''; } // TVA Intra print ''; // Conditions de reglement par defaut $langs->load('bills'); print '"; print ''; // Mode de reglement par defaut print '"; print ''; // Relative discounts (Discounts-Drawbacks-Rebates) print ''; print ''; // Absolute discounts (Discounts-Drawbacks-Rebates) print ''; print ''; print ''; if ($object->client) { print ''; print ''; print ''; } // Multiprice level if (! empty($conf->global->PRODUIT_MULTIPRICES)) { print '"; print ''; } if ($object->client == 2 || $object->client == 3) { // Level of prospect print '"; print ''; // Status $object->loadCacheOfProspStatus(); print ''; } // Categories if (!empty( $conf->categorie->enabled ) && !empty( $user->rights->categorie->lire )) { print ''; print '"; } // Other attributes $parameters=array('socid'=>$object->id, 'colspan' => ' colspan="3"', 'colspanvalue' => '3'); $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; if (empty($reshook) && ! empty($extrafields->attribute_label)) { print $object->showOptionals($extrafields); } // Sales representative include DOL_DOCUMENT_ROOT.'/societe/tpl/linesalesrepresentative.tpl.php'; // Module Adherent if (! empty($conf->adherent->enabled)) { $langs->load("members"); $langs->load("users"); print ''; print ''; print "\n"; } print "
'.$langs->trans("ThirdPartyName").''; print $form->showrefnav($object,'socid','',($user->societe_id?0:1),'rowid','nom','',''); print '
'.$langs->trans('AliasNameShort').''; print $object->name_alias; print "
'.$langs->trans('ProspectCustomer').''; print $object->getLibCustProspStatut(); print '
'.$langs->trans("Prefix").''; print ($object->prefix_comm?$object->prefix_comm:' '); print '
'; print $langs->trans('CustomerCode').''; print $object->code_client; if ($object->check_codeclient() <> 0) print ' ('.$langs->trans("WrongCustomerCode").')'; print '
'; print $form->editfieldkey("CustomerAccountancyCode",'customeraccountancycode',$object->code_compta,$object,$user->rights->societe->creer); print ''; print $form->editfieldval("CustomerAccountancyCode",'customeraccountancycode',$object->code_compta,$object,$user->rights->societe->creer); print '
'.$langs->trans('Address').''; dol_print_address($object->address,'gmap','thirdparty',$object->id); print "
'.$langs->trans('Zip').' / '.$langs->trans('Town').''.$object->zip.(($object->zip && $object->town)?' / ':'').$object->town."
'.$langs->trans("Country").''; if (! empty($object->country_code)) { //$img=picto_from_langcode($object->country_code); $img=''; if ($object->isInEEC()) print $form->textwithpicto(($img?$img.' ':'').$object->country,$langs->trans("CountryIsInEEC"),1,0); else print ($img?$img.' ':'').$object->country; } print '
'.$langs->trans('EMail').''.dol_print_email($object->email,0,$object->id,'AC_EMAIL').'
'.$langs->trans("Web").''.dol_print_url($object->url,'_blank').'
'.$langs->trans('Phone').''.dol_print_phone($object->phone,$object->country_code,0,$object->id,'AC_TEL').''.$langs->trans('Fax').''.dol_print_phone($object->fax,$object->country_code,0,$object->id,'AC_FAX').'
'.$langs->trans('Skype').''.dol_print_skype($object->skype,0,$object->id,'AC_SKYPE').'
'.$langs->trans('VATIsUsed').''; print yn($object->tva_assuj); print '
'.$langs->trans("LocalTax1IsUsedES").''; print yn($object->localtax1_assuj); print '
'.$langs->trans("LocalTax2IsUsedES").''; print yn($object->localtax2_assuj); print '
'.$langs->trans('VATIntra').''; print $object->tva_intra; print '
'; print ''; print '
'; print $langs->trans('PaymentConditions'); print ''; if (($action != 'editconditions') && $user->rights->societe->creer) print 'id.'">'.img_edit($langs->trans('SetConditions'),1).'
'; print '
'; if ($action == 'editconditions') { $form->form_conditions_reglement($_SERVER['PHP_SELF'].'?socid='.$object->id, $object->cond_reglement_id, 'cond_reglement_id',1); } else { $form->form_conditions_reglement($_SERVER['PHP_SELF'].'?socid='.$object->id, $object->cond_reglement_id, 'none'); } print "
'; print ''; print '
'; print $langs->trans('PaymentMode'); print ''; if (($action != 'editmode') && $user->rights->societe->creer) print 'id.'">'.img_edit($langs->trans('SetMode'),1).'
'; print '
'; if ($action == 'editmode') { $form->form_modes_reglement($_SERVER['PHP_SELF'].'?socid='.$object->id,$object->mode_reglement_id,'mode_reglement_id'); } else { $form->form_modes_reglement($_SERVER['PHP_SELF'].'?socid='.$object->id,$object->mode_reglement_id,'none'); } print "
'; print '
'; print $langs->trans("CustomerRelativeDiscountShort"); print ''; if ($user->rights->societe->creer && !$user->societe_id > 0) { print ''.img_edit($langs->trans("Modify")).''; } print '
'; print '
'.($object->remise_percent?''.$object->remise_percent.'%':$langs->trans("DiscountNone")).'
'; print ''; print '
'; print $langs->trans("CustomerAbsoluteDiscountShort"); print ''; if ($user->rights->societe->creer && !$user->societe_id > 0) { print ''.img_edit($langs->trans("Modify")).''; } print '
'; print '
'; $amount_discount=$object->getAvailableDiscounts(); if ($amount_discount < 0) dol_print_error($db,$object->error); if ($amount_discount > 0) print ''.price($amount_discount,1,$langs,1,-1,-1,$conf->currency).''; else print $langs->trans("DiscountNone"); print '
'; print $form->editfieldkey("OutstandingBill",'outstanding_limit',$object->outstanding_limit,$object,$user->rights->societe->creer); print ''; $limit_field_type = (! empty($conf->global->MAIN_USE_JQUERY_JEDITABLE)) ? 'numeric' : 'amount'; print $form->editfieldval("OutstandingBill",'outstanding_limit',$object->outstanding_limit,$object,$user->rights->societe->creer,$limit_field_type,($object->outstanding_limit != '' ? price($object->outstanding_limit) : '')); if (empty($object->outstanding_limit)) print $langs->trans("NoLimit"); // display amount and link to unpaid bill $outstandingBills = $object->get_OutstandingBill(); print ' (' . $langs->trans('CurrentOutstandingBill') . ': '; print price($outstandingBills, '', $langs, 0, 0, - 1, $conf->currency); if ($object->outstanding_limit != '') { if ($outstandingBills > $object->outstanding_limit) print img_warning($langs->trans("OutstandingBillReached")); //print ' / ' . price($soc->outstanding_limit); } print ')'; print '
'; print '
'; print $langs->trans("PriceLevel"); print ''; if ($user->rights->societe->creer) { print ''.img_edit($langs->trans("Modify")).''; } print '
'; print '
'; print $object->price_level; $keyforlabel='PRODUIT_MULTIPRICES_LABEL'.$object->price_level; if (! empty($conf->global->$keyforlabel)) print ' - '.$langs->trans($conf->global->$keyforlabel); print "
'; print ''; print '
'; print $langs->trans('ProspectLevel'); print ''; if ($action != 'editlevel' && $user->rights->societe->creer) print 'id.'">'.img_edit($langs->trans('Modify'),1).'
'; print '
'; if ($action == 'editlevel') $formcompany->form_prospect_level($_SERVER['PHP_SELF'].'?socid='.$object->id,$object->fk_prospectlevel,'prospect_level_id',1); else print $object->getLibProspLevel(); print "
'.$langs->trans("StatusProsp").''.$object->getLibProspCommStatut(4, $object->cacheprospectstatus[$object->stcomm_id]['label']); print '    
'; foreach($object->cacheprospectstatus as $key => $val) { $titlealt='default'; if (! empty($val['code']) && ! in_array($val['code'], array('ST_NO', 'ST_NEVER', 'ST_TODO', 'ST_PEND', 'ST_DONE'))) $titlealt=$val['label']; if ($object->stcomm_id != $val['id']) print ''.img_action($titlealt,$val['code']).''; } print '
' . $langs->trans( "Categories" ) . ''; print $form->showCategories( $object->id, 'customer', 1 ); print "
'.$langs->trans("LinkedToDolibarrMember").''; $adh=new Adherent($db); $result=$adh->fetch('','',$object->id); if ($result > 0) { $adh->ref=$adh->getFullName($langs); print $adh->getNomUrl(1); } else { print $langs->trans("ThirdpartyNotLinkedToMember"); } print '
"; print '
'; // Nbre max d'elements des petites listes $MAXLIST=4; $tableaushown=1; // Lien recap print ''; print ''; print ''; print ''; print '
'; print '
'.$langs->trans("Summary").''.$langs->trans("ShowCustomerPreview").'
'; print '
'; $now=dol_now(); /* * Last proposals */ if (! empty($conf->propal->enabled) && $user->rights->propal->lire) { $propal_static = new Propal($db); $sql = "SELECT s.nom, s.rowid, p.rowid as propalid, p.fk_statut, p.total_ht"; $sql.= ", p.tva as total_tva"; $sql.= ", p.total as total_ttc"; $sql.= ", p.ref, p.ref_client, p.remise"; $sql.= ", p.datep as dp, p.fin_validite as datelimite"; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."propal as p, ".MAIN_DB_PREFIX."c_propalst as c"; $sql.= " WHERE p.fk_soc = s.rowid AND p.fk_statut = c.id"; $sql.= " AND s.rowid = ".$object->id; $sql.= " AND p.entity = ".$conf->entity; $sql.= " ORDER BY p.datep DESC"; $resql=$db->query($sql); if ($resql) { $var=true; $num = $db->num_rows($resql); if ($num > 0) { print ''; print ''; print ''; print ''; } $i = 0; while ($i < $num && $i < $MAXLIST) { $objp = $db->fetch_object($resql); $var=!$var; print ""; print '\n"; print ''; print ''; $i++; } $db->free($resql); if ($num > 0) print "
'; print ''; print '
'.$langs->trans("LastPropals",($num<=$MAXLIST?"":$MAXLIST)).''.$langs->trans("AllPropals").' '.$num.''.img_picto($langs->trans("Statistics"),'stats').'
'; $propal_static->id = $objp->propalid; $propal_static->ref = $objp->ref; $propal_static->ref_client = $objp->ref_client; $propal_static->total_ht = $objp->total_ht; $propal_static->total_tva = $objp->total_tva; $propal_static->total_ttc = $objp->total_ttc; print $propal_static->getNomUrl(1); if ( ($db->jdate($objp->dp) < ($now - $conf->propal->cloture->warning_delay)) && $objp->fk_statut == 1 ) { print " ".img_warning(); } print ''.dol_print_date($db->jdate($objp->dp),'day')."'.price($objp->total_ht).''.$propal_static->LibStatut($objp->fk_statut,5).'
"; } else { dol_print_error($db); } } /* * Last orders */ if (! empty($conf->commande->enabled) && $user->rights->commande->lire) { $commande_static=new Commande($db); $sql = "SELECT s.nom, s.rowid"; $sql.= ", c.rowid as cid, c.total_ht"; $sql.= ", c.tva as total_tva"; $sql.= ", c.total_ttc"; $sql.= ", c.ref, c.ref_client, c.fk_statut, c.facture"; $sql.= ", c.date_commande as dc"; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."commande as c"; $sql.= " WHERE c.fk_soc = s.rowid "; $sql.= " AND s.rowid = ".$object->id; $sql.= " AND c.entity = ".$conf->entity; $sql.= " ORDER BY c.date_commande DESC"; $resql=$db->query($sql); if ($resql) { $var=true; $num = $db->num_rows($resql); if ($num > 0) { // Check if there are orders billable $sql2 = 'SELECT s.nom, s.rowid as socid, s.client, c.rowid, c.ref, c.total_ht, c.ref_client,'; $sql2.= ' c.date_valid, c.date_commande, c.date_livraison, c.fk_statut, c.facture as facturee'; $sql2.= ' FROM '.MAIN_DB_PREFIX.'societe as s'; $sql2.= ', '.MAIN_DB_PREFIX.'commande as c'; $sql2.= ' WHERE c.fk_soc = s.rowid'; $sql2.= ' AND s.rowid = '.$object->id; // Show orders with status validated, shipping started and delivered (well any order we can bill) $sql2.= " AND ((c.fk_statut IN (1,2)) OR (c.fk_statut = 3 AND c.facture = 0))"; $resql2=$db->query($sql2); $orders2invoice = $db->num_rows($resql2); $db->free($resql2); print ''; print ''; print ''; print ''; } $i = 0; while ($i < $num && $i < $MAXLIST) { $objp = $db->fetch_object($resql); $var=!$var; print ""; print '\n"; print ''; print ''; $i++; } $db->free($resql); if ($num >0) print "
'; print ''; //if($num2 > 0) print ''; //else print ''; print '
'.$langs->trans("LastCustomerOrders",($num<=$MAXLIST?"":$MAXLIST)).''.$langs->trans("AllOrders").' '.$num.''.img_picto($langs->trans("Statistics"),'stats').''.img_picto($langs->trans("CreateInvoiceForThisCustomer"),'object_bill').''.img_picto($langs->trans("NoOrdersToInvoice"),'object_bill').'
'; $commande_static->id = $objp->cid; $commande_static->ref = $objp->ref; $commande_static->ref_client=$objp->ref_client; $commande_static->total_ht = $objp->total_ht; $commande_static->total_tva = $objp->total_tva; $commande_static->total_ttc = $objp->total_ttc; print $commande_static->getNomUrl(1); print ''.dol_print_date($db->jdate($objp->dc),'day')."'.price($objp->total_ht).''.$commande_static->LibStatut($objp->fk_statut,$objp->facture,5).'
"; } else { dol_print_error($db); } } /* * Last sendings */ if (! empty($conf->expedition->enabled) && $user->rights->expedition->lire) { $sendingstatic = new Expedition($db); $sql = 'SELECT e.rowid as id'; $sql.= ', e.ref'; $sql.= ', e.date_creation'; $sql.= ', e.fk_statut as statut'; $sql.= ', s.nom'; $sql.= ', s.rowid as socid'; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."expedition as e"; $sql.= " WHERE e.fk_soc = s.rowid AND s.rowid = ".$object->id; $sql.= " AND e.entity IN (".getEntity('expedition', 1).")"; $sql.= ' GROUP BY e.rowid'; $sql.= ', e.ref'; $sql.= ', e.date_creation'; $sql.= ', e.fk_statut'; $sql.= ', s.nom'; $sql.= ', s.rowid'; $sql.= " ORDER BY e.date_creation DESC"; $resql = $db->query($sql); if ($resql) { $var = true; $num = $db->num_rows($resql); $i = 0; if ($num > 0) { print ''; $tableaushown=1; print ''; print ''; print ''; } while ($i < $num && $i < $MAXLIST) { $objp = $db->fetch_object($resql); $var = ! $var; print ""; print ''; if ($objp->date_creation > 0) { print ''; } else { print ''; } print ''; print "\n"; $i++; } $db->free($resql); if ($num > 0) print "
'; print ''; print '
'.$langs->trans("LastSendings",($num<=$MAXLIST?"":$MAXLIST)).''.$langs->trans("AllSendings").' '.$num.''.img_picto($langs->trans("Statistics"),'stats').'
'; $sendingstatic->id = $objp->id; $sendingstatic->ref = $objp->ref; print $sendingstatic->getNomUrl(1); print ''.dol_print_date($db->jdate($objp->date_creation),'day').'!!!' . $sendingstatic->LibStatut($objp->statut, 5) . '
"; } else { dol_print_error($db); } } /* * Last linked contracts */ if (! empty($conf->contrat->enabled) && $user->rights->contrat->lire) { $contratstatic=new Contrat($db); $sql = "SELECT s.nom, s.rowid, c.rowid as id, c.ref as ref, c.statut, c.datec as dc"; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."contrat as c"; $sql.= " WHERE c.fk_soc = s.rowid "; $sql.= " AND s.rowid = ".$object->id; $sql.= " AND c.entity = ".$conf->entity; $sql.= " ORDER BY c.datec DESC"; $resql=$db->query($sql); if ($resql) { $var=true; $num = $db->num_rows($resql); if ($num >0 ) { print ''; print ''; print ''; print ''; } $i = 0; while ($i < $num && $i < $MAXLIST) { $contrat=new Contrat($db); $objp = $db->fetch_object($resql); $var=!$var; print ""; print '\n"; print '\n"; print ''; print '\n"; print ''; $i++; } $db->free($resql); if ($num > 0) print "
'; print '
'.$langs->trans("LastContracts",($num<=$MAXLIST?"":$MAXLIST)).''.$langs->trans("AllContracts").' '.$num.'
'; $contrat->id=$objp->id; $contrat->ref=$objp->ref?$objp->ref:$objp->id; print $contrat->getNomUrl(1,12); print "'.dol_print_date($db->jdate($objp->dc),'day')." '; $contrat->fetch_lines(); print $contrat->getLibStatut(4); print "
"; } else { dol_print_error($db); } } /* * Last interventions */ if (! empty($conf->ficheinter->enabled) && $user->rights->ficheinter->lire) { $sql = "SELECT s.nom, s.rowid, f.rowid as id, f.ref, f.fk_statut, f.duree as duration, f.datei as startdate"; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."fichinter as f"; $sql.= " WHERE f.fk_soc = s.rowid"; $sql.= " AND s.rowid = ".$object->id; $sql.= " AND f.entity = ".$conf->entity; $sql.= " ORDER BY f.tms DESC"; $fichinter_static=new Fichinter($db); $resql=$db->query($sql); if ($resql) { $var=true; $num = $db->num_rows($resql); if ($num > 0) { print ''; print ''; print ''; print ''; $var=!$var; } $i = 0; while ($i < $num && $i < $MAXLIST) { $objp = $db->fetch_object($resql); $fichinter_static->id=$objp->id; $fichinter_static->statut=$objp->fk_statut; print ""; print ''."\n"; //print ''."\n"; print ''."\n"; print ''."\n"; print ''; $var=!$var; $i++; } $db->free($resql); if ($num > 0) print "
'.$langs->trans("LastInterventions",($num<=$MAXLIST?"":$MAXLIST)).''.$langs->trans("AllInterventions").' '.$num.'
'.img_object($langs->trans("ShowPropal"),"propal").' '.$objp->ref.''.dol_print_date($db->jdate($objp->startdate)).''.convertSecondToTime($objp->duration).''.$fichinter_static->getLibStatut(5).'
"; } else { dol_print_error($db); } } /* * Last invoices */ if (! empty($conf->facture->enabled) && $user->rights->facture->lire) { $facturestatic = new Facture($db); $sql = 'SELECT f.rowid as facid, f.facnumber, f.type, f.amount'; $sql.= ', f.total as total_ht'; $sql.= ', f.tva as total_tva'; $sql.= ', f.total_ttc'; $sql.= ', f.datef as df, f.datec as dc, f.paye as paye, f.fk_statut as statut'; $sql.= ', s.nom, s.rowid as socid'; $sql.= ', SUM(pf.amount) as am'; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture as f"; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'paiement_facture as pf ON f.rowid=pf.fk_facture'; $sql.= " WHERE f.fk_soc = s.rowid AND s.rowid = ".$object->id; $sql.= " AND f.entity = ".$conf->entity; $sql.= ' GROUP BY f.rowid, f.facnumber, f.type, f.amount, f.total, f.tva, f.total_ttc,'; $sql.= ' f.datef, f.datec, f.paye, f.fk_statut,'; $sql.= ' s.nom, s.rowid'; $sql.= " ORDER BY f.datef DESC, f.datec DESC"; $resql=$db->query($sql); if ($resql) { $var=true; $num = $db->num_rows($resql); $i = 0; if ($num > 0) { print ''; $tableaushown=1; print ''; print ''; print ''; } while ($i < $num && $i < $MAXLIST) { $objp = $db->fetch_object($resql); $var=!$var; print ""; print ''; if ($objp->df > 0) { print ''; } else { print ''; } print ''; print ''; print "\n"; $i++; } $db->free($resql); if ($num > 0) print "
'; print ''; print '
'.$langs->trans("LastCustomersBills",($num<=$MAXLIST?"":$MAXLIST)).''.$langs->trans("AllBills").' '.$num.''.img_picto($langs->trans("Statistics"),'stats').'
'; $facturestatic->id = $objp->facid; $facturestatic->ref = $objp->facnumber; $facturestatic->type = $objp->type; $facturestatic->total_ht = $objp->total_ht; $facturestatic->total_tva = $objp->total_tva; $facturestatic->total_ttc = $objp->total_ttc; print $facturestatic->getNomUrl(1); print ''.dol_print_date($db->jdate($objp->df),'day').'!!!'.price($objp->total_ht).''.($facturestatic->LibStatut($objp->paye,$objp->statut,5,$objp->am)).'
"; } else { dol_print_error($db); } } print '
'; print '
'; dol_fiche_end(); /* * Barre d'actions */ $parameters = array(); $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been print '
'; if (! empty($conf->propal->enabled) && $user->rights->propal->creer) { $langs->load("propal"); print ''; } if (! empty($conf->commande->enabled) && $user->rights->commande->creer) { $langs->load("orders"); print ''; } if ($user->rights->contrat->creer) { $langs->load("contracts"); print ''; } if (! empty($conf->ficheinter->enabled) && $user->rights->ficheinter->creer) { $langs->load("fichinter"); print ''; } // Add invoice if ($user->societe_id == 0) { if (! empty($conf->deplacement->enabled)) { $langs->load("trips"); print ''; } if (! empty($conf->facture->enabled)) { if ($user->rights->facture->creer) { $langs->load("bills"); $langs->load("orders"); if (! empty($conf->commande->enabled)) { if (! empty($orders2invoice) && $orders2invoice > 0) print ''; else print ''; } if ($object->client != 0) print ''; else print ''; } else { print ''; } } } // Add action if (! empty($conf->agenda->enabled) && ! empty($conf->global->MAIN_REPEATTASKONEACHTAB)) { if ($user->rights->agenda->myactions->create) { print ''; } else { print ''; } } print '
'; if (! empty($conf->global->MAIN_REPEATCONTACTONEACHTAB)) { // List of contacts show_contacts($conf,$langs,$db,$object,$_SERVER["PHP_SELF"].'?socid='.$object->id); } // Addresses list if (! empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) && ! empty($conf->global->MAIN_REPEATADDRESSONEACHTAB)) { show_addresses($conf,$langs,$db,$object,$_SERVER["PHP_SELF"].'?socid='.$object->id); } if (! empty($conf->global->MAIN_REPEATTASKONEACHTAB)) { print load_fiche_titre($langs->trans("ActionsOnCompany"),'',''); // List of todo actions show_actions_todo($conf,$langs,$db,$object); // List of done actions show_actions_done($conf,$langs,$db,$object); } } else { dol_print_error($db,'Bad value for socid parameter'); } // End of page llxFooter(); $db->close();