From c451386b8e845ba67cdb41a32168b5ec4c64337b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 28 Oct 2009 17:47:44 +0000 Subject: [PATCH] Qual: Better compatibility with other databases --- htdocs/compta/fiche.php | 464 ++++++++++++++++++++-------------------- 1 file changed, 232 insertions(+), 232 deletions(-) diff --git a/htdocs/compta/fiche.php b/htdocs/compta/fiche.php index 384740b1f4a..4889b2a4748 100644 --- a/htdocs/compta/fiche.php +++ b/htdocs/compta/fiche.php @@ -45,26 +45,26 @@ $result = restrictedArea($user, 'societe',$socid,''); if ($mode == 'search') { - if ($mode-search == 'soc') - { - $sql = "SELECT s.rowid FROM ".MAIN_DB_PREFIX."societe as s "; - $sql .= " WHERE lower(s.nom) like '%".strtolower($socname)."%'"; - } + if ($mode-search == 'soc') + { + $sql = "SELECT s.rowid FROM ".MAIN_DB_PREFIX."societe as s "; + $sql .= " WHERE lower(s.nom) like '%".strtolower($socname)."%'"; + } - if ( $db->query($sql) ) - { - if ( $db->num_rows() == 1) - { - $obj = $db->fetch_object(); - $socid = $obj->rowid; - } - $db->free(); - } + if ( $db->query($sql) ) + { + if ( $db->num_rows() == 1) + { + $obj = $db->fetch_object(); + $socid = $obj->rowid; + } + $db->free(); + } - if ($user->societe_id > 0) - { - $socid = $user->societe_id; - } + if ($user->societe_id > 0) + { + $socid = $user->societe_id; + } } @@ -82,8 +82,8 @@ $form = new Form($db); if ($socid > 0) { - $societe = new Societe($db); - $societe->fetch($socid, $to); // si $to='next' ajouter " AND s.rowid > $socid ORDER BY idp ASC LIMIT 1"; + $societe = new Societe($db); + $societe->fetch($socid, $to); // si $to='next' ajouter " AND s.rowid > $socid ORDER BY idp ASC LIMIT 1"; if ($societe->id <= 0) { dol_print_error($db,$societe->error); @@ -97,60 +97,60 @@ if ($socid > 0) dol_fiche_head($head, 'compta', $langs->trans("ThirdParty"),0,'company'); - print ''; - print '\n"; + print "\n"; - print '\n"; + print "\n"; + $i++; + } + $db->free($resql); + } + else + { + dol_print_error($db); + } + print "
'; + print ''; + print '
'; - print ''; + print '
'; - print ''; + print ''; - // Prefix - print ''; + // Prefix + print ''; - if ($societe->client) - { - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - } + if ($societe->client) + { + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + } - if ($societe->fournisseur) - { - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - } + if ($societe->fournisseur) + { + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + } - print '"; + print '"; - print ''; - print ''; + print ''; + print ''; // Country - print ''; // Phone - print ''; + print ''; - // Fax - print ''; + // Fax + print ''; - // EMail + // EMail print ''; - // Web - print ''; + // Web + print ''; // Assujeti a TVA ou pas print ''; @@ -159,185 +159,185 @@ if ($socid > 0) print ''; print ''; - // TVA Intra - print ''; + // TVA Intra + print ''; - if ($societe->client == 1) - { - // Remise permanente - print ''; - print ''; + if ($societe->client == 1) + { + // Remise permanente + print ''; + print ''; - // Reductions (Discounts-Drawbacks-Rebates) - print ''; - print ''; + print ''; - print ''; - } + if ($amount_discount > 0) print price($amount_discount).' '.$langs->trans("Currency".$conf->monnaie); + else print $langs->trans("DiscountNone"); + print ''; + print ''; + } - print "
'.$langs->trans("Name").''.$societe->nom.'
'.$langs->trans("Name").''.$societe->nom.'
'.$langs->trans("Prefix").''; - print ($societe->prefix_comm?$societe->prefix_comm:' '); - print '
'.$langs->trans("Prefix").''; + print ($societe->prefix_comm?$societe->prefix_comm:' '); + print '
'.$langs->trans("CustomerCode"). ''. $societe->code_client . '
'.$langs->trans("CustomerAccountancyCode").''.$societe->code_compta.'
'.$langs->trans("CustomerCode"). ''. $societe->code_client . '
'.$langs->trans("CustomerAccountancyCode").''.$societe->code_compta.'
'.$langs->trans("SupplierCode"). ''. $societe->code_fournisseur . '
'.$langs->trans("SupplierAccountancyCode").''.$societe->code_compta_fournisseur.'
'.$langs->trans("SupplierCode"). ''. $societe->code_fournisseur . '
'.$langs->trans("SupplierAccountancyCode").''.$societe->code_compta_fournisseur.'
'.$langs->trans("Address").''.nl2br($societe->adresse)."
'.$langs->trans("Address").''.nl2br($societe->adresse)."
'.$langs->trans('Zip').''.$societe->cp.''.$langs->trans('Town').''.$societe->ville.'
'.$langs->trans('Zip').''.$societe->cp.''.$langs->trans('Town').''.$societe->ville.'
'.$langs->trans('Country').''; + print '
'.$langs->trans('Country').''; if ($societe->isInEEC()) print $form->textwithpicto($societe->pays,$langs->trans("CountryIsInEEC"),1,0); else print $societe->pays; print '
'.$langs->trans("Phone").''.dol_print_phone($societe->tel,$societe->pays_code,0,$societe->id,'AC_TEL').'
'.$langs->trans("Phone").''.dol_print_phone($societe->tel,$societe->pays_code,0,$societe->id,'AC_TEL').''.$langs->trans("Fax").''.dol_print_phone($societe->fax,$societe->pays_code,0,$societe->id,'AC_FAX').'
'.$langs->trans("Fax").''.dol_print_phone($societe->fax,$societe->pays_code,0,$societe->id,'AC_FAX').'
'.$langs->trans('EMail').''.dol_print_email($societe->email,0,$societe->id,'AC_EMAIL').'
'.$langs->trans("Web").''.dol_print_url($societe->url,'_blank').'
'.$langs->trans("Web").''.dol_print_url($societe->url,'_blank').'
'.$langs->trans('VATIntraVeryShort').''; - print $societe->tva_intra; - print '
'.$langs->trans('VATIntraVeryShort').''; + print $societe->tva_intra; + print '
'; - print '
'; - print $langs->trans("CustomerRelativeDiscountShort"); - print ''; - if (!$user->societe_id > 0) - { - print ''.img_edit($langs->trans("Modify")).''; - } - print '
'; - print '
'.($societe->remise_client?price2num($societe->remise_client,'MT').'%':$langs->trans("DiscountNone")).'
'; + print '
'; + print $langs->trans("CustomerRelativeDiscountShort"); + print ''; + if (!$user->societe_id > 0) + { + print ''.img_edit($langs->trans("Modify")).''; + } + print '
'; + print '
'.($societe->remise_client?price2num($societe->remise_client,'MT').'%':$langs->trans("DiscountNone")).'
'; - print ''; - print '
'; - print $langs->trans("CustomerAbsoluteDiscountShort"); - print ''; - if (!$user->societe_id > 0) - { - print ''.img_edit($langs->trans("Modify")).''; - } - print '
'; - print '
'; + // Reductions (Discounts-Drawbacks-Rebates) + print '
'; + print ''; + print '
'; + print $langs->trans("CustomerAbsoluteDiscountShort"); + print ''; + if (!$user->societe_id > 0) + { + print ''.img_edit($langs->trans("Modify")).''; + } + print '
'; + print '
'; $amount_discount=$societe->getAvailableDiscounts(); if ($amount_discount < 0) dol_print_error($db,$societe->error); - if ($amount_discount > 0) print price($amount_discount).' '.$langs->trans("Currency".$conf->monnaie); - else print $langs->trans("DiscountNone"); - print '
"; + print "
"; - print "
'; + print ''; - // Nbre max d'elements des petites listes - $MAXLIST=5; - $tableaushown=1; + // Nbre max d'elements des petites listes + $MAXLIST=5; + $tableaushown=1; - // Lien recap - print ''; - print ''; - print ''; - print ''; - print '
'; - print '
'.$langs->trans("Summary").''.$langs->trans("ShowAccountancyPreview").'
'; - print '
'; + // Lien recap + print ''; + print ''; + print ''; + print ''; + print '
'; + print '
'.$langs->trans("Summary").''.$langs->trans("ShowAccountancyPreview").'
'; + print '
'; - /* - * Last invoices - */ - if ($conf->facture->enabled && $user->rights->facture->lire) - { - $facturestatic = new Facture($db); + /* + * Last invoices + */ + if ($conf->facture->enabled && $user->rights->facture->lire) + { + $facturestatic = new Facture($db); - print ''; + print '
'; - $sql = 'SELECT f.rowid as facid, f.facnumber, f.type, f.amount, f.total, f.total_ttc'; - $sql.= ', '.$db->pdate("f.datef").' as df, 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 = ".$societe->id; - $sql.= ' GROUP BY f.rowid'; - $sql.= " ORDER BY f.datef DESC, f.datec DESC"; + $sql = 'SELECT f.rowid as facid, f.facnumber, f.type, f.amount, f.total, f.total_ttc,'; + $sql.= ' '.$db->pdate("f.datef").' as df, '.$db->pdate("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 = ".$societe->id; + $sql.= ' GROUP BY f.rowid, f.facnumber, f.type, f.amount, f.total, f.total_ttc, f.datef, f.datec, f.paye, f.fk_statut, 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) - { - $tableaushown=1; - print ''; - print ''; - print ''; - } + $resql=$db->query($sql); + if ($resql) + { + $var=true; + $num = $db->num_rows($resql); + $i = 0; + if ($num > 0) + { + $tableaushown=1; + print ''; + print ''; + print ''; + } - while ($i < $num && $i < $MAXLIST) - { - $objp = $db->fetch_object($resql); - $var=!$var; - print ""; - print ''; - if ($objp->df > 0) - { - print "\n"; - } - else - { - print "\n"; - } - print "\n"; + while ($i < $num && $i < $MAXLIST) + { + $objp = $db->fetch_object($resql); + $var=!$var; + print ""; + print ''; + if ($objp->df > 0) + { + print "\n"; + } + else + { + print "\n"; + } + print "\n"; - print '\n"; - print "\n"; - $i++; - } - $db->free($resql); - } - else - { - dol_print_error($db); - } - print "
'.$langs->trans("LastCustomersBills",($num<=$MAXLIST?"":$MAXLIST)).''.$langs->trans("AllBills").' ('.$num.')
'.$langs->trans("LastCustomersBills",($num<=$MAXLIST?"":$MAXLIST)).''.$langs->trans("AllBills").' ('.$num.')
'; - $facturestatic->id=$objp->facid; - $facturestatic->ref=$objp->facnumber; - $facturestatic->type=$objp->type; - print $facturestatic->getNomUrl(1); - print '".dol_print_date($objp->df)."!!!".price($objp->total_ttc)."
'; + $facturestatic->id=$objp->facid; + $facturestatic->ref=$objp->facnumber; + $facturestatic->type=$objp->type; + print $facturestatic->getNomUrl(1); + print '".dol_print_date($objp->df)."!!!".price($objp->total_ttc)."'.($facturestatic->LibStatut($objp->paye,$objp->statut,5,$objp->am))."
"; - } + print '
'.($facturestatic->LibStatut($objp->paye,$objp->statut,5,$objp->am))."
"; + } - /* - * Last project - */ - if ($conf->projet->enabled && $user->rights->projet->lire) - { - print ''; + /* + * Last project + */ + if ($conf->projet->enabled && $user->rights->projet->lire) + { + print '
'; - $sql = "SELECT p.rowid,p.title,p.ref,".$db->pdate("p.dateo")." as do"; - $sql .= " FROM ".MAIN_DB_PREFIX."projet as p"; - $sql .= " WHERE p.fk_soc = $societe->id"; - $sql .= " ORDER by p.dateo"; + $sql = "SELECT p.rowid,p.title,p.ref,".$db->pdate("p.dateo")." as do"; + $sql .= " FROM ".MAIN_DB_PREFIX."projet as p"; + $sql .= " WHERE p.fk_soc = $societe->id"; + $sql .= " ORDER by p.dateo"; - if ( $db->query($sql) ) - { - $var=true; - $i = 0 ; - $num = $db->num_rows(); - if ($num > 0) - { - $tableaushown=1; - print ''; - print ''; - print ''; - } - while ($i < $num && $i < $MAXLIST) - { - $obj = $db->fetch_object(); - $var = !$var; - print ""; - print ''; + if ( $db->query($sql) ) + { + $var=true; + $i = 0 ; + $num = $db->num_rows(); + if ($num > 0) + { + $tableaushown=1; + print ''; + print ''; + print ''; + } + while ($i < $num && $i < $MAXLIST) + { + $obj = $db->fetch_object(); + $var = !$var; + print ""; + print ''; - print ""; - $i++; - } - $db->free(); - } - else - { - dol_print_error($db); - } - print "
'.$langs->trans("LastProjects",($num<=$MAXLIST?"":$MAXLIST)).''.$langs->trans("AllProjects").' ('.$num.')
'.img_object($langs->trans("ShowProject"),"project")." ".$obj->title.'
'.$langs->trans("LastProjects",($num<=$MAXLIST?"":$MAXLIST)).''.$langs->trans("AllProjects").' ('.$num.')
'.img_object($langs->trans("ShowProject"),"project")." ".$obj->title.'".dol_print_date($obj->do,"day") ."
"; - } + print "".dol_print_date($obj->do,"day") .""; + $i++; + } + $db->free(); + } + else + { + dol_print_error($db); + } + print ""; + } - print ""; - print "\n"; + print ""; + print "\n"; - /* - * Barre d'actions - */ - print '
'; + /* + * Barre d'actions + */ + print '
'; if ($user->societe_id == 0) { @@ -363,45 +363,45 @@ if ($socid > 0) } } - if ($conf->agenda->enabled) - { - if ($user->rights->agenda->myactions->create) - { + if ($conf->agenda->enabled) + { + if ($user->rights->agenda->myactions->create) + { print ''.$langs->trans("AddAction").''; - } - else - { + } + else + { print ''.$langs->trans("AddAction").''; - } - } + } + } if ($user->rights->societe->contact->creer) { print "".$langs->trans("AddContact").""; } - print '
'; - print "
\n"; + print '
'; + print "
\n"; /* - * Liste des contacts - */ + * Liste des contacts + */ show_contacts($conf,$langs,$db,$societe); - /* - * Listes des actions a faire - */ + /* + * Listes des actions a faire + */ show_actions_todo($conf,$langs,$db,$societe); - /* - * Listes des actions effectuees - */ + /* + * Listes des actions effectuees + */ show_actions_done($conf,$langs,$db,$societe); } else { - dol_print_error($db,'Bad value for socid parameter'); + dol_print_error($db,'Bad value for socid parameter'); } $db->close();