diff --git a/ChangeLog b/ChangeLog index 22b71858b4c..f214ca75010 100644 --- a/ChangeLog +++ b/ChangeLog @@ -41,18 +41,18 @@ For users: - New: A more responsive desgin for statistic box of home page. - Qual: Implement same rule for return value of all command line scripts (0 when success, <>0 if error). - New: [ task #1005 ] Adapting to Spanish legislation bill numbering -- New: [ task #1011 ] Now supplier order and invoice deal with payment terms and mode -- New: [ task #1014 ] Add option to recursivly add parent category -- New: [ task #1016 ] Can define a specific numbering for deposits -- New: [ task #918 ] Stock replenishment -- Fix: [ bug #992 ] Proforma invoices don't have a separated numeric count -- New : Add pdf link into supplier invoice list and supplier order list -- New : Genrate auto the PDF for supplier invoice -- New : Add category into filter webservice thirdparty method getListOfThirdParties -- New : Allow to define margin or mark rate during quoting, ordering, invoicing -- New : User permissions on margin module -- New : Add ref supplier into muscadet model -- New : Add ability to copy contact address to clipboard +- New: [ task #1011 ] Now supplier order and invoice deal with payment terms and mode. +- New: [ task #1014 ] Add option to recursivly add parent category. +- New: [ task #1016 ] Can define a specific numbering for deposits. +- New: [ task #918 ] Stock replenishment. +- Fix: [ bug #992 ] Proforma invoices don't have a separated numeric count. +- New : Add pdf link into supplier invoice list and supplier order list. +- New : Genrate auto the PDF for supplier invoice. +- New : Add category into filter webservice thirdparty method getListOfThirdParties. +- New : Allow to define margin or mark rate during quoting, ordering, invoicing. +- New : User permissions on margin module. +- New : Add ref supplier into muscadet model/ +- New : Add ability to copy contact address to clipboard. - New: Can use tag {mm} before {yy} even when there is a reset into numbering masks. - New: [ task #1060 ] Register fields localtax(1|2)_type into details tables. - New: [ task #923 ] Localtax support for ODT templates. diff --git a/build/debian/README.howto b/build/debian/README.howto index 4978b686070..6f06f5ab91b 100644 --- a/build/debian/README.howto +++ b/build/debian/README.howto @@ -207,8 +207,11 @@ Note: If there was errors managed manually, you may need to make a git commit bu > sbuild ... > dput ... -* Go into page. You should see new package into unstable. -http://packages.qa.debian.org/t/tcpdf.html +* Package arrives into FTPmaster taskboard with status NEW (pending upload). You can view it at: +http://ftp-master.debian.org/new/ + +* Once package is validated, you should see it into area unstable at: +http://packages.qa.debian.org * Package will be into release when test will be moved as stable. diff --git a/dev/iso-normes/vat_number_names.txt b/dev/iso-normes/vat_number_names.txt new file mode 100644 index 00000000000..23fce59ed3b --- /dev/null +++ b/dev/iso-normes/vat_number_names.txt @@ -0,0 +1 @@ +http://en.wikipedia.org/wiki/VAT_identification_number \ No newline at end of file diff --git a/htdocs/adherents/fiche.php b/htdocs/adherents/fiche.php index 2648a8ae721..251eb062b15 100644 --- a/htdocs/adherents/fiche.php +++ b/htdocs/adherents/fiche.php @@ -273,6 +273,8 @@ if ($action == 'update' && ! $_POST["cancel"] && $user->rights->adherent->creer) $object->pass = trim($_POST["pass"]); $object->societe = trim($_POST["societe"]); + $object->company = trim($_POST["societe"]); + $object->address = trim($_POST["address"]); $object->zip = trim($_POST["zipcode"]); $object->town = trim($_POST["town"]); diff --git a/htdocs/comm/propal/list.php b/htdocs/comm/propal/list.php index b0f51e442c6..45e69448f43 100644 --- a/htdocs/comm/propal/list.php +++ b/htdocs/comm/propal/list.php @@ -296,9 +296,6 @@ if ($result) print ''; print ''; print ''; - print ''; - print ''; - print ''; print ''; print $langs->trans('Month').': '; print ' '.$langs->trans('Year').': '; diff --git a/htdocs/compta/bank/search.php b/htdocs/compta/bank/search.php index cc3f0cd548d..650733dbb9c 100644 --- a/htdocs/compta/bank/search.php +++ b/htdocs/compta/bank/search.php @@ -42,7 +42,7 @@ $debit=GETPOST("debit"); $credit=GETPOST("credit"); $type=GETPOST("type"); $account=GETPOST("account"); -$bid=GETPOST("bid"); +$bid=GETPOST("bid","int"); $param=''; if ($description) $param.='&description='.$description; @@ -83,7 +83,7 @@ $sql.= " b.fk_account, b.fk_type,"; $sql.= " ba.rowid as bankid, ba.ref as bankref,"; $sql.= " bu.label as labelurl, bu.url_id"; $sql.= " FROM "; -if (! empty($_REQUEST["bid"])) $sql.= MAIN_DB_PREFIX."bank_class as l,"; +if ($bid) $sql.= MAIN_DB_PREFIX."bank_class as l,"; $sql.= " ".MAIN_DB_PREFIX."bank_account as ba,"; $sql.= " ".MAIN_DB_PREFIX."bank as b"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank_url as bu ON bu.fk_bank = b.rowid AND type = 'company'"; @@ -92,21 +92,21 @@ $sql.= " WHERE b.fk_account = ba.rowid"; $sql.= " AND ba.entity = ".$conf->entity; if (GETPOST("req_nb")) { - $sql.= " AND b.num_chq like '%".$db->escape(GETPOST("req_nb"))."%'"; + $sql.= " AND b.num_chq LIKE '%".$db->escape(GETPOST("req_nb"))."%'"; $param.='&req_nb='.urlencode(GETPOST("req_nb")); } if (GETPOST("thirdparty")) { - $sql.=" AND (COALESCE(s.nom,'') LIKE '%".$db->escape(GETPOST("thirdparty"))."%')"; + $sql.=" AND s.nom LIKE '%".$db->escape(GETPOST("thirdparty"))."%'"; $param.='&thirdparty='.urlencode(GETPOST("thirdparty")); } -if (! empty($_REQUEST["bid"])) +if ($bid) { - $sql.= " AND b.rowid=l.lineid AND l.fk_categ=".$_REQUEST["bid"]; + $sql.= " AND b.rowid=l.lineid AND l.fk_categ=".$bid; } -if(! empty($type)) +if (! empty($type)) { - $sql .= " AND b.fk_type = '" . $type ."' "; + $sql.= " AND b.fk_type = '".$db->escape($type)."' "; } // Search criteria amount $si=0; diff --git a/htdocs/compta/resultat/clientfourn.php b/htdocs/compta/resultat/clientfourn.php index d8c134c12ef..d28f457fb2b 100644 --- a/htdocs/compta/resultat/clientfourn.php +++ b/htdocs/compta/resultat/clientfourn.php @@ -116,7 +116,8 @@ $total_ttc=0; if ($modecompta=="CREANCES-DETTES") { $nom=$langs->trans("AnnualByCompaniesDueDebtMode"); - $nom.='
('.$langs->trans("SeeReportInInputOutputMode",'','').')'; + $calcmode=$langs->trans("CalcModeDebt"); + $calcmode.='
('.$langs->trans("SeeReportInInputOutputMode",'','').')'; $period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1); //$periodlink=''.img_previous().' '.img_next().''; $description=$langs->trans("RulesResultDue"); @@ -127,7 +128,8 @@ if ($modecompta=="CREANCES-DETTES") } else { $nom=$langs->trans("AnnualByCompaniesInputOutputMode"); - $nom.='
('.$langs->trans("SeeReportInDueDebtMode",'','').')'; + $calcmode=$langs->trans("CalcModeEngagement"); + $calcmode.='
('.$langs->trans("SeeReportInDueDebtMode",'','').')'; //$period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',1,1,0,'',1,0,1); $period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1); //$periodlink=''.img_previous().' '.img_next().''; @@ -135,7 +137,7 @@ else { $builddate=time(); //$exportlink=$langs->trans("NotYetAvailable"); } -report_header($nom,$nomlink,$period,$periodlink,$description,$builddate,$exportlink,array('modecompta'=>$modecompta)); +report_header($nom,$nomlink,$period,$periodlink,$description,$builddate,$exportlink,array('modecompta'=>$modecompta),$calcmode); // Show report array print ''; diff --git a/htdocs/compta/resultat/index.php b/htdocs/compta/resultat/index.php index 4279490d801..e4ead871b42 100644 --- a/htdocs/compta/resultat/index.php +++ b/htdocs/compta/resultat/index.php @@ -63,7 +63,8 @@ $exportlink=''; if ($modecompta == 'CREANCES-DETTES') { $nom=$langs->trans("AnnualSummaryDueDebtMode"); - $nom.='
('.$langs->trans("SeeReportInInputOutputMode",'','').')'; + $calcmode=$langs->trans("CalcModeDebt"); + $calcmode.='
('.$langs->trans("SeeReportInInputOutputMode",'','').')'; $period="$year_start - $year_end"; $periodlink=($year_start?"".img_previous()."".img_next()."":""); $description=$langs->trans("RulesAmountWithTaxIncluded"); @@ -75,7 +76,8 @@ if ($modecompta == 'CREANCES-DETTES') } else { $nom=$langs->trans("AnnualSummaryInputOutputMode"); - $nom.='
('.$langs->trans("SeeReportInDueDebtMode",'','').')'; + $calcmode=$langs->trans("CalcModeEngagement"); + $calcmode.='
('.$langs->trans("SeeReportInDueDebtMode",'','').')'; $period="$year_start - $year_end"; $periodlink=($year_start?"".img_previous()."".img_next()."":""); $description=$langs->trans("RulesAmountWithTaxIncluded"); @@ -83,7 +85,7 @@ else { $builddate=time(); //$exportlink=$langs->trans("NotYetAvailable"); } -report_header($nom,$nomlink,$period,$periodlink,$description,$builddate,$exportlink,array('modecompta'=>$modecompta)); +report_header($nom,$nomlink,$period,$periodlink,$description,$builddate,$exportlink,array('modecompta'=>$modecompta),$calcmode); /* diff --git a/htdocs/compta/stats/cabyprodserv.php b/htdocs/compta/stats/cabyprodserv.php index ec9e0ea0a58..95ca831c37c 100644 --- a/htdocs/compta/stats/cabyprodserv.php +++ b/htdocs/compta/stats/cabyprodserv.php @@ -142,7 +142,8 @@ $formother = new FormOther($db); $nom=$langs->trans("SalesTurnover").', '.$langs->trans("ByProductsAndServices"); if ($modecompta=="CREANCES-DETTES") { - $nom.='
('.$langs->trans("SeeReportInInputOutputMode",'','').')'; + $calcmode=$langs->trans("CalcModeDebt"); + $calcmode.='
('.$langs->trans("SeeReportInInputOutputMode",'','').')'; $period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1); @@ -155,7 +156,8 @@ if ($modecompta=="CREANCES-DETTES") { $builddate=time(); } else { - $nom.='
('.$langs->trans("SeeReportInDueDebtMode",'','').')'; + $calcmode=$langs->trans("CalcModeEngagement"); + $calcmode.='
('.$langs->trans("SeeReportInDueDebtMode",'','').')'; $period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1); @@ -165,7 +167,7 @@ if ($modecompta=="CREANCES-DETTES") { $builddate=time(); } -report_header($nom,$nomlink,$period,$periodlink,$description,$builddate,$exportlink,$tableparams); +report_header($nom,$nomlink,$period,$periodlink,$description,$builddate,$exportlink,$tableparams,$calcmode); // SQL request @@ -382,8 +384,7 @@ if ($modecompta == 'CREANCES-DETTES') { print ''; } else { // $modecompta != 'CREANCES-DETTES' - // TODO: better message - print '
' . $langs->trans("WarningNotRelevant") . '
'; + print '
'.$langs->trans("TurnoverPerProductInCommitmentAccountingNotRelevant") . '
'; } llxFooter(); diff --git a/htdocs/compta/stats/cabyuser.php b/htdocs/compta/stats/cabyuser.php index 82bbff465eb..7473f71eaf1 100644 --- a/htdocs/compta/stats/cabyuser.php +++ b/htdocs/compta/stats/cabyuser.php @@ -137,7 +137,8 @@ $form=new Form($db); // Show report header if ($modecompta=="CREANCES-DETTES") { $nom=$langs->trans("SalesTurnover").', '.$langs->trans("ByUserAuthorOfInvoice"); - $nom.='
('.$langs->trans("SeeReportInInputOutputMode",'','').')'; + $calcmode=$langs->trans("CalcModeDebt"); + $calcmode.='
('.$langs->trans("SeeReportInInputOutputMode",'','').')'; $period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1); //$periodlink="".img_previous()."".img_next().""; $description=$langs->trans("RulesCADue"); @@ -147,7 +148,8 @@ if ($modecompta=="CREANCES-DETTES") { //$exportlink=$langs->trans("NotYetAvailable"); } else { $nom=$langs->trans("SalesTurnover").', '.$langs->trans("ByUserAuthorOfInvoice"); - $nom.='
('.$langs->trans("SeeReportInDueDebtMode",'','').')'; + $calcmode=$langs->trans("CalcModeEngagement"); + $calcmode.='
('.$langs->trans("SeeReportInDueDebtMode",'','').')'; $period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1); //$periodlink="".img_previous()."".img_next().""; $description=$langs->trans("RulesCAIn"); @@ -158,7 +160,7 @@ if ($modecompta=="CREANCES-DETTES") { $moreparam=array(); if (! empty($modecompta)) $moreparam['modecompta']=$modecompta; -report_header($nom,$nomlink,$period,$periodlink,$description,$builddate,$exportlink,$moreparam); +report_header($nom,$nomlink,$period,$periodlink,$description,$builddate,$exportlink,$moreparam,$calcmode); // Show array diff --git a/htdocs/compta/stats/casoc.php b/htdocs/compta/stats/casoc.php index 214ce25e625..f154b2a69f6 100644 --- a/htdocs/compta/stats/casoc.php +++ b/htdocs/compta/stats/casoc.php @@ -151,7 +151,8 @@ $formother = new FormOther($db); if ($modecompta=="CREANCES-DETTES") { $nom=$langs->trans("SalesTurnover").', '.$langs->trans("ByThirdParties"); - $nom.='
('.$langs->trans("SeeReportInInputOutputMode",'','').')'; + $calcmode=$langs->trans("CalcModeDebt"); + $calcmode.='
('.$langs->trans("SeeReportInInputOutputMode",'','').')'; $period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1); //$periodlink=''.img_previous().''.img_next().''; $description=$langs->trans("RulesCADue"); @@ -161,7 +162,8 @@ if ($modecompta=="CREANCES-DETTES") //$exportlink=$langs->trans("NotYetAvailable"); } else { $nom=$langs->trans("SalesTurnover").', '.$langs->trans("ByThirdParties"); - $nom.='
('.$langs->trans("SeeReportInDueDebtMode",'','').')'; + $calcmode=$langs->trans("CalcModeEngagement"); + $calcmode.='
('.$langs->trans("SeeReportInDueDebtMode",'','').')'; $period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1); //$periodlink=''.img_previous().''.img_next().''; $description=$langs->trans("RulesCAIn"); @@ -170,7 +172,7 @@ if ($modecompta=="CREANCES-DETTES") //$exportlink=$langs->trans("NotYetAvailable"); } -report_header($nom,$nomlink,$period,$periodlink,$description,$builddate,$exportlink,$tableparams); +report_header($nom,$nomlink,$period,$periodlink,$description,$builddate,$exportlink,$tableparams,$calcmode); // Show Array @@ -227,7 +229,7 @@ $sql.= " AND f.entity = ".$conf->entity; if ($socid) $sql.= " AND f.fk_soc = ".$socid; $sql.= " GROUP BY s.rowid, s.nom"; $sql.= " ORDER BY s.rowid"; -echo $sql; +//echo $sql; $result = $db->query($sql); if ($result) { diff --git a/htdocs/compta/stats/index.php b/htdocs/compta/stats/index.php index bf31220ddaf..8cdbb8ddad4 100644 --- a/htdocs/compta/stats/index.php +++ b/htdocs/compta/stats/index.php @@ -60,7 +60,8 @@ $form=new Form($db); if ($modecompta=="CREANCES-DETTES") { $nom=$langs->trans("SalesTurnover"); - $nom.='
('.$langs->trans("SeeReportInInputOutputMode",'','').')'; + $calcmode=$langs->trans("CalcModeDebt"); + $calcmode.='
('.$langs->trans("SeeReportInInputOutputMode",'','').')'; $period="$year_start - $year_end"; $periodlink=($year_start?"".img_previous()."".img_next()."":""); $description=$langs->trans("RulesCADue"); @@ -71,7 +72,8 @@ if ($modecompta=="CREANCES-DETTES") } else { $nom=$langs->trans("SalesTurnover"); - $nom.='
('.$langs->trans("SeeReportInDueDebtMode",'','').')'; + $calcmode=$langs->trans("CalcModeEngagement"); + $calcmode.='
('.$langs->trans("SeeReportInDueDebtMode",'','').')'; $period="$year_start - $year_end"; $periodlink=($year_start?"".img_previous()."".img_next()."":""); $description=$langs->trans("RulesCAIn"); @@ -81,7 +83,7 @@ else { } $moreparam=array(); if (! empty($modecompta)) $moreparam['modecompta']=$modecompta; -report_header($nom,$nomlink,$period,$periodlink,$description,$builddate,$exportlink,$moreparam); +report_header($nom,$nomlink,$period,$periodlink,$description,$builddate,$exportlink,$moreparam,$calcmode); if ($modecompta == 'CREANCES-DETTES') diff --git a/htdocs/compta/tva/clients.php b/htdocs/compta/tva/clients.php index 871e8a583ef..fbde1584541 100644 --- a/htdocs/compta/tva/clients.php +++ b/htdocs/compta/tva/clients.php @@ -1,7 +1,7 @@ * Copyright (C) 2004 Eric Seigne - * Copyright (C) 2004-2010 Laurent Destailleur + * Copyright (C) 2004-2013 Laurent Destailleur * Copyright (C) 2006 Yannick Warnier * * This program is free software; you can redistribute it and/or modify @@ -110,6 +110,8 @@ $fsearch.=' '; if ($modetax==1) // Calculate on invoice for goods and services { $nom=$langs->trans("VATReportByCustomersInDueDebtMode"); + $calcmode=$langs->trans("CalcModeVATDebt"); + $calcmode.='
('.$langs->trans("TaxModuleSetupToModifyRules",DOL_URL_ROOT.'/admin/taxes.php').')'; //$nom.='
('.$langs->trans("SeeVATReportInInputOutputMode",'','').')'; $period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1); //$periodlink=($year_start?"".img_previous()." ".img_next()."":""); @@ -121,7 +123,6 @@ if ($modetax==1) // Calculate on invoice for goods and services if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $description.='
'.$langs->trans("DepositsAreNotIncluded"); else $description.='
'.$langs->trans("DepositsAreIncluded"); $description.=$fsearch; - $description.='
('.$langs->trans("TaxModuleSetupToModifyRules",DOL_URL_ROOT.'/admin/taxes.php').')'; $builddate=time(); //$exportlink=$langs->trans("NotYetAvailable"); @@ -137,6 +138,8 @@ if ($modetax==1) // Calculate on invoice for goods and services if ($modetax==0) // Invoice for goods, payment for services { $nom=$langs->trans("VATReportByCustomersInInputOutputMode"); + $calcmode=$langs->trans("CalcModeVATEngagement"); + $calcmode.='
('.$langs->trans("TaxModuleSetupToModifyRules",DOL_URL_ROOT.'/admin/taxes.php').')'; //$nom.='
('.$langs->trans("SeeVATReportInDueDebtMode",'','').')'; $period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1); //$periodlink=($year_start?"".img_previous()." ".img_next()."":""); @@ -149,7 +152,6 @@ if ($modetax==0) // Invoice for goods, payment for services //if ($conf->global->MAIN_MODULE_COMPTABILITE || $conf->global->MAIN_MODULE_ACCOUNTING) $description.='
'.img_warning().' '.$langs->trans('OptionVatInfoModuleComptabilite'); //if (! empty($conf->global->MAIN_MODULE_COMPTABILITE)) $description.='
'.$langs->trans("WarningDepositsNotIncluded"); $description.=$fsearch; - $description.='
('.$langs->trans("TaxModuleSetupToModifyRules",DOL_URL_ROOT.'/admin/taxes.php').')'; $builddate=time(); //$exportlink=$langs->trans("NotYetAvailable"); @@ -162,7 +164,7 @@ if ($modetax==0) // Invoice for goods, payment for services $amountsup=$langs->trans("AmountHT"); if ($mysoc->tva_assuj) $vatsup.=' ('.$langs->trans("ToGetBack").')'; } -report_header($nom,$nomlink,$period,$periodlink,$description,$builddate,$exportlink); +report_header($nom,$nomlink,$period,$periodlink,$description,$builddate,$exportlink,array(),$calcmode); $vatcust=$langs->trans("VATReceived"); $vatsup=$langs->trans("VATPaid"); diff --git a/htdocs/compta/tva/quadri_detail.php b/htdocs/compta/tva/quadri_detail.php index 0d859d96c06..cc084655bf0 100644 --- a/htdocs/compta/tva/quadri_detail.php +++ b/htdocs/compta/tva/quadri_detail.php @@ -1,7 +1,7 @@ * Copyright (C) 2004 Eric Seigne - * Copyright (C) 2004-2010 Laurent Destailleur + * Copyright (C) 2004-2013 Laurent Destailleur * Copyright (C) 2006-2007 Yannick Warnier * * This program is free software; you can redistribute it and/or modify @@ -121,10 +121,13 @@ $fsearch.=' '; //$fsearch.=' '.$langs->trans("SalesTurnoverMinimum").': '; //$fsearch.=' '; + // Affiche en-tete du rapport if ($modetax==1) // Calculate on invoice for goods and services { $nom=$langs->trans("VATReportByQuartersInDueDebtMode"); + $calcmode=$langs->trans("CalcModeVATDebt"); + $calcmode.='
('.$langs->trans("TaxModuleSetupToModifyRules",DOL_URL_ROOT.'/admin/taxes.php').')'; $period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1); $prevyear=$year_start; $prevquarter=$q; if ($prevquarter > 1) $prevquarter--; @@ -140,7 +143,6 @@ if ($modetax==1) // Calculate on invoice for goods and services //if (! empty($conf->global->MAIN_MODULE_COMPTABILITE)) $description.='
'.$langs->trans("WarningDepositsNotIncluded"); if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $description.='
'.$langs->trans("DepositsAreNotIncluded"); else $description.='
'.$langs->trans("DepositsAreIncluded"); - $description.='
('.$langs->trans("TaxModuleSetupToModifyRules",DOL_URL_ROOT.'/admin/taxes.php').')'; $description.=$fsearch; $builddate=time(); //$exportlink=$langs->trans("NotYetAvailable"); @@ -159,6 +161,8 @@ if ($modetax==1) // Calculate on invoice for goods and services if ($modetax==0) // Invoice for goods, payment for services { $nom=$langs->trans("VATReportByQuartersInInputOutputMode"); + $calcmode=$langs->trans("CalcModeVATEngagement"); + $calcmode.='
('.$langs->trans("TaxModuleSetupToModifyRules",DOL_URL_ROOT.'/admin/taxes.php').')'; $period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1); $prevyear=$year_start; $prevquarter=$q; if ($prevquarter > 1) $prevquarter--; @@ -176,7 +180,6 @@ if ($modetax==0) // Invoice for goods, payment for services //if ($conf->global->MAIN_MODULE_COMPTABILITE || $conf->global->MAIN_MODULE_ACCOUNTING) $description.='
'.img_warning().' '.$langs->trans('OptionVatInfoModuleComptabilite'); //if (! empty($conf->global->MAIN_MODULE_COMPTABILITE)) $description.='
'.$langs->trans("WarningDepositsNotIncluded"); $description.=$fsearch; - $description.='
('.$langs->trans("TaxModuleSetupToModifyRules",DOL_URL_ROOT.'/admin/taxes.php').')'; $builddate=time(); //$exportlink=$langs->trans("NotYetAvailable"); @@ -191,7 +194,7 @@ if ($modetax==0) // Invoice for goods, payment for services $vatsup=$langs->trans("VATPaid"); if ($mysoc->tva_assuj) $vatsup.=' ('.$langs->trans("ToGetBack").')'; } -report_header($nom,$nomlink,$period,$periodlink,$description,$builddate,$exportlink); +report_header($nom,$nomlink,$period,$periodlink,$description,$builddate,$exportlink,array(),$calcmode); $vatcust=$langs->trans("VATReceived"); $vatsup=$langs->trans("VATPaid"); diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index c6413b4beae..692a340b6ca 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -1,6 +1,6 @@ - * Copyright (C) 2005-2012 Regis Houssin + * Copyright (C) 2005-2013 Regis Houssin * Copyright (C) 2010-2013 Juanjo Menent * Copyright (C) 2012 Christophe Battarel * Copyright (C) 2011-2012 Philippe Grand @@ -464,7 +464,7 @@ abstract class CommonObject $sql.= " WHERE tc.element='".$this->element."'"; if ($activeonly == 1) $sql.= " AND tc.active=1"; // only the active type - + if (! empty($source)) $sql.= " AND tc.source='".$source."'"; $sql.= " ORDER by tc.".$order; @@ -1112,9 +1112,9 @@ abstract class CommonObject $row = $this->db->fetch_row($resql); $rows[] = $row[0]; // Add parent line into array rows $childrens = $this->getChildrenOfLine($row[0]); - if (! empty($children)) + if (! empty($childrens)) { - foreach($children as $child) + foreach($childrens as $child) { array_push($rows, $child); } @@ -2621,7 +2621,7 @@ abstract class CommonObject } } - + /* This is to show add lines */ diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 3296a879523..4f5119697d0 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -4,7 +4,7 @@ * Copyright (C) 2004 Benoit Mortier * Copyright (C) 2004 Sebastien Di Cintio * Copyright (C) 2004 Eric Seigne - * Copyright (C) 2005-2012 Regis Houssin + * Copyright (C) 2005-2013 Regis Houssin * Copyright (C) 2006 Andre Cianfarani * Copyright (C) 2006 Marc Barilley/Ocebo * Copyright (C) 2007 Franky Van Liedekerke @@ -800,7 +800,7 @@ class Form while ($i < $num) { $obj = $this->db->fetch_object($resql); - + if ($conf->global->SOCIETE_ADD_REF_IN_LIST) { if (($obj->client) && (!empty($obj->code_client))) { $label = $obj->code_client. ' - '; @@ -814,7 +814,7 @@ class Form { $label=$obj->nom; } - + if ($showtype) { if ($obj->client || $obj->fournisseur) $label.=' ('; @@ -2484,9 +2484,9 @@ class Form /** * Show a confirmation HTML form or AJAX popup. - * Easiest way to use this is with useajax=1. - * If you use useajax='xxx', you must also add jquery code to trigger opening of box (with correct parameters) - * just after calling this method. For example: + * Easiest way to use this is with useajax=1. + * If you use useajax='xxx', you must also add jquery code to trigger opening of box (with correct parameters) + * just after calling this method. For example: * print ''; -} else { +if (empty($resql)) +{ dol_print_error($db); + exit; } +$num = $db->num_rows($resql); +$i = 0; + +$helpurl = 'EN:Module_Stocks_En|FR:Module_Stock|'; +$helpurl .= 'ES:Módulo_Stocks'; + +llxHeader('', $title, $helpurl, $title); + +$head = array(); +$head[0][0] = DOL_URL_ROOT.'/product/stock/replenish.php'; +$head[0][1] = $title; +$head[0][2] = 'replenish'; +$head[1][0] = DOL_URL_ROOT.'/product/stock/replenishorders.php'; +$head[1][1] = $langs->trans("ReplenishmentOrders"); +$head[1][2] = 'replenishorders'; + +dol_fiche_head($head, 'replenish', $langs->trans('Replenishment'), 0, 'stock'); + +print $langs->trans("ReplenishmentStatusDesc").'

'; + +if ($sref || $snom || $sall || $salert || GETPOST('search', 'alpha')) { + $filters = '&sref=' . $sref . '&snom=' . $snom; + $filters .= '&sall=' . $sall; + $filters .= '&salert=' . $salert; + print_barre_liste( + $texte, + $page, + 'replenish.php', + $filters, + $sortfield, + $sortorder, + '', + $num + ); +} else { + $filters = '&sref=' . $sref . '&snom=' . $snom; + $filters .= '&fourn_id=' . $fourn_id; + $filters .= (isset($type)?'&type=' . $type:''); + $filters .= '&salert=' . $salert; + print_barre_liste( + $texte, + $page, + 'replenish.php', + $filters, + $sortfield, + $sortorder, + '', + $num + ); +} + +print '
'. + ''. + ''. + ''. + ''. + ''. + ''. + + '
'; + +$param = (isset($type)? '&type=' . $type : ''); +$param .= '&fourn_id=' . $fourn_id . '&snom='. $snom . '&salert=' . $salert; +$param .= '&sref=' . $sref; + +// Lignes des titres +print ''. + ''; +print_liste_field_titre( + $langs->trans('Ref'), + 'replenish.php', + 'p.ref', + $param, + '', + '', + $sortfield, + $sortorder +); +print_liste_field_titre( + $langs->trans('Label'), + 'replenish.php', + 'p.label', + $param, + '', + '', + $sortfield, + $sortorder +); +if (!empty($conf->service->enabled) && $type == 1) +{ + print_liste_field_titre( + $langs->trans('Duration'), + 'replenish.php', + 'p.duration', + $param, + '', + 'align="center"', + $sortfield, + $sortorder + ); +} +print_liste_field_titre( + $langs->trans('DesiredStock'), + 'replenish.php', + 'p.desiredstock', + $param, + '', + 'align="right"', + $sortfield, + $sortorder +); +if ($conf->global->USE_VIRTUAL_STOCK) +{ + $stocklabel = $langs->trans('VirtualStock'); +} +else +{ + $stocklabel = $langs->trans('PhysicalStock'); +} +print_liste_field_titre( + $stocklabel, + 'replenish.php', + 'stock_physique', + $param, + '', + 'align="right"', + $sortfield, + $sortorder +); +print_liste_field_titre( + $langs->trans('Ordered'), + 'replenish.php', + '', + $param, + '', + 'align="right"', + $sortfield, + $sortorder +); +print_liste_field_titre( + $langs->trans('StockToBuy'), + 'replenish.php', + '', + $param, + '', + 'align="right"', + $sortfield, + $sortorder +); +print_liste_field_titre( + $langs->trans('Supplier'), + 'replenish.php', + '', + $param, + '', + 'align="right"', + $sortfield, + $sortorder +); +print ''; + +// Lignes des champs de filtre +print ''. +''. +''. +''; +if (!empty($conf->service->enabled) && $type == 1) +{ + print ''; +} +print ''. + ''. + ''. + ''. + ''. + ''; + +$prod = new Product($db); + +$var = True; +while ($i < min($num, $limit)) +{ + $objp = $db->fetch_object($resql); + + if ($conf->global->STOCK_SUPPORTS_SERVICES || $objp->fk_product_type == 0) + { + // Multilangs + if (! empty($conf->global->MAIN_MULTILANGS)) + { + $sql = 'SELECT label'; + $sql .= ' FROM ' . MAIN_DB_PREFIX . 'product_lang'; + $sql .= ' WHERE fk_product = ' . $objp->rowid; + $sql .= ' AND lang = "' . $langs->getDefaultLang() . '"'; + $sql .= ' LIMIT 1'; + + $resqlm = $db->query($sql); + if ($resqlm) + { + $objtp = $db->fetch_object($resqlm); + if (!empty($objtp->label)) $objp->label = $objtp->label; + } + } + $form = new Form($db); + $var =! $var; + $prod->ref = $objp->ref; + $prod->id = $objp->rowid; + $prod->type = $objp->fk_product_type; + $ordered = ordered($prod->id); + + if ($conf->global->USE_VIRTUAL_STOCK) + { + //compute virtual stock + $prod->fetch($prod->id); + $result=$prod->load_stats_commande(0, '1,2'); + if ($result < 0) { + dol_print_error($db, $prod->error); + } + $stock_commande_client = $prod->stats_commande['qty']; + $result=$prod->load_stats_commande_fournisseur(0, '3'); + if ($result < 0) { + dol_print_error($db,$prod->error); + } + $stock_commande_fournisseur = $prod->stats_commande_fournisseur['qty']; + $stock = $objp->stock_physique - $stock_commande_client + $stock_commande_fournisseur; + } + else + { + $stock = $objp->stock_physique; + } + $warning=''; + + if ($objp->seuil_stock_alerte && ($stock < $objp->seuil_stock_alerte)) + { + $warning = img_warning($langs->trans('StockTooLow')) . ' '; + } + //depending on conf, use either physical stock or + //virtual stock to compute the stock to buy value + $stocktobuy = max($objp->desiredstock - $stock - $ordered, 0); + $disabled = ''; + if($ordered > 0) { + if($ordered + $stock >= $objp->desiredstock) { + $picto = img_picto('', './img/yes', '', 1); + $disabled = 'disabled="disabled"'; + } + else { + $picto = img_picto('', './img/no', '', 1); + } + } else { + $picto = img_picto('', './img/no', '', 1); + } + + print ''; + + // Select field + //print ''; + print ''; + + print ''. + ''. + ''; + + if (!empty($conf->service->enabled) && $type == 1) { + if (preg_match('/([0-9]+)y/i', $objp->duration, $regs)) { + $duration = $regs[1] . ' ' . $langs->trans('DurationYear'); + } elseif (preg_match('/([0-9]+)m/i', $objp->duration, $regs)) { + $duration = $regs[1] . ' ' . $langs->trans('DurationMonth'); + } elseif (preg_match('/([0-9]+)d/i', $objp->duration, $regs)) { + $duration = $regs[1] . ' ' . $langs->trans('DurationDay'); + } else { + $duration = $objp->duration; + } + print ''; + } + + print ''. + ''. + ''; + + // To order + //print ''; + print ''; + + // Supplier + print ''; + + print ''; + } + $i++; +} +$value = $langs->trans("CreateOrders"); +print '
 '. +''. +''. +''. +'  ' . $langs->trans('AlertOnly') . '   '. + ''. + ''. + '
'. + $prod->getNomUrl(1, '', 16). + '' . $objp->label . ''. + $duration. + '' . $objp->desiredstock . ''. + $warning . $stock. + ''. + ''. + $ordered . ' ' . $picto. + ''. $form->select_product_fourn_price($prod->id, 'fourn'.$i, 1).'
'. + ''. + ''. + '
'. + ''. + '
'. + ''; + +if ($num > $conf->liste_limit) +{ + if ($sref || $snom || $sall || $salert || GETPOST('search', 'alpha')) + { + $filters = '&sref=' . $sref . '&snom=' . $snom; + $filters .= '&sall=' . $sall; + $filters .= '&salert=' . $salert; + print_barre_liste( + '', + $page, + 'replenish.php', + $filters, + $sortfield, + $sortorder, + '', + $num, + 0, + '' + ); + } else { + $filters = '&sref=' . $sref . '&snom=' . $snom; + $filters .= '&fourn_id=' . $fourn_id; + $filters .= (isset($type)? '&type=' . $type : ''); + $filters .= '&salert=' . $salert; + print_barre_liste( + '', + $page, + 'replenish.php', + $filters, + $sortfield, + $sortorder, + '', + $num, + 0, + '' + ); + } +} + +$db->free($resql); + +print ' +'; + + llxFooter(); $db->close(); -?> +?> \ No newline at end of file diff --git a/htdocs/product/stock/replenishorders.php b/htdocs/product/stock/replenishorders.php index e5e4379baa8..be7a0ed0821 100644 --- a/htdocs/product/stock/replenishorders.php +++ b/htdocs/product/stock/replenishorders.php @@ -48,7 +48,9 @@ $head[0][2] = 'replenish'; $head[1][0] = DOL_URL_ROOT.'/product/stock/replenishorders.php'; $head[1][1] = $texte; $head[1][2] = 'replenishorders'; + dol_fiche_head($head, 'replenishorders', $langs->trans('Replenishment'), 0, 'stock'); + $commandestatic = new CommandeFournisseur($db); $sref = GETPOST('search_ref', 'alpha'); $snom = GETPOST('search_nom', 'alpha'); @@ -72,21 +74,15 @@ if (!$sortfield) { $offset = $conf->liste_limit * $page ; $sql = 'SELECT s.rowid as socid, s.nom, cf.date_creation as dc,'; -$sql .= ' cf.rowid, cf.ref, cf.fk_statut, cf.total_ttc'; -$sql .= ", cf.fk_user_author, u.login"; -$sql .= ' FROM (' . MAIN_DB_PREFIX . 'societe as s,'; -$sql .= ' ' . MAIN_DB_PREFIX . 'commande_fournisseur as cf'; - +$sql.= ' cf.rowid, cf.ref, cf.fk_statut, cf.total_ttc, cf.fk_user_author,'; +$sql.= ' u.login'; +$sql.= ' FROM '.MAIN_DB_PREFIX.'societe as s, '.MAIN_DB_PREFIX.'commande_fournisseur as cf'; +$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'user as u ON cf.fk_user_author = u.rowid'; if (!$user->rights->societe->client->voir && !$socid) { $sql.= ', ' . MAIN_DB_PREFIX . 'societe_commerciaux as sc'; - } - -$sql .= ') LEFT JOIN ' . MAIN_DB_PREFIX . 'user as u '; -$sql .= 'ON cf.fk_user_author = u.rowid'; -$sql .= ' WHERE cf.fk_soc = s.rowid '; -$sql .= ' AND cf.entity = ' . $conf->entity; - +$sql.= ' WHERE cf.fk_soc = s.rowid '; +$sql.= ' AND cf.entity = ' . $conf->entity; if ($conf->global->STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER) { $sql .= ' AND cf.fk_statut < 3'; } elseif ($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER) { @@ -94,7 +90,6 @@ if ($conf->global->STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER) { } else { $sql .= ' AND cf.fk_statut < 5'; } - if (!$user->rights->societe->client->voir && !$socid) { $sql .= ' AND s.rowid = sc.fk_soc AND sc.fk_user = ' . $user->id; } @@ -117,13 +112,13 @@ if ($suser) { if ($sttc) { $sql .= ' AND cf.total_ttc = ' . price2num($sttc); } -if ($sdate) +if ($sdate) { - if (GETPOST('search_datemonth', 'int') && GETPOST('search_dateday', 'int') && GETPOST('search_dateyear', 'int')) + if (GETPOST('search_datemonth', 'int') && GETPOST('search_dateday', 'int') && GETPOST('search_dateyear', 'int')) { $date = dol_mktime(0, 0, 0, GETPOST('search_datemonth', 'int'), GETPOST('search_dateday', 'int'), GETPOST('search_dateyear', 'int')); } - else + else { $date = dol_stringtotime($sdate); } @@ -145,20 +140,24 @@ $sql .= ', cf.total_ttc, cf.fk_user_author, u.login, s.rowid, s.nom'; $sql .= ' ORDER BY ' . $sortfield . ' ' . $sortorder . ' '; $sql .= $db->plimit($conf->liste_limit+1, $offset); $resql = $db->query($sql); -if ($resql) +if ($resql) { $num = $db->num_rows($resql); $i = 0; + print $langs->trans("ReplenishmentOrdersDesc").'

'; + print_barre_liste( - $langs->trans('ReplenishmentOrders'), + '', $page, 'replenishorders.php', '', $sortfield, $sortorder, '', - $num + $num, + 0, + '' ); print '
'. ''. @@ -255,8 +254,7 @@ if ($resql) { $obj = $db->fetch_object($resql); $var = !$var; - if (!dispatched($obj->rowid) && - (!$sproduct || in_array($sproduct, getProducts($obj->rowid)))) + if (!dispatched($obj->rowid) && (!$sproduct || in_array($sproduct, getProducts($obj->rowid)))) { $href = DOL_URL_ROOT . '/fourn/commande/fiche.php?id=' . $obj->rowid; print ''. @@ -288,9 +286,10 @@ if ($resql) ''; + // Date if ($obj->dc) { - $date = dol_print_date($db->jdate($obj->dc), 'day'); + $date = dol_print_date($db->jdate($obj->dc), 'dayhour'); } else { $date = '-'; } @@ -310,6 +309,10 @@ if ($resql) $db->free($resql); } +else +{ + dol_print_error($db); +} llxFooter(); $db->close(); diff --git a/htdocs/societe/class/address.class.php b/htdocs/societe/class/address.class.php deleted file mode 100644 index 0f1091b37ce..00000000000 --- a/htdocs/societe/class/address.class.php +++ /dev/null @@ -1,524 +0,0 @@ - - * Copyright (C) 2004-2006 Laurent Destailleur - * Copyright (C) 2005-2011 Regis Houssin - * - * 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/societe/class/address.class.php - * \ingroup societe - * \brief Fichier de la classe des adresses des tiers - */ - - -/** - * \class Address - * \brief Class to manage addresses - */ -class Address -{ - var $db; - - var $id; - var $type; - var $label; - var $socid; - var $name; - var $address; - var $zip; - var $town; - var $country_id; - var $country_code; - var $phone; - var $fax; - var $note; - - - /** - * Constructor - * - * @param DoliDB $db Database handler - */ - function __construct($db) - { - $this->db = $db; - } - - /** - * Create address into database - * - * @param int $socid Company socid - * @param User $user Object user making creation - * @return int 0 if OK, < 0 if KO - */ - function create($socid, $user='') - { - global $langs,$conf; - - // Nettoyage parametres - $this->name = trim($this->name); - $this->label = trim($this->label); - - dol_syslog(get_class($this)."::create label=".$this->label); - - $this->db->begin(); - - $result = $this->verify(); - - if ($result >= 0) - { - $now=dol_now(); - - $sql = "INSERT INTO ".MAIN_DB_PREFIX."societe_address (label, fk_soc, name, datec, fk_user_creat) "; - $sql .= " VALUES ('".$this->db->escape($this->label)."', '".$socid."', '".$this->db->escape($this->name)."', ".$this->db->idate($now).", '".$user->id."')"; - - $result=$this->db->query($sql); - if ($result) - { - $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."societe_address"); - - $ret = $this->update($this->id, $socid, $user); - - if ($ret >= 0) - { - dol_syslog(get_class($this)."::create success id=".$this->id); - $this->db->commit(); - return 0; - } - else - { - dol_syslog(get_class($this)."::create echec update"); - $this->db->rollback(); - return -3; - } - } - else - - { - if ($this->db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') - { - - $this->error=$langs->trans("ErrorCompanyNameAlreadyExists",$this->nom); - } - else - { - dol_syslog(get_class($this)."::create echec insert sql=$sql"); - } - $this->db->rollback(); - return -2; - } - - } - else - { - $this->db->rollback(); - dol_syslog(get_class($this)."::create echec verify sql=$sql"); - return -1; - } - } - - - /** - * Verification lors de la modification de l'adresse - * - * @return int 0 if OK, <0 if KO - */ - function verify() - { - $this->label = trim($this->label); - $this->name = trim($this->name); - $result = 0; - if (!$this->name || !$this->label) - { - $this->error = "The name of company and the label can not be empty.\n"; - $result = -2; - } - return $result; - } - - - /** - * Mise a jour des parametres de l'adresse - * - * @param int $id id address - * @param int $socid id third party - * @param User $user Utilisateur qui demande la mise a jour - * @return int <0 if KO, >=0 if OK - */ - function update($id, $socid, $user='') - { - global $langs; - - // Clean parameters - $this->fk_soc = $socid; - $this->label = trim($this->label); - $this->name = trim($this->name); - $this->address = trim($this->address); - $this->zip = trim($this->zip); - $this->town = trim($this->town); - $this->country_id = trim($this->country_id); - $this->phone = trim($this->phone); - $this->phone = preg_replace("/\s/","",$this->phone); - $this->phone = preg_replace("/\./","",$this->phone); - $this->fax = trim($this->fax); - $this->fax = preg_replace("/\s/","",$this->fax); - $this->fax = preg_replace("/\./","",$this->fax); - $this->note = trim($this->note); - - $result = $this->verify(); // Verifie que nom et label obligatoire - - if ($result >= 0) - { - dol_syslog(get_class($this)."::Update verify ok"); - - $this->db->begin(); - - $sql = "UPDATE ".MAIN_DB_PREFIX."societe_address"; - $sql.= " SET label = '" . $this->db->escape($this->label) ."'"; // Champ obligatoire - $sql.= ", name = '" . $this->db->escape($this->name) ."'"; // Champ obligatoire - $sql.= ", address = ".($this->address?"'".$this->db->escape($this->address)."'":"null"); - $sql.= ", zip = ".($this->zip?"'".$this->db->escape($this->zip)."'":"null"); - $sql.= ", town = ".($this->town?"'".$this->db->escape($this->town)."'":"null"); - $sql.= ", fk_pays = '" . ($this->country_id?$this->db->escape($this->country_id):'0') ."'"; - $sql.= ", note = ".($this->note?"'".$this->db->escape($this->note)."'":"null"); - $sql.= ", phone = ".($this->phone?"'".$this->db->escape($this->phone)."'":"null"); - $sql.= ", fax = ".($this->fax?"'".$this->db->escape($this->fax)."'":"null"); - if ($user) $sql .= ",fk_user_modif = '".$user->id."'"; - $sql .= " WHERE fk_soc = '" . $socid ."' AND rowid = '" . $this->db->escape($id) ."'"; - - dol_syslog(get_class($this)."::Update sql=".$sql, LOG_DEBUG); - $resql=$this->db->query($sql); - if ($resql) - { - dol_syslog(get_class($this)."::Update success"); - $this->db->commit(); - return 1; - } - else - { - if ($this->db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') - { - - $this->error=$langs->trans("ErrorDuplicateField",$this->name); - $result=-1; - } - else - { - $this->error=$this->db->lasterror(); - dol_syslog(get_class($this)."::Update error sql=".$sql, LOG_ERR); - $result=-2; - } - $this->db->rollback(); - return $result; - } - } - - } - - /** - * Charge depuis la base toutes les adresses d'une societe - * - * @param int $socid Id de la societe a charger en memoire - * @param User $user Objet de l'utilisateur - * @return int >0 si ok, <0 si ko - */ - function fetch_lines($socid, $user=0) - { - global $langs, $conf; - - $sql = 'SELECT rowid, nom, client, fournisseur'; - $sql .= ' FROM '.MAIN_DB_PREFIX.'societe'; - $sql .= ' WHERE rowid = '.$socid; - - $resqlsoc=$this->db->query($sql); - if ($resqlsoc) - { - if ($this->db->num_rows($resqlsoc)) - { - $obj = $this->db->fetch_object($resqlsoc); - - $this->socname = $obj->nom; - $this->socid = $obj->rowid; - $this->id = $obj->rowid; - $this->client = $obj->client; - $this->fournisseur = $obj->fournisseur; - } - - $this->db->free($resqlsoc); - - $this->lines = array(); - - // Adresses liees a la societe - if ($this->socid) - { - $sql = 'SELECT a.rowid as id, a.label, a.name, a.address, a.datec as dc'; - $sql .= ', a.tms as date_update, a.fk_soc'; - $sql .= ', a.zip, a.town, a.note, a.fk_pays as country_id, a.phone, a.fax'; - $sql .= ', p.code as country_code, p.libelle as country'; - $sql .= ' FROM '.MAIN_DB_PREFIX.'societe_address as a'; - $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_pays as p ON a.fk_pays = p.rowid'; - $sql .= ' WHERE a.fk_soc = '.$this->socid; - - $resql=$this->db->query($sql); - if ($resql) - { - $num = $this->db->num_rows($resql); - $i = 0; - while ($i < $num) - { - $objp = $this->db->fetch_object($resql); - - $line = new AddressLine($this->db); - - $line->id = $objp->id; - $line->date_creation = $this->db->jdate($objp->dc); - $line->date_update = $this->db->jdate($objp->date_update); - $line->label = $objp->label; - $line->name = $objp->name; - $line->address = $objp->address; - $line->zip = $objp->zip; - $line->town = $objp->town; - $line->country_id = $objp->country_id; - $line->country_code = $objp->country_id?$objp->country_code:''; - $line->country = $objp->country_id?($langs->trans('Country'.$objp->country_code)!='Country'.$objp->country_code?$langs->trans('Country'.$objp->country_code):$objp->country):''; - $line->phone = $objp->phone; - $line->fax = $objp->fax; - $line->note = $objp->note; - - $this->lines[$i] = $line; - $i++; - } - $this->db->free($resql); - return $num; - } - else - { - dol_syslog(get_class($this).'::Fetch Erreur: aucune adresse', LOG_ERR); - return 0; - } - } - else - { - dol_syslog(get_class($this).'::Fetch Erreur: societe inconnue', LOG_ERR); - return -1; - } - } - else - { - dol_syslog(get_class($this).'::Fetch '.$this->db->error(), LOG_ERR); - $this->error=$this->db->error(); - } - } - - /** - * Charge depuis la base l'objet adresse - * - * @param int $id Id de l'adresse a charger en memoire - * @param User $user Objet de l'utilisateur - * @return int >0 si ok, <0 si ko - */ - function fetch_address($id, $user=0) - { - global $langs; - global $conf; - - $sql = 'SELECT a.rowid, a.fk_soc, a.label, a.name, a.address, a.datec as date_creation'; - $sql .= ', a.tms as date_update'; - $sql .= ', a.zip, a.town, a.note, a.fk_pays as country_id, a.phone, a.fax'; - $sql .= ', p.code as country_code, p.libelle as country'; - $sql .= ' FROM '.MAIN_DB_PREFIX.'societe_address as a'; - $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_pays as p ON a.fk_pays = p.rowid'; - $sql .= ' WHERE a.rowid = '.$id; - $resql=$this->db->query($sql); - if ($resql) - { - if ($this->db->num_rows($resql)) - { - $obj = $this->db->fetch_object($resql); - - $this->id = $obj->rowid; - $this->socid = $obj->fk_soc; - - $this->date_update = $this->db->jdate($obj->date_update); - $this->date_creation = $this->db->jdate($obj->date_creation); - - $this->label = $obj->label; - $this->name = $obj->name; - $this->address = $obj->address; - $this->zip = $obj->zip; - $this->town = $obj->town; - - $this->country_id = $obj->country_id; - $this->country_code = $obj->country_id?$obj->country_code:''; - $this->country = $obj->country_id?($langs->trans('Country'.$obj->country_code)!='Country'.$obj->country_code?$langs->trans('Country'.$obj->country_code):$obj->country):''; - - $this->phone = $obj->phone; - $this->fax = $obj->fax; - $this->note = $obj->note; - - $result = 1; - } - else - { - dol_syslog('Erreur Societe::Fetch aucune adresse avec id='.$this->id.' - '.$sql); - $this->error='Erreur Societe::Fetch aucune adresse avec id='.$this->id.' - '.$sql; - $result = -2; - } - - $this->db->free($resql); - } - else - { - dol_syslog('Erreur Societe::Fetch echec sql='.$sql); - dol_syslog('Erreur Societe::Fetch '.$this->db->error()); - $this->error=$this->db->error(); - $result = -3; - } - - return $result; - } - - - /** - * Suppression d'une adresse - * - * @param int $id id de la societe a supprimer - * @param int $socid id third party - * @return void - */ - function delete($id,$socid) - { - dol_syslog("Address::Delete"); - - $sql = "DELETE FROM ".MAIN_DB_PREFIX."societe_address"; - $sql.= " WHERE rowid = ".$id; - $sql.= " AND fk_soc = ".$socid; - - $result = $this->db->query($sql); - - if (!$result) - { - print $this->db->error() . '
' . $sql; - } - } - - /** - * Return name of address with link (and eventually picto) - * Use $this->id, $this->label, $this->socid - * - * @param int $withpicto Include picto with link - * @param string $option Where the link point to - * @return string String with URL - */ - function getNomUrl($withpicto=0,$option='') - { - global $langs; - - $result=''; - - $lien = ''; - $lienfin=''; - - if ($withpicto) $result.=($lien.img_object($langs->trans("ShowAddress").': '.$this->label,'address').$lienfin.' '); - $result.=$lien.$this->label.$lienfin; - return $result; - } - - - /** - * Charge les informations d'ordre info dans l'objet societe - * - * @param int $id id de la societe a charger - * @return void - */ - function info($id) - { - $sql = "SELECT s.rowid, s.nom, datec, datea,"; - $sql.= " fk_user_creat, fk_user_modif"; - $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; - $sql.= " WHERE s.rowid = ".$id; - - $result=$this->db->query($sql); - if ($result) - { - if ($this->db->num_rows($result)) - { - $obj = $this->db->fetch_object($result); - - $this->id = $obj->rowid; - - if ($obj->fk_user_creat) { - $cuser = new User($this->db); - $cuser->fetch($obj->fk_user_creat); - $this->user_creation = $cuser; - } - - if ($obj->fk_user_modif) { - $muser = new User($this->db); - $muser->fetch($obj->fk_user_modif); - $this->user_modification = $muser; - } - $this->ref = $obj->nom; - $this->date_creation = $this->db->jdate($obj->datec); - $this->date_modification = $this->db->jdate($obj->datea); - } - - $this->db->free($result); - - } - else - { - dol_print_error($this->db); - } - } - -} - - -/** - * \class AddressLine - * \brief Class to manage one address line - */ -class AddressLine -{ - - var $id; - var $date_creation; - var $date_update; - var $label; - var $name; - var $address; - var $zip; - var $town; - var $country_id; - var $country_code; - var $country; - var $phone; - var $fax; - var $note; - - - /** - * Constructor - * - * @param DoliDB $db Database handler - */ - function __construct($db) - { - $this->db = $db; - } -} -?> \ No newline at end of file
'. price($obj->total_ttc). '