diff --git a/dev/codesniffer/ruleset.xml b/dev/codesniffer/ruleset.xml index 3926d2fdde7..aae09c3597a 100755 --- a/dev/codesniffer/ruleset.xml +++ b/dev/codesniffer/ruleset.xml @@ -203,11 +203,15 @@ 0 + 0 + + 0 + 0 diff --git a/dev/skeletons/modMyModule.class.php b/dev/skeletons/modMyModule.class.php index e599665b645..8f819e58438 100644 --- a/dev/skeletons/modMyModule.class.php +++ b/dev/skeletons/modMyModule.class.php @@ -83,7 +83,7 @@ class modMyModule extends DolibarrModules // 'models' => 0, // Set this to 1 if module has its own models directory (core/modules/xxx) // 'css' => '/mymodule/css/mymodule.css.php', // Set this to relative path of css if module has its own css file // 'hooks' => array('hookcontext1','hookcontext2') // Set here all hooks context managed by module - // 'workflow' => array('order' => array('WORKFLOW_ORDER_AUTOCREATE_INVOICE')) // Set here all workflow context managed by module + // 'workflow' => array('WORKFLOW_MODULE1_YOURACTIONTYPE_MODULE2'=>array('enabled'=>'! empty($conf->module1->enabled) && ! empty($conf->module2->enabled)', 'picto'=>'yourpicto@mymodule')) // Set here all workflow context managed by module // ); $this->module_parts = array(); diff --git a/htdocs/adherents/document.php b/htdocs/adherents/document.php index 5b7ca0d2614..0ba89db6895 100644 --- a/htdocs/adherents/document.php +++ b/htdocs/adherents/document.php @@ -40,13 +40,6 @@ $id=GETPOST('id','int'); $action=GETPOST('action','alpha'); $confirm=GETPOST('confirm','alpha'); -$mesg=''; -if (isset($_SESSION['DolMessage'])) -{ - $mesg=$_SESSION['DolMessage']; - unset($_SESSION['DolMessage']); -} - // Security check if ($user->societe_id > 0) { @@ -120,7 +113,7 @@ if ($action == 'confirm_deletefile' && $confirm == 'yes') $langs->load("other"); $file = $upload_dir . "/" . GETPOST('urlfile'); // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP). dol_delete_file($file); - $_SESSION['DolMessage'] = '
'.$langs->trans("FileWasRemoved",GETPOST('urlfile')).'
'; + $_SESSION['dol_message'] = '
'.$langs->trans("FileWasRemoved",GETPOST('urlfile')).'
'; Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id); exit; } diff --git a/htdocs/admin/company.php b/htdocs/admin/company.php index 3e995d780be..c0c1fcba460 100644 --- a/htdocs/admin/company.php +++ b/htdocs/admin/company.php @@ -740,7 +740,7 @@ else // Forme juridique $var=!$var; print ''.$langs->trans("JuridicalStatus").''; - print getFormeJuridiqueLabel($conf->global->MAIN_INFO_SOCIETE_FORME_JURIDIQUE,1); + print getFormeJuridiqueLabel($conf->global->MAIN_INFO_SOCIETE_FORME_JURIDIQUE); print ''; // ProfId1 diff --git a/htdocs/admin/modules.php b/htdocs/admin/modules.php index e0eb74f6aca..8c39f3a8fe7 100644 --- a/htdocs/admin/modules.php +++ b/htdocs/admin/modules.php @@ -200,7 +200,7 @@ print $langs->trans("TotalNumberOfActivatedModules",($nbofactivatedmodules-1)); if ($nbofactivatedmodules <= 1) print ' '.img_warning($langs->trans("YouMustEnableOneModule")); print '
'."\n"; -print "
\n"; +print "
\n"; $h = 0; diff --git a/htdocs/admin/workflow.php b/htdocs/admin/workflow.php index 33f16d98a7b..c9fe8782a45 100755 --- a/htdocs/admin/workflow.php +++ b/htdocs/admin/workflow.php @@ -77,34 +77,40 @@ print "\n"; clearstatcache(); $workflowcodes=array( - 'WORKFLOW_PROPAL_AUTOCREATE_ORDER'=>array('enabled'=>($conf->propal->enabled && $conf->commande->enabled), 'picto'=>'order'), - 'WORKFLOW_ORDER_CLASSIFY_BILLED_PROPAL'=>array('enabled'=>($conf->propal->enabled && $conf->commande->enabled), 'picto'=>'order','warning'=>'WarningCloseAlways'), - 'WORKFLOW_ORDER_AUTOCREATE_INVOICE'=>array('enabled'=>($conf->commande->enabled && $conf->facture->enabled), 'picto'=>'bill'), - 'WORKFLOW_INVOICE_CLASSIFY_BILLED_ORDER'=>array('enabled'=>($conf->facture->enabled && $conf->commande->enabled), 'picto'=>'bill','warning'=>'WarningCloseAlways'), + 'WORKFLOW_PROPAL_AUTOCREATE_ORDER'=>array('enabled'=>'! empty($conf->propal->enabled) && ! empty($conf->commande->enabled)', 'picto'=>'order'), + 'WORKFLOW_ORDER_CLASSIFY_BILLED_PROPAL'=>array('enabled'=>'! empty($conf->propal->enabled) && ! empty($conf->commande->enabled)', 'picto'=>'order','warning'=>'WarningCloseAlways'), + 'WORKFLOW_ORDER_AUTOCREATE_INVOICE'=>array('enabled'=>'! empty($conf->commande->enabled) && ! empty($conf->facture->enabled)', 'picto'=>'bill'), + 'WORKFLOW_INVOICE_CLASSIFY_BILLED_ORDER'=>array('enabled'=>'! empty($conf->facture->enabled) && ! empty($conf->commande->enabled)', 'picto'=>'bill','warning'=>'WarningCloseAlways'), ); -if (! empty($conf->modules_parts['workflow']) && is_array($conf->modules_parts['workflow'])) $workflow = array_merge($workflow, $conf->modules_parts['workflow']); +if (! empty($conf->modules_parts['workflow']) && is_array($conf->modules_parts['workflow'])) +{ + foreach($conf->modules_parts['workflow'] as $workflow) + { + $workflowcodes = array_merge($workflowcodes, $workflow); + } +} $nbqualified=0; -foreach($workflowcodes as $key => $tmparray) +foreach($workflowcodes as $key => $params) { - $picto=$tmparray['picto']; - $enabled=$tmparray['enabled']; - if (empty($enabled)) continue; + $picto=$params['picto']; + $enabled=$params['enabled']; + if (! verifCond($enabled)) continue; $nbqualified++; $var = !$var; print "\n"; print "".img_object('', $picto).$langs->trans('desc'.$key); - if (! empty($tmparray['warning'])) + if (! empty($params['warning'])) { $langs->load("errors"); - print ' '.img_warning($langs->transnoentitiesnoconv($tmparray['warning'])); + print ' '.img_warning($langs->transnoentitiesnoconv($params['warning'])); } print "\n"; print ''; - if ($conf->use_javascript_ajax) + if (! empty($conf->use_javascript_ajax)) { print ajax_constantonoff($key); } diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index c0f92cc9288..b2e8bad1f03 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -1084,21 +1084,28 @@ class Categorie */ function get_all_ways () { - $ways = array (); + $ways = array(); - foreach ($this->get_meres() as $mere) + $parents=$this->get_meres(); + if (! empty($parents)) { - foreach ($mere->get_all_ways() as $way) + foreach ($parents as $parent) { - $w = $way; - $w[] = $this; - - $ways[] = $w; + $allways=$parent->get_all_ways(); + if (! empty($allways)) + { + foreach ($allways as $way) + { + $w = $way; + $w[] = $this; + $ways[] = $w; + } + } } - } - if (count($ways) == 0) - $ways[0][0] = $this; + if (count($ways) == 0) + $ways[0][0] = $this; + } return $ways; } diff --git a/htdocs/comm/fiche.php b/htdocs/comm/fiche.php index 962d15653e5..a4316343284 100644 --- a/htdocs/comm/fiche.php +++ b/htdocs/comm/fiche.php @@ -78,7 +78,7 @@ if ($action == 'setcustomeraccountancycode') $result=$object->update($object->id,$user,1,1,0); if ($result < 0) { - $mesg=join(',',$object->errors); + $mesgs[]=join(',',$object->errors); } $action=""; } @@ -158,11 +158,6 @@ if ($id > 0) dol_print_error($db,$object->error); } - if ($errmesg) - { - print "".$errmesg."
"; - } - /* * Affichage onglets */ @@ -821,6 +816,7 @@ else dol_print_error($db,'Bad value for socid parameter'); } +dol_htmloutput_mesg('',$mesgs); // End of page llxFooter(); diff --git a/htdocs/comm/mailing/fiche.php b/htdocs/comm/mailing/fiche.php index 7f070c07df5..e7ed17f5e04 100644 --- a/htdocs/comm/mailing/fiche.php +++ b/htdocs/comm/mailing/fiche.php @@ -41,13 +41,6 @@ $action=GETPOST('action','alpha'); $confirm=GETPOST('confirm','alpha'); $urlfrom=GETPOST('urlfrom'); -$mesg=''; -if (isset($_SESSION['DolMessage'])) -{ - $mesg=$_SESSION['DolMessage']; - unset($_SESSION['DolMessage']); -} - $object=new Mailing($db); $result=$object->fetch($id); @@ -79,7 +72,7 @@ if ($conf->global->MAILING_EMAIL_UNSUBSCRIBE) $object->substitutionarray, array( '__CHECK_READ__' => 'CheckMail', - '__UNSUSCRIBE__' => 'Unsubscribe' + '__UNSUBSCRIBE__' => 'Unsubscribe' ) ); } @@ -104,7 +97,7 @@ if ($conf->global->MAILING_EMAIL_UNSUBSCRIBE) $object->substitutionarrayfortest, array( '__CHECK_READ__' => 'TESTCheckMail', - '__UNSUSCRIBE__' => 'TESTUnsubscribe' + '__UNSUBSCRIBE__' => 'TESTUnsubscribe' ) ); } @@ -231,7 +224,7 @@ if ($action == 'sendallconfirmed' && $confirm == 'yes') '__ID__' => $obj->source_id, '__EMAIL__' => $obj->email, '__CHECK_READ__' => '', - '__UNSUSCRIBE__' => ''.$langs->trans("MailUnsubcribe").'', + '__UNSUBSCRIBE__' => ''.$langs->trans("MailUnsubcribe").'', '__MAILTOEMAIL__' => ''.$obj->email.'', '__LASTNAME__' => $obj->nom, '__FIRSTNAME__' => $obj->prenom, @@ -562,7 +555,7 @@ if ($action == 'confirm_valid' && $confirm == 'yes') { $object->valid($user); - $_SESSION['DolMessage']='
'.$langs->trans("MailingSuccessfullyValidated").'
'; + $_SESSION['dol_message']='
'.$langs->trans("MailingSuccessfullyValidated").'
'; Header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); exit; @@ -928,7 +921,7 @@ else print '

'; } - if (! empty($mesgembedded)) dol_htmloutput_mesg($mesgembedded,'','warning',1); + if (! empty($mesgembedded)) dol_htmloutput_mesg($mesgembedded,'','warning',1); // Affichage formulaire de TEST if ($action == 'test') diff --git a/htdocs/comm/propal.php b/htdocs/comm/propal.php index 01943653763..b8f03a32b38 100644 --- a/htdocs/comm/propal.php +++ b/htdocs/comm/propal.php @@ -63,6 +63,7 @@ $search_montant_ht=GETPOST('search_montant_ht','alpha'); $sall=GETPOST("sall"); $mesg=(GETPOST("msg") ? GETPOST("msg") : GETPOST("mesg")); +$mesgs=array(); $year=GETPOST("year"); $month=GETPOST("month"); @@ -824,8 +825,8 @@ else if ($action == "addline" && $user->rights->propale->creer) -1, 0, $_POST['fk_parent_line'], - $fk_fournprice, - $pa_ht + $fk_fournprice, + $pa_ht ); if ($result > 0) @@ -863,7 +864,7 @@ else if ($action == "addline" && $user->rights->propale->creer) } // Mise a jour d'une ligne dans la propale -else if ($action == 'updateligne' && $user->rights->propale->creer && $_POST["save"] == $langs->trans("Save")) +else if ($action == 'updateligne' && $user->rights->propale->creer && GETPOST('save') == $langs->trans("Save")) { if (! $object->fetch($_POST["id"]) > 0) { @@ -922,9 +923,9 @@ else if ($action == 'updateligne' && $user->rights->propale->creer && $_POST["sa $info_bits, $special_code, $_POST['fk_parent_line'], - 0, - $fk_fournprice, - $pa_ht + 0, + $fk_fournprice, + $pa_ht ); // Define output language @@ -1266,7 +1267,7 @@ print $formconfirm; print ''; -$linkback=''.$langs->trans("BackToList").''; +$linkback=''.$langs->trans("BackToList").''; // Ref print ''; print ''; // Project -if ($conf->projet->enabled) +if (! empty($conf->projet->enabled)) { $langs->load("projects"); print '
'.$langs->trans('Ref').''; @@ -1278,7 +1279,7 @@ print '
'; print ''; -if ($action != 'refclient' && $object->brouillon) print ''; +if ($action != 'refclient' && ! empty($object->brouillon)) print ''; print '
'; print $langs->trans('RefCustomer').''; print ''.img_edit($langs->trans('Modify')).''.img_edit($langs->trans('Modify')).'
'; print '
'; if ($user->rights->propale->creer && $action == 'refclient') @@ -1337,10 +1338,10 @@ print ''; print ''; -if ($action != 'editdate' && $object->brouillon) print ''; +if ($action != 'editdate' && ! empty($object->brouillon)) print ''; print '
'; print $langs->trans('Date'); print 'id.'">'.img_edit($langs->trans('SetDate'),1).'id.'">'.img_edit($langs->trans('SetDate'),1).'
'; print '
'; -if ($object->brouillon && $action == 'editdate') +if (! empty($object->brouillon) && $action == 'editdate') { print '
'; print ''; @@ -1368,10 +1369,10 @@ print '
'; print ''; -if ($action != 'editecheance' && $object->brouillon) print ''; +if ($action != 'editecheance' && ! empty($object->brouillon)) print ''; print '
'; print $langs->trans('DateEndPropal'); print 'id.'">'.img_edit($langs->trans('SetConditions'),1).'id.'">'.img_edit($langs->trans('SetConditions'),1).'
'; print '
'; -if ($object->brouillon && $action == 'editecheance') +if (! empty($object->brouillon) && $action == 'editecheance') { print ''; print ''; @@ -1382,7 +1383,7 @@ if ($object->brouillon && $action == 'editecheance') } else { - if ($object->fin_validite) + if (! empty($object->fin_validite)) { print dol_print_date($object->fin_validite,'daytext'); if ($object->statut == 1 && $object->fin_validite < ($now - $conf->propal->cloture->warning_delay)) print img_warning($langs->trans("Late")); @@ -1400,7 +1401,7 @@ print '
'; print ''; -if ($action != 'editconditions' && $object->brouillon) print ''; +if ($action != 'editconditions' && ! empty($object->brouillon)) print ''; print '
'; print $langs->trans('PaymentConditionsShort'); print 'id.'">'.img_edit($langs->transnoentitiesnoconv('SetConditions'),1).'id.'">'.img_edit($langs->transnoentitiesnoconv('SetConditions'),1).'
'; print '
'; if ($action == 'editconditions') @@ -1420,7 +1421,7 @@ print '
'; print ''; -if ($action != 'editdate_livraison' && $object->brouillon) print ''; +if ($action != 'editdate_livraison' && ! empty($object->brouillon)) print ''; print '
'; print $langs->trans('DeliveryDate'); print 'id.'">'.img_edit($langs->transnoentitiesnoconv('SetDeliveryDate'),1).'id.'">'.img_edit($langs->transnoentitiesnoconv('SetDeliveryDate'),1).'
'; print '
'; if ($action == 'editdate_livraison') @@ -1443,9 +1444,9 @@ print '
'; print ''; -if ($action != 'editavailability' && $object->brouillon) print ''; +if ($action != 'editavailability' && ! empty($object->brouillon)) print ''; print '
'; print $langs->trans('AvailabilityPeriod'); -if ($conf->commande->enabled) print ' ('.$langs->trans('AfterOrder').')'; +if (! empty($conf->commande->enabled)) print ' ('.$langs->trans('AfterOrder').')'; print 'id.'">'.img_edit($langs->transnoentitiesnoconv('SetAvailability'),1).'id.'">'.img_edit($langs->transnoentitiesnoconv('SetAvailability'),1).'
'; print '
'; if ($action == 'editavailability') @@ -1465,7 +1466,7 @@ print '
'; print ''; -if ($action != 'editdemandreason' && $object->brouillon) print ''; +if ($action != 'editdemandreason' && ! empty($object->brouillon)) print ''; print '
'; print $langs->trans('Source'); print 'id.'">'.img_edit($langs->transnoentitiesnoconv('SetDemandReason'),1).'id.'">'.img_edit($langs->transnoentitiesnoconv('SetDemandReason'),1).'
'; print '
'; //print $object->demand_reason_id; @@ -1487,7 +1488,7 @@ print ''; print ''; -if ($action != 'editmode' && $object->brouillon) print ''; +if ($action != 'editmode' && ! empty($object->brouillon)) print ''; print '
'; print $langs->trans('PaymentMode'); print 'id.'">'.img_edit($langs->transnoentitiesnoconv('SetMode'),1).'id.'">'.img_edit($langs->transnoentitiesnoconv('SetMode'),1).'
'; print '
'; if ($action == 'editmode') @@ -1501,7 +1502,7 @@ else print '
'; @@ -1525,7 +1526,7 @@ if ($conf->projet->enabled) else { print '
'; - if (!empty($object->fk_project)) + if (! empty($object->fk_project)) { print ''; $proj = new Project($db); @@ -1732,7 +1733,7 @@ if ($action != 'presend') } // Create an order - if ($conf->commande->enabled && $object->statut == 2 && $user->societe_id == 0) + if (! empty($conf->commande->enabled) && $object->statut == 2 && $user->societe_id == 0) { if ($user->rights->commande->creer) { @@ -1763,9 +1764,9 @@ if ($action != 'presend') } // Clone - if ($object->type == 0 && $user->rights->propale->creer) + if ($user->rights->propale->creer) { - print ''.$langs->trans("ToClone").''; + print ''.$langs->trans("ToClone").''; } // Delete diff --git a/htdocs/comm/propal/document.php b/htdocs/comm/propal/document.php index 5940c01c247..884d000adad 100644 --- a/htdocs/comm/propal/document.php +++ b/htdocs/comm/propal/document.php @@ -2,7 +2,7 @@ /* Copyright (C) 2003-2004 Rodolphe Quiedeville * Copyright (C) 2004-2009 Laurent Destailleur * Copyright (C) 2005 Marc Barilley / Ocebo - * Copyright (C) 2005-2011 Regis Houssin + * Copyright (C) 2005-2012 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 @@ -39,20 +39,14 @@ $confirm = GETPOST('confirm','alpha'); $id = GETPOST('id','int'); $ref = GETPOST('ref','alpha'); -$mesg=''; -if (isset($_SESSION['DolMessage'])) -{ - $mesg=$_SESSION['DolMessage']; - unset($_SESSION['DolMessage']); -} - // Security check -if ($user->societe_id) +$socid=''; +if (! empty($user->societe_id)) { $action=''; $socid = $user->societe_id; } -$result = restrictedArea($user, 'propale', $id, 'propal'); +$result = restrictedArea($user, 'propal', $id); // Get parameters $sortfield = GETPOST("sortfield",'alpha'); @@ -77,7 +71,7 @@ if ($object->id > 0) */ // Envoi fichier -if ($_POST["sendit"] && ! empty($conf->global->MAIN_UPLOAD_DOC)) +if (GETPOST('sendit') && ! empty($conf->global->MAIN_UPLOAD_DOC)) { if ($object->id > 0) { @@ -131,7 +125,7 @@ if ($action == 'confirm_deletefile' && $confirm == 'yes') $upload_dir = $conf->propal->dir_output . "/" . dol_sanitizeFileName($object->ref); $file = $upload_dir . '/' . GETPOST('urlfile'); // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP). dol_delete_file($file,0,0,0,$object); - $_SESSION['DolMessage'] = '
'.$langs->trans("FileWasRemoved",GETPOST('urlfile')).'
'; + $_SESSION['dol_message'] = '
'.$langs->trans("FileWasRemoved",GETPOST('urlfile')).'
'; Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id); exit; } @@ -149,11 +143,11 @@ $form = new Form($db); if ($object->id > 0) { $upload_dir = $conf->propal->dir_output.'/'.dol_sanitizeFileName($object->ref); - + $head = propal_prepare_head($object); dol_fiche_head($head, 'document', $langs->trans('Proposal'), 0, 'propal'); - - + + // Construit liste des fichiers $filearray=dol_dir_list($upload_dir,"files",0,'','\.meta$',$sortfield,(strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC),1); $totalsize=0; @@ -161,17 +155,17 @@ if ($object->id > 0) { $totalsize+=$file['size']; } - - + + print ''; - - $linkback=''.$langs->trans("BackToList").''; - + + $linkback=''.$langs->trans("BackToList").''; + // Ref print ''; - + // Ref client print ''; print ''; print ''; print ''; print ''; print ''; print ''; @@ -151,7 +140,7 @@ $var=!$var; print ''; print ''; print ''; print ''; print ''; @@ -169,7 +158,7 @@ print '
'; print ''; -$db->close(); -llxFooter('$Date: 2011/07/31 22:23:21 $ - $Revision: 1.6 $'); +llxFooter(); +$db->close(); ?> diff --git a/htdocs/commissions/index.php b/htdocs/commissions/index.php index 65e2ad70b21..c6988f19b8d 100644 --- a/htdocs/commissions/index.php +++ b/htdocs/commissions/index.php @@ -48,10 +48,12 @@ $offset = $conf->liste_limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; +$startdate=$enddate=''; + if (!empty($_POST['startdatemonth'])) - $startdate = date('Y-m-d', dol_mktime(12, 0, 0, $_POST['startdatemonth'], $_POST['startdateday'], $_POST['startdateyear'])); + $startdate = date('Y-m-d', dol_mktime(12, 0, 0, $_POST['startdatemonth'], $_POST['startdateday'], $_POST['startdateyear'])); if (!empty($_POST['enddatemonth'])) - $enddate = date('Y-m-d', dol_mktime(12, 0, 0, $_POST['enddatemonth'], $_POST['enddateday'], $_POST['enddateyear'])); + $enddate = date('Y-m-d', dol_mktime(12, 0, 0, $_POST['enddatemonth'], $_POST['enddateday'], $_POST['enddateyear'])); /* * View @@ -90,7 +92,7 @@ else { if (! $sortfield) $sortfield="u.login"; } -// Date d�but +// Start date print ''; print ''; // Include unpayed invoices print ''; // Total Margin -if ($conf->global->COMMISSION_BASE == "MARGES") { - print ''; +if ($conf->global->COMMISSION_BASE == "MARGIN") { + print ''; } -elseif ($conf->global->COMMISSION_BASE == "CA") { - print ''; +elseif ($conf->global->COMMISSION_BASE == "TURNOVER") { + print ''; } // Total Commission @@ -135,13 +137,13 @@ print ''; $sql = "SELECT distinct s.nom, s.rowid as socid, s.code_client, s.client, sc.fk_user as agent,"; $sql.= " u.login,"; $sql.= " f.facnumber, f.total as total_ht,"; -if ($conf->global->COMMISSION_BASE == "MARGES") { - $sql.= " sum(case d.product_type when 1 then 0 else (((d.subprice * (1 - d.remise_percent / 100)) - d.buy_price_ht) * d.qty) end) as productBase," ; - $sql.= " sum(case d.product_type when 1 then (((d.subprice * (1 - d.remise_percent / 100)) - d.buy_price_ht) * d.qty) else 0 end) as serviceBase," ; +if ($conf->global->COMMISSION_BASE == "MARGIN") { + $sql.= " sum(case d.product_type when 1 then 0 else (((d.subprice * (1 - d.remise_percent / 100)) - d.buy_price_ht) * d.qty) end) as productBase," ; + $sql.= " sum(case d.product_type when 1 then (((d.subprice * (1 - d.remise_percent / 100)) - d.buy_price_ht) * d.qty) else 0 end) as serviceBase," ; } -elseif ($conf->global->COMMISSION_BASE == "CA") { - $sql.= " sum(case d.product_type when 1 then 0 else (((d.subprice * (1 - d.remise_percent / 100))) * d.qty) end) as productBase," ; - $sql.= " sum(case d.product_type when 1 then (((d.subprice * (1 - d.remise_percent / 100))) * d.qty) else 0 end) as serviceBase," ; +elseif ($conf->global->COMMISSION_BASE == "TURNOVER") { + $sql.= " sum(case d.product_type when 1 then 0 else (((d.subprice * (1 - d.remise_percent / 100))) * d.qty) end) as productBase," ; + $sql.= " sum(case d.product_type when 1 then (((d.subprice * (1 - d.remise_percent / 100))) * d.qty) else 0 end) as serviceBase," ; } $sql.= " f.datef, f.paye, f.fk_statut as statut, f.rowid as facid"; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; @@ -152,13 +154,13 @@ $sql.= ", ".MAIN_DB_PREFIX."user as u"; $sql.= " WHERE f.fk_soc = s.rowid"; $sql.= " AND sc.fk_soc = f.fk_soc"; $sql.= " AND sc.fk_user = u.rowid"; -if ($_REQUEST['unpayed'] == 'on') +if (GETPOST('unpayed') == 'on') $sql.= " AND f.fk_statut > 0"; else $sql.= " AND f.fk_statut > 1"; $sql.= " AND s.entity = ".$conf->entity; $sql.= " AND d.fk_facture = f.rowid"; -if ($conf->global->COMMISSION_BASE == "MARGES") +if ($conf->global->COMMISSION_BASE == "MARGIN") $sql.= " AND d.buy_price_ht IS NOT NULL AND d.buy_price_ht <> 0"; if ($agentid > 0) $sql.= " AND sc.fk_user = $agentid"; @@ -178,37 +180,38 @@ if ($result) { $num = $db->num_rows($result); - print '
'; - print_barre_liste($langs->trans("CommissionDetails"),$page,$_SERVER["PHP_SELF"],"&socid=$societe->id",$sortfield,$sortorder,'',$num,0,''); + print '
'; + print_barre_liste($langs->trans("CommissionDetails"),$page,$_SERVER["PHP_SELF"],"",$sortfield,$sortorder,'',$num,0,''); $i = 0; print "
'.$langs->trans('Ref').''; print $form->showrefnav($object,'ref',$linkback,1,'ref','ref',''); print '
'; print ''; print ''; - + // Customer print ""; print ''; - + print ''; print ''; - + print '
'; @@ -182,34 +176,34 @@ if ($object->id > 0) print $object->ref_client; print '
".$langs->trans("Company")."'.$object->thirdparty->getNomUrl(1).'
'.$langs->trans("NbOfAttachedFiles").''.count($filearray).'
'.$langs->trans("TotalSizeOfAttachedFiles").''.$totalsize.' '.$langs->trans("bytes").'
'; - + print ''; - + dol_htmloutput_mesg($mesg,$mesgs); - + /* * Confirmation suppression fichier */ if ($action == 'delete') { - $ret=$form->form_confirm($_SERVER["PHP_SELF"].'?id='.$id.'&urlfile='.urlencode(GETPOST("urlfile")), $langs->trans('DeleteFile'), $langs->trans('ConfirmDeleteFile'), 'confirm_deletefile', '', 0, 1); + $ret=$form->form_confirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&urlfile='.urlencode(GETPOST("urlfile")), $langs->trans('DeleteFile'), $langs->trans('ConfirmDeleteFile'), 'confirm_deletefile', '', 0, 1); if ($ret == 'html') print '
'; } - + // Affiche formulaire upload $formfile=new FormFile($db); - $formfile->form_attach_new_file(DOL_URL_ROOT.'/comm/propal/document.php?id='.$object->id,'',0,0,$user->rights->propale->creer,50,$object); - - + $formfile->form_attach_new_file($_SERVER['PHP_SELF'].'?id='.$object->id,'',0,0,$user->rights->propale->creer,50,$object); + + // List of document $param='&id='.$object->id; $formfile->list_of_documents($filearray,$object,'propal',$param); @@ -219,7 +213,6 @@ else print $langs->trans("UnkownError"); } -$db->close(); - llxFooter(); +$db->close(); ?> diff --git a/htdocs/commande/document.php b/htdocs/commande/document.php index e158495b0c2..ded13509385 100644 --- a/htdocs/commande/document.php +++ b/htdocs/commande/document.php @@ -2,7 +2,7 @@ /* Copyright (C) 2003-2007 Rodolphe Quiedeville * Copyright (C) 2004-2008 Laurent Destailleur * Copyright (C) 2005 Marc Barilley / Ocebo - * Copyright (C) 2005-2011 Regis Houssin + * Copyright (C) 2005-2012 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 @@ -40,13 +40,6 @@ $confirm = GETPOST('confirm'); $id = GETPOST('id','int'); $ref = GETPOST('ref'); -$mesg=''; -if (isset($_SESSION['DolMessage'])) -{ - $mesg=$_SESSION['DolMessage']; - unset($_SESSION['DolMessage']); -} - // Security check if ($user->societe_id) { @@ -74,7 +67,7 @@ $object = new Commande($db); */ // Envoi fichier -if ($_POST["sendit"] && ! empty($conf->global->MAIN_UPLOAD_DOC)) +if (GETPOST('sendit') && ! empty($conf->global->MAIN_UPLOAD_DOC)) { if ($object->fetch($id)) { @@ -129,7 +122,7 @@ else if ($action == 'confirm_deletefile' && $confirm == 'yes') $upload_dir = $conf->commande->dir_output . "/" . dol_sanitizeFileName($object->ref); $file = $upload_dir . '/' . GETPOST('urlfile'); // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP). dol_delete_file($file,0,0,0,$object); - $_SESSION['DolMessage'] = '
'.$langs->trans("FileWasRemoved",GETPOST('urlfile')).'
'; + $_SESSION['dol_message'] = '
'.$langs->trans("FileWasRemoved",GETPOST('urlfile')).'
'; Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id); exit; } diff --git a/htdocs/commande/fiche.php b/htdocs/commande/fiche.php index 5c00f9c6cdd..a4d41a23227 100644 --- a/htdocs/commande/fiche.php +++ b/htdocs/commande/fiche.php @@ -1,32 +1,32 @@ * Copyright (C) 2004-2012 Laurent Destailleur - * Copyright (C) 2005 Marc Barilley / Ocebo - * Copyright (C) 2005-2012 Regis Houssin - * Copyright (C) 2006 Andre Cianfarani - * Copyright (C) 2010-2012 Juanjo Menent - * Copyright (C) 2011 Philippe Grand - * Copyright (C) 2012 Christophe Battarel - * - * 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 2 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 . - */ +* Copyright (C) 2005 Marc Barilley / Ocebo +* Copyright (C) 2005-2012 Regis Houssin +* Copyright (C) 2006 Andre Cianfarani +* Copyright (C) 2010-2012 Juanjo Menent +* Copyright (C) 2011 Philippe Grand +* Copyright (C) 2012 Christophe Battarel +* +* 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 2 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/commande/fiche.php - * \ingroup commande - * \brief Page to show customer order - */ +* \ingroup commande +* \brief Page to show customer order +*/ require("../main.inc.php"); require_once(DOL_DOCUMENT_ROOT."/core/class/html.formfile.class.php"); @@ -36,11 +36,11 @@ require_once(DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'); require_once(DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'); require_once(DOL_DOCUMENT_ROOT."/core/lib/order.lib.php"); require_once(DOL_DOCUMENT_ROOT."/core/lib/functions2.lib.php"); -if ($conf->projet->enabled) require_once(DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'); -if ($conf->projet->enabled) require_once(DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php'); -if ($conf->propal->enabled) require_once(DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'); - -if (!$user->rights->commande->lire) accessforbidden(); +if (! empty($conf->projet->enabled)) { + require_once(DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'); + require_once(DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php'); + require_once(DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'); +} $langs->load('orders'); $langs->load('sendings'); @@ -50,14 +50,17 @@ $langs->load('propal'); $langs->load('deliveries'); $langs->load('products'); if (! empty($conf->margin->enabled)) - $langs->load('margins'); + $langs->load('margins'); + +$id=(GETPOST('id','int')?GETPOST('id','int'):GETPOST('orderid','int')); +$ref=GETPOST('ref','alpha'); +$socid=GETPOST('socid','int'); +$action=GETPOST('action','alpha'); +$confirm=GETPOST('confirm','alpha'); +$lineid=GETPOST('lineid','int'); +$origin=GETPOST('origin','alpha'); +$originid=GETPOST('origin_id','int'); -$id = (GETPOST('id','int')?GETPOST('id','int'):GETPOST("orderid")); -$ref = GETPOST('ref'); -$socid = GETPOST('socid','int'); -$action = GETPOST('action'); -$confirm = GETPOST('confirm'); -$lineid = GETPOST('lineid'); $mesg = GETPOST('mesg'); //PDF @@ -66,8 +69,8 @@ $hidedesc = (GETPOST('hidedesc','int') ? GETPOST('hidedesc','int') : (! empty( $hideref = (GETPOST('hideref','int') ? GETPOST('hideref','int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 1 : 0)); // Security check -if ($user->societe_id) $socid=$user->societe_id; -$result=restrictedArea($user,'commande',$id,''); +if (! empty($user->societe_id)) $socid=$user->societe_id; +$result=restrictedArea($user,'commande',$id); $object = new Commande($db); @@ -94,45 +97,45 @@ $reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Action clone object if ($action == 'confirm_clone' && $confirm == 'yes' && $user->rights->commande->creer) { - if (1==0 && ! GETPOST('clone_content') && ! GETPOST('clone_receivers')) - { - $mesg='
'.$langs->trans("NoCloneOptionsSpecified").'
'; - } - else - { - if ($object->id > 0) - { - $result=$object->createFromClone($socid, $hookmanager); - if ($result > 0) - { - header("Location: ".$_SERVER['PHP_SELF'].'?id='.$result); - exit; - } - else - { - $mesg='
'.$object->error.'
'; - $action=''; - } - } - } + if (1==0 && ! GETPOST('clone_content') && ! GETPOST('clone_receivers')) + { + $mesg='
'.$langs->trans("NoCloneOptionsSpecified").'
'; + } + else + { + if ($object->id > 0) + { + $result=$object->createFromClone($socid, $hookmanager); + if ($result > 0) + { + header("Location: ".$_SERVER['PHP_SELF'].'?id='.$result); + exit; + } + else + { + $mesg='
'.$object->error.'
'; + $action=''; + } + } + } } // Reopen a closed order else if ($action == 'reopen' && $user->rights->commande->creer) { - if ($object->statut == 3) - { - $result = $object->set_reopen($user); - if ($result > 0) - { - Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id); - exit; - } - else - { - $mesg='
'.$object->error.'
'; - } - } + if ($object->statut == 3) + { + $result = $object->set_reopen($user); + if ($result > 0) + { + Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id); + exit; + } + else + { + $mesg='
'.$object->error.'
'; + } + } } // Suppression de la commande @@ -159,7 +162,7 @@ else if ($action == 'confirm_deleteline' && $confirm == 'yes' && $user->rights-> // Define output language $outputlangs = $langs; $newlang=''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) $newlang=$_REQUEST['lang_id']; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id')) $newlang=GETPOST('lang_id'); if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang; if (! empty($newlang)) { @@ -168,11 +171,11 @@ else if ($action == 'confirm_deleteline' && $confirm == 'yes' && $user->rights-> } if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { - $ret=$object->fetch($id); // Reload to get new records + $ret=$object->fetch($object->id); // Reload to get new records commande_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $hookmanager); } - Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id); + Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id); exit; } else @@ -184,313 +187,317 @@ else if ($action == 'confirm_deleteline' && $confirm == 'yes' && $user->rights-> // Categorisation dans projet else if ($action == 'classin' && $user->rights->commande->creer) { - $object->setProject($_POST['projectid']); + $object->setProject(GETPOST('projectid')); } // Add order else if ($action == 'add' && $user->rights->commande->creer) { - $datecommande = dol_mktime(12, 0, 0, $_POST['remonth'], $_POST['reday'], $_POST['reyear']); - $datelivraison = dol_mktime(12, 0, 0, $_POST['liv_month'],$_POST['liv_day'],$_POST['liv_year']); + $datecommande = dol_mktime(12, 0, 0, GETPOST('remonth'), GETPOST('reday'), GETPOST('reyear')); + $datelivraison = dol_mktime(12, 0, 0, GETPOST('liv_month'),GETPOST('liv_day'),GETPOST('liv_year')); - $object->socid=$socid; - $object->fetch_thirdparty(); + $object->socid=$socid; + $object->fetch_thirdparty(); - $db->begin(); + $db->begin(); - $object->date_commande = $datecommande; - $object->note = $_POST['note']; - $object->note_public = $_POST['note_public']; - $object->source = $_POST['source_id']; - $object->fk_project = $_POST['projectid']; - $object->ref_client = $_POST['ref_client']; - $object->modelpdf = $_POST['model']; - $object->cond_reglement_id = $_POST['cond_reglement_id']; - $object->mode_reglement_id = $_POST['mode_reglement_id']; - $object->availability_id = $_POST['availability_id']; - $object->demand_reason_id = $_POST['demand_reason_id']; - $object->date_livraison = $datelivraison; - $object->fk_delivery_address = $_POST['fk_address']; - $object->contactid = $_POST['contactidp']; + $object->date_commande = $datecommande; + $object->note = GETPOST('note'); + $object->note_public = GETPOST('note_public'); + $object->source = GETPOST('source_id'); + $object->fk_project = GETPOST('projectid'); + $object->ref_client = GETPOST('ref_client'); + $object->modelpdf = GETPOST('model'); + $object->cond_reglement_id = GETPOST('cond_reglement_id'); + $object->mode_reglement_id = GETPOST('mode_reglement_id'); + $object->availability_id = GETPOST('availability_id'); + $object->demand_reason_id = GETPOST('demand_reason_id'); + $object->date_livraison = $datelivraison; + $object->fk_delivery_address = GETPOST('fk_address'); + $object->contactid = GETPOST('contactidp'); - // If creation from another object of another module (Example: origin=propal, originid=1) - if ($_POST['origin'] && $_POST['originid']) - { - // Parse element/subelement (ex: project_task) - $element = $subelement = $_POST['origin']; - if (preg_match('/^([^_]+)_([^_]+)/i',$_POST['origin'],$regs)) - { - $element = $regs[1]; - $subelement = $regs[2]; - } + // If creation from another object of another module (Example: origin=propal, originid=1) + if ($origin && $originid) + { + // Parse element/subelement (ex: project_task) + $element = $subelement = $origin; + if (preg_match('/^([^_]+)_([^_]+)/i',$origin,$regs)) + { + $element = $regs[1]; + $subelement = $regs[2]; + } - // For compatibility - if ($element == 'order') { $element = $subelement = 'commande'; } - if ($element == 'propal') { $element = 'comm/propal'; $subelement = 'propal'; } - if ($element == 'contract') { $element = $subelement = 'contrat'; } + // For compatibility + if ($element == 'order') { + $element = $subelement = 'commande'; + } + if ($element == 'propal') { + $element = 'comm/propal'; $subelement = 'propal'; + } + if ($element == 'contract') { + $element = $subelement = 'contrat'; + } - $object->origin = $_POST['origin']; - $object->origin_id = $_POST['originid']; + $object->origin = $origin; + $object->origin_id = $originid; - // Possibility to add external linked objects with hooks - $object->linked_objects[$object->origin] = $object->origin_id; - if (is_array($_POST['other_linked_objects']) && ! empty($_POST['other_linked_objects'])) - { - $object->linked_objects = array_merge($object->linked_objects, $_POST['other_linked_objects']); - } + // Possibility to add external linked objects with hooks + $object->linked_objects[$object->origin] = $object->origin_id; + $other_linked_objects=GETPOST('other_linked_objects','array'); + if (! empty($other_linked_objects)) + { + $object->linked_objects = array_merge($object->linked_objects, $other_linked_objects); + } - $object_id = $object->create($user); + $object_id = $object->create($user); - if ($object_id > 0) - { - dol_include_once('/'.$element.'/class/'.$subelement.'.class.php'); + if ($object_id > 0) + { + dol_include_once('/'.$element.'/class/'.$subelement.'.class.php'); - $classname = ucfirst($subelement); - $srcobject = new $classname($db); + $classname = ucfirst($subelement); + $srcobject = new $classname($db); - dol_syslog("Try to find source object origin=".$object->origin." originid=".$object->origin_id." to add lines"); - $result=$srcobject->fetch($object->origin_id); - if ($result > 0) - { - $lines = $srcobject->lines; - if (empty($lines) && method_exists($srcobject,'fetch_lines')) $lines = $srcobject->fetch_lines(); + dol_syslog("Try to find source object origin=".$object->origin." originid=".$object->origin_id." to add lines"); + $result=$srcobject->fetch($object->origin_id); + if ($result > 0) + { + $lines = $srcobject->lines; + if (empty($lines) && method_exists($srcobject,'fetch_lines')) $lines = $srcobject->fetch_lines(); - $fk_parent_line=0; - $num=count($lines); + $fk_parent_line=0; + $num=count($lines); - for ($i=0;$i<$num;$i++) - { - $desc=($lines[$i]->desc?$lines[$i]->desc:$lines[$i]->libelle); - $product_type=($lines[$i]->product_type?$lines[$i]->product_type:0); + for ($i=0;$i<$num;$i++) + { + $desc=($lines[$i]->desc?$lines[$i]->desc:$lines[$i]->libelle); + $product_type=($lines[$i]->product_type?$lines[$i]->product_type:0); - // Dates - // TODO mutualiser - $date_start=$lines[$i]->date_debut_prevue; - if ($lines[$i]->date_debut_reel) $date_start=$lines[$i]->date_debut_reel; - if ($lines[$i]->date_start) $date_start=$lines[$i]->date_start; - $date_end=$lines[$i]->date_fin_prevue; - if ($lines[$i]->date_fin_reel) $date_end=$lines[$i]->date_fin_reel; - if ($lines[$i]->date_end) $date_end=$lines[$i]->date_end; + // Dates + // TODO mutualiser + $date_start=$lines[$i]->date_debut_prevue; + if ($lines[$i]->date_debut_reel) $date_start=$lines[$i]->date_debut_reel; + if ($lines[$i]->date_start) $date_start=$lines[$i]->date_start; + $date_end=$lines[$i]->date_fin_prevue; + if ($lines[$i]->date_fin_reel) $date_end=$lines[$i]->date_fin_reel; + if ($lines[$i]->date_end) $date_end=$lines[$i]->date_end; - // Reset fk_parent_line for no child products and special product - if (($lines[$i]->product_type != 9 && empty($lines[$i]->fk_parent_line)) || $lines[$i]->product_type == 9) { - $fk_parent_line = 0; - } + // Reset fk_parent_line for no child products and special product + if (($lines[$i]->product_type != 9 && empty($lines[$i]->fk_parent_line)) || $lines[$i]->product_type == 9) { + $fk_parent_line = 0; + } - $result = $object->addline( - $object_id, - $desc, - $lines[$i]->subprice, - $lines[$i]->qty, - $lines[$i]->tva_tx, - $lines[$i]->localtax1_tx, - $lines[$i]->localtax2_tx, - $lines[$i]->fk_product, - $lines[$i]->remise_percent, - $lines[$i]->info_bits, - $lines[$i]->fk_remise_except, - 'HT', - 0, - $datestart, - $dateend, - $product_type, - $lines[$i]->rang, - $lines[$i]->special_code, - $fk_parent_line, - $lines[$i]->fk_fournprice, - $lines[$i]->pa_ht - ); + $result = $object->addline( + $object_id, + $desc, + $lines[$i]->subprice, + $lines[$i]->qty, + $lines[$i]->tva_tx, + $lines[$i]->localtax1_tx, + $lines[$i]->localtax2_tx, + $lines[$i]->fk_product, + $lines[$i]->remise_percent, + $lines[$i]->info_bits, + $lines[$i]->fk_remise_except, + 'HT', + 0, + $datestart, + $dateend, + $product_type, + $lines[$i]->rang, + $lines[$i]->special_code, + $fk_parent_line, + $lines[$i]->fk_fournprice, + $lines[$i]->pa_ht + ); - if ($result < 0) - { - $error++; - break; - } + if ($result < 0) + { + $error++; + break; + } - // Defined the new fk_parent_line - if ($result > 0 && $lines[$i]->product_type == 9) { - $fk_parent_line = $result; - } - } + // Defined the new fk_parent_line + if ($result > 0 && $lines[$i]->product_type == 9) { + $fk_parent_line = $result; + } + } - // Hooks - $parameters=array('objFrom'=>$srcobject); - $reshook=$hookmanager->executeHooks('createFrom',$parameters,$object,$action); // Note that $action and $object may have been modified by hook - if ($reshook < 0) $error++; - } - else - { - $mesg=$srcobject->error; - $error++; - } - } - else - { - $mesg=$object->error; - $error++; - } - } - else - { - $object_id = $object->create($user); + // Hooks + $parameters=array('objFrom'=>$srcobject); + $reshook=$hookmanager->executeHooks('createFrom',$parameters,$object,$action); // Note that $action and $object may have been modified by hook + if ($reshook < 0) $error++; + } + else + { + $mesg=$srcobject->error; + $error++; + } + } + else + { + $mesg=$object->error; + $error++; + } + } + else + { + $object_id = $object->create($user); - // If some invoice's lines already known - $NBLINES=8; - for ($i = 1 ; $i <= $NBLINES ; $i++) - { - if ($_POST['idprod'.$i]) - { - $xid = 'idprod'.$i; - $xqty = 'qty'.$i; - $xremise = 'remise_percent'.$i; - $object->add_product($_POST[$xid],$_POST[$xqty],$_POST[$xremise]); - } - } - } + // If some invoice's lines already known + $NBLINES=8; + for ($i = 1 ; $i <= $NBLINES ; $i++) + { + if ($_POST['idprod'.$i]) + { + $xid = 'idprod'.$i; + $xqty = 'qty'.$i; + $xremise = 'remise_percent'.$i; + $object->add_product($_POST[$xid],$_POST[$xqty],$_POST[$xremise]); + } + } + } - // Insert default contacts if defined - if ($object_id > 0) - { - if ($_POST["contactidp"]) - { - $result=$object->add_contact($_POST["contactidp"],'CUSTOMER','external'); + // Insert default contacts if defined + if ($object_id > 0) + { + if (GETPOST('contactidp')) + { + $result=$object->add_contact(GETPOST('contactidp'),'CUSTOMER','external'); + if ($result < 0) + { + $mesg = '
'.$langs->trans("ErrorFailedToAddContact").'
'; + $error++; + } + } - if ($result < 0) - { - $mesg = '
'.$langs->trans("ErrorFailedToAddContact").'
'; - $error++; - } - } - - $id = $object_id; - $action = ''; - } - - // End of object creation, we show it - if ($object_id > 0 && ! $error) - { - $db->commit(); - Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object_id); - exit; - } - else - { - $db->rollback(); - $action='create'; - $socid=$_POST['socid']; - if (! $mesg) $mesg='
'.$object->error.'
'; - } + $id = $object_id; + $action = ''; + } + // End of object creation, we show it + if ($object_id > 0 && ! $error) + { + $db->commit(); + Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object_id); + exit; + } + else + { + $db->rollback(); + $action='create'; + if (! $mesg) $mesg='
'.$object->error.'
'; + } } else if ($action == 'classifybilled' && $user->rights->commande->creer) { - $ret=$object->classifyBilled(); + $ret=$object->classifyBilled(); } // Positionne ref commande client else if ($action == 'set_ref_client' && $user->rights->commande->creer) { - $object->set_ref_client($user, $_POST['ref_client']); + $object->set_ref_client($user, GETPOST('ref_client')); } else if ($action == 'setremise' && $user->rights->commande->creer) { - $object->set_remise($user, $_POST['remise']); + $object->set_remise($user, GETPOST('remise')); } else if ($action == 'setabsolutediscount' && $user->rights->commande->creer) { - if ($_POST["remise_id"]) - { - if ($object->id > 0) - { - $object->insert_discount($_POST["remise_id"]); - } - else - { - dol_print_error($db,$object->error); - } - } + if (GETPOST('remise_id')) + { + if ($object->id > 0) + { + $object->insert_discount(GETPOST('remise_id')); + } + else + { + dol_print_error($db,$object->error); + } + } } else if ($action == 'setdate' && $user->rights->commande->creer) { - //print "x ".$_POST['liv_month'].", ".$_POST['liv_day'].", ".$_POST['liv_year']; - $date=dol_mktime(0, 0, 0, $_POST['order_month'], $_POST['order_day'], $_POST['order_year']); + //print "x ".$_POST['liv_month'].", ".$_POST['liv_day'].", ".$_POST['liv_year']; + $date=dol_mktime(0, 0, 0, GETPOST('order_month'), GETPOST('order_day'), GETPOST('order_year')); - $result=$object->set_date($user,$date); - if ($result < 0) - { - $mesg='
'.$object->error.'
'; - } + $result=$object->set_date($user,$date); + if ($result < 0) + { + $mesg='
'.$object->error.'
'; + } } else if ($action == 'setdate_livraison' && $user->rights->commande->creer) { - //print "x ".$_POST['liv_month'].", ".$_POST['liv_day'].", ".$_POST['liv_year']; - $datelivraison=dol_mktime(0, 0, 0, $_POST['liv_month'], $_POST['liv_day'], $_POST['liv_year']); + //print "x ".$_POST['liv_month'].", ".$_POST['liv_day'].", ".$_POST['liv_year']; + $datelivraison=dol_mktime(0, 0, 0, GETPOST('liv_month'), GETPOST('liv_day'), GETPOST('liv_year')); - $result=$object->set_date_livraison($user,$datelivraison); - if ($result < 0) - { - $mesg='
'.$object->error.'
'; - } + $result=$object->set_date_livraison($user,$datelivraison); + if ($result < 0) + { + $mesg='
'.$object->error.'
'; + } } else if ($action == 'setmode' && $user->rights->commande->creer) { - $result = $object->setPaymentMethods(GETPOST('mode_reglement_id','int')); - if ($result < 0) dol_print_error($db,$object->error); + $result = $object->setPaymentMethods(GETPOST('mode_reglement_id','int')); + if ($result < 0) dol_print_error($db,$object->error); } else if ($action == 'setavailability' && $user->rights->commande->creer) { - $result=$object->availability($_POST['availability_id']); - if ($result < 0) dol_print_error($db,$object->error); + $result=$object->availability(GETPOST('availability_id')); + if ($result < 0) dol_print_error($db,$object->error); } else if ($action == 'setdemandreason' && $user->rights->commande->creer) { - $result=$object->demand_reason($_POST['demand_reason_id']); - if ($result < 0) dol_print_error($db,$object->error); + $result=$object->demand_reason(GETPOST('demand_reason_id')); + if ($result < 0) dol_print_error($db,$object->error); } else if ($action == 'setconditions' && $user->rights->commande->creer) { - $result=$object->setPaymentTerms(GETPOST('cond_reglement_id','int')); - if ($result < 0) - { - dol_print_error($db,$object->error); - } - else + $result=$object->setPaymentTerms(GETPOST('cond_reglement_id','int')); + if ($result < 0) + { + dol_print_error($db,$object->error); + } + else { if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) - { - // Define output language - $outputlangs = $langs; - $newlang=GETPOST('lang_id','alpha'); - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang; - if (! empty($newlang)) - { - $outputlangs = new Translate("",$conf); - $outputlangs->setDefaultLang($newlang); - } + { + // Define output language + $outputlangs = $langs; + $newlang=GETPOST('lang_id','alpha'); + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang; + if (! empty($newlang)) + { + $outputlangs = new Translate("",$conf); + $outputlangs->setDefaultLang($newlang); + } - $ret=$object->fetch($id); // Reload to get new records - commande_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $hookmanager); - } - } + $ret=$object->fetch($object->id); // Reload to get new records + commande_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $hookmanager); + } + } } else if ($action == 'setremisepercent' && $user->rights->commande->creer) { - $result = $object->set_remise($user, $_POST['remise_percent']); + $result = $object->set_remise($user, GETPOST('remise_percent')); } else if ($action == 'setremiseabsolue' && $user->rights->commande->creer) { - $result = $object->set_remise_absolue($user, $_POST['remise_absolue']); + $result = $object->set_remise_absolue($user, GETPOST('remise_absolue')); } else if ($action == 'setnote_public' && $user->rights->commande->creer) @@ -507,72 +514,72 @@ else if ($action == 'setnote' && $user->rights->commande->creer) /* * Ajout d'une ligne produit dans la commande - */ +*/ else if ($action == 'addline' && $user->rights->commande->creer) { - $result=0; + $result=0; - if (empty($_POST['idprod']) && $_POST["type"] < 0) - { - $mesg = '
'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Type")).'
'; - $result = -1 ; - } - if (empty($_POST['idprod']) && (! isset($_POST["np_price"]) || $_POST["np_price"]=='')) // Unit price can be 0 but not '' - { - $mesg = '
'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("UnitPriceHT")).'
'; - $result = -1 ; - } + if (! GETPOST('idprod') && GETPOST('type') < 0) + { + $mesg = '
'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Type")).'
'; + $result = -1 ; + } + if (! GETPOST('idprod') && GETPOST('np_price')=='') // Unit price can be 0 but not '' + { + $mesg = '
'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("UnitPriceHT")).'
'; + $result = -1 ; + } - if ($result >= 0 && $_POST['qty'] && (($_POST['np_price'] != '' && ($_POST['np_desc'] || $_POST['dp_desc'])) || $_POST['idprod'])) - { - // Clean parameters - $suffixe = $_POST['idprod'] ? '_predef' : ''; - $date_start=dol_mktime(0, 0, 0, $_POST['date_start'.$suffixe.'month'], $_POST['date_start'.$suffixe.'day'], $_POST['date_start'.$suffixe.'year']); - $date_end=dol_mktime(0, 0, 0, $_POST['date_end'.$suffixe.'month'], $_POST['date_end'.$suffixe.'day'], $_POST['date_end'.$suffixe.'year']); - $price_base_type = 'HT'; + if ($result >= 0 && GETPOST('qty') && ((GETPOST('np_price') != '' && (GETPOST('np_desc') || GETPOST('dp_desc'))) || GETPOST('idprod'))) + { + // Clean parameters + $suffixe = GETPOST('idprod') ? '_predef' : ''; + $date_start=dol_mktime(0, 0, 0, GETPOST('date_start'.$suffixe.'month'), GETPOST('date_start'.$suffixe.'day'), GETPOST('date_start'.$suffixe.'year')); + $date_end=dol_mktime(0, 0, 0, GETPOST('date_end'.$suffixe.'month'), GETPOST('date_end'.$suffixe.'day'), GETPOST('date_end'.$suffixe.'year')); + $price_base_type = 'HT'; - // Ecrase $pu par celui du produit - // Ecrase $desc par celui du produit - // Ecrase $txtva par celui du produit - // Ecrase $base_price_type par celui du produit - if ($_POST['idprod']) - { - $prod = new Product($db); - $prod->fetch($_POST['idprod']); + // Ecrase $pu par celui du produit + // Ecrase $desc par celui du produit + // Ecrase $txtva par celui du produit + // Ecrase $base_price_type par celui du produit + if (GETPOST('idprod')) + { + $prod = new Product($db); + $prod->fetch(GETPOST('idprod')); - $tva_tx = get_default_tva($mysoc,$object->client,$prod->id); + $tva_tx = get_default_tva($mysoc,$object->client,$prod->id); - // multiprix - if ($conf->global->PRODUIT_MULTIPRICES && $object->client->price_level) - { - $pu_ht = $prod->multiprices[$object->client->price_level]; - $pu_ttc = $prod->multiprices_ttc[$object->client->price_level]; - $price_min = $prod->multiprices_min[$object->client->price_level]; - $price_base_type = $prod->multiprices_base_type[$object->client->price_level]; - } - else - { - $pu_ht = $prod->price; - $pu_ttc = $prod->price_ttc; - $price_min = $prod->price_min; - $price_base_type = $prod->price_base_type; - } + // multiprix + if ($conf->global->PRODUIT_MULTIPRICES && $object->client->price_level) + { + $pu_ht = $prod->multiprices[$object->client->price_level]; + $pu_ttc = $prod->multiprices_ttc[$object->client->price_level]; + $price_min = $prod->multiprices_min[$object->client->price_level]; + $price_base_type = $prod->multiprices_base_type[$object->client->price_level]; + } + else + { + $pu_ht = $prod->price; + $pu_ttc = $prod->price_ttc; + $price_min = $prod->price_min; + $price_base_type = $prod->price_base_type; + } - // On reevalue prix selon taux tva car taux tva transaction peut etre different - // de ceux du produit par defaut (par exemple si pays different entre vendeur et acheteur). - if ($tva_tx != $prod->tva_tx) - { - if ($price_base_type != 'HT') - { - $pu_ht = price2num($pu_ttc / (1 + ($tva_tx/100)), 'MU'); - } - else - { - $pu_ttc = price2num($pu_ht * (1 + ($tva_tx/100)), 'MU'); - } - } + // On reevalue prix selon taux tva car taux tva transaction peut etre different + // de ceux du produit par defaut (par exemple si pays different entre vendeur et acheteur). + if ($tva_tx != $prod->tva_tx) + { + if ($price_base_type != 'HT') + { + $pu_ht = price2num($pu_ttc / (1 + ($tva_tx/100)), 'MU'); + } + else + { + $pu_ttc = price2num($pu_ht * (1 + ($tva_tx/100)), 'MU'); + } + } - // Define output language + // Define output language if (! empty($conf->global->MAIN_MULTILANGS) && ! empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) { $outputlangs = $langs; @@ -592,1737 +599,1739 @@ else if ($action == 'addline' && $user->rights->commande->creer) $desc = $prod->description; } - $desc.= ($desc && $_POST['np_desc']) ? ((dol_textishtml($desc) || dol_textishtml($_POST['np_desc']))?"
\n":"\n") : ""; - $desc.= $_POST['np_desc']; - $type = $prod->type; - } - else - { - $pu_ht=$_POST['np_price']; - $tva_tx=str_replace('*','',$_POST['np_tva_tx']); - $tva_npr=preg_match('/\*/',$_POST['np_tva_tx'])?1:0; - $desc=$_POST['dp_desc']; - $type=$_POST["type"]; - } + $desc.= ($desc && GETPOST('np_desc')) ? ((dol_textishtml($desc) || dol_textishtml(GETPOST('np_desc')))?"
\n":"\n") : ""; + $desc.= GETPOST('np_desc'); + $type = $prod->type; + } + else + { + $pu_ht=GETPOST('np_price'); + $tva_tx=str_replace('*','',GETPOST('np_tva_tx')); + $tva_npr=preg_match('/\*/',GETPOST('np_tva_tx'))?1:0; + $desc=GETPOST('dp_desc'); + $type=GETPOST('type'); + } - // Local Taxes - $localtax1_tx= get_localtax($tva_tx, 1, $object->client); - $localtax2_tx= get_localtax($tva_tx, 2, $object->client); + // Local Taxes + $localtax1_tx= get_localtax($tva_tx, 1, $object->client); + $localtax2_tx= get_localtax($tva_tx, 2, $object->client); - $desc=dol_htmlcleanlastbr($desc); + $desc=dol_htmlcleanlastbr($desc); - // ajout prix achat - $fk_fournprice = $_POST['np_fournprice']; - if ( ! empty($_POST['np_buying_price']) ) - $pa_ht = $_POST['np_buying_price']; - else - $pa_ht = null; - - $info_bits=0; - if ($tva_npr) $info_bits |= 0x01; + // ajout prix achat + $fk_fournprice = GETPOST('np_fournprice'); + if (GETPOST('np_buying_price')) + $pa_ht = GETPOST('np_buying_price'); + else + $pa_ht = null; - if ($result >= 0) - { - if($price_min && (price2num($pu_ht)*(1-price2num($_POST['remise_percent'])/100) < price2num($price_min))) - { - //print "CantBeLessThanMinPrice ".$up_ht." - ".GETPOST('remise_percent')." - ".$product->price_min; - $mesg = '
'.$langs->trans("CantBeLessThanMinPrice",price2num($price_min,'MU').' '.$langs->trans("Currency".$conf->currency)).'
' ; - } - else - { - // Insert line - $result = $object->addline( - $id, - $desc, - $pu_ht, - $_POST['qty'], - $tva_tx, - $localtax1_tx, - $localtax2_tx, - $_POST['idprod'], - $_POST['remise_percent'], - $info_bits, - 0, - $price_base_type, - $pu_ttc, - $date_start, - $date_end, - $type, - -1, - '', - $_POST['fk_parent_line'], - $fk_fournprice, - $pa_ht - ); + $info_bits=0; + if ($tva_npr) $info_bits |= 0x01; - if ($result > 0) - { - if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) - { - // Define output language - $outputlangs = $langs; - $newlang=GETPOST('lang_id','alpha'); - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang; - if (! empty($newlang)) - { - $outputlangs = new Translate("",$conf); - $outputlangs->setDefaultLang($newlang); - } + if ($result >= 0) + { + if($price_min && (price2num($pu_ht)*(1-price2num(GETPOST('remise_percent'))/100) < price2num($price_min))) + { + //print "CantBeLessThanMinPrice ".$up_ht." - ".GETPOST('remise_percent')." - ".$product->price_min; + $mesg = '
'.$langs->trans("CantBeLessThanMinPrice",price2num($price_min,'MU').' '.$langs->trans("Currency".$conf->currency)).'
' ; + } + else + { + // Insert line + $result = $object->addline( + $object->id, + $desc, + $pu_ht, + GETPOST('qty'), + $tva_tx, + $localtax1_tx, + $localtax2_tx, + GETPOST('idprod'), + GETPOST('remise_percent'), + $info_bits, + 0, + $price_base_type, + $pu_ttc, + $date_start, + $date_end, + $type, + -1, + '', + GETPOST('fk_parent_line'), + $fk_fournprice, + $pa_ht + ); - $ret=$object->fetch($id); // Reload to get new records - commande_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $hookmanager); - } + if ($result > 0) + { + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) + { + // Define output language + $outputlangs = $langs; + $newlang=GETPOST('lang_id','alpha'); + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang; + if (! empty($newlang)) + { + $outputlangs = new Translate("",$conf); + $outputlangs->setDefaultLang($newlang); + } - unset($_POST['qty']); - unset($_POST['type']); - unset($_POST['idprod']); - unset($_POST['remise_percent']); - unset($_POST['dp_desc']); - unset($_POST['np_desc']); - unset($_POST['np_price']); - unset($_POST['np_tva_tx']); - unset($_POST['np_buying_price']); - } - else - { - $mesg='
'.$object->error.'
'; - } - } - } - } + $ret=$object->fetch($object->id); // Reload to get new records + commande_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $hookmanager); + } + + unset($_POST['qty']); + unset($_POST['type']); + unset($_POST['idprod']); + unset($_POST['remise_percent']); + unset($_POST['dp_desc']); + unset($_POST['np_desc']); + unset($_POST['np_price']); + unset($_POST['np_tva_tx']); + unset($_POST['np_buying_price']); + } + else + { + $mesg='
'.$object->error.'
'; + } + } + } + } } /* * Mise a jour d'une ligne dans la commande - */ -else if ($action == 'updateligne' && $user->rights->commande->creer && $_POST['save'] == $langs->trans('Save')) +*/ +else if ($action == 'updateligne' && $user->rights->commande->creer && GETPOST('save') == $langs->trans('Save')) { - // Clean parameters - $date_start=''; - $date_end=''; - $date_start=dol_mktime(0, 0, 0, $_POST['date_start'.$suffixe.'month'], $_POST['date_start'.$suffixe.'day'], $_POST['date_start'.$suffixe.'year']); - $date_end=dol_mktime(0, 0, 0, $_POST['date_end'.$suffixe.'month'], $_POST['date_end'.$suffixe.'day'], $_POST['date_end'.$suffixe.'year']); - $description=dol_htmlcleanlastbr($_POST['desc']); - $up_ht=GETPOST('pu')?GETPOST('pu'):GETPOST('subprice'); + // Clean parameters + $date_start=''; + $date_end=''; + $date_start=dol_mktime(0, 0, 0, GETPOST('date_start'.$suffixe.'month'), GETPOST('date_start'.$suffixe.'day'), GETPOST('date_start'.$suffixe.'year')); + $date_end=dol_mktime(0, 0, 0, GETPOST('date_end'.$suffixe.'month'), GETPOST('date_end'.$suffixe.'day'), GETPOST('date_end'.$suffixe.'year')); + $description=dol_htmlcleanlastbr(GETPOST('desc')); + $up_ht=GETPOST('pu')?GETPOST('pu'):GETPOST('subprice'); - // Define info_bits - $info_bits=0; - if (preg_match('/\*/',$_POST['tva_tx'])) $info_bits |= 0x01; + // Define info_bits + $info_bits=0; + if (preg_match('/\*/',GETPOST('tva_tx'))) $info_bits |= 0x01; - // Define vat_rate - $vat_rate=$_POST['tva_tx']; - $vat_rate=str_replace('*','',$vat_rate); - $localtax1_rate=get_localtax($vat_rate,1,$object->client); - $localtax2_rate=get_localtax($vat_rate,2,$object->client); + // Define vat_rate + $vat_rate=GETPOST('tva_tx'); + $vat_rate=str_replace('*','',$vat_rate); + $localtax1_rate=get_localtax($vat_rate,1,$object->client); + $localtax2_rate=get_localtax($vat_rate,2,$object->client); - // ajout prix d'achat - $fk_fournprice = $_POST['fournprice']; - if ( ! empty($_POST['buying_price']) ) - $pa_ht = $_POST['buying_price']; - else - $pa_ht = null; - - // Check parameters - if (empty($_POST['productid']) && $_POST["type"] < 0) - { - $mesg = '
'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Type")).'
'; - $result = -1 ; - } - // Check minimum price - if(! empty($_POST['productid'])) - { - $productid = $_POST['productid']; - $product = new Product($db); - $product->fetch($productid); - $type=$product->type; - $price_min = $product->price_min; - if ($conf->global->PRODUIT_MULTIPRICES && $object->client->price_level) $price_min = $product->multiprices_min[$object->client->price_level]; - } - if ($price_min && GETPOST('productid') && (price2num($up_ht)*(1-price2num($_POST['remise_percent'])/100) < price2num($price_min))) - { - $mesg = '
'.$langs->trans("CantBeLessThanMinPrice",price2num($price_min,'MU').' '.$langs->trans("Currency".$conf->currency)).'
' ; - $result=-1; - } + // ajout prix d'achat + $fk_fournprice = GETPOST('fournprice'); + if (GETPOST('buying_price')) + $pa_ht = GETPOST('buying_price'); + else + $pa_ht = null; - // Define params - if (! empty($_POST['productid'])) - { - $type=$product->type; - } - else - { - $type=$_POST["type"]; - } + // Check minimum price + if (GETPOST('productid')) + { + $productid = GETPOST('productid'); + $product = new Product($db); + $product->fetch($productid); + $type=$product->type; + $price_min = $product->price_min; + if ($conf->global->PRODUIT_MULTIPRICES && $object->client->price_level) $price_min = $product->multiprices_min[$object->client->price_level]; - if ($result >= 0) - { - $result = $object->updateline( - $_POST['lineid'], - $description, - $up_ht, - $_POST['qty'], - $_POST['remise_percent'], - $vat_rate, - $localtax1_rate, - $localtax2_rate, - 'HT', - $info_bits, - $date_start, - $date_end, - $type, - $_POST['fk_parent_line'], - 0, - $fk_fournprice, - $pa_ht - ); + if ($price_min && (price2num($up_ht)*(1-price2num(GETPOST('remise_percent'))/100) < price2num($price_min))) + { + $mesg = '
'.$langs->trans("CantBeLessThanMinPrice",price2num($price_min,'MU').' '.$langs->trans("Currency".$conf->currency)).'
' ; + $error++; + } + } + else + { + $type=GETPOST('type'); - if ($result >= 0) - { - // Define output language - $outputlangs = $langs; - $newlang=''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) $newlang=$_REQUEST['lang_id']; - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang; - if (! empty($newlang)) - { - $outputlangs = new Translate("",$conf); - $outputlangs->setDefaultLang($newlang); - } - if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) - { - $ret=$object->fetch($object->id); // Reload to get new records - commande_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $hookmanager); - unset($_POST['qty']); - unset($_POST['type']); - unset($_POST['np_price']); - unset($_POST['dp_desc']); - unset($_POST['np_tva_tx']); - unset($_POST['np_buying_price']); - } - } - else - { - dol_print_error($db,$object->error); - exit; - } - } + // Check parameters + if (GETPOST('type') < 0) { + $mesg = '
'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Type")).'
'; + $error++; + } + } + + if (! $error) + { + $result = $object->updateline( + GETPOST('lineid'), + $description, + $up_ht, + GETPOST('qty'), + GETPOST('remise_percent'), + $vat_rate, + $localtax1_rate, + $localtax2_rate, + 'HT', + $info_bits, + $date_start, + $date_end, + $type, + GETPOST('fk_parent_line'), + 0, + $fk_fournprice, + $pa_ht + ); + + if ($result >= 0) + { + // Define output language + $outputlangs = $langs; + $newlang=''; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id')) $newlang=GETPOST('lang_id'); + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang; + if (! empty($newlang)) + { + $outputlangs = new Translate("",$conf); + $outputlangs->setDefaultLang($newlang); + } + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) + { + $ret=$object->fetch($object->id); // Reload to get new records + commande_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $hookmanager); + unset($_POST['qty']); + unset($_POST['type']); + unset($_POST['np_price']); + unset($_POST['dp_desc']); + unset($_POST['np_tva_tx']); + unset($_POST['np_buying_price']); + } + } + else + { + dol_print_error($db,$object->error); + exit; + } + } } -else if ($action == 'updateligne' && $user->rights->commande->creer && $_POST['cancel'] == $langs->trans('Cancel')) +else if ($action == 'updateligne' && $user->rights->commande->creer && GETPOST('cancel') == $langs->trans('Cancel')) { - Header('Location: '.$_SERVER['PHP_SELF'].'?id='.$object->id); // Pour reaffichage de la fiche en cours d'edition - exit; + Header('Location: '.$_SERVER['PHP_SELF'].'?id='.$object->id); // Pour reaffichage de la fiche en cours d'edition + exit; } else if ($action == 'confirm_validate' && $confirm == 'yes' && $user->rights->commande->valider) { - $idwarehouse=GETPOST('idwarehouse'); + $idwarehouse=GETPOST('idwarehouse'); - // Check parameters - if (! empty($conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER) && $object->hasProductsOrServices(1)) - { - if (! $idwarehouse || $idwarehouse == -1) - { - $error++; - $errors[]=$langs->trans('ErrorFieldRequired',$langs->transnoentitiesnoconv("Warehouse")); - $action=''; - } - } + // Check parameters + if (! empty($conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER) && $object->hasProductsOrServices(1)) + { + if (! $idwarehouse || $idwarehouse == -1) + { + $error++; + $mesgs[]='
'.$langs->trans('ErrorFieldRequired',$langs->transnoentitiesnoconv("Warehouse")).'
'; + $action=''; + } + } - if (! $error) - { - $result=$object->valid($user,$idwarehouse); - if ($result >= 0) - { - // Define output language - $outputlangs = $langs; - $newlang=''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) $newlang=$_REQUEST['lang_id']; - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang; - if (! empty($newlang)) - { - $outputlangs = new Translate("",$conf); - $outputlangs->setDefaultLang($newlang); - } - if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) commande_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $hookmanager); - } - } + if (! $error) + { + $result=$object->valid($user,$idwarehouse); + if ($result >= 0) + { + // Define output language + $outputlangs = $langs; + $newlang=''; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) $newlang=$_REQUEST['lang_id']; + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang; + if (! empty($newlang)) + { + $outputlangs = new Translate("",$conf); + $outputlangs->setDefaultLang($newlang); + } + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) commande_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $hookmanager); + } + } } // Go back to draft status else if ($action == 'confirm_modif' && $user->rights->commande->creer) { - $idwarehouse=GETPOST('idwarehouse'); + $idwarehouse=GETPOST('idwarehouse'); - // Check parameters - if (! empty($conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER) && $object->hasProductsOrServices(1)) - { - if (! $idwarehouse || $idwarehouse == -1) - { - $error++; - $errors[]=$langs->trans('ErrorFieldRequired',$langs->transnoentitiesnoconv("Warehouse")); - $action=''; - } - } + // Check parameters + if (! empty($conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER) && $object->hasProductsOrServices(1)) + { + if (! $idwarehouse || $idwarehouse == -1) + { + $error++; + $mesgs[]='
'.$langs->trans('ErrorFieldRequired',$langs->transnoentitiesnoconv("Warehouse")).'
'; + $action=''; + } + } if (! $error) { - $result = $object->set_draft($user,$idwarehouse); - if ($result >= 0) - { - // Define output language - $outputlangs = $langs; - $newlang=''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) $newlang=$_REQUEST['lang_id']; - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang; - if (! empty($newlang)) - { - $outputlangs = new Translate("",$conf); - $outputlangs->setDefaultLang($newlang); - } - if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) - { - $ret=$object->fetch($object->id); // Reload to get new records - commande_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $hookmanager); - } - } + $result = $object->set_draft($user,$idwarehouse); + if ($result >= 0) + { + // Define output language + $outputlangs = $langs; + $newlang=''; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) $newlang=$_REQUEST['lang_id']; + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang; + if (! empty($newlang)) + { + $outputlangs = new Translate("",$conf); + $outputlangs->setDefaultLang($newlang); + } + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) + { + $ret=$object->fetch($object->id); // Reload to get new records + commande_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $hookmanager); + } + } } } else if ($action == 'confirm_shipped' && $confirm == 'yes' && $user->rights->commande->cloturer) { - $result = $object->cloture($user); - if ($result < 0) $mesgs=$object->errors; + $result = $object->cloture($user); + if ($result < 0) $mesgs=$object->errors; } else if ($action == 'confirm_cancel' && $confirm == 'yes' && $user->rights->commande->valider) { - $idwarehouse=GETPOST('idwarehouse'); + $idwarehouse=GETPOST('idwarehouse'); - // Check parameters - if (! empty($conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER) && $object->hasProductsOrServices(1)) - { - if (! $idwarehouse || $idwarehouse == -1) - { - $error++; - $errors[]=$langs->trans('ErrorFieldRequired',$langs->transnoentitiesnoconv("Warehouse")); - $action=''; - } - } + // Check parameters + if (! empty($conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER) && $object->hasProductsOrServices(1)) + { + if (! $idwarehouse || $idwarehouse == -1) + { + $error++; + $mesgs[]='
'.$langs->trans('ErrorFieldRequired',$langs->transnoentitiesnoconv("Warehouse")).'
'; + $action=''; + } + } if (! $error) { - $result = $object->cancel($idwarehouse); + $result = $object->cancel($idwarehouse); } } /* * Ordonnancement des lignes - */ +*/ else if ($action == 'up' && $user->rights->commande->creer) { - $object->line_up($_GET['rowid']); + $object->line_up(GETPOST('rowid')); - // Define output language - $outputlangs = $langs; - $newlang=''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) $newlang=$_REQUEST['lang_id']; - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang; - if (! empty($newlang)) - { - $outputlangs = new Translate("",$conf); - $outputlangs->setDefaultLang($newlang); - } + // Define output language + $outputlangs = $langs; + $newlang=''; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) $newlang=$_REQUEST['lang_id']; + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang; + if (! empty($newlang)) + { + $outputlangs = new Translate("",$conf); + $outputlangs->setDefaultLang($newlang); + } - if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) commande_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $hookmanager); + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) commande_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $hookmanager); - Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id.'#'.$_GET['rowid']); - exit; + Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id.'#'.GETPOST('rowid')); + exit; } else if ($action == 'down' && $user->rights->commande->creer) { - $object->line_down($_GET['rowid']); + $object->line_down(GETPOST('rowid')); - // Define output language - $outputlangs = $langs; - $newlang=''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) $newlang=$_REQUEST['lang_id']; - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang; - if (! empty($newlang)) - { - $outputlangs = new Translate("",$conf); - $outputlangs->setDefaultLang($newlang); - } - if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) commande_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $hookmanager); + // Define output language + $outputlangs = $langs; + $newlang=''; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) $newlang=$_REQUEST['lang_id']; + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang; + if (! empty($newlang)) + { + $outputlangs = new Translate("",$conf); + $outputlangs->setDefaultLang($newlang); + } + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) commande_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $hookmanager); - Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id.'#'.$_GET['rowid']); - exit; + Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id.'#'.GETPOST('rowid')); + exit; } else if ($action == 'builddoc') // In get or post { - /* - * Generate order document - * define into /core/modules/commande/modules_commande.php - */ + /* + * Generate order document + * define into /core/modules/commande/modules_commande.php + */ - // Sauvegarde le dernier modele choisi pour generer un document - if ($_REQUEST['model']) - { - $object->setDocModel($user, $_REQUEST['model']); - } + // Sauvegarde le dernier modele choisi pour generer un document + if ($_REQUEST['model']) + { + $object->setDocModel($user, $_REQUEST['model']); + } - // Define output language - $outputlangs = $langs; - $newlang=''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) $newlang=$_REQUEST['lang_id']; - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang; - if (! empty($newlang)) - { - $outputlangs = new Translate("",$conf); - $outputlangs->setDefaultLang($newlang); - } - $result=commande_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $hookmanager); - if ($result <= 0) - { - dol_print_error($db,$result); - exit; - } - else - { - Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id.(empty($conf->global->MAIN_JUMP_TAG)?'':'#builddoc')); - exit; - } + // Define output language + $outputlangs = $langs; + $newlang=''; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) $newlang=$_REQUEST['lang_id']; + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang; + if (! empty($newlang)) + { + $outputlangs = new Translate("",$conf); + $outputlangs->setDefaultLang($newlang); + } + $result=commande_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $hookmanager); + if ($result <= 0) + { + dol_print_error($db,$result); + exit; + } + else + { + Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id.(empty($conf->global->MAIN_JUMP_TAG)?'':'#builddoc')); + exit; + } } // Remove file in doc form else if ($action == 'remove_file') { - if ($object->id > 0) - { - require_once(DOL_DOCUMENT_ROOT."/core/lib/files.lib.php"); + if ($object->id > 0) + { + require_once(DOL_DOCUMENT_ROOT."/core/lib/files.lib.php"); - $langs->load("other"); - $upload_dir = $conf->commande->dir_output; - $file = $upload_dir . '/' . GETPOST('file'); - dol_delete_file($file,0,0,0,$object); - $mesg = '
'.$langs->trans("FileWasRemoved",GETPOST('file')).'
'; - } + $langs->load("other"); + $upload_dir = $conf->commande->dir_output; + $file = $upload_dir . '/' . GETPOST('file'); + dol_delete_file($file,0,0,0,$object); + $mesg = '
'.$langs->trans("FileWasRemoved",GETPOST('file')).'
'; + } } /* * Add file in email form - */ -if ($_POST['addfile']) +*/ +if (GETPOST('addfile')) { - require_once(DOL_DOCUMENT_ROOT."/core/lib/files.lib.php"); + require_once(DOL_DOCUMENT_ROOT."/core/lib/files.lib.php"); - // Set tmp user directory TODO Use a dedicated directory for temp mails files - $vardir=$conf->user->dir_output."/".$user->id; - $upload_dir_tmp = $vardir.'/temp'; + // Set tmp user directory TODO Use a dedicated directory for temp mails files + $vardir=$conf->user->dir_output."/".$user->id; + $upload_dir_tmp = $vardir.'/temp'; - $mesg=dol_add_file_process($upload_dir_tmp,0,0); + $mesg=dol_add_file_process($upload_dir_tmp,0,0); - $action ='presend'; + $action ='presend'; } /* * Remove file in email form - */ -if (! empty($_POST['removedfile'])) +*/ +if (GETPOST('removedfile')) { - require_once(DOL_DOCUMENT_ROOT."/core/lib/files.lib.php"); + require_once(DOL_DOCUMENT_ROOT."/core/lib/files.lib.php"); - // Set tmp user directory - $vardir=$conf->user->dir_output."/".$user->id; - $upload_dir_tmp = $vardir.'/temp'; + // Set tmp user directory + $vardir=$conf->user->dir_output."/".$user->id; + $upload_dir_tmp = $vardir.'/temp'; // TODO Delete only files that was uploaded from email form - $mesg=dol_remove_file_process($_POST['removedfile'],0); + $mesg=dol_remove_file_process(GETPOST('removedfile'),0); - $action ='presend'; + $action ='presend'; } /* * Send mail - */ -if ($action == 'send' && ! $_POST['addfile'] && ! $_POST['removedfile'] && ! $_POST['cancel']) +*/ +if ($action == 'send' && ! GETPOST('addfile') && ! GETPOST('removedfile') && ! GETPOST('cancel')) { - $langs->load('mails'); + $langs->load('mails'); - if ($object->id > 0) - { -// $ref = dol_sanitizeFileName($object->ref); -// $file = $conf->commande->dir_output . '/' . $ref . '/' . $ref . '.pdf'; - -// if (is_readable($file)) -// { - if ($_POST['sendto']) - { - // Le destinataire a ete fourni via le champ libre - $sendto = $_POST['sendto']; - $sendtoid = 0; - } - elseif ($_POST['receiver'] != '-1') - { - // Recipient was provided from combo list - if ($_POST['receiver'] == 'thirdparty') // Id of third party - { - $sendto = $object->client->email; - $sendtoid = 0; - } - else // Id du contact - { - $sendto = $object->client->contact_get_property($_POST['receiver'],'email'); - $sendtoid = $_POST['receiver']; - } - } - - if (dol_strlen($sendto)) - { - $langs->load("commercial"); - - $from = $_POST['fromname'] . ' <' . $_POST['frommail'] .'>'; - $replyto = $_POST['replytoname']. ' <' . $_POST['replytomail'].'>'; - $message = $_POST['message']; - $sendtocc = $_POST['sendtocc']; - $deliveryreceipt = $_POST['deliveryreceipt']; - - if ($_POST['action'] == 'send') - { - if (dol_strlen($_POST['subject'])) $subject=$_POST['subject']; - else $subject = $langs->transnoentities('Order').' '.$object->ref; - $actiontypecode='AC_COM'; - $actionmsg = $langs->transnoentities('MailSentBy').' '.$from.' '.$langs->transnoentities('To').' '.$sendto.".\n"; - if ($message) - { - $actionmsg.=$langs->transnoentities('MailTopic').": ".$subject."\n"; - $actionmsg.=$langs->transnoentities('TextUsedInTheMessageBody').":\n"; - $actionmsg.=$message; - } - $actionmsg2=$langs->transnoentities('Action'.$actiontypecode); - } - - // Create form object - include_once(DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'); - $formmail = new FormMail($db); - - $attachedfiles=$formmail->get_attached_files(); - $filepath = $attachedfiles['paths']; - $filename = $attachedfiles['names']; - $mimetype = $attachedfiles['mimes']; - - // Send mail - require_once(DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'); - $mailfile = new CMailFile($subject,$sendto,$from,$message,$filepath,$mimetype,$filename,$sendtocc,'',$deliveryreceipt); - if ($mailfile->error) - { - $mesg='
'.$mailfile->error.'
'; - } - else - { - $result=$mailfile->sendfile(); - if ($result) - { - $mesg=$langs->trans('MailSuccessfulySent',$mailfile->getValidAddress($from,2),$mailfile->getValidAddress($sendto,2)); // Must not contains " - - $error=0; - - // Initialisation donnees - $object->sendtoid = $sendtoid; - $object->actiontypecode = $actiontypecode; - $object->actionmsg = $actionmsg; - $object->actionmsg2 = $actionmsg2; - $object->fk_element = $object->id; - $object->elementtype = $object->element; - - // Appel des triggers - include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php"); - $interface=new Interfaces($db); - $result=$interface->run_triggers('ORDER_SENTBYMAIL',$object,$user,$langs,$conf); - if ($result < 0) { $error++; $this->errors=$interface->errors; } - // Fin appel triggers - - if ($error) - { - dol_print_error($db); - } - else - { - // Redirect here - // This avoid sending mail twice if going out and then back to page - Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id.'&mesg='.urlencode($mesg)); - exit; - } - } - else - { - $langs->load("other"); - $mesg='
'; - if ($mailfile->error) - { - $mesg.=$langs->trans('ErrorFailedToSendMail',$from,$sendto); - $mesg.='
'.$mailfile->error; - } - else - { - $mesg.='No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS'; - } - $mesg.='
'; - } - } -/* } - else - { - $langs->load("other"); - $mesg='
'.$langs->trans('ErrorMailRecipientIsEmpty').' !
'; - $action='presend'; - dol_syslog('Recipient email is empty'); - }*/ - } - else - { - $langs->load("errors"); - $mesg='
'.$langs->trans('ErrorCantReadFile',$file).'
'; - dol_syslog('Failed to read file: '.$file); - } - } - else - { - $langs->load("other"); - $mesg='
'.$langs->trans('ErrorFailedToReadEntity',$langs->trans("Order")).'
'; - dol_syslog($langs->trans('ErrorFailedToReadEntity', $langs->trans("Order"))); - } -} - -if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) -{ - if ($action == 'addcontact' && $user->rights->commande->creer) + if ($object->id > 0) { - if ($object->id > 0) + // $ref = dol_sanitizeFileName($object->ref); + // $file = $conf->commande->dir_output . '/' . $ref . '/' . $ref . '.pdf'; + + // if (is_readable($file)) + // { + if (GETPOST('sendto')) { - $contactid = (GETPOST('userid') ? GETPOST('userid') : GETPOST('contactid')); - $result = $object->add_contact($contactid, $_POST["type"], $_POST["source"]); + // Le destinataire a ete fourni via le champ libre + $sendto = GETPOST('sendto'); + $sendtoid = 0; + } + elseif (GETPOST('receiver') != '-1') + { + // Recipient was provided from combo list + if (GETPOST('receiver') == 'thirdparty') // Id of third party + { + $sendto = $object->client->email; + $sendtoid = 0; + } + else // Id du contact + { + $sendto = $object->client->contact_get_property(GETPOST('receiver'),'email'); + $sendtoid = GETPOST('receiver'); + } } - if ($result >= 0) + if (dol_strlen($sendto)) { - Header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); - exit; - } - else - { - if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') + $langs->load("commercial"); + + $from = GETPOST('fromname') . ' <' . GETPOST('frommail') .'>'; + $replyto = GETPOST('replytoname'). ' <' . GETPOST('replytomail').'>'; + $message = GETPOST('message'); + $sendtocc = GETPOST('sendtocc'); + $deliveryreceipt = GETPOST('deliveryreceipt'); + + if ($action == 'send') { - $langs->load("errors"); - $mesg = '
'.$langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType").'
'; + if (dol_strlen(GETPOST('subject'))) $subject=GETPOST('subject'); + else $subject = $langs->transnoentities('Order').' '.$object->ref; + $actiontypecode='AC_COM'; + $actionmsg = $langs->transnoentities('MailSentBy').' '.$from.' '.$langs->transnoentities('To').' '.$sendto.".\n"; + if ($message) + { + $actionmsg.=$langs->transnoentities('MailTopic').": ".$subject."\n"; + $actionmsg.=$langs->transnoentities('TextUsedInTheMessageBody').":\n"; + $actionmsg.=$message; + } + $actionmsg2=$langs->transnoentities('Action'.$actiontypecode); + } + + // Create form object + include_once(DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'); + $formmail = new FormMail($db); + + $attachedfiles=$formmail->get_attached_files(); + $filepath = $attachedfiles['paths']; + $filename = $attachedfiles['names']; + $mimetype = $attachedfiles['mimes']; + + // Send mail + require_once(DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'); + $mailfile = new CMailFile($subject,$sendto,$from,$message,$filepath,$mimetype,$filename,$sendtocc,'',$deliveryreceipt); + if ($mailfile->error) + { + $mesg='
'.$mailfile->error.'
'; } else { - $mesg = '
'.$object->error.'
'; + $result=$mailfile->sendfile(); + if ($result) + { + $mesg=$langs->trans('MailSuccessfulySent',$mailfile->getValidAddress($from,2),$mailfile->getValidAddress($sendto,2)); // Must not contains " + + $error=0; + + // Initialisation donnees + $object->sendtoid = $sendtoid; + $object->actiontypecode = $actiontypecode; + $object->actionmsg = $actionmsg; + $object->actionmsg2 = $actionmsg2; + $object->fk_element = $object->id; + $object->elementtype = $object->element; + + // Appel des triggers + include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php"); + $interface=new Interfaces($db); + $result=$interface->run_triggers('ORDER_SENTBYMAIL',$object,$user,$langs,$conf); + if ($result < 0) { + $error++; $this->errors=$interface->errors; + } + // Fin appel triggers + + if ($error) + { + dol_print_error($db); + } + else + { + // Redirect here + // This avoid sending mail twice if going out and then back to page + Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id.'&mesg='.urlencode($mesg)); + exit; + } + } + else + { + $langs->load("other"); + $mesg='
'; + if ($mailfile->error) + { + $mesg.=$langs->trans('ErrorFailedToSendMail',$from,$sendto); + $mesg.='
'.$mailfile->error; + } + else + { + $mesg.='No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS'; + } + $mesg.='
'; + } + } + /* } + else + { + $langs->load("other"); + $mesg='
'.$langs->trans('ErrorMailRecipientIsEmpty').' !
'; + $action='presend'; + dol_syslog('Recipient email is empty'); + }*/ + } + else + { + $langs->load("errors"); + $mesg='
'.$langs->trans('ErrorCantReadFile',$file).'
'; + dol_syslog('Failed to read file: '.$file); + } + } + else + { + $langs->load("other"); + $mesg='
'.$langs->trans('ErrorFailedToReadEntity',$langs->trans("Order")).'
'; + dol_syslog($langs->trans('ErrorFailedToReadEntity', $langs->trans("Order"))); + } + } + + if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) + { + if ($action == 'addcontact' && $user->rights->commande->creer) + { + if ($object->id > 0) + { + $contactid = (GETPOST('userid') ? GETPOST('userid') : GETPOST('contactid')); + $result = $object->add_contact($contactid, GETPOST('type'), GETPOST('source')); + } + + if ($result >= 0) + { + Header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); + exit; + } + else + { + if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') + { + $langs->load("errors"); + $mesg = '
'.$langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType").'
'; + } + else + { + $mesg = '
'.$object->error.'
'; + } + } + } + + // bascule du statut d'un contact + else if ($action == 'swapstatut' && $user->rights->commande->creer) + { + if ($object->id > 0) + { + $result=$object->swapContactStatus(GETPOST('ligne')); + } + else + { + dol_print_error($db); + } + } + + // Efface un contact + else if ($action == 'deletecontact' && $user->rights->commande->creer) + { + $result = $object->delete_contact($lineid); + + if ($result >= 0) + { + Header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); + exit; + } + else { + dol_print_error($db); } } } - // bascule du statut d'un contact - else if ($action == 'swapstatut' && $user->rights->commande->creer) + + /* + * View + */ + + llxHeader('',$langs->trans('Order'),'EN:Customers_Orders|FR:Commandes_Clients|ES:Pedidos de clientes'); + + $form = new Form($db); + $formfile = new FormFile($db); + $formorder = new FormOrder($db); + + + /********************************************************************* + * + * Mode creation + * + *********************************************************************/ + if ($action == 'create' && $user->rights->commande->creer) { - if ($object->id > 0) + print_fiche_titre($langs->trans('CreateOrder')); + + dol_htmloutput_mesg($mesg,$mesgs,'error'); + + $soc = new Societe($db); + if ($socid) $res=$soc->fetch($socid); + + if ($origin && $originid) { - $result=$object->swapContactStatus(GETPOST('ligne')); + // Parse element/subelement (ex: project_task) + $element = $subelement = $origin; + if (preg_match('/^([^_]+)_([^_]+)/i',$origin,$regs)) + { + $element = $regs[1]; + $subelement = $regs[2]; + } + + if ($element == 'project') + { + $projectid=$originid; + } + else + { + // For compatibility + if ($element == 'order' || $element == 'commande') { + $element = $subelement = 'commande'; + } + if ($element == 'propal') { + $element = 'comm/propal'; $subelement = 'propal'; + } + if ($element == 'contract') { + $element = $subelement = 'contrat'; + } + + dol_include_once('/'.$element.'/class/'.$subelement.'.class.php'); + + $classname = ucfirst($subelement); + $objectsrc = new $classname($db); + $objectsrc->fetch($originid); + if (empty($objectsrc->lines) && method_exists($objectsrc,'fetch_lines')) $objectsrc->fetch_lines(); + $objectsrc->fetch_thirdparty(); + + $projectid = (!empty($objectsrc->fk_project)?$object->fk_project:''); + $ref_client = (!empty($objectsrc->ref_client)?$object->ref_client:''); + + $soc = $objectsrc->client; + $cond_reglement_id = (!empty($objectsrc->cond_reglement_id)?$objectsrc->cond_reglement_id:(!empty($soc->cond_reglement_id)?$soc->cond_reglement_id:1)); + $mode_reglement_id = (!empty($objectsrc->mode_reglement_id)?$objectsrc->mode_reglement_id:(!empty($soc->mode_reglement_id)?$soc->mode_reglement_id:0)); + $availability_id = (!empty($objectsrc->availability_id)?$objectsrc->availability_id:(!empty($soc->availability_id)?$soc->availability_id:0)); + $demand_reason_id = (!empty($objectsrc->demand_reason_id)?$objectsrc->demand_reason_id:(!empty($soc->demand_reason_id)?$soc->demand_reason_id:0)); + $remise_percent = (!empty($objectsrc->remise_percent)?$objectsrc->remise_percent:(!empty($soc->remise_percent)?$soc->remise_percent:0)); + $remise_absolue = (!empty($objectsrc->remise_absolue)?$objectsrc->remise_absolue:(!empty($soc->remise_absolue)?$soc->remise_absolue:0)); + $dateinvoice = empty($conf->global->MAIN_AUTOFILL_DATE)?-1:0; + + $note_private = (! empty($objectsrc->note) ? $objectsrc->note : (! empty($objectsrc->note_private) ? $objectsrc->note_private : '')); + $note_public = (! empty($objectsrc->note_public) ? $objectsrc->note_public : ''); + + // Object source contacts list + $srccontactslist = $objectsrc->liste_contact(-1,'external',1); + } } else { - dol_print_error($db); + $cond_reglement_id = $soc->cond_reglement_id; + $mode_reglement_id = $soc->mode_reglement_id; + $availability_id = $soc->availability_id; + $demand_reason_id = $soc->demand_reason_id; + $remise_percent = $soc->remise_percent; + $remise_absolue = 0; + $dateinvoice = empty($conf->global->MAIN_AUTOFILL_DATE)?-1:0; } - } + $absolute_discount=$soc->getAvailableDiscounts(); - // Efface un contact - else if ($action == 'deletecontact' && $user->rights->commande->creer) - { - $result = $object->delete_contact($lineid); - if ($result >= 0) + + $nbrow=10; + + print ''; + print ''; + print ''; + print '' ."\n"; + print ''; + print ''; + print ''; + print ''; + + print ''; + + // Reference + print ''; + + // Reference client + print ''; + print ''; + + // Client + print ''; + + /* + * Contact de la commande + */ + print "'; + + // Ligne info remises tiers + print ''; + + // Date + print ''; + + // Date de livraison + print ""; + + // Conditions de reglement + print ''; + + // Mode de reglement + print ''; + + // Delivery delay + print ''; + + // What trigger creation + print ''; + + // Project + if (! empty($conf->projet->enabled)) + { + $projectid = 0; + if ($origin == 'project') $projectid = ($originid?$originid:0); + + print ''; + } + + // Other attributes + $parameters=array('objectsrc' => $objectsrc, 'colspan' => ' colspan="3"'); + $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook + if (empty($reshook) && ! empty($extrafields->attribute_label)) + { + foreach($extrafields->attribute_label as $key=>$label) + { + $value=(isset($_POST["options_".$key])?$_POST["options_".$key]:$object->array_options["options_".$key]); + print "'."\n"; + } + } + + // Template to use by default + print ''; + print '"; + + + // Note publique + print ''; + print ''; + print ''; + + // Note privee + if (! $user->societe_id) + { + print ''; + print ''; + print ''; + } + + if (is_object($objectsrc)) + { + // TODO for compatibility + if ($origin == 'contrat') + { + // Calcul contrat->price (HT), contrat->total (TTC), contrat->tva + $objectsrc->remise_absolue=$remise_absolue; + $objectsrc->remise_percent=$remise_percent; + $objectsrc->update_price(1); + } + + print "\n"; + print "\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''; + print ''; + + $newclassname=$classname; + if ($newclassname=='Propal') $newclassname='CommercialProposal'; + print ''; + print ''; + print '"; + if ($mysoc->country_code=='ES') + { + if ($mysoc->localtax1_assuj=="1") //Localtax1 RE + { + print '"; + } + + if ($mysoc->localtax2_assuj=="1") //Localtax2 IRPF + { + print '"; + } + } + print '"; + } + else + { + if ($conf->global->PRODUCT_SHOW_WHEN_CREATE) + { + /* + * Services/produits predefinis + */ + $NBLINES=8; + + print ''; + } + } + + print '
'.$langs->trans('Ref').''.$langs->trans("Draft").'
'.$langs->trans('RefCustomer').''; + print '
'.$langs->trans('Customer').''.$soc->getNomUrl(1).'
".$langs->trans("DefaultContact").''; + $form->select_contacts($soc->id,$setcontact,'contactidp',1,$srccontactslist); + print '
'.$langs->trans('Discounts').''; + if ($soc->remise_client) print $langs->trans("CompanyHasRelativeDiscount",$soc->remise_client); + else print $langs->trans("CompanyHasNoRelativeDiscount"); + print '. '; + $absolute_discount=$soc->getAvailableDiscounts(); + if ($absolute_discount) print $langs->trans("CompanyHasAbsoluteDiscount",price($absolute_discount),$langs->trans("Currency".$conf->currency)); + else print $langs->trans("CompanyHasNoAbsoluteDiscount"); + print '.'; + print '
'.$langs->trans('Date').''; + $form->select_date('','re','','','',"crea_commande",1,1); + print '
".$langs->trans("DeliveryDate").''; + if ($conf->global->DATE_LIVRAISON_WEEK_DELAY) { - Header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); - exit; + $datedelivery = time() + ((7*$conf->global->DATE_LIVRAISON_WEEK_DELAY) * 24 * 60 * 60); } - else { - dol_print_error($db); + else + { + $datedelivery=empty($conf->global->MAIN_AUTOFILL_DATE)?-1:0; + } + $form->select_date($datedelivery,'liv_','','','',"crea_commande",1,1); + print "
'.$langs->trans('PaymentConditionsShort').''; + $form->select_conditions_paiements($soc->cond_reglement,'cond_reglement_id',-1,1); + print '
'.$langs->trans('PaymentMode').''; + $form->select_types_paiements($soc->mode_reglement,'mode_reglement_id'); + print '
'.$langs->trans('AvailabilityPeriod').''; + $form->select_availability($propal->availability,'availability_id','',1); + print '
'.$langs->trans('Source').''; + $form->select_demand_reason(($origin=='propal'?'SRC_COMM':''),'demand_reason_id','',1); + print '
'.$langs->trans('Project').''; + $numprojet=select_projects($soc->id,$projectid); + if ($numprojet==0) + { + print '   '.$langs->trans("AddProject").''; + } + print '
".$label.''; + print $extrafields->showInputField($key,$value); + print '
'.$langs->trans('Model').''; + include_once(DOL_DOCUMENT_ROOT.'/core/modules/commande/modules_commande.php'); + $liste=ModelePDFCommandes::liste_modeles($db); + print $form->selectarray('model',$liste,$conf->global->COMMANDE_ADDON_PDF); + print "
'.$langs->trans('NotePublic').''; + require_once(DOL_DOCUMENT_ROOT."/core/class/doleditor.class.php"); + $doleditor=new DolEditor('note_public', $note_public, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, 70); + print $doleditor->Create(1); + //print ''; + print '
'.$langs->trans('NotePrivate').''; + require_once(DOL_DOCUMENT_ROOT."/core/class/doleditor.class.php"); + $doleditor=new DolEditor('note', $note_private, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, 70); + print $doleditor->Create(1); + //print ''; + print '
'.$langs->trans($newclassname).''.$objectsrc->getNomUrl(1).'
'.$langs->trans('TotalHT').''.price($objectsrc->total_ht).'
'.$langs->trans('TotalVAT').''.price($objectsrc->total_tva)."
'.$langs->transcountry("AmountLT1",$mysoc->country_code).''.price($objectsrc->total_localtax1)."
'.$langs->transcountry("AmountLT2",$mysoc->country_code).''.price($objectsrc->total_localtax2)."
'.$langs->trans('TotalTTC').''.price($objectsrc->total_ttc)."
'; + + print ''; + print ''; + print ''; + print ''; + print ''; + for ($i = 1 ; $i <= $NBLINES ; $i++) + { + print ''; + print ''; + print ''; + } + + print '
'.$langs->trans('ProductsAndServices').''.$langs->trans('Qty').''.$langs->trans('ReductionShort').'
'; + // multiprix + if($conf->global->PRODUIT_MULTIPRICES) + print $form->select_produits('','idprod'.$i,'',$conf->product->limit_size,$soc->price_level); + else + print $form->select_produits('','idprod'.$i,'',$conf->product->limit_size); + print '%
'; + print '
'; + + // Button "Create Draft" + print '
'; + + print ''; + + + // Show origin lines + if (is_object($objectsrc)) + { + $title=$langs->trans('ProductsAndServices'); + print_titre($title); + + print ''; + + $objectsrc->printOriginLinesList($hookmanager); + + print '
'; + } + + } + else + { + /* *************************************************************************** */ + /* */ + /* Mode vue et edition */ + /* */ + /* *************************************************************************** */ + $now=dol_now(); + + if ($object->id > 0) + { + dol_htmloutput_mesg($mesg,$mesgs); + + $product_static=new Product($db); + + $soc = new Societe($db); + $soc->fetch($object->socid); + + $author = new User($db); + $author->fetch($object->user_author_id); + + $head = commande_prepare_head($object); + dol_fiche_head($head, 'order', $langs->trans("CustomerOrder"), 0, 'order'); + + $formconfirm=''; + + /* + * Confirmation de la suppression de la commande + */ + if ($action == 'delete') + { + $formconfirm=$form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DeleteOrder'), $langs->trans('ConfirmDeleteOrder'), 'confirm_delete', '', 0, 1); + } + + /* + * Confirmation de la validation + */ + if ($action == 'validate') + { + // on verifie si l'objet est en numerotation provisoire + $ref = substr($object->ref, 1, 4); + if ($ref == 'PROV') + { + $numref = $object->getNextNumRef($soc); + } + else + { + $numref = $object->ref; + } + + $text=$langs->trans('ConfirmValidateOrder',$numref); + if ($conf->notification->enabled) + { + require_once(DOL_DOCUMENT_ROOT ."/core/class/notify.class.php"); + $notify=new Notify($db); + $text.='
'; + $text.=$notify->confirmMessage('NOTIFY_VAL_ORDER',$object->socid); + } + $formquestion=array(); + if (! empty($conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER) && $object->hasProductsOrServices(1)) + { + $langs->load("stocks"); + require_once(DOL_DOCUMENT_ROOT."/product/class/html.formproduct.class.php"); + $formproduct=new FormProduct($db); + $formquestion=array( + //'text' => $langs->trans("ConfirmClone"), + //array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1), + //array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans("PuttingPricesUpToDate"), 'value' => 1), + array('type' => 'other', 'name' => 'idwarehouse', 'label' => $langs->trans("SelectWarehouseForStockDecrease"), 'value' => $formproduct->selectWarehouses(GETPOST('idwarehouse'),'idwarehouse','',1))); + } + + $formconfirm=$form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ValidateOrder'), $text, 'confirm_validate', $formquestion, 0, 1, 220); + } + + // Confirm back to draft status + if ($action == 'modif') + { + $text=$langs->trans('ConfirmUnvalidateOrder',$object->ref); + $formquestion=array(); + if (! empty($conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER) && $object->hasProductsOrServices(1)) + { + $langs->load("stocks"); + require_once(DOL_DOCUMENT_ROOT."/product/class/html.formproduct.class.php"); + $formproduct=new FormProduct($db); + $formquestion=array( + //'text' => $langs->trans("ConfirmClone"), + //array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1), + //array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans("PuttingPricesUpToDate"), 'value' => 1), + array('type' => 'other', 'name' => 'idwarehouse', 'label' => $langs->trans("SelectWarehouseForStockIncrease"), 'value' => $formproduct->selectWarehouses(GETPOST('idwarehouse'),'idwarehouse','',1))); + } + + $formconfirm=$form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('UnvalidateOrder'), $text, 'confirm_modif', $formquestion, "yes", 1, 220); + } + + + /* + * Confirmation de la cloture + */ + if ($action == 'shipped') + { + $formconfirm=$form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('CloseOrder'), $langs->trans('ConfirmCloseOrder'), 'confirm_shipped', '', 0, 1); + } + + /* + * Confirmation de l'annulation + */ + if ($action == 'cancel') + { + $text=$langs->trans('ConfirmCancelOrder',$object->ref); + $formquestion=array(); + if (! empty($conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER) && $object->hasProductsOrServices(1)) + { + $langs->load("stocks"); + require_once(DOL_DOCUMENT_ROOT."/product/class/html.formproduct.class.php"); + $formproduct=new FormProduct($db); + $formquestion=array( + //'text' => $langs->trans("ConfirmClone"), + //array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1), + //array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans("PuttingPricesUpToDate"), 'value' => 1), + array('type' => 'other', 'name' => 'idwarehouse', 'label' => $langs->trans("SelectWarehouseForStockIncrease"), 'value' => $formproduct->selectWarehouses(GETPOST('idwarehouse'),'idwarehouse','',1))); + } + + $formconfirm=$form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('Cancel'), $text, 'confirm_cancel', $formquestion, 0, 1); + } + + /* + * Confirmation de la suppression d'une ligne produit + */ + if ($action == 'ask_deleteline') + { + $formconfirm=$form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&lineid='.$lineid, $langs->trans('DeleteProductLine'), $langs->trans('ConfirmDeleteProductLine'), 'confirm_deleteline', '', 0, 1); + } + + // Clone confirmation + if ($action == 'clone') + { + // Create an array for form + $formquestion=array( + //'text' => $langs->trans("ConfirmClone"), + //array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1), + //array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans("PuttingPricesUpToDate"), 'value' => 1), + array('type' => 'other', 'name' => 'socid', 'label' => $langs->trans("SelectThirdParty"), 'value' => $form->select_company(GETPOST('socid','int'),'socid','(s.client=1 OR s.client=3)')) + ); + // Paiement incomplet. On demande si motif = escompte ou autre + $formconfirm=$form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id,$langs->trans('CloneOrder'),$langs->trans('ConfirmCloneOrder',$object->ref),'confirm_clone',$formquestion,'yes',1); + } + + if (! $formconfirm) + { + $parameters=array('lineid'=>$lineid); + $formconfirm=$hookmanager->executeHooks('formConfirm',$parameters,$object,$action); // Note that $action and $object may have been modified by hook + } + + // Print form confirm + print $formconfirm; + + /* + * Commande + */ + $nbrow=9; + if ($conf->projet->enabled) $nbrow++; + + //Local taxes + if ($mysoc->country_code=='ES') + { + if($mysoc->localtax1_assuj=="1") $nbrow++; + if($mysoc->localtax2_assuj=="1") $nbrow++; + } + + print ''; + + // Ref + print ''; + print ''; + print ''; + + // Ref commande client + print ''; + print ''; + + + // Societe + print ''; + print ''; + print ''; + + // Ligne info remises tiers + print ''; + + // Date + print ''; + print ''; + + // Delivery date planed + print ''; + + // Terms of payment + print ''; + + print ''; + + // Mode of payment + print ''; + + // Availability + print ''; + + // Source + print ''; + + // Project + if (! empty($conf->projet->enabled)) + { + $langs->load('projects'); + print ''; + } + + // Other attributes + $parameters=array('colspan' => ' colspan="2"'); + $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook + if (empty($reshook) && ! empty($extrafields->attribute_label)) + { + foreach($extrafields->attribute_label as $key=>$label) + { + $value=(isset($_POST["options_".$key])?$_POST["options_".$key]:$object->array_options["options_".$key]); + print ''."\n"; + } + } + + // Total HT + print ''; + print ''; + print ''; + + // Margin Infos + if (! empty($conf->margin->enabled)) { + print ''; + } + print ''; + + // Total TVA + print ''; + print ''; + + // Amount Local Taxes + if ($mysoc->country_code=='ES') + { + if ($mysoc->localtax1_assuj=="1") //Localtax1 RE + { + print ''; + print ''; + print ''; + } + if ($mysoc->localtax2_assuj=="1") //Localtax2 IRPF + { + print ''; + print ''; + print ''; + } + } + + // Total TTC + print ''; + print ''; + + // Statut + print ''; + print ''; + print ''; + + print '
'.$langs->trans('Ref').''; + print $form->showrefnav($object,'ref','',1,'ref','ref'); + print '
'; + print ''; + if ($action != 'refcustomer' && $object->brouillon) print ''; + print '
'; + print $langs->trans('RefCustomer').''; + print ''.img_edit($langs->trans('Modify')).'
'; + print '
'; + if ($user->rights->commande->creer && $action == 'refcustomer') + { + print '
'; + print ''; + print ''; + print ''; + print ' '; + print '
'; + } + else + { + print $object->ref_client; + } + print '
'.$langs->trans('Company').''.$soc->getNomUrl(1).'
'.$langs->trans('Discounts').''; + if ($soc->remise_client) print $langs->trans("CompanyHasRelativeDiscount",$soc->remise_client); + else print $langs->trans("CompanyHasNoRelativeDiscount"); + print '. '; + $absolute_discount=$soc->getAvailableDiscounts('','fk_facture_source IS NULL'); + $absolute_creditnote=$soc->getAvailableDiscounts('','fk_facture_source IS NOT NULL'); + $absolute_discount=price2num($absolute_discount,'MT'); + $absolute_creditnote=price2num($absolute_creditnote,'MT'); + if ($absolute_discount) + { + if ($object->statut > 0) + { + print $langs->trans("CompanyHasAbsoluteDiscount",price($absolute_discount),$langs->transnoentities("Currency".$conf->currency)); + } + else + { + // Remise dispo de type non avoir + $filter='fk_facture_source IS NULL'; + print '
'; + $form->form_remise_dispo($_SERVER["PHP_SELF"].'?id='.$object->id,0,'remise_id',$soc->id,$absolute_discount,$filter); + } + } + if ($absolute_creditnote) + { + print $langs->trans("CompanyHasCreditNote",price($absolute_creditnote),$langs->transnoentities("Currency".$conf->currency)).'. '; + } + if (! $absolute_discount && ! $absolute_creditnote) print $langs->trans("CompanyHasNoAbsoluteDiscount").'.'; + print '
'; + print ''; + + if ($action != 'editdate' && $object->brouillon) print ''; + print '
'; + print $langs->trans('Date'); + print 'id.'">'.img_edit($langs->trans('SetDate'),1).'
'; + print '
'; + if ($action == 'editdate') + { + print '
'; + print ''; + print ''; + $form->select_date($object->date,'order_','','','',"setdate"); + print ''; + print '
'; + } + else + { + print $object->date ? dol_print_date($object->date,'daytext') : ' '; + } + print '
'; + print ''; + + if ($action != 'editdate_livraison') print ''; + print '
'; + print $langs->trans('DateDeliveryPlanned'); + print 'id.'">'.img_edit($langs->trans('SetDeliveryDate'),1).'
'; + print '
'; + if ($action == 'editdate_livraison') + { + print '
'; + print ''; + print ''; + $form->select_date($object->date_livraison?$object->date_livraison:-1,'liv_','','','',"setdate_livraison"); + print ''; + print '
'; + } + else + { + print $object->date_livraison ? dol_print_date($object->date_livraison,'daytext') : ' '; + } + print '
'; + print ''; + if ($action != 'editconditions' && $object->brouillon) print ''; + print '
'; + print $langs->trans('PaymentConditionsShort'); + print 'id.'">'.img_edit($langs->trans('SetConditions'),1).'
'; + print '
'; + if ($action == 'editconditions') + { + $form->form_conditions_reglement($_SERVER['PHP_SELF'].'?id='.$object->id,$object->cond_reglement_id,'cond_reglement_id',1); + } + else + { + $form->form_conditions_reglement($_SERVER['PHP_SELF'].'?id='.$object->id,$object->cond_reglement_id,'none',1); + } + print '
'; + print ''; + if ($action != 'editmode' && $object->brouillon) print ''; + print '
'; + print $langs->trans('PaymentMode'); + print 'id.'">'.img_edit($langs->trans('SetMode'),1).'
'; + print '
'; + if ($action == 'editmode') + { + $form->form_modes_reglement($_SERVER['PHP_SELF'].'?id='.$object->id,$object->mode_reglement_id,'mode_reglement_id'); + } + else + { + $form->form_modes_reglement($_SERVER['PHP_SELF'].'?id='.$object->id,$object->mode_reglement_id,'none'); + } + print '
'; + print ''; + if ($action != 'editavailability' && $object->brouillon) print ''; + print '
'; + print $langs->trans('AvailabilityPeriod'); + print 'id.'">'.img_edit($langs->trans('SetAvailability'),1).'
'; + print '
'; + if ($action == 'editavailability') + { + $form->form_availability($_SERVER['PHP_SELF'].'?id='.$object->id,$object->availability_id,'availability_id',1); + } + else + { + $form->form_availability($_SERVER['PHP_SELF'].'?id='.$object->id,$object->availability_id,'none',1); + } + print '
'; + print ''; + if ($action != 'editdemandreason' && ! empty($object->brouillon)) print ''; + print '
'; + print $langs->trans('Source'); + print 'id.'">'.img_edit($langs->trans('SetDemandReason'),1).'
'; + print '
'; + if ($action == 'editdemandreason') + { + $form->form_demand_reason($_SERVER['PHP_SELF'].'?id='.$object->id,$object->demand_reason_id,'demand_reason_id',1); + } + else + { + $form->form_demand_reason($_SERVER['PHP_SELF'].'?id='.$object->id,$object->demand_reason_id,'none'); + } + // Removed because using dictionnary is an admin feature, not a user feature. Ther is already the "star" to show info to admin users. + // This is to avoid too heavy screens and have an uniform look and feel for all screens. + //print ''; + //print ''.$langs->trans("DictionnarySource").''; + print '
'; + print ''; + if ($action != 'classify') print ''; + print '
'; + print $langs->trans('Project'); + print ''.img_edit($langs->trans('SetProject')).'
'; + print '
'; + //print "$object->id, $object->socid, $object->fk_project"; + if ($action == 'classify') + { + $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'projectid'); + } + else + { + $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none'); + } + print '
'.$label.''; + print $extrafields->showInputField($key,$value); + print '
'.$langs->trans('AmountHT').''.price($object->total_ht).''.$langs->trans('Currency'.$conf->currency).''; + $object->displayMarginInfos(); + print '
'.$langs->trans('AmountVAT').''.price($object->total_tva).''.$langs->trans('Currency'.$conf->currency).'
'.$langs->transcountry("AmountLT1",$mysoc->country_code).''.price($object->total_localtax1).''.$langs->trans("Currency".$conf->currency).'
'.$langs->transcountry("AmountLT2",$mysoc->country_code).''.price($object->total_localtax2).''.$langs->trans("Currency".$conf->currency).'
'.$langs->trans('AmountTTC').''.price($object->total_ttc).''.$langs->trans('Currency'.$conf->currency).'
'.$langs->trans('Status').''.$object->getLibStatut(4).'

'; + print "\n"; + + if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) + { + require_once(DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'); + $formcompany= new FormCompany($db); + + $blocname = 'contacts'; + $title = $langs->trans('ContactsAddresses'); + include(DOL_DOCUMENT_ROOT.'/core/tpl/bloc_showhide.tpl.php'); + } + + if (! empty($conf->global->MAIN_DISABLE_NOTES_TAB)) + { + $blocname = 'notes'; + $title = $langs->trans('Notes'); + include(DOL_DOCUMENT_ROOT.'/core/tpl/bloc_showhide.tpl.php'); + } + + /* + * Lines + */ + $result = $object->getLinesArray(); + + $numlines = count($object->lines); + + if ($conf->use_javascript_ajax && $object->statut == 0) + { + include(DOL_DOCUMENT_ROOT.'/core/tpl/ajaxrow.tpl.php'); + } + + print ''; + + // Show object lines + if (! empty($object->lines)) $object->printObjectLines($action,$mysoc,$soc,$lineid,1,$hookmanager); + + /* + * Form to add new line + */ + if ($object->statut == 0 && $user->rights->commande->creer) + { + if ($action != 'editline') + { + $var=true; + + $object->formAddFreeProduct(1,$mysoc,$soc,$hookmanager); + + // Add predefined products/services + if ($conf->product->enabled || $conf->service->enabled) + { + $var=!$var; + $object->formAddPredefinedProduct(1,$mysoc,$soc,$hookmanager); + } + + $parameters=array(); + $reshook=$hookmanager->executeHooks('formAddObject',$parameters,$object,$action); // Note that $action and $object may have been modified by hook + } + } + print '
'; + print ''; + + + /* + * Boutons actions + */ + if ($action != 'presend') + { + if ($user->societe_id == 0 && $action <> 'editline') + { + print '
'; + + // Valid + if ($object->statut == 0 && $object->total_ttc >= 0 && $numlines > 0 && $user->rights->commande->valider) + { + print ''.$langs->trans('Validate').''; + } + + // Edit + if ($object->statut == 1 && $user->rights->commande->creer) + { + print ''.$langs->trans('Modify').''; + } + + // Send + if ($object->statut > 0) + { + if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) || $user->rights->commande->order_advance->send)) + { + print ''.$langs->trans('SendByMail').''; + } + else print ''.$langs->trans('SendByMail').''; + } + + // Ship + $numshipping=0; + if ($conf->expedition->enabled) + { + $numshipping = $object->nb_expedition(); + + if ($object->statut > 0 && $object->statut < 3 && $object->getNbOfProductsLines() > 0) + { + if (($conf->expedition_bon->enabled && $user->rights->expedition->creer) + || ($conf->livraison_bon->enabled && $user->rights->expedition->livraison->creer)) + { + if ($user->rights->expedition->creer) + { + print ''.$langs->trans('ShipProduct').''; + } + else + { + print ''.$langs->trans('ShipProduct').''; + } + } + else + { + $langs->load("errors"); + print ''.$langs->trans('ShipProduct').''; + } + } + } + + // Reopen a closed order + if ($object->statut == 3) + { + print ''.$langs->trans('ReOpen').''; + } + + + // Create bill and Classify billed + if ($conf->facture->enabled && $object->statut > 0 && ! $object->billed) + { + if ($user->rights->facture->creer && empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) + { + print ''.$langs->trans("CreateBill").''; + } + if ($user->rights->commande->creer && $object->statut > 2 && empty($conf->global->WORKFLOW_DISABLE_CLASSIFY_BILLED_FROM_ORDER) && empty($conf->global->WORsKFLOW_BILL_ON_SHIPMENT)) + { + print ''.$langs->trans("ClassifyBilled").''; + } + } + + // Set to shipped + if (($object->statut == 1 || $object->statut == 2) && $user->rights->commande->cloturer) + { + print ''.$langs->trans('ClassifyShipped').''; + } + + // Clone + if ($user->rights->commande->creer) + { + print ''.$langs->trans("ToClone").''; + } + + // Cancel order + if ($object->statut == 1 && $user->rights->commande->annuler) + { + print ''.$langs->trans('Cancel').''; + } + + // Delete order + if ($user->rights->commande->supprimer) + { + if ($numshipping == 0) + { + print ''.$langs->trans('Delete').''; + } + else + { + print ''.$langs->trans("Delete").''; + } + } + + print '
'; + } + print '
'; + } + + + if ($action != 'presend') + { + print '
'; + print ''; // ancre + + /* + * Documents generes + * + */ + $comref = dol_sanitizeFileName($object->ref); + $file = $conf->commande->dir_output . '/' . $comref . '/' . $comref . '.pdf'; + $relativepath = $comref.'/'.$comref.'.pdf'; + $filedir = $conf->commande->dir_output . '/' . $comref; + $urlsource=$_SERVER["PHP_SELF"]."?id=".$object->id; + $genallowed=$user->rights->commande->creer; + $delallowed=$user->rights->commande->supprimer; + + $somethingshown=$formfile->show_documents('commande',$comref,$filedir,$urlsource,$genallowed,$delallowed,$object->modelpdf,1,0,0,28,0,'','','',$soc->default_lang,$hookmanager); + + /* + * Linked object block + */ + $somethingshown=$object->showLinkedObjectBlock(); + + print ''; + + // List of actions on element + include_once(DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'); + $formactions=new FormActions($db); + $somethingshown=$formactions->showactions($object,'order',$socid); + + print '
'; + } + + + /* + * Action presend + * + */ + if ($action == 'presend') + { + $ref = dol_sanitizeFileName($object->ref); + include_once(DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'); + $fileparams = dol_most_recent_file($conf->commande->dir_output . '/' . $ref); + $file=$fileparams['fullname']; + + // Build document if it not exists + if (! $file || ! is_readable($file)) + { + // Define output language + $outputlangs = $langs; + $newlang=''; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) $newlang=$_REQUEST['lang_id']; + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang; + if (! empty($newlang)) + { + $outputlangs = new Translate("",$conf); + $outputlangs->setDefaultLang($newlang); + } + + $result=commande_pdf_create($db, $object, GETPOST('model')?GETPOST('model'):$object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $hookmanager); + if ($result <= 0) + { + dol_print_error($db,$result); + exit; + } + $fileparams = dol_most_recent_file($conf->commande->dir_output . '/' . $ref); + $file=$fileparams['fullname']; + } + + print '
'; + print_titre($langs->trans('SendOrderByMail')); + + // Cree l'objet formulaire mail + include_once(DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'); + $formmail = new FormMail($db); + $formmail->fromtype = 'user'; + $formmail->fromid = $user->id; + $formmail->fromname = $user->getFullName($langs); + $formmail->frommail = $user->email; + $formmail->withfrom=1; + $formmail->withto=GETPOST('sendto')?GETPOST('sendto'):1; + $formmail->withtosocid=$soc->id; + $formmail->withtocc=1; + $formmail->withtoccsocid=0; + $formmail->withtoccc=$conf->global->MAIN_EMAIL_USECCC; + $formmail->withtocccsocid=0; + $formmail->withtopic=$langs->trans('SendOrderRef','__ORDERREF__'); + $formmail->withfile=2; + $formmail->withbody=1; + $formmail->withdeliveryreceipt=1; + $formmail->withcancel=1; + // Tableau des substitutions + $formmail->substit['__ORDERREF__']=$object->ref; + $formmail->substit['__SIGNATURE__']=$user->signature; + $formmail->substit['__PERSONALIZED__']=''; + // Tableau des parametres complementaires + $formmail->param['action']='send'; + $formmail->param['models']='order_send'; + $formmail->param['orderid']=$object->id; + $formmail->param['returnurl']=$_SERVER["PHP_SELF"].'?id='.$object->id; + + // Init list of files + if (GETPOST("mode")=='init') + { + $formmail->clear_attached_files(); + $formmail->add_attached_files($file,basename($file),dol_mimetype($file)); + } + + // Show form + $formmail->show_form(); + + print '
'; + } } } -} -/* - * View - */ - -llxHeader('',$langs->trans('Order'),'EN:Customers_Orders|FR:Commandes_Clients|ES:Pedidos de clientes'); - -$form = new Form($db); -$formfile = new FormFile($db); -$formorder = new FormOrder($db); - - -/********************************************************************* - * - * Mode creation - * - *********************************************************************/ -if ($action == 'create' && $user->rights->commande->creer) -{ - print_fiche_titre($langs->trans('CreateOrder')); - - dol_htmloutput_mesg($mesg,$mesgs,'error'); - - $soc = new Societe($db); - if ($socid) $res=$soc->fetch($socid); - - if (GETPOST('origin') && GETPOST('originid')) - { - // Parse element/subelement (ex: project_task) - $element = $subelement = GETPOST('origin'); - if (preg_match('/^([^_]+)_([^_]+)/i',GETPOST('origin'),$regs)) - { - $element = $regs[1]; - $subelement = $regs[2]; - } - - if ($element == 'project') - { - $projectid=GETPOST('originid'); - } - else - { - // For compatibility - if ($element == 'order' || $element == 'commande') { $element = $subelement = 'commande'; } - if ($element == 'propal') { $element = 'comm/propal'; $subelement = 'propal'; } - if ($element == 'contract') { $element = $subelement = 'contrat'; } - - dol_include_once('/'.$element.'/class/'.$subelement.'.class.php'); - - $classname = ucfirst($subelement); - $objectsrc = new $classname($db); - $objectsrc->fetch(GETPOST('originid')); - if (empty($objectsrc->lines) && method_exists($objectsrc,'fetch_lines')) $objectsrc->fetch_lines(); - $objectsrc->fetch_thirdparty(); - - $projectid = (!empty($objectsrc->fk_project)?$object->fk_project:''); - $ref_client = (!empty($objectsrc->ref_client)?$object->ref_client:''); - - $soc = $objectsrc->client; - $cond_reglement_id = (!empty($objectsrc->cond_reglement_id)?$objectsrc->cond_reglement_id:(!empty($soc->cond_reglement_id)?$soc->cond_reglement_id:1)); - $mode_reglement_id = (!empty($objectsrc->mode_reglement_id)?$objectsrc->mode_reglement_id:(!empty($soc->mode_reglement_id)?$soc->mode_reglement_id:0)); - $availability_id = (!empty($objectsrc->availability_id)?$objectsrc->availability_id:(!empty($soc->availability_id)?$soc->availability_id:0)); - $demand_reason_id = (!empty($objectsrc->demand_reason_id)?$objectsrc->demand_reason_id:(!empty($soc->demand_reason_id)?$soc->demand_reason_id:0)); - $remise_percent = (!empty($objectsrc->remise_percent)?$objectsrc->remise_percent:(!empty($soc->remise_percent)?$soc->remise_percent:0)); - $remise_absolue = (!empty($objectsrc->remise_absolue)?$objectsrc->remise_absolue:(!empty($soc->remise_absolue)?$soc->remise_absolue:0)); - $dateinvoice = empty($conf->global->MAIN_AUTOFILL_DATE)?-1:0; - - $note_private = (! empty($objectsrc->note) ? $objectsrc->note : (! empty($objectsrc->note_private) ? $objectsrc->note_private : '')); - $note_public = (! empty($objectsrc->note_public) ? $objectsrc->note_public : ''); - - // Object source contacts list - $srccontactslist = $objectsrc->liste_contact(-1,'external',1); - } - } - else - { - $cond_reglement_id = $soc->cond_reglement_id; - $mode_reglement_id = $soc->mode_reglement_id; - $availability_id = $soc->availability_id; - $demand_reason_id = $soc->demand_reason_id; - $remise_percent = $soc->remise_percent; - $remise_absolue = 0; - $dateinvoice = empty($conf->global->MAIN_AUTOFILL_DATE)?-1:0; - } - $absolute_discount=$soc->getAvailableDiscounts(); - - - - $nbrow=10; - - print '
'; - print ''; - print ''; - print '' ."\n"; - print ''; - print ''; - print ''; - print ''; - - print ''; - - // Reference - print ''; - - // Reference client - print ''; - print ''; - - // Client - print ''; - - /* - * Contact de la commande - */ - print "'; - - // Ligne info remises tiers - print ''; - - // Date - print ''; - - // Date de livraison - print ""; - - // Conditions de reglement - print ''; - - // Mode de reglement - print ''; - - // Delivery delay - print ''; - - // What trigger creation - print ''; - - // Project - if ($conf->projet->enabled) - { - $projectid = 0; - if (isset($_GET["origin"]) && $_GET["origin"] == 'project') $projectid = ($_GET["originid"]?$_GET["originid"]:0); - - print ''; - } - - // Other attributes - $parameters=array('objectsrc' => $objectsrc, 'colspan' => ' colspan="3"'); - $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook - if (empty($reshook) && ! empty($extrafields->attribute_label)) - { - foreach($extrafields->attribute_label as $key=>$label) - { - $value=(isset($_POST["options_".$key])?$_POST["options_".$key]:$object->array_options["options_".$key]); - print "'."\n"; - } - } - - // Template to use by default - print ''; - print '"; - - - // Note publique - print ''; - print ''; - print ''; - - // Note privee - if (! $user->societe_id) - { - print ''; - print ''; - print ''; - } - - if (is_object($objectsrc)) - { - // TODO for compatibility - if ($_GET['origin'] == 'contrat') - { - // Calcul contrat->price (HT), contrat->total (TTC), contrat->tva - $objectsrc->remise_absolue=$remise_absolue; - $objectsrc->remise_percent=$remise_percent; - $objectsrc->update_price(1); - } - - print "\n"; - print "\n"; - print ''."\n"; - print ''."\n"; - print ''."\n"; - print ''; - print ''; - - $newclassname=$classname; - if ($newclassname=='Propal') $newclassname='CommercialProposal'; - print ''; - print ''; - print '"; - if ($mysoc->country_code=='ES') - { - if ($mysoc->localtax1_assuj=="1") //Localtax1 RE - { - print '"; - } - - if ($mysoc->localtax2_assuj=="1") //Localtax2 IRPF - { - print '"; - } - } - print '"; - } - else - { - if ($conf->global->PRODUCT_SHOW_WHEN_CREATE) - { - /* - * Services/produits predefinis - */ - $NBLINES=8; - - print ''; - } - } - - print '
'.$langs->trans('Ref').''.$langs->trans("Draft").'
'.$langs->trans('RefCustomer').''; - print '
'.$langs->trans('Customer').''.$soc->getNomUrl(1).'
".$langs->trans("DefaultContact").''; - $form->select_contacts($soc->id,$setcontact,'contactidp',1,$srccontactslist); - print '
'.$langs->trans('Discounts').''; - if ($soc->remise_client) print $langs->trans("CompanyHasRelativeDiscount",$soc->remise_client); - else print $langs->trans("CompanyHasNoRelativeDiscount"); - print '. '; - $absolute_discount=$soc->getAvailableDiscounts(); - if ($absolute_discount) print $langs->trans("CompanyHasAbsoluteDiscount",price($absolute_discount),$langs->trans("Currency".$conf->currency)); - else print $langs->trans("CompanyHasNoAbsoluteDiscount"); - print '.'; - print '
'.$langs->trans('Date').''; - $form->select_date('','re','','','',"crea_commande",1,1); - print '
".$langs->trans("DeliveryDate").''; - if ($conf->global->DATE_LIVRAISON_WEEK_DELAY) - { - $datedelivery = time() + ((7*$conf->global->DATE_LIVRAISON_WEEK_DELAY) * 24 * 60 * 60); - } - else - { - $datedelivery=empty($conf->global->MAIN_AUTOFILL_DATE)?-1:0; - } - $form->select_date($datedelivery,'liv_','','','',"crea_commande",1,1); - print "
'.$langs->trans('PaymentConditionsShort').''; - $form->select_conditions_paiements($soc->cond_reglement,'cond_reglement_id',-1,1); - print '
'.$langs->trans('PaymentMode').''; - $form->select_types_paiements($soc->mode_reglement,'mode_reglement_id'); - print '
'.$langs->trans('AvailabilityPeriod').''; - $form->select_availability($propal->availability,'availability_id','',1); - print '
'.$langs->trans('Source').''; - $form->select_demand_reason((GETPOST("origin")=='propal'?'SRC_COMM':''),'demand_reason_id','',1); - print '
'.$langs->trans('Project').''; - $numprojet=select_projects($soc->id,$projectid); - if ($numprojet==0) - { - print '   '.$langs->trans("AddProject").''; - } - print '
".$label.''; - print $extrafields->showInputField($key,$value); - print '
'.$langs->trans('Model').''; - include_once(DOL_DOCUMENT_ROOT.'/core/modules/commande/modules_commande.php'); - $liste=ModelePDFCommandes::liste_modeles($db); - print $form->selectarray('model',$liste,$conf->global->COMMANDE_ADDON_PDF); - print "
'.$langs->trans('NotePublic').''; - require_once(DOL_DOCUMENT_ROOT."/core/class/doleditor.class.php"); - $doleditor=new DolEditor('note_public', $note_public, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, 70); - print $doleditor->Create(1); - //print ''; - print '
'.$langs->trans('NotePrivate').''; - require_once(DOL_DOCUMENT_ROOT."/core/class/doleditor.class.php"); - $doleditor=new DolEditor('note', $note_private, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, 70); - print $doleditor->Create(1); - //print ''; - print '
'.$langs->trans($newclassname).''.$objectsrc->getNomUrl(1).'
'.$langs->trans('TotalHT').''.price($objectsrc->total_ht).'
'.$langs->trans('TotalVAT').''.price($objectsrc->total_tva)."
'.$langs->transcountry("AmountLT1",$mysoc->country_code).''.price($objectsrc->total_localtax1)."
'.$langs->transcountry("AmountLT2",$mysoc->country_code).''.price($objectsrc->total_localtax2)."
'.$langs->trans('TotalTTC').''.price($objectsrc->total_ttc)."
'; - - print ''; - print ''; - print ''; - print ''; - print ''; - for ($i = 1 ; $i <= $NBLINES ; $i++) - { - print ''; - print ''; - print ''; - } - - print '
'.$langs->trans('ProductsAndServices').''.$langs->trans('Qty').''.$langs->trans('ReductionShort').'
'; - // multiprix - if($conf->global->PRODUIT_MULTIPRICES) - print $form->select_produits('','idprod'.$i,'',$conf->product->limit_size,$soc->price_level); - else - print $form->select_produits('','idprod'.$i,'',$conf->product->limit_size); - print '%
'; - print '
'; - - // Button "Create Draft" - print '
'; - - print '
'; - - - // Show origin lines - if (is_object($objectsrc)) - { - $title=$langs->trans('ProductsAndServices'); - print_titre($title); - - print ''; - - $objectsrc->printOriginLinesList($hookmanager); - - print '
'; - } - -} -else -{ - /* *************************************************************************** */ - /* */ - /* Mode vue et edition */ - /* */ - /* *************************************************************************** */ - $now=dol_now(); - - if ($object->id > 0) - { - dol_htmloutput_mesg($mesg,$mesgs); - dol_htmloutput_errors('',$errors); - - $product_static=new Product($db); - - $soc = new Societe($db); - $soc->fetch($object->socid); - - $author = new User($db); - $author->fetch($object->user_author_id); - - $head = commande_prepare_head($object); - dol_fiche_head($head, 'order', $langs->trans("CustomerOrder"), 0, 'order'); - - $formconfirm=''; - - /* - * Confirmation de la suppression de la commande - */ - if ($action == 'delete') - { - $formconfirm=$form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DeleteOrder'), $langs->trans('ConfirmDeleteOrder'), 'confirm_delete', '', 0, 1); - } - - /* - * Confirmation de la validation - */ - if ($action == 'validate') - { - // on verifie si l'objet est en numerotation provisoire - $ref = substr($object->ref, 1, 4); - if ($ref == 'PROV') - { - $numref = $object->getNextNumRef($soc); - } - else - { - $numref = $object->ref; - } - - $text=$langs->trans('ConfirmValidateOrder',$numref); - if ($conf->notification->enabled) - { - require_once(DOL_DOCUMENT_ROOT ."/core/class/notify.class.php"); - $notify=new Notify($db); - $text.='
'; - $text.=$notify->confirmMessage('NOTIFY_VAL_ORDER',$object->socid); - } - $formquestion=array(); - if (! empty($conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER) && $object->hasProductsOrServices(1)) - { - $langs->load("stocks"); - require_once(DOL_DOCUMENT_ROOT."/product/class/html.formproduct.class.php"); - $formproduct=new FormProduct($db); - $formquestion=array( - //'text' => $langs->trans("ConfirmClone"), - //array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1), - //array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans("PuttingPricesUpToDate"), 'value' => 1), - array('type' => 'other', 'name' => 'idwarehouse', 'label' => $langs->trans("SelectWarehouseForStockDecrease"), 'value' => $formproduct->selectWarehouses(GETPOST('idwarehouse'),'idwarehouse','',1))); - } - - $formconfirm=$form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ValidateOrder'), $text, 'confirm_validate', $formquestion, 0, 1, 220); - } - - // Confirm back to draft status - if ($action == 'modif') - { - $text=$langs->trans('ConfirmUnvalidateOrder',$object->ref); - $formquestion=array(); - if (! empty($conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER) && $object->hasProductsOrServices(1)) - { - $langs->load("stocks"); - require_once(DOL_DOCUMENT_ROOT."/product/class/html.formproduct.class.php"); - $formproduct=new FormProduct($db); - $formquestion=array( - //'text' => $langs->trans("ConfirmClone"), - //array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1), - //array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans("PuttingPricesUpToDate"), 'value' => 1), - array('type' => 'other', 'name' => 'idwarehouse', 'label' => $langs->trans("SelectWarehouseForStockIncrease"), 'value' => $formproduct->selectWarehouses(GETPOST('idwarehouse'),'idwarehouse','',1))); - } - - $formconfirm=$form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('UnvalidateOrder'), $text, 'confirm_modif', $formquestion, "yes", 1, 220); - } - - - /* - * Confirmation de la cloture - */ - if ($action == 'shipped') - { - $formconfirm=$form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('CloseOrder'), $langs->trans('ConfirmCloseOrder'), 'confirm_shipped', '', 0, 1); - } - - /* - * Confirmation de l'annulation - */ - if ($action == 'cancel') - { - $text=$langs->trans('ConfirmCancelOrder',$object->ref); - $formquestion=array(); - if (! empty($conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER) && $object->hasProductsOrServices(1)) - { - $langs->load("stocks"); - require_once(DOL_DOCUMENT_ROOT."/product/class/html.formproduct.class.php"); - $formproduct=new FormProduct($db); - $formquestion=array( - //'text' => $langs->trans("ConfirmClone"), - //array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1), - //array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans("PuttingPricesUpToDate"), 'value' => 1), - array('type' => 'other', 'name' => 'idwarehouse', 'label' => $langs->trans("SelectWarehouseForStockIncrease"), 'value' => $formproduct->selectWarehouses(GETPOST('idwarehouse'),'idwarehouse','',1))); - } - - $formconfirm=$form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('Cancel'), $text, 'confirm_cancel', $formquestion, 0, 1); - } - - /* - * Confirmation de la suppression d'une ligne produit - */ - if ($action == 'ask_deleteline') - { - $formconfirm=$form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&lineid='.$lineid, $langs->trans('DeleteProductLine'), $langs->trans('ConfirmDeleteProductLine'), 'confirm_deleteline', '', 0, 1); - } - - // Clone confirmation - if ($action == 'clone') - { - // Create an array for form - $formquestion=array( - //'text' => $langs->trans("ConfirmClone"), - //array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1), - //array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans("PuttingPricesUpToDate"), 'value' => 1), - array('type' => 'other', 'name' => 'socid', 'label' => $langs->trans("SelectThirdParty"), 'value' => $form->select_company(GETPOST('socid','int'),'socid','(s.client=1 OR s.client=3)')) - ); - // Paiement incomplet. On demande si motif = escompte ou autre - $formconfirm=$form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id,$langs->trans('CloneOrder'),$langs->trans('ConfirmCloneOrder',$object->ref),'confirm_clone',$formquestion,'yes',1); - } - - if (! $formconfirm) - { - $parameters=array('lineid'=>$lineid); - $formconfirm=$hookmanager->executeHooks('formConfirm',$parameters,$object,$action); // Note that $action and $object may have been modified by hook - } - - // Print form confirm - print $formconfirm; - - /* - * Commande - */ - $nbrow=9; - if ($conf->projet->enabled) $nbrow++; - - //Local taxes - if ($mysoc->country_code=='ES') - { - if($mysoc->localtax1_assuj=="1") $nbrow++; - if($mysoc->localtax2_assuj=="1") $nbrow++; - } - - print ''; - - // Ref - print ''; - print ''; - print ''; - - // Ref commande client - print ''; - print ''; - - - // Societe - print ''; - print ''; - print ''; - - // Ligne info remises tiers - print ''; - - // Date - print ''; - print ''; - - // Delivery date planed - print ''; - - // Terms of payment - print ''; - - print ''; - - // Mode of payment - print ''; - - // Availability - print ''; - - // Source - print ''; - - // Project - if ($conf->projet->enabled) - { - $langs->load('projects'); - print ''; - } - - // Other attributes - $parameters=array('colspan' => ' colspan="2"'); - $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook - if (empty($reshook) && ! empty($extrafields->attribute_label)) - { - foreach($extrafields->attribute_label as $key=>$label) - { - $value=(isset($_POST["options_".$key])?$_POST["options_".$key]:$object->array_options["options_".$key]); - print ''."\n"; - } - } - - // Total HT - print ''; - print ''; - print ''; - - // Margin Infos - if (! empty($conf->margin->enabled)) { - print ''; - } - print ''; - - // Total TVA - print ''; - print ''; - - // Amount Local Taxes - if ($mysoc->country_code=='ES') - { - if ($mysoc->localtax1_assuj=="1") //Localtax1 RE - { - print ''; - print ''; - print ''; - } - if ($mysoc->localtax2_assuj=="1") //Localtax2 IRPF - { - print ''; - print ''; - print ''; - } - } - - // Total TTC - print ''; - print ''; - - // Statut - print ''; - print ''; - print ''; - - print '
'.$langs->trans('Ref').''; - print $form->showrefnav($object,'ref','',1,'ref','ref'); - print '
'; - print ''; - if ($action != 'refcustomer' && $object->brouillon) print ''; - print '
'; - print $langs->trans('RefCustomer').''; - print ''.img_edit($langs->trans('Modify')).'
'; - print '
'; - if ($user->rights->commande->creer && $action == 'refcustomer') - { - print '
'; - print ''; - print ''; - print ''; - print ' '; - print '
'; - } - else - { - print $object->ref_client; - } - print '
'.$langs->trans('Company').''.$soc->getNomUrl(1).'
'.$langs->trans('Discounts').''; - if ($soc->remise_client) print $langs->trans("CompanyHasRelativeDiscount",$soc->remise_client); - else print $langs->trans("CompanyHasNoRelativeDiscount"); - print '. '; - $absolute_discount=$soc->getAvailableDiscounts('','fk_facture_source IS NULL'); - $absolute_creditnote=$soc->getAvailableDiscounts('','fk_facture_source IS NOT NULL'); - $absolute_discount=price2num($absolute_discount,'MT'); - $absolute_creditnote=price2num($absolute_creditnote,'MT'); - if ($absolute_discount) - { - if ($object->statut > 0) - { - print $langs->trans("CompanyHasAbsoluteDiscount",price($absolute_discount),$langs->transnoentities("Currency".$conf->currency)); - } - else - { - // Remise dispo de type non avoir - $filter='fk_facture_source IS NULL'; - print '
'; - $form->form_remise_dispo($_SERVER["PHP_SELF"].'?id='.$object->id,0,'remise_id',$soc->id,$absolute_discount,$filter); - } - } - if ($absolute_creditnote) - { - print $langs->trans("CompanyHasCreditNote",price($absolute_creditnote),$langs->transnoentities("Currency".$conf->currency)).'. '; - } - if (! $absolute_discount && ! $absolute_creditnote) print $langs->trans("CompanyHasNoAbsoluteDiscount").'.'; - print '
'; - print ''; - - if ($action != 'editdate' && $object->brouillon) print ''; - print '
'; - print $langs->trans('Date'); - print 'id.'">'.img_edit($langs->trans('SetDate'),1).'
'; - print '
'; - if ($action == 'editdate') - { - print '
'; - print ''; - print ''; - $form->select_date($object->date,'order_','','','',"setdate"); - print ''; - print '
'; - } - else - { - print $object->date ? dol_print_date($object->date,'daytext') : ' '; - } - print '
'; - print ''; - - if ($action != 'editdate_livraison') print ''; - print '
'; - print $langs->trans('DateDeliveryPlanned'); - print 'id.'">'.img_edit($langs->trans('SetDeliveryDate'),1).'
'; - print '
'; - if ($action == 'editdate_livraison') - { - print '
'; - print ''; - print ''; - $form->select_date($object->date_livraison?$object->date_livraison:-1,'liv_','','','',"setdate_livraison"); - print ''; - print '
'; - } - else - { - print $object->date_livraison ? dol_print_date($object->date_livraison,'daytext') : ' '; - } - print '
'; - print ''; - if ($action != 'editconditions' && $object->brouillon) print ''; - print '
'; - print $langs->trans('PaymentConditionsShort'); - print 'id.'">'.img_edit($langs->trans('SetConditions'),1).'
'; - print '
'; - if ($action == 'editconditions') - { - $form->form_conditions_reglement($_SERVER['PHP_SELF'].'?id='.$object->id,$object->cond_reglement_id,'cond_reglement_id',1); - } - else - { - $form->form_conditions_reglement($_SERVER['PHP_SELF'].'?id='.$object->id,$object->cond_reglement_id,'none',1); - } - print '
'; - print ''; - if ($action != 'editmode' && $object->brouillon) print ''; - print '
'; - print $langs->trans('PaymentMode'); - print 'id.'">'.img_edit($langs->trans('SetMode'),1).'
'; - print '
'; - if ($action == 'editmode') - { - $form->form_modes_reglement($_SERVER['PHP_SELF'].'?id='.$object->id,$object->mode_reglement_id,'mode_reglement_id'); - } - else - { - $form->form_modes_reglement($_SERVER['PHP_SELF'].'?id='.$object->id,$object->mode_reglement_id,'none'); - } - print '
'; - print ''; - if ($action != 'editavailability' && $object->brouillon) print ''; - print '
'; - print $langs->trans('AvailabilityPeriod'); - print 'id.'">'.img_edit($langs->trans('SetAvailability'),1).'
'; - print '
'; - if ($action == 'editavailability') - { - $form->form_availability($_SERVER['PHP_SELF'].'?id='.$object->id,$object->availability_id,'availability_id',1); - } - else - { - $form->form_availability($_SERVER['PHP_SELF'].'?id='.$object->id,$object->availability_id,'none',1); - } - print '
'; - print ''; - if ($_GET['action'] != 'editdemandreason' && $object->brouillon) print ''; - print '
'; - print $langs->trans('Source'); - print 'id.'">'.img_edit($langs->trans('SetDemandReason'),1).'
'; - print '
'; - if ($_GET['action'] == 'editdemandreason') - { - $form->form_demand_reason($_SERVER['PHP_SELF'].'?id='.$object->id,$object->demand_reason_id,'demand_reason_id',1); - } - else - { - $form->form_demand_reason($_SERVER['PHP_SELF'].'?id='.$object->id,$object->demand_reason_id,'none'); - } - // Removed because using dictionnary is an admin feature, not a user feature. Ther is already the "star" to show info to admin users. - // This is to avoid too heavy screens and have an uniform look and feel for all screens. - //print ''; - //print ''.$langs->trans("DictionnarySource").''; - print '
'; - print ''; - if ($action != 'classify') print ''; - print '
'; - print $langs->trans('Project'); - print ''.img_edit($langs->trans('SetProject')).'
'; - print '
'; - //print "$object->id, $object->socid, $object->fk_project"; - if ($action == 'classify') - { - $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'projectid'); - } - else - { - $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none'); - } - print '
'.$label.''; - print $extrafields->showInputField($key,$value); - print '
'.$langs->trans('AmountHT').''.price($object->total_ht).''.$langs->trans('Currency'.$conf->currency).''; - $object->displayMarginInfos(); - print '
'.$langs->trans('AmountVAT').''.price($object->total_tva).''.$langs->trans('Currency'.$conf->currency).'
'.$langs->transcountry("AmountLT1",$mysoc->country_code).''.price($object->total_localtax1).''.$langs->trans("Currency".$conf->currency).'
'.$langs->transcountry("AmountLT2",$mysoc->country_code).''.price($object->total_localtax2).''.$langs->trans("Currency".$conf->currency).'
'.$langs->trans('AmountTTC').''.price($object->total_ttc).''.$langs->trans('Currency'.$conf->currency).'
'.$langs->trans('Status').''.$object->getLibStatut(4).'

'; - print "\n"; - - if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) - { - require_once(DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'); - $formcompany= new FormCompany($db); - - $blocname = 'contacts'; - $title = $langs->trans('ContactsAddresses'); - include(DOL_DOCUMENT_ROOT.'/core/tpl/bloc_showhide.tpl.php'); - } - - if (! empty($conf->global->MAIN_DISABLE_NOTES_TAB)) - { - $blocname = 'notes'; - $title = $langs->trans('Notes'); - include(DOL_DOCUMENT_ROOT.'/core/tpl/bloc_showhide.tpl.php'); - } - - /* - * Lines - */ - $result = $object->getLinesArray(); - - $numlines = count($object->lines); - - if ($conf->use_javascript_ajax && $object->statut == 0) - { - include(DOL_DOCUMENT_ROOT.'/core/tpl/ajaxrow.tpl.php'); - } - - print ''; - - // Show object lines - if (! empty($object->lines)) $object->printObjectLines($action,$mysoc,$soc,$lineid,1,$hookmanager); - - /* - * Form to add new line - */ - if ($object->statut == 0 && $user->rights->commande->creer) - { - if ($action != 'editline') - { - $var=true; - - $object->formAddFreeProduct(1,$mysoc,$soc,$hookmanager); - - // Add predefined products/services - if ($conf->product->enabled || $conf->service->enabled) - { - $var=!$var; - $object->formAddPredefinedProduct(1,$mysoc,$soc,$hookmanager); - } - - $parameters=array(); - $reshook=$hookmanager->executeHooks('formAddObject',$parameters,$object,$action); // Note that $action and $object may have been modified by hook - } - } - print '
'; - print ''; - - - /* - * Boutons actions - */ - if ($action != 'presend') - { - if ($user->societe_id == 0 && $action <> 'editline') - { - print '
'; - - // Valid - if ($object->statut == 0 && $object->total_ttc >= 0 && $numlines > 0 && $user->rights->commande->valider) - { - print ''.$langs->trans('Validate').''; - } - - // Edit - if ($object->statut == 1 && $user->rights->commande->creer) - { - print ''.$langs->trans('Modify').''; - } - - // Send - if ($object->statut > 0) - { - if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) || $user->rights->commande->order_advance->send)) - { - print ''.$langs->trans('SendByMail').''; - } - else print ''.$langs->trans('SendByMail').''; - } - - // Ship - $numshipping=0; - if ($conf->expedition->enabled) - { - $numshipping = $object->nb_expedition(); - - if ($object->statut > 0 && $object->statut < 3 && $object->getNbOfProductsLines() > 0) - { - if (($conf->expedition_bon->enabled && $user->rights->expedition->creer) - || ($conf->livraison_bon->enabled && $user->rights->expedition->livraison->creer)) - { - if ($user->rights->expedition->creer) - { - print ''.$langs->trans('ShipProduct').''; - } - else - { - print ''.$langs->trans('ShipProduct').''; - } - } - else - { - $langs->load("errors"); - print ''.$langs->trans('ShipProduct').''; - } - } - } - - // Reopen a closed order - if ($object->statut == 3) - { - print ''.$langs->trans('ReOpen').''; - } - - - // Create bill and Classify billed - if ($conf->facture->enabled && $object->statut > 0 && ! $object->billed) - { - if ($user->rights->facture->creer && empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) - { - print ''.$langs->trans("CreateBill").''; - } - if ($user->rights->commande->creer && $object->statut > 2 && empty($conf->global->WORKFLOW_DISABLE_CLASSIFY_BILLED_FROM_ORDER) && empty($conf->global->WORsKFLOW_BILL_ON_SHIPMENT)) - { - print ''.$langs->trans("ClassifyBilled").''; - } - } - - // Set to shipped - if (($object->statut == 1 || $object->statut == 2) && $user->rights->commande->cloturer) - { - print ''.$langs->trans('ClassifyShipped').''; - } - - // Clone - if ($user->rights->commande->creer) - { - print ''.$langs->trans("ToClone").''; - } - - // Cancel order - if ($object->statut == 1 && $user->rights->commande->annuler) - { - print ''.$langs->trans('Cancel').''; - } - - // Delete order - if ($user->rights->commande->supprimer) - { - if ($numshipping == 0) - { - print ''.$langs->trans('Delete').''; - } - else - { - print ''.$langs->trans("Delete").''; - } - } - - print '
'; - } - print '
'; - } - - - if ($action != 'presend') - { - print '
'; - print ''; // ancre - - /* - * Documents generes - * - */ - $comref = dol_sanitizeFileName($object->ref); - $file = $conf->commande->dir_output . '/' . $comref . '/' . $comref . '.pdf'; - $relativepath = $comref.'/'.$comref.'.pdf'; - $filedir = $conf->commande->dir_output . '/' . $comref; - $urlsource=$_SERVER["PHP_SELF"]."?id=".$object->id; - $genallowed=$user->rights->commande->creer; - $delallowed=$user->rights->commande->supprimer; - - $somethingshown=$formfile->show_documents('commande',$comref,$filedir,$urlsource,$genallowed,$delallowed,$object->modelpdf,1,0,0,28,0,'','','',$soc->default_lang,$hookmanager); - - /* - * Linked object block - */ - $somethingshown=$object->showLinkedObjectBlock(); - - print ''; - - // List of actions on element - include_once(DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'); - $formactions=new FormActions($db); - $somethingshown=$formactions->showactions($object,'order',$socid); - - print '
'; - } - - - /* - * Action presend - * - */ - if ($action == 'presend') - { - $ref = dol_sanitizeFileName($object->ref); - include_once(DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'); - $fileparams = dol_most_recent_file($conf->commande->dir_output . '/' . $ref); - $file=$fileparams['fullname']; - - // Build document if it not exists - if (! $file || ! is_readable($file)) - { - // Define output language - $outputlangs = $langs; - $newlang=''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) $newlang=$_REQUEST['lang_id']; - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang; - if (! empty($newlang)) - { - $outputlangs = new Translate("",$conf); - $outputlangs->setDefaultLang($newlang); - } - - $result=commande_pdf_create($db, $object, GETPOST('model')?GETPOST('model'):$object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $hookmanager); - if ($result <= 0) - { - dol_print_error($db,$result); - exit; - } - $fileparams = dol_most_recent_file($conf->commande->dir_output . '/' . $ref); - $file=$fileparams['fullname']; - } - - print '
'; - print_titre($langs->trans('SendOrderByMail')); - - // Cree l'objet formulaire mail - include_once(DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'); - $formmail = new FormMail($db); - $formmail->fromtype = 'user'; - $formmail->fromid = $user->id; - $formmail->fromname = $user->getFullName($langs); - $formmail->frommail = $user->email; - $formmail->withfrom=1; - $formmail->withto=empty($_POST["sendto"])?1:$_POST["sendto"]; - $formmail->withtosocid=$soc->id; - $formmail->withtocc=1; - $formmail->withtoccsocid=0; - $formmail->withtoccc=$conf->global->MAIN_EMAIL_USECCC; - $formmail->withtocccsocid=0; - $formmail->withtopic=$langs->trans('SendOrderRef','__ORDERREF__'); - $formmail->withfile=2; - $formmail->withbody=1; - $formmail->withdeliveryreceipt=1; - $formmail->withcancel=1; - // Tableau des substitutions - $formmail->substit['__ORDERREF__']=$object->ref; - $formmail->substit['__SIGNATURE__']=$user->signature; - $formmail->substit['__PERSONALIZED__']=''; - // Tableau des parametres complementaires - $formmail->param['action']='send'; - $formmail->param['models']='order_send'; - $formmail->param['orderid']=$object->id; - $formmail->param['returnurl']=$_SERVER["PHP_SELF"].'?id='.$object->id; - - // Init list of files - if (GETPOST("mode")=='init') - { - $formmail->clear_attached_files(); - $formmail->add_attached_files($file,basename($file),dol_mimetype($file)); - } - - // Show form - $formmail->show_form(); - - print '
'; - } - } -} - - -llxFooter(); -$db->close(); -?> + llxFooter(); + $db->close(); + ?> diff --git a/htdocs/commande/orderstoinvoice.php b/htdocs/commande/orderstoinvoice.php index a521f766574..cae2461a780 100755 --- a/htdocs/commande/orderstoinvoice.php +++ b/htdocs/commande/orderstoinvoice.php @@ -62,7 +62,7 @@ if ($action == 'create') { if (! is_array($selected)) { - $mesg='
'.$langs->trans('Error_OrderNotChecked').'
'; + $mesgs[]='
'.$langs->trans('Error_OrderNotChecked').'
'; } else { @@ -80,9 +80,9 @@ $htmlother = new FormOther($db); /* * Actions -*/ + */ -if (($action == 'create' || $action == 'add') && ! $mesg ) +if (($action == 'create' || $action == 'add') && empty($mesgs)) { require_once(DOL_DOCUMENT_ROOT."/core/class/html.formfile.class.php"); require_once(DOL_DOCUMENT_ROOT."/core/class/html.formother.class.php"); @@ -92,8 +92,10 @@ if (($action == 'create' || $action == 'add') && ! $mesg ) require_once(DOL_DOCUMENT_ROOT."/core/lib/functions2.lib.php"); require_once(DOL_DOCUMENT_ROOT.'/core/lib/invoice.lib.php'); require_once(DOL_DOCUMENT_ROOT."/core/lib/date.lib.php"); - if ($conf->projet->enabled) require_once(DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'); - if ($conf->projet->enabled) require_once(DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php'); + if (! empty($conf->projet->enabled)) { + require_once(DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'); + require_once(DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php'); + } $langs->load('bills'); $langs->load('products'); $langs->load('main'); @@ -117,7 +119,6 @@ if (($action == 'create' || $action == 'add') && ! $mesg ) $_POST['originid']=$orders_id[0]; } - if (GETPOST('mesg','int',1) && isset($_SESSION['message'])) $mesg=$_SESSION['message']; $sall=isset($_GET['sall'])?trim($_GET['sall']):trim($_POST['sall']); $projectid=isset($_GET['projectid'])?$_GET['projectid']:0; $id =(GETPOST('id')?GETPOST("id"):GETPOST("facid")); // For backward compatibility @@ -242,7 +243,7 @@ if (($action == 'create' || $action == 'add') && ! $mesg ) } else { - $mesg=$discount->error; + $mesgs[]=$discount->error; $error++; break; } @@ -310,7 +311,7 @@ if (($action == 'create' || $action == 'add') && ! $mesg ) } else { - $mesg=$srcobject->error; + $mesgs[]=$srcobject->error; $error++; } $ii++; @@ -318,7 +319,7 @@ if (($action == 'create' || $action == 'add') && ! $mesg ) } else { - $mesg=$object->error; + $mesgs[]=$object->error; $error++; } } @@ -338,7 +339,7 @@ if (($action == 'create' || $action == 'add') && ! $mesg ) $action='create'; $_GET["origin"]=$_POST["origin"]; $_GET["originid"]=$_POST["originid"]; - if (! $mesg) $mesg='
'.$object->error.'
'; + $mesgs[]='
'.$object->error.'
'; } } @@ -354,9 +355,10 @@ if (($action == 'create' || $action == 'add') && ! $mesg ) if ($action == 'create') { $facturestatic=new Facture($db); + llxHeader(); print_fiche_titre($langs->trans('NewBill')); - dol_htmloutput_mesg($mesg); + $soc = new Societe($db); if ($socid) $res=$soc->fetch($socid); if ($res) @@ -474,7 +476,6 @@ if (($action == 'create' || $action == 'add') && ! $mesg ) print "\n"; } - //Mode liste else { @@ -669,8 +670,8 @@ else } -$db->close(); -dol_htmloutput_mesg($mesg); -llxFooter(); +dol_htmloutput_mesg($mesg,$mesgs); +llxFooter(); +$db->close(); ?> \ No newline at end of file diff --git a/htdocs/admin/commissions.php b/htdocs/commissions/admin/commissions.php similarity index 65% rename from htdocs/admin/commissions.php rename to htdocs/commissions/admin/commissions.php index 64e618633ac..a48f6ead1ca 100644 --- a/htdocs/admin/commissions.php +++ b/htdocs/commissions/admin/commissions.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2012 Christophe Battarel * * 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 @@ -12,9 +12,7 @@ * 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, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * or see http://www.gnu.org/ + * along with this program. If not, see . */ /** @@ -23,33 +21,24 @@ * \brief Page to setup advanced commissions module */ -$res=@include("../main.inc.php"); // For root directory - +include("../../main.inc.php"); require_once(DOL_DOCUMENT_ROOT."/commissions/lib/commissions.lib.php"); require_once(DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php"); $langs->load("admin"); $langs->load("commissions"); -if (!$user->admin) -accessforbidden(); +if (! $user->admin) accessforbidden(); -// init -if ($conf->global->COMMISSION_BASE == "") { - if ($conf->marges->enabled) - $conf->global->COMMISSION_BASE = "MARGES"; - else - $conf->global->COMMISSION_BASE = "CA"; -} /* * Action */ -if (isset($_POST['commissionBase'])) +if (GETPOST('commissionBase')) { - if (dolibarr_set_const($db, 'COMMISSION_BASE', $_POST['commissionBase'], 'string', 0, '', $conf->entity) > 0) + if (dolibarr_set_const($db, 'COMMISSION_BASE', GETPOST('commissionBase'), 'string', 0, '', $conf->entity) > 0) { - $conf->global->COMMISSION_BASE = $_POST['commissionBase']; + $conf->global->COMMISSION_BASE = GETPOST('commissionBase'); } else { @@ -57,9 +46,9 @@ if (isset($_POST['commissionBase'])) } } -if (isset($_POST['productCommissionRate'])) +if (GETPOST('productCommissionRate')) { - if (dolibarr_set_const($db, 'PRODUCT_COMMISSION_RATE', $_POST['productCommissionRate'], 'rate', 0, '', $conf->entity) > 0) + if (dolibarr_set_const($db, 'PRODUCT_COMMISSION_RATE', GETPOST('productCommissionRate'), 'rate', 0, '', $conf->entity) > 0) { } else @@ -68,9 +57,9 @@ if (isset($_POST['productCommissionRate'])) } } -if (isset($_POST['serviceCommissionRate'])) +if (GETPOST('serviceCommissionRate')) { - if (dolibarr_set_const($db, 'SERVICE_COMMISSION_RATE', $_POST['serviceCommissionRate'], 'rate', 0, '', $conf->entity) > 0) + if (dolibarr_set_const($db, 'SERVICE_COMMISSION_RATE', GETPOST('serviceCommissionRate'), 'rate', 0, '', $conf->entity) > 0) { } else @@ -91,7 +80,7 @@ $linkback=''.$langs->trans("BackToM print_fiche_titre($langs->trans("commissionsSetup"),$linkback,'setup'); -$head = commissions_admin_prepare_head($adh); +$head = commissions_admin_prepare_head(); dol_fiche_head($head, 'parameters', $langs->trans("Commissions"), 0, 'commissions'); @@ -111,21 +100,21 @@ $form = new Form($db); print '
'; -// COMMISSION BASE (CA / MARGES) +// COMMISSION BASE (TURNOVER / MARGIN) $var=!$var; print '
'.$langs->trans("CommissionBase").''; -print 'global->COMMISSION_BASE == "CA") +print 'global->COMMISSION_BASE) && $conf->global->COMMISSION_BASE == "TURNOVER") print 'checked'; print ' />'; -print $langs->trans("CommissionBasedOnCA"); +print $langs->trans("CommissionBasedOnTurnover"); print '
'; -print 'marges->enabled) +print 'margin->enabled)) print 'disabled'; -elseif ($conf->global->COMMISSION_BASE == "MARGES") +elseif (isset($conf->global->COMMISSION_BASE) && $conf->global->COMMISSION_BASE == "MARGIN") print 'checked'; print ' />'; print $langs->trans("CommissionBasedOnMargins"); @@ -141,7 +130,7 @@ $var=!$var; print '
'.$langs->trans("ProductCommissionRate").''; -print '  %'; +print '  %'; print ''.$langs->trans('ProductCommissionRateDetails').'
'.$langs->trans("ServiceCommissionRate").''; -print '  %'; +print '  %'; print ''.$langs->trans('ServiceCommissionRateDetails').'
'.$langs->trans('StartDate').''; $form->select_date($startdate,'startdate','','',1,"sel",1,1); @@ -106,22 +108,22 @@ print '
'.$langs->trans("IncludeUnpayedInvoices").''; print ''; print '
'.$langs->trans("TotalMargin").''; - print ''; // set by jquery (see below) - print '
'.$langs->trans("TotalMargin").''; + print ''; // set by jquery (see below) + print '
'.$langs->trans("CATotal").''; - print ''; // set by jquery (see below) - print '
'.$langs->trans("TurnoverTotal").''; + print ''; // set by jquery (see below) + print '
"; print ''; if ($agentid > 0) - print_liste_field_titre($langs->trans("Customer"),$_SERVER["PHP_SELF"],"s.nom","","&agentid=".$_REQUEST["agentid"],'align="center"',$sortfield,$sortorder); - else - print_liste_field_titre($langs->trans("CommercialAgent"),$_SERVER["PHP_SELF"],"u.login","","&agentid=".$_REQUEST["agentid"],'align="center"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Customer"),$_SERVER["PHP_SELF"],"s.nom","","&agentid=".$agentid,'align="center"',$sortfield,$sortorder); + else + print_liste_field_titre($langs->trans("CommercialAgent"),$_SERVER["PHP_SELF"],"u.login","","&agentid=".$agentid,'align="center"',$sortfield,$sortorder); - // product commission - if ($conf->global->COMMISSION_BASE == "MARGES") - print_liste_field_titre($langs->trans("ProductMargin"),$_SERVER["PHP_SELF"],"productBase","","&agentid=".$_REQUEST["agentid"],'align="right"',$sortfield,$sortorder); - elseif ($conf->global->COMMISSION_BASE == "CA") - print_liste_field_titre($langs->trans("ProductCA"),$_SERVER["PHP_SELF"],"productBase","","&agentid=".$_REQUEST["agentid"],'align="right"',$sortfield,$sortorder); + // product commission + if ($conf->global->COMMISSION_BASE == "MARGIN") + print_liste_field_titre($langs->trans("ProductMargin"),$_SERVER["PHP_SELF"],"productBase","","&agentid=".$agentid,'align="right"',$sortfield,$sortorder); + elseif ($conf->global->COMMISSION_BASE == "TURNOVER") + print_liste_field_titre($langs->trans("ProductTurnover"),$_SERVER["PHP_SELF"],"productBase","","&agentid=".$agentid,'align="right"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("CommissionRate"),$_SERVER["PHP_SELF"],"","","&agentid=".$_REQUEST["agentid"],'align="right"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("ProductCommission"),$_SERVER["PHP_SELF"],"","","&agentid=".$_REQUEST["agentid"],'align="right"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("CommissionRate"),$_SERVER["PHP_SELF"],"","","&agentid=".$agentid,'align="right"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("ProductCommission"),$_SERVER["PHP_SELF"],"","","&agentid=".$agentid,'align="right"',$sortfield,$sortorder); - // service commission - if ($conf->global->COMMISSION_BASE == "MARGES") - print_liste_field_titre($langs->trans("ServiceMargin"),$_SERVER["PHP_SELF"],"serviceBase","","&agentid=".$_REQUEST["agentid"],'align="right"',$sortfield,$sortorder); - elseif ($conf->global->COMMISSION_BASE == "CA") - print_liste_field_titre($langs->trans("ServiceCA"),$_SERVER["PHP_SELF"],"serviceBase","","&agentid=".$_REQUEST["agentid"],'align="right"',$sortfield,$sortorder); + // service commission + if ($conf->global->COMMISSION_BASE == "MARGIN") + print_liste_field_titre($langs->trans("ServiceMargin"),$_SERVER["PHP_SELF"],"serviceBase","","&agentid=".$agentid,'align="right"',$sortfield,$sortorder); + elseif ($conf->global->COMMISSION_BASE == "TURNOVER") + print_liste_field_titre($langs->trans("ServiceTurnover"),$_SERVER["PHP_SELF"],"serviceBase","","&agentid=".$agentid,'align="right"',$sortfield,$sortorder); + + print_liste_field_titre($langs->trans("CommissionRate"),$_SERVER["PHP_SELF"],"","","&agentid=".$agentid,'align="right"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("ServiceCommission"),$_SERVER["PHP_SELF"],"","","&agentid=".$agentid,'align="right"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("CommissionRate"),$_SERVER["PHP_SELF"],"","","&agentid=".$_REQUEST["agentid"],'align="right"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("ServiceCommission"),$_SERVER["PHP_SELF"],"","","&agentid=".$_REQUEST["agentid"],'align="right"',$sortfield,$sortorder); // total commission - print_liste_field_titre($langs->trans("TotalCommission"),$_SERVER["PHP_SELF"],"","","&agentid=".$_REQUEST["agentid"],'align="right"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("TotalCommission"),$_SERVER["PHP_SELF"],"","","&agentid=".$agentid,'align="right"',$sortfield,$sortorder); print "\n"; @@ -227,32 +230,39 @@ if ($result) print ""; if ($agentid > 0) { - $companystatic->id=$objp->socid; - $companystatic->nom=$objp->nom; - $companystatic->client=$objp->client; - print "\n"; - } - else { - $userstatic->id=$objp->agent; - $userstatic->login=$objp->login; - print "\n"; - } - // product commission - $productCommission = $conf->global->PRODUCT_COMMISSION_RATE * $objp->productBase / 100; - print "\n"; - print "\n"; + $companystatic->id=$objp->socid; + $companystatic->nom=$objp->nom; + $companystatic->client=$objp->client; + print "\n"; + } + else { + $userstatic->id=$objp->agent; + $userstatic->login=$objp->login; + print "\n"; + } + + // product commission + $productCommissionRate=(! empty($conf->global->PRODUCT_COMMISSION_RATE)?$conf->global->PRODUCT_COMMISSION_RATE:0); + $productBase=(! empty($objp->productBase)?$objp->productBase:0); + $productCommission = (! empty($productBase)?($productCommissionRate * $productBase / 100):0); + print "\n"; + print "\n"; print "\n"; - // service commission - $serviceCommission = $conf->global->SERVICE_COMMISSION_RATE * $objp->serviceBase / 100; - print "\n"; - print "\n"; + + // service commission + $serviceCommissionRate=(! empty($conf->global->SERVICE_COMMISSION_RATE)?$conf->global->SERVICE_COMMISSION_RATE:0); + $serviceBase=(! empty($objp->serviceBase)?$objp->serviceBase:0); + $serviceCommission = (! empty($serviceBase)?($serviceCommissionRate * $serviceBase / 100):0); + print "\n"; + print "\n"; print "\n"; + // total commission print "\n"; print "\n"; $i++; - $cumul_base_produit += $objp->productBase; - $cumul_base_service += $objp->serviceBase; + $cumul_base_produit += $productBase; + $cumul_base_service += $serviceBase; $cumul_commission_produit += $productCommission; $cumul_commission_service += $serviceCommission; } @@ -261,25 +271,25 @@ if ($result) // affichage totaux commission $var=!$var; print ''; - if ($client) - print '"; - // product commission + if (! empty($client)) + print '"; + // product commission print "\n"; - print "\n"; + print "\n"; print "\n"; - // service commission + // service commission print "\n"; - print "\n"; + print "\n"; print "\n"; // total commission print "\n"; print "\n"; - print "
".$companystatic->getNomUrl(1,'customer')."".$userstatic->getLoginUrl(1)."".price($objp->productBase)."".price($conf->global->PRODUCT_COMMISSION_RATE)."".$companystatic->getNomUrl(1,'customer')."".$userstatic->getLoginUrl(1)."".price($productBase)."".price($productCommissionRate)."".price($productCommission)."".price($objp->serviceBase)."".price($conf->global->SERVICE_COMMISSION_RATE)."".price($serviceBase)."".price($serviceCommissionRate)."".price($serviceCommission)."".price($productCommission + $serviceCommission)."
'; - else - print ''; - print $langs->trans('TotalCommission')."'; + else + print ''; + print $langs->trans('TotalCommission')."".price($cumul_base_produit)."".price($conf->global->PRODUCT_COMMISSION_RATE)."".price((! empty($conf->global->PRODUCT_COMMISSION_RATE)?$conf->global->PRODUCT_COMMISSION_RATE:0))."".price($cumul_commission_produit)."".price($cumul_base_service)."".price($conf->global->SERVICE_COMMISSION_RATE)."".price((! empty($conf->global->SERVICE_COMMISSION_RATE)?$conf->global->SERVICE_COMMISSION_RATE:0))."".price($cumul_commission_service)."".price($cumul_commission_produit + $cumul_commission_service)."
"; + print ""; } else { diff --git a/htdocs/commissions/lib/commissions.lib.php b/htdocs/commissions/lib/commissions.lib.php index ca71d41536c..89fba20a60c 100644 --- a/htdocs/commissions/lib/commissions.lib.php +++ b/htdocs/commissions/lib/commissions.lib.php @@ -42,7 +42,7 @@ function commissions_admin_prepare_head() // Entries must be declared in modules descriptor with line // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab - complete_head_from_modules($conf,$langs,$object,$head,$h,'commissionsadmin'); + complete_head_from_modules($conf,$langs,'',$head,$h,'commissionsadmin'); return $head; } diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index 806af455da9..917d2d8f227 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -54,11 +54,6 @@ $langs->load('main'); if (! empty($conf->margin->enabled)) $langs->load('margins'); -$mesg=''; -$errors=array(); - -if (GETPOST('mesg','int',1) && isset($_SESSION['message'])) $mesg=$_SESSION['message']; - $sall=trim(GETPOST('sall')); $projectid=(GETPOST('projectid')?GETPOST('projectid','int'):0); @@ -116,7 +111,7 @@ if ($action == 'confirm_clone' && $confirm == 'yes' && $user->rights->facture->c { if (1==0 && empty($_REQUEST["clone_content"]) && empty($_REQUEST["clone_receivers"])) { - $mesg='
'.$langs->trans("NoCloneOptionsSpecified").'
'; + $mesgs[]='
'.$langs->trans("NoCloneOptionsSpecified").'
'; } else { @@ -130,7 +125,7 @@ if ($action == 'confirm_clone' && $confirm == 'yes' && $user->rights->facture->c } else { - $mesg=$object->error; + $mesgs[]=$object->error; $action=''; } } @@ -152,7 +147,7 @@ else if ($action == 'reopen' && $user->rights->facture->creer) } else { - $mesg='
'.$object->error.'
'; + $mesgs[]='
'.$object->error.'
'; } } } @@ -170,7 +165,7 @@ else if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->fact } else { - $mesg='
'.$object->error.'
'; + $mesgs[]='
'.$object->error.'
'; } } @@ -206,7 +201,7 @@ else if ($action == 'confirm_deleteline' && $confirm == 'yes' && $user->rights-> } else { - $mesg='
'.$object->error.'
'; + $mesgs[]='
'.$object->error.'
'; $action=''; } } @@ -230,7 +225,7 @@ else if ($action == 'valid' && $user->rights->facture->creer) // Si avoir, le signe doit etre negatif if ($object->total_ht >= 0) { - $mesg='
'.$langs->trans("ErrorInvoiceAvoirMustBeNegative").'
'; + $mesgs[]='
'.$langs->trans("ErrorInvoiceAvoirMustBeNegative").'
'; $action=''; } } @@ -239,7 +234,7 @@ else if ($action == 'valid' && $user->rights->facture->creer) // Si non avoir, le signe doit etre positif if (empty($conf->global->FACTURE_ENABLE_NEGATIVE) && $object->total_ht < 0) { - $mesg='
'.$langs->trans("ErrorInvoiceOfThisTypeMustBePositive").'
'; + $mesgs[]='
'.$langs->trans("ErrorInvoiceOfThisTypeMustBePositive").'
'; $action=''; } } @@ -306,7 +301,7 @@ else if ($action == "setabsolutediscount" && $user->rights->facture->creer) $result=$object->insert_discount($_POST["remise_id"]); if ($result < 0) { - $mesg='
'.$object->error.'
'; + $mesgs[]='
'.$object->error.'
'; } } else @@ -323,7 +318,7 @@ else if ($action == "setabsolutediscount" && $user->rights->facture->creer) $result=$discount->link_to_invoice(0,$id); if ($result < 0) { - $mesg='
'.$discount->error.'
'; + $mesgs[]='
'.$discount->error.'
'; } } } @@ -362,7 +357,7 @@ else if ($action == 'confirm_valid' && $confirm == 'yes' && $user->rights->factu if (! $idwarehouse || $idwarehouse == -1) { $error++; - $errors[]=$langs->trans('ErrorFieldRequired',$langs->transnoentitiesnoconv("Warehouse")); + $mesgs[]=$langs->trans('ErrorFieldRequired',$langs->transnoentitiesnoconv("Warehouse")); $action=''; } } @@ -390,7 +385,7 @@ else if ($action == 'confirm_valid' && $confirm == 'yes' && $user->rights->factu } else { - $mesg='
'.$object->error.'
'; + $mesgs[]='
'.$object->error.'
'; } } } @@ -409,7 +404,7 @@ else if ($action == 'confirm_modif' && ((empty($conf->global->MAIN_USE_ADVANCED_ if (! $idwarehouse || $idwarehouse == -1) { $error++; - $errors[]=$langs->trans('ErrorFieldRequired',$langs->transnoentitiesnoconv("Warehouse")); + $mesgs[]=$langs->trans('ErrorFieldRequired',$langs->transnoentitiesnoconv("Warehouse")); $action=''; } } @@ -486,7 +481,7 @@ else if ($action == 'confirm_paid_partially' && $confirm == 'yes' && $user->righ } else { - $mesg='
'.$langs->trans("ErrorFieldRequired",$langs->trans("Reason")).'
'; + $mesgs[]='
'.$langs->trans("ErrorFieldRequired",$langs->trans("Reason")).'
'; } } // Classify "abandoned" @@ -501,7 +496,7 @@ else if ($action == 'confirm_canceled' && $confirm == 'yes') } else { - $mesg='
'.$langs->trans("ErrorFieldRequired",$langs->trans("Reason")).'
'; + $mesgs[]='
'.$langs->trans("ErrorFieldRequired",$langs->trans("Reason")).'
'; } } @@ -560,18 +555,18 @@ else if ($action == 'confirm_converttoreduc' && $confirm == 'yes' && $user->righ $result=$object->set_paid($user); if ($result > 0) { - //$mesg='OK'.$discount->id; + //$mesgs[]='OK'.$discount->id; $db->commit(); } else { - $mesg='
'.$object->error.'
'; + $mesgs[]='
'.$object->error.'
'; $db->rollback(); } } else { - $mesg='
'.$discount->error.'
'; + $mesgs[]='
'.$discount->error.'
'; $db->rollback(); } } @@ -595,13 +590,13 @@ else if ($action == 'add' && $user->rights->facture->creer) if (empty($datefacture)) { $error++; - $mesg='
'.$langs->trans("ErrorFieldRequired",$langs->trans("Date")).'
'; + $mesgs[]='
'.$langs->trans("ErrorFieldRequired",$langs->trans("Date")).'
'; } if (! ($_POST['fac_replacement'] > 0)) { $error++; - $mesg='
'.$langs->trans("ErrorFieldRequired",$langs->trans("ReplaceInvoice")).'
'; + $mesgs[]='
'.$langs->trans("ErrorFieldRequired",$langs->trans("ReplaceInvoice")).'
'; } if (! $error) @@ -627,7 +622,7 @@ else if ($action == 'add' && $user->rights->facture->creer) $object->type = 1; $id=$object->createFromCurrent($user); - if ($id <= 0) $mesg=$object->error; + if ($id <= 0) $mesgs[]=$object->error; } } @@ -637,14 +632,14 @@ else if ($action == 'add' && $user->rights->facture->creer) if (! $_POST['fac_avoir'] > 0) { $error++; - $mesg='
'.$langs->trans("ErrorFieldRequired",$langs->trans("CorrectInvoice")).'
'; + $mesgs[]='
'.$langs->trans("ErrorFieldRequired",$langs->trans("CorrectInvoice")).'
'; } $datefacture = dol_mktime(12, 0, 0, $_POST['remonth'], $_POST['reday'], $_POST['reyear']); if (empty($datefacture)) { $error++; - $mesg='
'.$langs->trans("ErrorFieldRequired",$langs->trans("Date")).'
'; + $mesgs[]='
'.$langs->trans("ErrorFieldRequired",$langs->trans("Date")).'
'; } if (! $error) @@ -696,7 +691,7 @@ else if ($action == 'add' && $user->rights->facture->creer) if (empty($datefacture)) { $error++; - $mesg='
'.$langs->trans("ErrorFieldRequired",$langs->trans("Date")).'
'; + $mesgs[]='
'.$langs->trans("ErrorFieldRequired",$langs->trans("Date")).'
'; } if (! $error) @@ -725,7 +720,7 @@ else if ($action == 'add' && $user->rights->facture->creer) if (empty($datefacture)) { $error++; - $mesg='
'.$langs->trans("ErrorFieldRequired",$langs->trans("Date")).'
'; + $mesgs[]='
'.$langs->trans("ErrorFieldRequired",$langs->trans("Date")).'
'; } if (! $error) @@ -816,7 +811,7 @@ else if ($action == 'add' && $user->rights->facture->creer) } else { - $mesg=$discount->error; + $mesgs[]=$discount->error; $error++; break; } @@ -866,8 +861,8 @@ else if ($action == 'add' && $user->rights->facture->creer) $object->origin, $lines[$i]->rowid, $fk_parent_line, - $lines[$i]->fk_fournprice, - $lines[$i]->pa_ht + $lines[$i]->fk_fournprice, + $lines[$i]->pa_ht ); if ($result > 0) @@ -895,13 +890,13 @@ else if ($action == 'add' && $user->rights->facture->creer) } else { - $mesg=$srcobject->error; + $mesgs[]=$srcobject->error; $error++; } } else { - $mesg=$object->error; + $mesgs[]=$object->error; $error++; } } @@ -938,7 +933,7 @@ else if ($action == 'add' && $user->rights->facture->creer) $action='create'; $_GET["origin"]=$_POST["origin"]; $_GET["originid"]=$_POST["originid"]; - if (! $mesg) $mesg='
'.$object->error.'
'; + $mesgs[]='
'.$object->error.'
'; } } @@ -950,27 +945,27 @@ else if (($action == 'addline' || $action == 'addline_predef') && $user->rights- if ($_POST['np_price'] < 0 && $_POST["qty"] < 0) { $langs->load("errors"); - $mesg='
'.$langs->trans("ErrorBothFieldCantBeNegative",$langs->transnoentitiesnoconv("UnitPriceHT"),$langs->transnoentitiesnoconv("Qty")).'
'; + $mesgs[]='
'.$langs->trans("ErrorBothFieldCantBeNegative",$langs->transnoentitiesnoconv("UnitPriceHT"),$langs->transnoentitiesnoconv("Qty")).'
'; $result = -1 ; } if (empty($_POST['idprod']) && $_POST["type"] < 0) { - $mesg='
'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Type")).'
'; + $mesgs[]='
'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Type")).'
'; $result = -1 ; } if (empty($_POST['idprod']) && (! isset($_POST["np_price"]) || $_POST["np_price"]=='')) // Unit price can be 0 but not '' { - $mesg='
'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("UnitPriceHT")).'
'; + $mesgs[]='
'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("UnitPriceHT")).'
'; $result = -1 ; } if (empty($_POST['idprod']) && empty($_POST["np_desc"]) && empty($_POST["dp_desc"])) { - $mesg='
'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Description")).'
'; + $mesgs[]='
'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Description")).'
'; $result = -1 ; } if (! isset($_POST['qty']) || $_POST['qty']=='') { - $mesg='
'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv('Qty')).'
'; + $mesgs[]='
'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv('Qty')).'
'; $result = -1 ; } if ($result >= 0 && ( ($_POST['np_price']!='' && ($_POST['np_desc'] || $_POST['dp_desc'])) || $_POST['idprod'] ) ) @@ -1082,7 +1077,7 @@ else if (($action == 'addline' || $action == 'addline_predef') && $user->rights- $pa_ht = $_POST['np_buying_price']; else $pa_ht = null; - + $info_bits=0; if ($tva_npr) $info_bits |= 0x01; @@ -1119,8 +1114,8 @@ else if (($action == 'addline' || $action == 'addline_predef') && $user->rights- '', 0, GETPOST('fk_parent_line'), - $fk_fournprice, - $pa_ht + $fk_fournprice, + $pa_ht ); } } @@ -1155,7 +1150,7 @@ else if (($action == 'addline' || $action == 'addline_predef') && $user->rights- } else { - if (empty($mesg)) $mesg='
'.$object->error.'
'; + $mesgs[]='
'.$object->error.'
'; } $action=''; @@ -1194,7 +1189,7 @@ else if ($action == 'updateligne' && $user->rights->facture->creer && $_POST['sa // Check parameters if (! GETPOST('productid') && GETPOST("type") < 0) { - $mesg = '
'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Type")).'
'; + $mesgs[] = '
'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Type")).'
'; $result = -1 ; } // Check minimum price @@ -1210,7 +1205,7 @@ else if ($action == 'updateligne' && $user->rights->facture->creer && $_POST['sa if ($object->type!=2 && $price_min && GETPOST('productid') && (price2num($up_ht)*(1-price2num(GETPOST('remise_percent'))/100) < price2num($price_min))) { //print "CantBeLessThanMinPrice ".$up_ht." - ".GETPOST('remise_percent')." - ".$product->price_min; - $mesg = '
'.$langs->trans("CantBeLessThanMinPrice",price2num($price_min,'MU').' '.$langs->trans("Currency".$conf->currency)).'
'; + $mesgs[] = '
'.$langs->trans("CantBeLessThanMinPrice",price2num($price_min,'MU').' '.$langs->trans("Currency".$conf->currency)).'
'; $result=-1; } @@ -1236,9 +1231,9 @@ else if ($action == 'updateligne' && $user->rights->facture->creer && $_POST['sa $info_bits, $type, GETPOST('fk_parent_line'), - 0, - $fk_fournprice, - $pa_ht + 0, + $fk_fournprice, + $pa_ht ); // Define output language @@ -1328,7 +1323,7 @@ if (GETPOST('addfile')) $vardir=$conf->user->dir_output."/".$user->id; $upload_dir_tmp = $vardir.'/temp'; - $mesg=dol_add_file_process($upload_dir_tmp,0,0); + $mesgs[]=dol_add_file_process($upload_dir_tmp,0,0); $action='presend'; } @@ -1345,7 +1340,7 @@ if (! empty($_POST['removedfile'])) $upload_dir_tmp = $vardir.'/temp'; // TODO Delete only files that was uploaded from email form - $mesg=dol_remove_file_process($_POST['removedfile'],0); + $mesgs[]=dol_remove_file_process($_POST['removedfile'],0); $action='presend'; } @@ -1476,8 +1471,8 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO { // Redirect here // This avoid sending mail twice if going out and then back to page - $_SESSION['message'] = $mesg; - Header('Location: '.$_SERVER["PHP_SELF"].'?facid='.$object->id.'&mesg=1'); + $_SESSION['dol_message'] = $mesg; + Header('Location: '.$_SERVER["PHP_SELF"].'?facid='.$object->id); exit; } } @@ -1495,27 +1490,28 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO $mesg.='No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS'; } $mesg.=''; + $mesgs[]=$mesg; } } /* } else { $langs->load("other"); - $mesg='
'.$langs->trans('ErrorMailRecipientIsEmpty').'
'; + $mesgs[]='
'.$langs->trans('ErrorMailRecipientIsEmpty').'
'; dol_syslog('Recipient email is empty'); }*/ } else { $langs->load("errors"); - $mesg='
'.$langs->trans('ErrorCantReadFile',$file).'
'; + $mesgs[]='
'.$langs->trans('ErrorCantReadFile',$file).'
'; dol_syslog('Failed to read file: '.$file); } } else { $langs->load("other"); - $mesg='
'.$langs->trans('ErrorFailedToReadEntity',$langs->trans("Invoice")).'
'; + $mesgs[]='
'.$langs->trans('ErrorFailedToReadEntity',$langs->trans("Invoice")).'
'; dol_syslog('Impossible de lire les donnees de la facture. Le fichier facture n\'a peut-etre pas ete genere.'); } @@ -1571,7 +1567,7 @@ else if ($action == 'remove_file') $upload_dir = $conf->facture->dir_output; $file = $upload_dir . '/' . GETPOST('file'); dol_delete_file($file,0,0,0,$object); - $mesg = '
'.$langs->trans("FileWasRemoved",GETPOST('file')).'
'; + $mesgs[] = '
'.$langs->trans("FileWasRemoved",GETPOST('file')).'
'; } } @@ -1597,11 +1593,11 @@ if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') { $langs->load("errors"); - $mesg = '
'.$langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType").'
'; + $mesgs[] = '
'.$langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType").'
'; } else { - $mesg = '
'.$object->error.'
'; + $mesgs[] = '
'.$object->error.'
'; } } } @@ -1661,9 +1657,6 @@ if ($action == 'create') print_fiche_titre($langs->trans('NewBill')); - dol_htmloutput_mesg($mesg); - dol_htmloutput_errors('',$errors); - $soc = new Societe($db); if ($socid) $res=$soc->fetch($socid); @@ -2109,8 +2102,6 @@ else if ($id > 0 || ! empty($ref)) /* * Show object in view mode */ - dol_htmloutput_mesg($mesg); - dol_htmloutput_errors('',$errors); $result=$object->fetch($id,$ref); if ($result > 0) @@ -3332,7 +3323,8 @@ else if ($id > 0 || ! empty($ref)) } } +dol_htmloutput_mesg('',$mesgs); llxFooter(); $db->close(); -?> +?> \ No newline at end of file diff --git a/htdocs/compta/facture/document.php b/htdocs/compta/facture/document.php index 7a789c32c4f..e023a0dd242 100644 --- a/htdocs/compta/facture/document.php +++ b/htdocs/compta/facture/document.php @@ -43,13 +43,6 @@ $confirm = GETPOST('confirm'); $id = GETPOST('facid','int'); $ref = GETPOST('ref'); -$mesg=''; -if (isset($_SESSION['DolMessage'])) -{ - $mesg=$_SESSION['DolMessage']; - unset($_SESSION['DolMessage']); -} - // Security check if ($user->societe_id) { @@ -132,7 +125,7 @@ if ($action == 'confirm_deletefile' && $confirm == 'yes') $upload_dir = $conf->facture->dir_output . "/" . dol_sanitizeFileName($object->ref); $file = $upload_dir . '/' . GETPOST('urlfile'); // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP). dol_delete_file($file,0,0,0,$object); - $_SESSION['DolMessage'] = '
'.$langs->trans("FileWasRemoved",GETPOST('urlfile')).'
'; + $_SESSION['dol_message'] = '
'.$langs->trans("FileWasRemoved",GETPOST('urlfile')).'
'; Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id); exit; } diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index 6c356015ab1..86a70f28e28 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -38,22 +38,18 @@ require_once(DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php'); require_once(DOL_DOCUMENT_ROOT."/core/lib/functions2.lib.php"); require_once(DOL_DOCUMENT_ROOT.'/core/lib/invoice.lib.php'); require_once(DOL_DOCUMENT_ROOT."/core/lib/date.lib.php"); -if ($conf->commande->enabled) require_once(DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'); -if ($conf->projet->enabled) +if (! empty($conf->commande->enabled)) require_once(DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'); +if (! empty($conf->projet->enabled)) { require_once(DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'); require_once(DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php'); } $langs->load('bills'); -//print 'ee'.$langs->trans('BillsCustomer');exit; - $langs->load('companies'); $langs->load('products'); $langs->load('main'); -if (GETPOST('mesg','int',1) && isset($_SESSION['message'])) $mesg=$_SESSION['message']; - $sall=trim(GETPOST('sall')); $projectid=(GETPOST('projectid')?GETPOST('projectid','int'):0); @@ -84,16 +80,19 @@ $pageprev = $page - 1; $pagenext = $page + 1; $search_user = GETPOST('search_user','int'); +$search_sale = GETPOST('search_sale','int'); $day = GETPOST('day','int'); $month = GETPOST('month','int'); $year = GETPOST('year','int'); +$filtre = GETPOST('filtre'); // Security check $fieldid = (! empty($ref)?'facnumber':'rowid'); -if ($user->societe_id) $socid=$user->societe_id; +if (! empty($user->societe_id)) $socid=$user->societe_id; $result = restrictedArea($user, 'facture', $id,'','','fk_soc',$fieldid); -$usehm=$conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE; +// FIXME $usehm not used ? +$usehm=(! empty($conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE)?$conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE:false); $object=new Facture($db); @@ -166,12 +165,12 @@ if ($userid) if ($userid == -1) $sql.=' AND f.fk_user_author IS NULL'; else $sql.=' AND f.fk_user_author = '.$userid; } -if ($_GET['filtre']) +if ($filtre) { - $filtrearr = explode(',', $_GET['filtre']); - foreach ($filtrearr as $fil) + $aFilter = explode(',', $filtre); + foreach ($aFilter as $filter) { - $filt = explode(':', $fil); + $filt = explode(':', $filter); $sql .= ' AND ' . trim($filt[0]) . ' = ' . trim($filt[1]); } } @@ -254,6 +253,7 @@ if ($resql) print ''; // If the user can view prospects other than his' + $moreforfilter=''; if ($user->rights->societe->client->voir || $socid) { $moreforfilter.=$langs->trans('ThirdPartiesOfSaleRepresentative'). ': '; @@ -314,6 +314,7 @@ if ($resql) { $var=True; $total=0; + $total_ttc=0; $totalrecu=0; while ($i < min($num,$limit)) diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php index d9b69e35fcf..6e03e4c5eae 100644 --- a/htdocs/contact/class/contact.class.php +++ b/htdocs/contact/class/contact.class.php @@ -805,8 +805,12 @@ class Contact extends CommonObject $sql = "SELECT count(mc.email) as nb"; $sql.= " FROM ".MAIN_DB_PREFIX."mailing_cibles as mc"; $sql.= " WHERE mc.email = '".$this->db->escape($this->email)."'"; - $sql.= " AND mc.statut=1"; // -1 erreur, 0 non envoye, 1 envoye avec succes + $sql.= " AND mc.statut NOT IN (-1,0)"; // -1 erreur, 0 non envoye, 1 envoye avec succes + + dol_syslog(get_class($this)."::getNbOfEMailings sql=".$sql, LOG_DEBUG); + $resql=$this->db->query($sql); + if ($resql) { $obj = $this->db->fetch_object($resql); diff --git a/htdocs/contrat/document.php b/htdocs/contrat/document.php index 8f3e0265caf..97dbbaa2c9c 100644 --- a/htdocs/contrat/document.php +++ b/htdocs/contrat/document.php @@ -41,13 +41,6 @@ $confirm = GETPOST('confirm','alpha'); $id = GETPOST('id','int'); $ref = GETPOST('ref','alpha'); -$mesg=''; -if (isset($_SESSION['DolMessage'])) -{ - $mesg=$_SESSION['DolMessage']; - unset($_SESSION['DolMessage']); -} - // Security check if ($user->societe_id > 0) { @@ -129,7 +122,7 @@ if ($action == 'confirm_deletefile' && $confirm == 'yes') $file = $upload_dir . '/' . GETPOST('urlfile'); // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP). $ret=dol_delete_file($file,0,0,0,$object); - $_SESSION['DolMessage'] = '
'.$langs->trans("FileWasRemoved",GETPOST('urlfile')).'
'; + $_SESSION['dol_message'] = '
'.$langs->trans("FileWasRemoved",GETPOST('urlfile')).'
'; Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id); exit; } @@ -175,9 +168,9 @@ if ($object->id) print '
'; print ''; - + dol_htmloutput_mesg($mesg,$mesgs); - + /* * Confirmation suppression fichier */ diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 752d904c330..35e158231e4 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -2055,7 +2055,7 @@ abstract class CommonObject $error=0; - if (count($this->array_options) > 0) + if (! empty($this->array_options)) { // Check parameters $langs->load('admin'); @@ -2533,7 +2533,7 @@ abstract class CommonObject print ''.$langs->trans('PriceUHT').''; print ''.$langs->trans('Qty').''; print ''.$langs->trans('ReductionShort').''; - if (! empty($conf->margin->enabled)) { + if (! empty($conf->margin->enabled)) { if ($conf->global->MARGIN_TYPE == "1") print ''.$langs->trans('BuyingPrice').''; else @@ -2861,43 +2861,43 @@ abstract class CommonObject 'total_margin' => 0, 'total_margin_rate' => '', 'total_mark_rate' => '' - ); - foreach($this->lines as $line) { - if (isset($line->fk_fournprice) && !$force_price) { + ); + foreach($this->lines as $line) { + if (isset($line->fk_fournprice) && !$force_price) { $product = new ProductFournisseur($this->db); - if ( $product->fetch_product_fournisseur_price($line->fk_fournprice)) + if ($product->fetch_product_fournisseur_price($line->fk_fournprice)) $line->pa_ht = $product->fourn_unitprice; - if ($conf->global->MARGIN_TYPE == "2" && $product->fourn_unitcharges > 0) + if (isset($conf->global->MARGIN_TYPE) && $conf->global->MARGIN_TYPE == "2" && $product->fourn_unitcharges > 0) $line->pa_ht += $product->fourn_unitcharges; - } - // si prix d'achat non renseign� et devrait l'�tre, alors prix achat = prix vente - if ((!isset($line->pa_ht) || $line->pa_ht == 0) && ($conf->global->ForceBuyingPriceIfNull == 1)) { - $line->pa_ht = $line->subprice * (1 - ($line->remise_percent / 100)); + } + // si prix d'achat non renseigné et devrait l'être, alors prix achat = prix vente + if ((!isset($line->pa_ht) || $line->pa_ht == 0) && (isset($conf->global->ForceBuyingPriceIfNull) && $conf->global->ForceBuyingPriceIfNull == 1)) { + $line->pa_ht = $line->subprice * (1 - ($line->remise_percent / 100)); } // calcul des marges - if(isset($line->fk_remise_except)) { // remise - if ($conf->global->MARGIN_METHODE_FOR_DISCOUNT == '1') { // remise globale consid�r�e comme produit - $marginInfos['pa_products'] += ($line->pa_ht != 0)?$line->pa_ht:$line->subprice * (1 - $line->remise_percent / 100); + if (isset($line->fk_remise_except) && isset($conf->global->MARGIN_METHODE_FOR_DISCOUNT)) { // remise + if ($conf->global->MARGIN_METHODE_FOR_DISCOUNT == '1') { // remise globale considérée comme produit + $marginInfos['pa_products'] += ($line->pa_ht != 0)?$line->pa_ht:$line->subprice * (1 - $line->remise_percent / 100); $marginInfos['pv_products'] += $line->subprice * (1 - $line->remise_percent / 100); - $marginInfos['pa_total'] += ($line->pa_ht != 0)?$line->pa_ht:$line->subprice * (1 - $line->remise_percent / 100); + $marginInfos['pa_total'] += ($line->pa_ht != 0)?$line->pa_ht:$line->subprice * (1 - $line->remise_percent / 100); $marginInfos['pv_total'] += $line->subprice * (1 - $line->remise_percent / 100); } - elseif ($conf->global->MARGIN_METHODE_FOR_DISCOUNT == '2') { // remise globale consid�r�e comme service - $marginInfos['pa_services'] += ($line->pa_ht != 0)?$line->pa_ht:$line->subprice * (1 - $line->remise_percent / 100); + elseif ($conf->global->MARGIN_METHODE_FOR_DISCOUNT == '2') { // remise globale considérée comme service + $marginInfos['pa_services'] += ($line->pa_ht != 0)?$line->pa_ht:$line->subprice * (1 - $line->remise_percent / 100); $marginInfos['pv_services'] += $line->subprice * (1 - ($line->remise_percent / 100)); - $marginInfos['pa_total'] += ($line->pa_ht != 0)?$line->pa_ht:$line->subprice * (1 - $line->remise_percent / 100); + $marginInfos['pa_total'] += ($line->pa_ht != 0)?$line->pa_ht:$line->subprice * (1 - $line->remise_percent / 100); $marginInfos['pv_total'] += $line->subprice * (1 - $line->remise_percent / 100); } elseif ($conf->global->MARGIN_METHODE_FOR_DISCOUNT == '3') { // remise globale prise en compte uniqt sur total - $marginInfos['pa_total'] += ($line->pa_ht != 0)?$line->pa_ht:$line->subprice * (1 - $line->remise_percent / 100); + $marginInfos['pa_total'] += ($line->pa_ht != 0)?$line->pa_ht:$line->subprice * (1 - $line->remise_percent / 100); $marginInfos['pv_total'] += $line->subprice * (1 - ($line->remise_percent / 100)); } } - else { - $type=$line->product_type?$line->product_type:$line->fk_product_type; + else { + $type=$line->product_type?$line->product_type:$line->fk_product_type; if ($type == 0) { // product - $marginInfos['pa_products'] += $line->qty * $line->pa_ht; + $marginInfos['pa_products'] += $line->qty * $line->pa_ht; $marginInfos['pv_products'] += $line->qty * $line->subprice * (1 - $line->remise_percent / 100); $marginInfos['pa_total'] += $line->qty * $line->pa_ht; $marginInfos['pv_total'] += $line->qty * $line->subprice * (1 - $line->remise_percent / 100); @@ -2910,32 +2910,32 @@ abstract class CommonObject } } } - + $marginInfos['margin_on_products'] = $marginInfos['pv_products'] - $marginInfos['pa_products']; if ($marginInfos['pa_products'] > 0) $marginInfos['margin_rate_products'] = 100 * round($marginInfos['margin_on_products'] / $marginInfos['pa_products'],5); if ($marginInfos['pv_products'] > 0) $marginInfos['mark_rate_products'] = 100 * round($marginInfos['margin_on_products'] / $marginInfos['pv_products'],5); - + $marginInfos['margin_on_services'] = $marginInfos['pv_services'] - $marginInfos['pa_services']; if ($marginInfos['pa_services'] > 0) $marginInfos['margin_rate_services'] = 100 * round($marginInfos['margin_on_services'] / $marginInfos['pa_services'],5); if ($marginInfos['pv_services'] > 0) $marginInfos['mark_rate_services'] = 100 * round($marginInfos['margin_on_services'] / $marginInfos['pv_services'],5); - + $marginInfos['total_margin'] = $marginInfos['pv_total'] - $marginInfos['pa_total']; if ($marginInfos['pa_total'] > 0) $marginInfos['total_margin_rate'] = 100 * round($marginInfos['total_margin'] / $marginInfos['pa_total'],5); if ($marginInfos['pv_total'] > 0) $marginInfos['total_mark_rate'] = 100 * round($marginInfos['total_margin'] / $marginInfos['pv_total'],5); - + return $marginInfos; } function displayMarginInfos($force_price=false) { global $langs, $conf; - $marginInfo = $this->getMarginInfos($force_price); + $marginInfo = $this->getMarginInfos($force_price); print ''; print ''; print ''; diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 3ecca91bfab..1837ea7c306 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -2184,7 +2184,7 @@ class Form $more.=''.$langs->trans("Poste").''; print ''; print ""; - if ($conf->agenda->enabled && $user->rights->agenda->myactions->create) + if (! empty($conf->agenda->enabled) && $user->rights->agenda->myactions->create) { print ''; } print ""; - $sql = "SELECT p.rowid, p.name, p.firstname, p.poste, p.phone, p.fax, p.email, p.note "; + $sql = "SELECT p.rowid, p.name, p.firstname, p.fk_pays, p.poste, p.phone, p.fax, p.email, p.note "; $sql .= " FROM ".MAIN_DB_PREFIX."socpeople as p"; $sql .= " WHERE p.fk_soc = ".$object->id; $sql .= " ORDER by p.datec"; @@ -552,12 +553,14 @@ function show_contacts($conf,$langs,$db,$object,$backtopage='') print ''; + $country_code = getCountry($obj->fk_pays, 2); + // Lien click to dial print ''; print ''; print ''; print ''; - print ''; + print ''; print ''; // Delivery date planned @@ -276,7 +268,7 @@ if ($id > 0 || ! empty($ref)) print $langs->trans('PaymentConditionsShort'); print ''; - if ($action != 'editconditions' && $commande->brouillon) print ''; + if ($action != 'editconditions' && ! empty($commande->brouillon)) print ''; print '
'.$langs->trans('Margins').''.$langs->trans("Tel").''.$langs->trans("Fax").''.$langs->trans("EMail").'  
'.$obj->poste.''; - print dol_print_phone($obj->phone,$obj->pays_code,$obj->rowid,$object->id,'AC_TEL'); + print dol_print_phone($obj->phone,$country_code,$obj->rowid,$object->id,'AC_TEL'); print ''; - print dol_print_phone($obj->fax,$obj->pays_code,$obj->rowid,$object->id,'AC_FAX'); + print dol_print_phone($obj->fax,$country_code,$obj->rowid,$object->id,'AC_FAX'); print ''; print dol_print_email($obj->email,$obj->rowid,$object->id,'AC_EMAIL'); diff --git a/htdocs/core/lib/functions2.lib.php b/htdocs/core/lib/functions2.lib.php index f067ae7a5dc..30423c65940 100644 --- a/htdocs/core/lib/functions2.lib.php +++ b/htdocs/core/lib/functions2.lib.php @@ -1,6 +1,6 @@ - * Copyright (C) 2008-2011 Regis Houssin + * Copyright (C) 2008-2012 Regis Houssin * Copyright (C) 2008 Raphael Bertrand (Resultic) * * This program is free software; you can redistribute it and/or modify diff --git a/htdocs/core/modules/mailings/modules_mailings.php b/htdocs/core/modules/mailings/modules_mailings.php index 44ad66059a8..e7635e808d6 100644 --- a/htdocs/core/modules/mailings/modules_mailings.php +++ b/htdocs/core/modules/mailings/modules_mailings.php @@ -158,7 +158,9 @@ class MailingTargets // This can't be abstract as it is used for some method $sql .= " (fk_mailing,"; $sql .= " fk_contact,"; $sql .= " nom, prenom, email, other, source_url, source_id,"; - if (! empty($conf->global->MAILING_EMAIL_UNSUBSCRIBE)) $sql .= " tag,"; + if (! empty($conf->global->MAILING_EMAIL_UNSUBSCRIBE)) { + $sql .= " tag,"; + } $sql.= " source_type)"; $sql .= " VALUES (".$mailing_id.","; $sql .= (empty($cibles[$i]['fk_contact']) ? '0' : "'".$cibles[$i]['fk_contact']."'") .","; @@ -168,7 +170,9 @@ class MailingTargets // This can't be abstract as it is used for some method $sql .= "'".$this->db->escape($cibles[$i]['other'])."',"; $sql .= "'".$this->db->escape($cibles[$i]['source_url'])."',"; $sql .= "'".$this->db->escape($cibles[$i]['source_id'])."',"; - if (! empty($conf->global->MAILING_EMAIL_UNSUBSCRIBE)) $sql .= "'".$this->db->escape(md5($cibles[$i]['email'].';'.$cibles[$i]['name'].';'.$mailing_id.';'.$conf->global->MAILING_EMAIL_UNSUBSCRIBE_KEY))."',"; + if (! empty($conf->global->MAILING_EMAIL_UNSUBSCRIBE)) { + $sql .= "'".$this->db->escape(md5($cibles[$i]['email'].';'.$cibles[$i]['name'].';'.$mailing_id.';'.$conf->global->MAILING_EMAIL_UNSUBSCRIBE_KEY))."',"; + } $sql .= "'".$this->db->escape($cibles[$i]['source_type'])."')"; $result=$this->db->query($sql); if ($result) @@ -189,6 +193,7 @@ class MailingTargets // This can't be abstract as it is used for some method } } + dol_syslog(get_class($this)."::add_to_target: sql ".$sql,LOG_DEBUG); dol_syslog(get_class($this)."::add_to_target: mailing ".$j." targets added"); //Update the status to show thirdparty mail that don't want to be contacted anymore' diff --git a/htdocs/core/modules/modCommissions.class.php b/htdocs/core/modules/modCommissions.class.php index b03fa23c6d1..0dbaa7690d8 100644 --- a/htdocs/core/modules/modCommissions.class.php +++ b/htdocs/core/modules/modCommissions.class.php @@ -67,7 +67,7 @@ class modCommissions extends DolibarrModules $this->dirs = array(); // Config pages. Put here list of php page names stored in admmin directory used to setup module. - $this->config_page_url = array("commissions.php"); + $this->config_page_url = array("commissions.php@commissions"); // Dependencies $this->depends = array("modFacture", "modMargin"); // List of modules id that must be enabled if this module is enabled @@ -77,7 +77,7 @@ class modCommissions extends DolibarrModules $this->langfiles = array("commissions"); // Constants - $this->const = array(); // List of particular constants to add when module is enabled + $this->const = array(0=>array('COMMISSION_BASE',"chaine","TURNOVER",'Default commission base',0)); // List of particular constants to add when module is enabled // New pages on tabs $this->tabs = array(); @@ -106,15 +106,15 @@ class modCommissions extends DolibarrModules // left menu entry $this->menu[$r]=array( - 'fk_menu'=>0, // Put 0 if this is a top menu - 'type'=>'top', // This is a Top menu entry + 'fk_menu'=>'fk_mainmenu=accountancy', // Put 0 if this is a top menu + 'type'=>'left', // This is a Top menu entry 'titre'=>'Commissions', - 'mainmenu'=>'commissions', - 'leftmenu'=>'0', // Use 1 if you also want to add left menu entries using this descriptor. Use 0 if left menu entries are defined in a file pre.inc.php (old school). + 'mainmenu'=>'accountancy', + 'leftmenu'=>'commissions', // Use 1 if you also want to add left menu entries using this descriptor. Use 0 if left menu entries are defined in a file pre.inc.php (old school). 'url'=>'/commissions/index.php', - 'langs'=>'commissions@commissions', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. - 'position'=>110, - 'enabled'=>'1', // Define condition to show or hide menu entry. Use '$conf->monmodule->enabled' if entry must be visible if module is enabled. + 'langs'=>'commissions', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. + 'position'=>200, + 'enabled'=>'$conf->commissions->enabled', // Define condition to show or hide menu entry. Use '$conf->monmodule->enabled' if entry must be visible if module is enabled. 'perms'=>'1', // Use 'perms'=>'$user->rights->monmodule->level1->level2' if you want your menu with a permission rules 'target'=>'', 'user'=>2); // 0=Menu for internal users, 1=external users, 2=both diff --git a/htdocs/core/modules/modFacture.class.php b/htdocs/core/modules/modFacture.class.php index 7990893036a..577107a3586 100644 --- a/htdocs/core/modules/modFacture.class.php +++ b/htdocs/core/modules/modFacture.class.php @@ -176,6 +176,7 @@ class modFacture extends DolibarrModules $this->export_permission[$r]=array(array("facture","facture","export")); $this->export_fields_array[$r]=array('s.rowid'=>"IdCompany",'s.nom'=>'CompanyName','s.address'=>'Address','s.cp'=>'Zip','s.ville'=>'Town','c.code'=>'CountryCode','s.tel'=>'Phone','s.siren'=>'ProfId1','s.siret'=>'ProfId2','s.ape'=>'ProfId3','s.idprof4'=>'ProfId4','s.code_compta'=>'CustomerAccountancyCode','s.code_compta_fournisseur'=>'SupplierAccountancyCode','s.tva_intra'=>'VATIntra','f.rowid'=>"InvoiceId",'f.facnumber'=>"InvoiceRef",'f.datec'=>"InvoiceDateCreation",'f.datef'=>"DateInvoice",'f.date_lim_reglement'=>"DateDue",'f.total'=>"TotalHT",'f.total_ttc'=>"TotalTTC",'f.tva'=>"TotalVAT",'f.paye'=>"InvoicePaid",'f.fk_statut'=>'InvoiceStatus','f.note'=>"NotePrivate",'f.note_public'=>"NotePublic",'fd.rowid'=>'LineId','fd.description'=>"LineDescription",'fd.price'=>"LineUnitPrice",'fd.tva_tx'=>"LineVATRate",'fd.qty'=>"LineQty",'fd.total_ht'=>"LineTotalHT",'fd.total_tva'=>"LineTotalVAT",'fd.total_ttc'=>"LineTotalTTC",'fd.date_start'=>"DateStart",'fd.date_end'=>"DateEnd",'fd.product_type'=>"TypeOfLineServiceOrProduct",'fd.fk_product'=>'ProductId','p.ref'=>'ProductRef','p.label'=>'ProductLabel'); $this->export_entities_array[$r]=array('s.rowid'=>"company",'s.nom'=>'company','s.address'=>'company','s.cp'=>'company','s.ville'=>'company','c.code'=>'company','s.tel'=>'company','s.siren'=>'company','s.siret'=>'company','s.ape'=>'company','s.idprof4'=>'company','s.code_compta'=>'company','s.code_compta_fournisseur'=>'company','s.tva_intra'=>'company','f.rowid'=>"invoice",'f.facnumber'=>"invoice",'f.datec'=>"invoice",'f.datef'=>"invoice",'f.date_lim_reglement'=>"invoice",'f.total'=>"invoice",'f.total_ttc'=>"invoice",'f.tva'=>"invoice",'f.paye'=>"invoice",'f.fk_statut'=>'invoice','f.note'=>"invoice",'f.note_public'=>"invoice",'fd.rowid'=>'invoice_line','fd.description'=>"invoice_line",'fd.price'=>"invoice_line",'fd.total_ht'=>"invoice_line",'fd.total_tva'=>"invoice_line",'fd.total_ttc'=>"invoice_line",'fd.tva_tx'=>"invoice_line",'fd.qty'=>"invoice_line",'fd.date_start'=>"invoice_line",'fd.date_end'=>"invoice_line",'fd.product_type'=>'invoice_line','fd.fk_product'=>'product','p.ref'=>'product','p.label'=>'product'); + $this->export_dependencies_array[$r]=array('invoice_line'=>'fd.rowid','product'=>'fd.rowid'); // To add unique key if we ask a field of a child to avoid the DISTINCT to discard them $this->export_sql_start[$r]='SELECT DISTINCT '; $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'societe as s'; @@ -193,6 +194,7 @@ class modFacture extends DolibarrModules $this->export_permission[$r]=array(array("facture","facture","export")); $this->export_fields_array[$r]=array('s.rowid'=>"IdCompany",'s.nom'=>'CompanyName','s.address'=>'Address','s.cp'=>'Zip','s.ville'=>'Town','c.code'=>'CountryCode','s.tel'=>'Phone','s.siren'=>'ProfId1','s.siret'=>'ProfId2','s.ape'=>'ProfId3','s.idprof4'=>'ProfId4','s.code_compta'=>'CustomerAccountancyCode','s.code_compta_fournisseur'=>'SupplierAccountancyCode','s.tva_intra'=>'VATIntra','f.rowid'=>"InvoiceId",'f.facnumber'=>"InvoiceRef",'f.datec'=>"InvoiceDateCreation",'f.datef'=>"DateInvoice",'f.date_lim_reglement'=>"DateDue",'f.total'=>"TotalHT",'f.total_ttc'=>"TotalTTC",'f.tva'=>"TotalVAT",'f.paye'=>"InvoicePaid",'f.fk_statut'=>'InvoiceStatus','f.note'=>"NotePrivate",'f.note_public'=>"NotePublic",'p.rowid'=>'PaymentId','pf.amount'=>'AmountPayment','p.datep'=>'DatePayment','p.num_paiement'=>'PaymentNumber'); $this->export_entities_array[$r]=array('s.rowid'=>"company",'s.nom'=>'company','s.address'=>'company','s.cp'=>'company','s.ville'=>'company','c.code'=>'company','s.tel'=>'company','s.siren'=>'company','s.siret'=>'company','s.ape'=>'company','s.idprof4'=>'company','s.code_compta'=>'company','s.code_compta_fournisseur'=>'company','s.tva_intra'=>'company','f.rowid'=>"invoice",'f.facnumber'=>"invoice",'f.datec'=>"invoice",'f.datef'=>"invoice",'f.date_lim_reglement'=>"invoice",'f.total'=>"invoice",'f.total_ttc'=>"invoice",'f.tva'=>"invoice",'f.paye'=>"invoice",'f.fk_statut'=>'invoice','f.note'=>"invoice",'f.note_public'=>"invoice",'p.rowid'=>'payment','pf.amount'=>'payment','p.datep'=>'payment','p.num_paiement'=>'payment'); + $this->export_dependencies_array[$r]=array('payment'=>'p.rowid'); // To add unique key if we ask a field of a child to avoid the DISTINCT to discard them $this->export_sql_start[$r]='SELECT DISTINCT '; $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'societe as s'; diff --git a/htdocs/core/modules/modMargin.class.php b/htdocs/core/modules/modMargin.class.php index a14068f348e..f94193393fc 100644 --- a/htdocs/core/modules/modMargin.class.php +++ b/htdocs/core/modules/modMargin.class.php @@ -59,13 +59,13 @@ class modMargin extends DolibarrModules $this->special = 0; // Name of png file (without png) used for this module. // Png file must be in theme/yourtheme/img directory under name object_pictovalue.png. - $this->picto='marges'; + $this->picto='margin'; // Data directories to create when module is enabled. $this->dirs = array('/margin/temp'); // Config pages. Put here list of php page names stored in admmin directory used to setup module. - $this->config_page_url = array("margin.php"); + $this->config_page_url = array("margin.php@margin"); // Dependencies $this->depends = array("modPropale", "modProduct"); // List of modules id that must be enabled if this module is enabled @@ -98,62 +98,19 @@ class modMargin extends DolibarrModules // left menu entry $this->menu[$r]=array( - 'fk_menu'=>0, // Put 0 if this is a top menu - 'type'=>'top', // This is a Top menu entry + 'fk_menu'=>'fk_mainmenu=accountancy', // Put 0 if this is a top menu + 'type'=>'left', // This is a Top menu entry 'titre'=>'Margins', - 'mainmenu'=>'margins', - 'leftmenu'=>'1', // Use 1 if you also want to add left menu entries using this descriptor. Use 0 if left menu entries are defined in a file pre.inc.php (old school). + 'mainmenu'=>'accountancy', + 'leftmenu'=>'margins', // Use 1 if you also want to add left menu entries using this descriptor. Use 0 if left menu entries are defined in a file pre.inc.php (old school). 'url'=>'/margin/index.php', 'langs'=>'margins', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. 'position'=>100, - 'enabled'=>'1', // Define condition to show or hide menu entry. Use '$conf->monmodule->enabled' if entry must be visible if module is enabled. + 'enabled'=>'$conf->margin->enabled', // Define condition to show or hide menu entry. Use '$conf->monmodule->enabled' if entry must be visible if module is enabled. 'perms'=>'1', // Use 'perms'=>'$user->rights->monmodule->level1->level2' if you want your menu with a permission rules 'target'=>'', 'user'=>2); // 0=Menu for internal users, 1=external users, 2=both $r++; - - // top menu entry - $this->menu[$r]=array( - 'fk_menu'=>'r=0', // Use r=value where r is index key used for the parent menu entry (higher parent must be a top menu entry) - 'type'=>'left', // This is a Left menu entry - 'titre'=>'ProductMargins', - 'mainmenu'=>'margins', - 'url'=>'/margin/productMargins.php', - 'langs'=>'margins', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. - 'position'=>100, - 'enabled'=>'1', // Define condition to show or hide menu entry. Use '$conf->monmodule->enabled' if entry must be visible if module is enabled. - 'perms'=>'1', // Use 'perms'=>'$user->rights->monmodule->level1->level2' if you want your menu with a permission rules - 'target'=>'', - 'user'=>2); // 0=Menu for internal users,1=external users, 2=both - $r++; - - $this->menu[$r]=array( - 'fk_menu'=>'r=0', // Use r=value where r is index key used for the parent menu entry (higher parent must be a top menu entry) - 'type'=>'left', // This is a Left menu entry - 'titre'=>'CustomerMargins', - 'mainmenu'=>'margins', - 'url'=>'/margin/customerMargins.php', - 'langs'=>'margins', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. - 'position'=>200, - 'enabled'=>'1', // Define condition to show or hide menu entry. Use '$conf->monmodule->enabled' if entry must be visible if module is enabled. - 'perms'=>'1', // Use 'perms'=>'$user->rights->monmodule->level1->level2' if you want your menu with a permission rules - 'target'=>'', - 'user'=>2); // 0=Menu for internal users,1=external users, 2=both - $r++; - - $this->menu[$r]=array( - 'fk_menu'=>'r=0', // Use r=value where r is index key used for the parent menu entry (higher parent must be a top menu entry) - 'type'=>'left', // This is a Left menu entry - 'titre'=>'AgentMargins', - 'mainmenu'=>'margins', - 'url'=>'/margin/agentMargins.php', - 'langs'=>'margins', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. - 'position'=>300, - 'enabled'=>'1', // Define condition to show or hide menu entry. Use '$conf->monmodule->enabled' if entry must be visible if module is enabled. - 'perms'=>'1', // Use 'perms'=>'$user->rights->monmodule->level1->level2' if you want your menu with a permission rules - 'target'=>'', - 'user'=>2); // 0=Menu for internal users,1=external users, 2=both - $r++; } /** diff --git a/htdocs/core/modules/societe/doc/doc_generic_odt.modules.php b/htdocs/core/modules/societe/doc/doc_generic_odt.modules.php index 67b6e76998c..5b7a3a8a2e6 100644 --- a/htdocs/core/modules/societe/doc/doc_generic_odt.modules.php +++ b/htdocs/core/modules/societe/doc/doc_generic_odt.modules.php @@ -160,7 +160,7 @@ class doc_generic_odt extends ModeleThirdPartyDoc * @param string $srctemplatepath Full path of source filename for generator using a template file * @return int 1 if OK, <=0 if KO */ - function write_file(&$object,$outputlangs,$srctemplatepath) + function write_file($object,$outputlangs,$srctemplatepath) { global $user,$langs,$conf,$mysoc; diff --git a/htdocs/core/modules/societe/modules_societe.class.php b/htdocs/core/modules/societe/modules_societe.class.php index a627ccdc3fb..491b511d6fd 100644 --- a/htdocs/core/modules/societe/modules_societe.class.php +++ b/htdocs/core/modules/societe/modules_societe.class.php @@ -370,7 +370,7 @@ abstract class ModeleAccountancyCode * @param Translate $outputlangs Object lang to use for translation * @return int <0 if KO, >0 if OK */ -function thirdparty_doc_create($db, &$object, $message, $modele, $outputlangs) +function thirdparty_doc_create($db, $object, $message, $modele, $outputlangs) { global $conf,$langs,$user; $langs->load("bills"); @@ -416,7 +416,7 @@ function thirdparty_doc_create($db, &$object, $message, $modele, $outputlangs) if ($obj->write_file($object, $outputlangs, $srctemplatepath) > 0) { $outputlangs->charset_output=$sav_charset_output; - + // Appel des triggers include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php"); $interface=new Interfaces($db); @@ -425,7 +425,7 @@ function thirdparty_doc_create($db, &$object, $message, $modele, $outputlangs) $error++; $this->errors=$interface->errors; } // Fin appel triggers - + return 1; } else diff --git a/htdocs/expedition/fiche.php b/htdocs/expedition/fiche.php index efa3d132d24..fc8c2ed7855 100644 --- a/htdocs/expedition/fiche.php +++ b/htdocs/expedition/fiche.php @@ -781,9 +781,9 @@ if ($action == 'create') if ($line->product_type == 0 || ! empty($conf->global->STOCK_SUPPORTS_SERVICES)) { // Show warehouse combo list - $ent = "entl".$indiceAsked; - $idl = "idl".$indiceAsked; - $tmpentrepot_id = is_numeric(GETPOST($ent,'int'))?GETPOST($ent,'int'):GETPOST('entrepot_id','int'); + $ent = "entl".$indiceAsked; + $idl = "idl".$indiceAsked; + $tmpentrepot_id = is_numeric(GETPOST($ent,'int'))?GETPOST($ent,'int'):GETPOST('entrepot_id','int'); print $formproduct->selectWarehouses($tmpentrepot_id,'entl'.$indiceAsked,'',1,0,$line->fk_product); if ($tmpentrepot_id && $tmpentrepot_id == GETPOST('entrepot_id','int')) { diff --git a/htdocs/expedition/shipment.php b/htdocs/expedition/shipment.php index 88fc29c764c..082e9e11228 100644 --- a/htdocs/expedition/shipment.php +++ b/htdocs/expedition/shipment.php @@ -231,15 +231,7 @@ if ($id > 0 || ! empty($ref)) // Date print '
'.$langs->trans('Date').''.dol_print_date($commande->date,'daytext').''.$langs->trans('Source').' : '.$commande->getLabelSource(); - if ($commande->source == 0 && $conf->propal->enabled && $commande->propale_id) - { - // Si source = propal - $propal = new Propal($db); - $propal->fetch($commande->propale_id); - print ' -> '.$propal->ref.''; - } - print ''.$langs->trans('Source').' : '.$commande->getLabelSource().'
id.'">'.img_edit($langs->trans('SetConditions'),1).'id.'">'.img_edit($langs->trans('SetConditions'),1).'
'; print ''; if ($action == 'editconditions') @@ -294,7 +286,7 @@ if ($id > 0 || ! empty($ref)) print ''; - if ($actionº != 'editmode' && $commande->brouillon) print ''; + if ($action != 'editmode' && ! empty($commande->brouillon)) print ''; print '
'; print $langs->trans('PaymentMode'); print 'id.'">'.img_edit($langs->trans('SetMode'),1).'id.'">'.img_edit($langs->trans('SetMode'),1).'
'; print ''; if ($action == 'editmode') @@ -394,7 +386,8 @@ if ($id > 0 || ! empty($ref)) print "\n"; $var=true; - $reste_a_livrer = array(); + $toBeShipped=array(); + $toBeShippedTotal=0; while ($i < $num) { $objp = $db->fetch_object($resql); @@ -412,25 +405,25 @@ if ($id > 0 || ! empty($ref)) // Product label if ($objp->fk_product > 0) { - // Define output language - if (! empty($conf->global->MAIN_MULTILANGS) && ! empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) - { - $commande->fetch_thirdparty(); - $prod = new Product($db, $objp->fk_product); - $outputlangs = $langs; - $newlang=''; - if (empty($newlang) && ! empty($_REQUEST['lang_id'])) $newlang=$_REQUEST['lang_id']; - if (empty($newlang)) $newlang=$commande->client->default_lang; - if (! empty($newlang)) - { - $outputlangs = new Translate("",$conf); - $outputlangs->setDefaultLang($newlang); - } + // Define output language + if (! empty($conf->global->MAIN_MULTILANGS) && ! empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) + { + $commande->fetch_thirdparty(); + $prod = new Product($db, $objp->fk_product); + $outputlangs = $langs; + $newlang=''; + if (empty($newlang) && ! empty($_REQUEST['lang_id'])) $newlang=$_REQUEST['lang_id']; + if (empty($newlang)) $newlang=$commande->client->default_lang; + if (! empty($newlang)) + { + $outputlangs = new Translate("",$conf); + $outputlangs->setDefaultLang($newlang); + } - $label = (! empty($prod->multilangs[$outputlangs->defaultlang]["libelle"])) ? $prod->multilangs[$outputlangs->defaultlang]["libelle"] : $objp->product_label; - } - else - $label = $objp->product_label; + $label = (! empty($prod->multilangs[$outputlangs->defaultlang]["libelle"])) ? $prod->multilangs[$outputlangs->defaultlang]["libelle"] : $objp->product_label; + } + else + $label = $objp->product_label; print ''; print ''; // ancre pour retourner sur la ligne @@ -475,17 +468,17 @@ if ($id > 0 || ! empty($ref)) $qtyProdCom=$objp->qty; print ''; // Nb of sending products for this line of order - $quantite_livree = $commande->expeditions[$objp->rowid]; - print $quantite_livree; + $qtyAlreadyShipped = (! empty($commande->expeditions[$objp->rowid])?$commande->expeditions[$objp->rowid]:0); + print $qtyAlreadyShipped; print ''; // Qty remains to ship print ''; if ($type == 0 || ! empty($conf->global->STOCK_SUPPORTS_SERVICES)) { - $reste_a_livrer[$objp->fk_product] = $objp->qty - $quantite_livree; - $reste_a_livrer_total += $reste_a_livrer[$objp->fk_product]; - print $reste_a_livrer[$objp->fk_product]; + $toBeShipped[$objp->fk_product] = $objp->qty - $qtyAlreadyShipped; + $toBeShippedTotal += $toBeShipped[$objp->fk_product]; + print $toBeShipped[$objp->fk_product]; } else { @@ -503,7 +496,7 @@ if ($id > 0 || ! empty($ref)) { print ''; print $product->stock_reel; - if ($product->stock_reel < $reste_a_livrer[$objp->fk_product]) + if ($product->stock_reel < $toBeShipped[$objp->fk_product]) { print ' '.img_warning($langs->trans("StockTooLow")); } @@ -580,7 +573,7 @@ if ($id > 0 || ! empty($ref)) if ($user->rights->expedition->creer) { print ''.$langs->trans("NewSending").''; - if ($reste_a_livrer_total <= 0) + if ($toBeShippedTotal <= 0) { print ' '.img_warning($langs->trans("WarningNoQtyLeftToSend")); } @@ -625,7 +618,7 @@ if ($id > 0 || ! empty($ref)) } print ''; print ''; - if ($reste_a_livrer_total <= 0) + if ($toBeShippedTotal <= 0) { print ' '.img_warning($langs->trans("WarningNoQtyLeftToSend")); } diff --git a/htdocs/exports/class/export.class.php b/htdocs/exports/class/export.class.php index bc4b9ee1265..013e41e2fea 100644 --- a/htdocs/exports/class/export.class.php +++ b/htdocs/exports/class/export.class.php @@ -24,8 +24,7 @@ /** - * \class Export - * \brief Class to manage exports + * Class to manage exports */ class Export { @@ -36,7 +35,8 @@ class Export var $array_export_label=array(); // Tableau de "libelle de lots" var $array_export_sql=array(); // Tableau des "requetes sql" var $array_export_fields=array(); // Tableau des listes de champ+libelle a exporter - //var $array_export_alias=array(); // Tableau des listes de champ+alias a exporter + var $array_export_entities=array(); // Tableau des listes de champ+alias a exporter + var $array_export_dependencies=array(); // array of list of entities that must take care of the DISTINCT if a field is added into export var $array_export_special=array(); // Tableau des operations speciales sur champ // To store export modules @@ -162,6 +162,8 @@ class Export $this->array_export_fields[$i]=$module->export_fields_array[$r]; // Tableau des entites a exporter (cle=champ, valeur=entite) $this->array_export_entities[$i]=$module->export_entities_array[$r]; + // Tableau des entites qui requiert abandon du DISTINCT (cle=entite, valeur=champ id child records) + $this->array_export_dependencies[$i]=$module->export_dependencies_array[$r]; // Tableau des operations speciales sur champ $this->array_export_special[$i]=$module->export_special_array[$r]; diff --git a/htdocs/exports/export.php b/htdocs/exports/export.php index 0670724d264..3fca99ee8fc 100644 --- a/htdocs/exports/export.php +++ b/htdocs/exports/export.php @@ -64,12 +64,13 @@ $entitytolang=array( // Translation code ); $array_selected=isset($_SESSION["export_selected_fields"])?$_SESSION["export_selected_fields"]:array(); -$datatoexport=isset($_GET["datatoexport"])? $_GET["datatoexport"] : (isset($_POST["datatoexport"])?$_POST["datatoexport"]:''); -$action=isset($_GET["action"]) ? $_GET["action"] : (isset($_POST["action"])?$_POST["action"]:''); -$step=isset($_GET["step"])? $_GET["step"] : (isset($_POST["step"])?$_POST["step"]:1); -$export_name=isset($_POST["export_name"])? $_POST["export_name"] : ''; -$hexa=isset($_POST["hexa"])? $_POST["hexa"] : ''; -$exportmodelid=isset($_POST["exportmodelid"])? $_POST["exportmodelid"] : ''; +$datatoexport=GETPOST("datatoexport"); +$action=GETPOST("action"); +$step=GETPOST("step")?GETPOST("step"):1; +$export_name=GETPOST("export_name"); +$hexa=GETPOST("hexa"); +$exportmodelid=GETPOST("exportmodelid"); +$field=GETPOST("field"); $objexport=new Export($db); $objexport->load_arrays($user,$datatoexport); @@ -87,12 +88,15 @@ $sqlusedforexport=''; if ($action=='selectfield') { - if ($_GET["field"]=='all') + $fieldsarray=$objexport->array_export_fields[0]; + $fieldsentitiesarray=$objexport->array_export_entities[0]; + $fieldsdependenciesarray=$objexport->array_export_dependencies[0]; + + if ($field=='all') { - $fieldsarray=$objexport->array_export_fields[0]; foreach($fieldsarray as $key=>$val) { - if (! empty($array_selected[$key])) continue; // If already selected, select next + if (! empty($array_selected[$key])) continue; // If already selected, check next $array_selected[$key]=count($array_selected)+1; //print_r($array_selected); $_SESSION["export_selected_fields"]=$array_selected; @@ -100,7 +104,13 @@ if ($action=='selectfield') } else { - $array_selected[$_GET["field"]]=count($array_selected)+1; + $array_selected[$field]=count($array_selected)+1; // We tag the key $field as "selected" + // We check if there is a dependency + if (! empty($fieldsdependenciesarray[$fieldsentitiesarray[$field]])) + { + // TODO Show warning "risk of duplicate record filtered" + + } //print_r($array_selected); $_SESSION["export_selected_fields"]=$array_selected; } diff --git a/htdocs/fichinter/document.php b/htdocs/fichinter/document.php index 3cc37c7959b..03ecf75522c 100644 --- a/htdocs/fichinter/document.php +++ b/htdocs/fichinter/document.php @@ -43,13 +43,6 @@ $ref = GETPOST('ref', 'alpha'); $action = GETPOST('action','alpha'); $confirm = GETPOST('confirm','alpha'); -$mesg=''; -if (isset($_SESSION['DolMessage'])) -{ - $mesg=$_SESSION['DolMessage']; - unset($_SESSION['DolMessage']); -} - // Security check if ($user->societe_id) $socid=$user->societe_id; $result = restrictedArea($user, 'ficheinter', $id, 'fichinter'); @@ -128,7 +121,7 @@ else if ($action == 'confirm_deletefile' && $confirm == 'yes') $file = $upload_dir . '/' . GETPOST('urlfile'); // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP). dol_delete_file($file,0,0,0,$object); - $_SESSION['DolMessage'] = '
'.$langs->trans("FileWasRemoved",GETPOST('urlfile')).'
'; + $_SESSION['dol_message'] = '
'.$langs->trans("FileWasRemoved",GETPOST('urlfile')).'
'; Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id); exit; } @@ -177,9 +170,9 @@ if ($object->id) print ''; print ''; - + dol_htmloutput_mesg($mesg,$mesgs); - + /* * Confirmation suppression fichier */ diff --git a/htdocs/filefunc.inc.php b/htdocs/filefunc.inc.php index ffa61de2c9c..f0471874ea4 100755 --- a/htdocs/filefunc.inc.php +++ b/htdocs/filefunc.inc.php @@ -77,7 +77,7 @@ if (! $result && ! empty($_SERVER["GATEWAY_INTERFACE"])) // If install not do // Force PHP error_reporting setup (Dolibarr may report warning without this) if (! empty($dolibarr_strict_mode)) -{ +{ error_reporting(E_ALL | E_STRICT); } else diff --git a/htdocs/fourn/commande/document.php b/htdocs/fourn/commande/document.php index d35b8900596..94483274ef7 100644 --- a/htdocs/fourn/commande/document.php +++ b/htdocs/fourn/commande/document.php @@ -46,14 +46,6 @@ $ref = GETPOST('ref', 'alpha'); $action = GETPOST('action','alpha'); $confirm = GETPOST('confirm','alpha'); -$mesg=''; -$mesgs=array(); -if (isset($_SESSION['DolMessage'])) -{ - $mesg=$_SESSION['DolMessage']; - unset($_SESSION['DolMessage']); -} - // Security check if ($user->societe_id) $socid=$user->societe_id; $result = restrictedArea($user, 'commande_fournisseur', $id,''); @@ -130,7 +122,7 @@ else if ($action == 'confirm_deletefile' && $confirm == 'yes') $file = $upload_dir . '/' . GETPOST('urlfile'); // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP). dol_delete_file($file,0,0,0,$object); - $_SESSION['DolMessage'] = '
'.$langs->trans("FileWasRemoved",GETPOST('urlfile')).'
'; + $_SESSION['dol_message'] = '
'.$langs->trans("FileWasRemoved",GETPOST('urlfile')).'
'; Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id); exit; } diff --git a/htdocs/install/lib/repair.lib.php b/htdocs/install/lib/repair.lib.php index c1f43865466..d965c1ff9c8 100644 --- a/htdocs/install/lib/repair.lib.php +++ b/htdocs/install/lib/repair.lib.php @@ -141,7 +141,7 @@ function clean_data_ecm_directories() } else dol_print_error($db,'Failed to run request'); - return; + return; } ?> diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 530216d2bae..9074c85c2d6 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -75,8 +75,8 @@ AntiVirusCommandExample= Example for ClamWin: c:\Progra~1\ClamWin\bin\clamscan.e AntiVirusParam= More parameters on command line AntiVirusParamExample= Example for ClamWin: --database="C:\Program Files (x86)\ClamWin\lib" ComptaSetup=Accounting module setup -UserSetup=User's management setup -MenuSetup=Menu's management setup +UserSetup=User management setup +MenuSetup=Menu management setup MenuLimits=Limits and accuracy MenuIdParent=Parent menu ID DetailMenuIdParent=ID of parent menu (0 for a top menu) @@ -216,7 +216,7 @@ OfficialWiki=Dolibarr documentation on Wiki OfficialDemo=Dolibarr online demo OfficialMarketPlace=Official market place for external modules/addons OfficialWebHostingService=Official web hosting service (Cloud hosting) -ForDocumentationSeeWiki=For user's or developer's documentation (Doc, FAQs...),
take a look at the Dolibarr Wiki:
%s +ForDocumentationSeeWiki=For user or developer documentation (Doc, FAQs...),
take a look at the Dolibarr Wiki:
%s ForAnswersSeeForum=For any other questions/help, you can use the Dolibarr forum:
%s HelpCenterDesc1=This area can help you to get a Help support service on Dolibarr. HelpCenterDesc2=Some part of this service are available in english only. @@ -333,53 +333,53 @@ ButtonHideUnauthorized=Hide buttons unauthorized (instead of seeing gray) Module0Name=Users & groups Module0Desc=Users and groups management Module1Name=Third parties -Module1Desc=Companies and contact's management +Module1Desc=Companies and contact management Module2Name=Commercial Module2Desc=Commercial management Module10Name=Accounting Module10Desc=Simple accounting management (invoice and payment dispatching) Module20Name=Proposals -Module20Desc=Commercial proposal's management +Module20Desc=Commercial proposal management Module22Name=Mass E-mailings -Module22Desc=Mass E-mailing's management +Module22Desc=Mass E-mailing management Module23Name= Energy Module23Desc= Monitoring the consumption of energies Module25Name=Customer Orders -Module25Desc=Customer order's management +Module25Desc=Customer order management Module30Name=Invoices -Module30Desc=Invoices and credit note's management for customers. Invoice's management for suppliers +Module30Desc=Invoice and credit note management for customers. Invoice management for suppliers Module40Name=Suppliers -Module40Desc=Supplier's management and buying (orders and invoices) +Module40Desc=Supplier management and buying (orders and invoices) Module42Name=Logs Module42Desc=Logging facilities (file, syslog, ...) Module49Name=Editors -Module49Desc=Editor's management +Module49Desc=Editor management Module50Name=Products -Module50Desc=Product's management +Module50Desc=Product management Module51Name=Mass mailings -Module51Desc=Mass paper mailing's management +Module51Desc=Mass paper mailing management Module52Name=Stocks -Module52Desc=Stock's management of products +Module52Desc=Stock management (products) Module53Name=Services -Module53Desc=Service's management +Module53Desc=Service management Module54Name=Contracts -Module54Desc=Contract's and service's management +Module54Desc=Contract and service management Module55Name=Barcodes -Module55Desc=Barcode's management +Module55Desc=Barcode management Module56Name=Telephony Module56Desc=Telephony integration Module57Name=Standing orders -Module57Desc=Standing orders and withdrawal's management +Module57Desc=Standing orders and withdrawal management Module58Name=ClickToDial Module58Desc=Integration of a ClickToDial system (Asterisk, ...) Module59Name=Bookmark4u Module59Desc=Add function to generate Bookmark4u account from a Dolibarr account Module70Name=Interventions -Module70Desc=Intervention's management -Module75Name=Expenses and trips notes -Module75Desc=Expenses and trips note's management +Module70Desc=Intervention management +Module75Name=Expense and trip notes +Module75Desc=Expense and trip notes management Module80Name=Shipments -Module80Desc=Shipments and delivery order's management +Module80Desc=Shipments and delivery order management Module85Name=Banks and cash Module85Desc=Management of bank or cash accounts Module100Name=External site @@ -399,17 +399,17 @@ Module310Desc=Foundation members management Module320Name=RSS Feed Module320Desc=Add RSS feed inside Dolibarr screen pages Module330Name=Bookmarks -Module330Desc=Bookmark's management +Module330Desc=Bookmark management Module400Name=Projects -Module400Desc=Project's management inside other modules +Module400Desc=Project management inside other modules Module410Name=Webcalendar Module410Desc=Webcalendar integration Module500Name=Taxes, social contributions and dividends -Module500Desc=Taxes and social contribution's management +Module500Desc=Taxes and social contribution management Module600Name=Notifications -Module600Desc=Send notifications by email on some Dolibarr business events to third party's contacts +Module600Desc=Send notifications by email on some Dolibarr business events to third party contacts Module700Name=Donations -Module700Desc=Donation's management +Module700Desc=Donation management Module800Name=OSCommerce by direct database access Module800Desc=Interface to show an OSCommerce or OSCSS shop via direct database access Module900Name=OSCommerce by WS @@ -419,13 +419,13 @@ Module1200Desc=Mantis integration Module1400Name=Accounting Module1400Desc=Accounting management (double parties) Module1780Name=Categories -Module1780Desc=Categorie's management (products, suppliers and customers) +Module1780Desc=Category management (products, suppliers and customers) Module2000Name=WYSIWYG editor Module2000Desc=Allow to edit some text area using an advanced editor Module2200Name=Lending rights Module2200Desc=Lending rights management Module2300Name=Menus -Module2300Desc=Menu's management +Module2300Desc=Menu management Module2400Name=Agenda Module2400Desc=Events/tasks and agenda management Module2500Name=Electronic Content Management @@ -493,7 +493,7 @@ Permission94=Export social contributions Permission95=Read reports Permission96=Setup dispatching Permission97=Read invoice accountancy dispatching -Permission98=Dispatch invoice's accountancy lines +Permission98=Dispatch invoice accountancy lines Permission101=Read sendings Permission102=Create/modify sendings Permission104=Validate sendings @@ -612,8 +612,8 @@ Permission703=Delete donations Permission1001=Read stocks Permission1002=Create/modify stocks Permission1003=Delete stocks -Permission1004=Read stock's movements -Permission1005=Create/modify stock's movements +Permission1004=Read stock movements +Permission1005=Create/modify stock movements Permission1101=Read delivery orders Permission1102=Create/modify delivery orders Permission1104=Validate delivery orders @@ -729,7 +729,7 @@ TableName=Table name TableLineFormat=Line format NbOfRecord=Nb of records Constraints=Constraints -ConstraintsType=Constraint's type +ConstraintsType=Constraints type ConstraintsToShowOrNotEntry=Constraint to show or not the menu entry AllMustBeOk=All of these must be checked Host=Server @@ -961,7 +961,7 @@ UseOptionLineIfNoQuantity=A line of product/service with a zero amount is consid FreeLegalTextOnProposal=Free text on commercial proposals WatermarkOnDraftProposal=Watermark on draft commercial proposals (any if empty) ##### Orders ##### -OrdersSetup=Order's management setup +OrdersSetup=Order management setup OrdersNumberingModules=Orders numbering modules OrdersModelModule=Order documents models HideTreadedOrders=Hide the treated or canceled orders in the list @@ -1033,7 +1033,7 @@ LDAPDnMemberActive=Members' synchronization LDAPDnMemberActiveExample=Activated/Unactivated synchronization LDAPContactDn=Dolibarr contacts' DN LDAPContactDnExample=Complete DN (ex: ou=contacts,dc=society,dc=com) -LDAPMemberDn=Dolibarr member's DN +LDAPMemberDn=Dolibarr members DN LDAPMemberDnExample=Complete DN (ex: ou=members,dc=society,dc=com) LDAPMemberObjectClassList=List of objectClass LDAPMemberObjectClassListExample=List of objectClass defining record attributes (ex: top,inetOrgPerson or top,user for active directory) @@ -1043,13 +1043,13 @@ LDAPGroupObjectClassList=List of objectClass LDAPGroupObjectClassListExample=List of objectClass defining record attributes (ex: top,groupOfUniqueNames) LDAPContactObjectClassList=List of objectClass LDAPContactObjectClassListExample=List of objectClass defining record attributes (ex: top,inetOrgPerson or top,user for active directory) -LDAPMemberTypeDn=Dolibarr member's type DN +LDAPMemberTypeDn=Dolibarr members type DN LDAPMemberTypeDnExample=Complete DN (ex: ou=type_members,dc=society,dc=com) LDAPTestConnect=Test LDAP connection -LDAPTestSynchroContact=Test contact's synchronization -LDAPTestSynchroUser=Test user's synchronization -LDAPTestSynchroGroup=Test group's synchronization -LDAPTestSynchroMember=Test member's synchronization +LDAPTestSynchroContact=Test contacts synchronization +LDAPTestSynchroUser=Test user synchronization +LDAPTestSynchroGroup=Test group synchronization +LDAPTestSynchroMember=Test member synchronization LDAPSynchroOK=Synchronization test successful LDAPSynchroKO=Failed synchronization test LDAPSynchroKOMayBePermissions=Failed synchronization test. Check that connexion to server is correctly configured and allows LDAP udpates @@ -1189,8 +1189,8 @@ FreeLegalTextOnDeliveryReceipts=Free text on delivery receipts ##### FCKeditor ##### AdvancedEditor=Advanced editor ActivateFCKeditor=Activate advanced editor for: -FCKeditorForCompany=WYSIWIG creation/edition of element's description and note (except products/services) -FCKeditorForProduct=WYSIWIG creation/edition of products/service's description and note +FCKeditorForCompany=WYSIWIG creation/edition of elements description and note (except products/services) +FCKeditorForProduct=WYSIWIG creation/edition of products/services description and note FCKeditorForProductDetails=WYSIWIG creation/edition of products details lines for all entities (proposals, orders, invoices, etc...). Warning: Using this option for this case is seriously not recommanded as it can create problems with special characters and page formating when building PDF files. FCKeditorForMailing=WYSIWIG creation/edition of mailings ##### OSCommerce 1 ##### @@ -1309,4 +1309,4 @@ TestGeoIPResult=Test of a conversion IP -> country ##### Projects ##### ProjectsNumberingModules=Projects numbering module ProjectsSetup=Project module setup -ProjectsModelModule=Project's report document model +ProjectsModelModule=Project reports document model diff --git a/htdocs/langs/fr_FR/commissions.lang b/htdocs/langs/fr_FR/commissions.lang index 350b12a8099..97dd17d9cba 100644 --- a/htdocs/langs/fr_FR/commissions.lang +++ b/htdocs/langs/fr_FR/commissions.lang @@ -23,14 +23,14 @@ ProductCommission=Commission / produits ServiceCommission=Commission / services CommissionBase=Base de calcul des commissions -CommissionBasedOnCA=Commissions calculées sur le CA +CommissionBasedOnTurnover=Commissions calculées sur le CA CommissionBasedOnMargins=Commissions calculées sur les marges CommissionBaseDetails=Définit le mode de calcul des commissions CommissionBasedOnMarginsDetails=Le calcul basé sur les marges nécessite l'activation du module marges. -CATotal = Chiffre d'affaire réalisé HT -ProductCA=CA HT / produits -ServiceCA=CA HT / services +TurnoverTotal = Chiffre d'affaire réalisé HT +ProductTurnover=CA HT / produits +ServiceTurnover=CA HT / services CommercialAgent=Agent commercial diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 7d8a41d5740..ed3320135fc 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -721,6 +721,14 @@ $bc=array(0=>'class="impair"',1=>'class="pair"'); $bcdd=array(0=>'class="impair drag drop"',1=>'class="pair drag drop"'); $bcnd=array(0=>'class="impair nodrag nodrop"',1=>'class="pair nodrag nodrop"'); +// Define messages variables +$mesg=''; $mesgs=array(); +if (isset($_SESSION['dol_message'])) +{ + $mesgs[]=$_SESSION['dol_message']; + unset($_SESSION['dol_message']); +} + // Constants used to defined number of lines in textarea if (empty($conf->browser->firefox)) { diff --git a/htdocs/admin/margin.php b/htdocs/margin/admin/margin.php similarity index 97% rename from htdocs/admin/margin.php rename to htdocs/margin/admin/margin.php index 782d4df55e0..1396c8c13a0 100644 --- a/htdocs/admin/margin.php +++ b/htdocs/margin/admin/margin.php @@ -16,12 +16,12 @@ */ /** - * \file /htdocs/admin/margin.php + * \file /htdocs/margin/admin/margin.php * \ingroup margin * \brief Page to setup margin module */ -include("../main.inc.php"); +include("../../main.inc.php"); require_once(DOL_DOCUMENT_ROOT."/margin/lib/margins.lib.php"); require_once(DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php"); @@ -121,7 +121,7 @@ $form = new Form($db); // GLOBAL DISCOUNT MANAGEMENT $var=!$var; -print "
"; +print ''; print ''; print ""; print ''; @@ -219,7 +219,7 @@ print ''; // GLOBAL DISCOUNT MANAGEMENT $var=!$var; -print ""; +print ''; print ''; print ""; print ''; diff --git a/htdocs/margin/agentMargins.php b/htdocs/margin/agentMargins.php index f11db0f42f4..82961207c56 100644 --- a/htdocs/margin/agentMargins.php +++ b/htdocs/margin/agentMargins.php @@ -39,12 +39,16 @@ $mesg = ''; $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); +if (! $sortorder) $sortorder="ASC"; +if (! $sortfield) $sortfield="s.nom"; $page = GETPOST("page",'int'); if ($page == -1) { $page = 0; } $offset = $conf->liste_limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; +$startdate=$enddate=''; + if (!empty($_POST['startdatemonth'])) $startdate = date('Y-m-d', dol_mktime(12, 0, 0, $_POST['startdatemonth'], $_POST['startdateday'], $_POST['startdateyear'])); if (!empty($_POST['enddatemonth'])) @@ -68,30 +72,16 @@ print_fiche_titre($text); // Show tabs $head=marges_prepare_head($user); $titre=$langs->trans("Margins"); -$picto='marges'; +$picto='margin'; dol_fiche_head($head, 'agentMargins', $titre, 0, $picto); print ''; print ''; -if ($agentid > 0) { - - print ''; - print ''; - - if (! $sortorder) $sortorder="ASC"; - if (! $sortfield) $sortfield="s.nom"; -} -else { - print ''; - print ''; - if (! $sortorder) $sortorder="ASC"; - if (! $sortfield) $sortfield="u.login"; -} +print ''; +print ''; // Start date print ''; @@ -112,14 +102,14 @@ print ''; // set by jquery (see below) print ''; // Margin Rate -if ($conf->global->DISPLAY_MARGIN_RATES) { +if (! empty($conf->global->DISPLAY_MARGIN_RATES)) { print ''; } // Mark Rate -if ($conf->global->DISPLAY_MARK_RATES) { +if (! empty($conf->global->DISPLAY_MARK_RATES)) { print ''; @@ -163,24 +153,25 @@ if ($result) { $num = $db->num_rows($result); - print '
'; - print_barre_liste($langs->trans("MarginDetails"),$page,$_SERVER["PHP_SELF"],"&socid=$societe->id",$sortfield,$sortorder,'',$num,0,''); + print '
'; + print_barre_liste($langs->trans("MarginDetails"),$page,$_SERVER["PHP_SELF"],"",$sortfield,$sortorder,'',$num,0,''); $i = 0; print "
'.$langs->trans('CommercialAgent').''; - print $form->select_dolusers($selected=$agentid,$htmlname='agentid',$show_empty=1,$exclude='',$disabled=0,$include='',$enableonly=''); - print '
'.$langs->trans('CommercialAgent').''; - print $form->select_dolusers($selected='',$htmlname='agentid',$show_empty=1,$exclude='',$disabled=0,$include='',$enableonly=''); - print '
'.$langs->trans('CommercialAgent').''; +print $form->select_dolusers($agentid,'agentid',1); +print '
'.$langs->trans('StartDate').'
'.$langs->trans("MarginRate").''; print ''; // set by jquery (see below) print '
'.$langs->trans("MarkRate").''; print ''; // set by jquery (see below) print '
"; print ''; if ($agentid > 0) - print_liste_field_titre($langs->trans("Customer"),$_SERVER["PHP_SELF"],"s.nom","","&agentid=".$_REQUEST["agentid"],'align="center"',$sortfield,$sortorder); - else - print_liste_field_titre($langs->trans("CommercialAgent"),$_SERVER["PHP_SELF"],"u.login","","&agentid=".$_REQUEST["agentid"],'align="center"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("SellingPrice"),$_SERVER["PHP_SELF"],"selling_price","","&agentid=".$_REQUEST["agentid"],'align="right"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("BuyingPrice"),$_SERVER["PHP_SELF"],"buyng_price","","&agentid=".$_REQUEST["agentid"],'align="right"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("Margin"),$_SERVER["PHP_SELF"],"marge","","&agentid=".$_REQUEST["agentid"],'align="right"',$sortfield,$sortorder); - if ($conf->global->DISPLAY_MARGIN_RATES) - print_liste_field_titre($langs->trans("MarginRate"),$_SERVER["PHP_SELF"],"d.marge_tx","","&agentid=".$_REQUEST["agentid"],'align="right"',$sortfield,$sortorder); - if ($conf->global->DISPLAY_MARK_RATES) - print_liste_field_titre($langs->trans("MarkRate"),$_SERVER["PHP_SELF"],"d.marque_tx","","&agentid=".$_REQUEST["agentid"],'align="right"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Customer"),$_SERVER["PHP_SELF"],"s.nom","","&agentid=".$agentid,'align="center"',$sortfield,$sortorder); + else + print_liste_field_titre($langs->trans("CommercialAgent"),$_SERVER["PHP_SELF"],"u.login","","&agentid=".$agentid,'align="center"',$sortfield,$sortorder); + + print_liste_field_titre($langs->trans("SellingPrice"),$_SERVER["PHP_SELF"],"selling_price","","&agentid=".$agentid,'align="right"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("BuyingPrice"),$_SERVER["PHP_SELF"],"buyng_price","","&agentid=".$agentid,'align="right"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Margin"),$_SERVER["PHP_SELF"],"marge","","&agentid=".$agentid,'align="right"',$sortfield,$sortorder); + if (! empty($conf->global->DISPLAY_MARGIN_RATES)) + print_liste_field_titre($langs->trans("MarginRate"),$_SERVER["PHP_SELF"],"d.marge_tx","","&agentid=".$agentid,'align="right"',$sortfield,$sortorder); + if (! empty($conf->global->DISPLAY_MARK_RATES)) + print_liste_field_titre($langs->trans("MarkRate"),$_SERVER["PHP_SELF"],"d.marque_tx","","&agentid=".$agentid,'align="right"',$sortfield,$sortorder); print "\n"; $cumul_achat = 0; @@ -188,34 +179,34 @@ if ($result) $cumul_qty = 0; if ($num > 0) { - $var=True; + $var=true; while ($i < $num && $i < $conf->liste_limit) { $objp = $db->fetch_object($result); - $marginRate = ($objp->buying_price != 0)?(100 * round($objp->marge / $objp->buying_price ,5)):'' ; - $markRate = ($objp->selling_price != 0)?(100 * round($objp->marge / $objp->selling_price ,5)):'' ; + $marginRate = ($objp->buying_price != 0)?(100 * round($objp->marge / $objp->buying_price, 5)):''; + $markRate = ($objp->selling_price != 0)?(100 * round($objp->marge / $objp->selling_price, 5)):''; $var=!$var; print ""; if ($agentid > 0) { - $companystatic->id=$objp->socid; - $companystatic->nom=$objp->nom; - $companystatic->client=$objp->client; - print "\n"; - } - else { - $userstatic->id=$objp->agent; - $userstatic->login=$objp->login; - print "\n"; - } + $companystatic->id=$objp->socid; + $companystatic->nom=$objp->nom; + $companystatic->client=$objp->client; + print "\n"; + } + else { + $userstatic->id=$objp->agent; + $userstatic->login=$objp->login; + print "\n"; + } print "\n"; print "\n"; print "\n"; - if ($conf->global->DISPLAY_MARGIN_RATES) + if (! empty($conf->global->DISPLAY_MARGIN_RATES)) print "\n"; - if ($conf->global->DISPLAY_MARK_RATES) + if (! empty($conf->global->DISPLAY_MARK_RATES)) print "\n"; print "\n"; $i++; @@ -227,24 +218,24 @@ if ($result) // affichage totaux marges $var=!$var; $totalMargin = $cumul_vente - $cumul_achat; - $marginRate = ($cumul_achat != 0)?(100 * round($totalMargin / $cumul_achat, 5)):'' ; - $markRate = ($cumul_vente != 0)?(100 * round($totalMargin / $cumul_vente, 5)):'' ; + $marginRate = ($cumul_achat != 0)?(100 * round($totalMargin / $cumul_achat, 5)):''; + $markRate = ($cumul_vente != 0)?(100 * round($totalMargin / $cumul_vente, 5)):''; print ''; - if ($client) - print '"; + if (! empty($client)) + print '"; print "\n"; print "\n"; print "\n"; - if ($conf->global->DISPLAY_MARGIN_RATES) + if (! empty($conf->global->DISPLAY_MARGIN_RATES)) print "\n"; - if ($conf->global->DISPLAY_MARK_RATES) + if (! empty($conf->global->DISPLAY_MARK_RATES)) print "\n"; print "\n"; - print "
".$companystatic->getNomUrl(1,'customer')."".$userstatic->getLoginUrl(1)."".$companystatic->getNomUrl(1,'customer')."".$userstatic->getLoginUrl(1)."".price($objp->selling_price)."".price($objp->buying_price)."".price($objp->marge)."".(($marginRate === '')?'n/a':price($marginRate)."%")."".(($markRate === '')?'n/a':price($markRate)."%")."
'; - else - print ''; - print $langs->trans('TotalMargin')."'; + else + print ''; + print $langs->trans('TotalMargin')."".price($cumul_vente)."".price($cumul_achat)."".price($totalMargin)."".(($marginRate === '')?'n/a':price($marginRate)."%")."".(($markRate === '')?'n/a':price($markRate)."%")."
"; + print ""; } else { diff --git a/htdocs/margin/customerMargins.php b/htdocs/margin/customerMargins.php index 979e67b6345..1953e8c0293 100644 --- a/htdocs/margin/customerMargins.php +++ b/htdocs/margin/customerMargins.php @@ -42,12 +42,16 @@ $mesg = ''; $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); +if (! $sortorder) $sortorder="ASC"; +if (! $sortfield) $sortfield="s.nom"; $page = GETPOST("page",'int'); if ($page == -1) { $page = 0; } $offset = $conf->liste_limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; +$startdate=$enddate=''; + if (!empty($_POST['startdatemonth'])) $startdate = date('Y-m-d', dol_mktime(12, 0, 0, $_POST['startdatemonth'], $_POST['startdateday'], $_POST['startdateyear'])); if (!empty($_POST['enddatemonth'])) @@ -70,37 +74,35 @@ print_fiche_titre($text); // Show tabs $head=marges_prepare_head($user); $titre=$langs->trans("Margins"); -$picto='marges'; +$picto='margin'; dol_fiche_head($head, 'customerMargins', $titre, 0, $picto); print ''; print ''; -$client = null; +$client = false; if ($socid > 0) { - $societe = new Societe($db, $socid); - $societe->fetch($socid); + $soc = new Societe($db, $socid); + $soc->fetch($socid); - if ($societe->client) - { - print ''; - print ''; + if ($soc->client) + { + print ''; + print ''; - $client = true; - if (! $sortorder) $sortorder="DESC"; - if (! $sortfield) $sortfield="f.datef"; - } + $client = true; + if (! $sortorder) $sortorder="DESC"; + if (! $sortfield) $sortfield="f.datef"; + } } -if (!$client) { - print ''; - print ''; - if (! $sortorder) $sortorder="ASC"; - if (! $sortfield) $sortfield="s.nom"; +else { + print ''; + print ''; } // Start date @@ -122,14 +124,14 @@ print ''; // set by jquery (see below) print ''; // Margin Rate -if ($conf->global->DISPLAY_MARGIN_RATES) { +if (! empty($conf->global->DISPLAY_MARGIN_RATES)) { print ''; } // Mark Rate -if ($conf->global->DISPLAY_MARK_RATES) { +if (! empty($conf->global->DISPLAY_MARK_RATES)) { print ''; @@ -169,25 +171,25 @@ if ($result) $num = $db->num_rows($result); print '
'; - print_barre_liste($langs->trans("MarginDetails"),$page,$_SERVER["PHP_SELF"],"&socid=$societe->id",$sortfield,$sortorder,'',$num,0,''); + print_barre_liste($langs->trans("MarginDetails"),$page,$_SERVER["PHP_SELF"],"",$sortfield,$sortorder,'',$num,0,''); $i = 0; print "
'.$langs->trans('ThirdPartyName').''; - $form->form_thirdparty($_SERVER['PHP_SELF'].'?socid='.$socid,$socid,'socid', $filter='client=1',$showempty=1, $showtype=0, $forcecombo=1); - print '
'.$langs->trans('ThirdPartyName').''; + $form->form_thirdparty($_SERVER['PHP_SELF'].'?socid='.$socid,$socid,'socid','client=1',1,0,1); + print '
'.$langs->trans('ThirdPartyName').''; - $form->form_thirdparty($_SERVER['PHP_SELF'].'?socid='.$socid,null,'socid', $filter='client=1',$showempty=1, $showtype=0, $forcecombo=1); - print '
'.$langs->trans('ThirdPartyName').''; + $form->form_thirdparty($_SERVER['PHP_SELF'].'?socid='.$socid,null,'socid','client=1',1,0,1); + print '
'.$langs->trans("MarginRate").''; print ''; // set by jquery (see below) print '
'.$langs->trans("MarkRate").''; print ''; // set by jquery (see below) print '
"; print ''; - if ($client) { - print_liste_field_titre($langs->trans("Invoice"),$_SERVER["PHP_SELF"],"f.facnumber","","&socid=".$_REQUEST["socid"],'',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("DateInvoice"),$_SERVER["PHP_SELF"],"f.datef","","&socid=".$_REQUEST["socid"],'align="center"',$sortfield,$sortorder); + if (! empty($client)) { + print_liste_field_titre($langs->trans("Invoice"),$_SERVER["PHP_SELF"],"f.facnumber","","&socid=".$socid,'',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("DateInvoice"),$_SERVER["PHP_SELF"],"f.datef","","&socid=".$socid,'align="center"',$sortfield,$sortorder); } else - print_liste_field_titre($langs->trans("Customer"),$_SERVER["PHP_SELF"],"s.nom","","&socid=".$_REQUEST["socid"],'align="center"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("SellingPrice"),$_SERVER["PHP_SELF"],"selling_price","","&socid=".$_REQUEST["socid"],'align="right"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("BuyingPrice"),$_SERVER["PHP_SELF"],"buyng_price","","&socid=".$_REQUEST["socid"],'align="right"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("Margin"),$_SERVER["PHP_SELF"],"marge","","&socid=".$_REQUEST["socid"],'align="right"',$sortfield,$sortorder); - if ($conf->global->DISPLAY_MARGIN_RATES) - print_liste_field_titre($langs->trans("MarginRate"),$_SERVER["PHP_SELF"],"d.marge_tx","","&socid=".$_REQUEST["socid"],'align="right"',$sortfield,$sortorder); - if ($conf->global->DISPLAY_MARK_RATES) - print_liste_field_titre($langs->trans("MarkRate"),$_SERVER["PHP_SELF"],"d.marque_tx","","&socid=".$_REQUEST["socid"],'align="right"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Customer"),$_SERVER["PHP_SELF"],"s.nom","","&socid=".$socid,'align="center"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("SellingPrice"),$_SERVER["PHP_SELF"],"selling_price","","&socid=".$socid,'align="right"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("BuyingPrice"),$_SERVER["PHP_SELF"],"buyng_price","","&socid=".$socid,'align="right"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Margin"),$_SERVER["PHP_SELF"],"marge","","&socid=".$socid,'align="right"',$sortfield,$sortorder); + if (! empty($conf->global->DISPLAY_MARGIN_RATES)) + print_liste_field_titre($langs->trans("MarginRate"),$_SERVER["PHP_SELF"],"d.marge_tx","","&socid=".$socid,'align="right"',$sortfield,$sortorder); + if (! empty($conf->global->DISPLAY_MARK_RATES)) + print_liste_field_titre($langs->trans("MarkRate"),$_SERVER["PHP_SELF"],"d.marque_tx","","&socid=".$socid,'align="right"',$sortfield,$sortorder); print "\n"; $cumul_achat = 0; @@ -200,8 +202,8 @@ if ($result) { $objp = $db->fetch_object($result); - $marginRate = ($objp->buying_price != 0)?(100 * round($objp->marge / $objp->buying_price ,5)):'' ; - $markRate = ($objp->selling_price != 0)?(100 * round($objp->marge / $objp->selling_price ,5)):'' ; + $marginRate = ($objp->buying_price != 0)?(100 * round($objp->marge / $objp->buying_price, 5)):'' ; + $markRate = ($objp->selling_price != 0)?(100 * round($objp->marge / $objp->selling_price, 5)):'' ; $var=!$var; @@ -224,9 +226,9 @@ if ($result) print "\n"; print "\n"; print "\n"; - if ($conf->global->DISPLAY_MARGIN_RATES) + if (! empty($conf->global->DISPLAY_MARGIN_RATES)) print "\n"; - if ($conf->global->DISPLAY_MARK_RATES) + if (! empty($conf->global->DISPLAY_MARK_RATES)) print "\n"; print "\n"; $i++; @@ -249,9 +251,9 @@ if ($result) print "\n"; print "\n"; print "\n"; - if ($conf->global->DISPLAY_MARGIN_RATES) + if (! empty($conf->global->DISPLAY_MARGIN_RATES)) print "\n"; - if ($conf->global->DISPLAY_MARK_RATES) + if (! empty($conf->global->DISPLAY_MARK_RATES)) print "\n"; print "\n"; diff --git a/htdocs/margin/lib/margins.lib.php b/htdocs/margin/lib/margins.lib.php index 77368e80455..96bd0ed5b5d 100644 --- a/htdocs/margin/lib/margins.lib.php +++ b/htdocs/margin/lib/margins.lib.php @@ -23,6 +23,7 @@ /** * Define head array for tabs of marges tools setup pages + * * @return Array of head */ function marges_admin_prepare_head() @@ -32,7 +33,7 @@ function marges_admin_prepare_head() $h = 0; $head = array(); - $head[$h][0] = DOL_URL_ROOT."/admin/margin.php"; + $head[$h][0] = DOL_URL_ROOT."/margin/admin/margin.php"; $head[$h][1] = $langs->trans("Parameters"); $head[$h][2] = 'parameters'; $h++; @@ -72,7 +73,20 @@ function marges_prepare_head($user) return $head; } -function getMarginInfos($pvht, $remise_percent, $tva_tx, $localtax1_tx, $localtax2_tx, $fk_pa, $paht) { +/** + * getMarginInfos + * + * @param float $pvht Buying price with tax + * @param float $remise_percent Discount percent + * @param float $tva_tx Vat rate + * @param float $localtax1_tx Vat rate special 1 + * @param float $localtax2_tx Vat rate special 2 + * @param int $fk_pa ??? + * @param float $paht Buying price without tax + * @return array Array of margin info + */ +function getMarginInfos($pvht, $remise_percent, $tva_tx, $localtax1_tx, $localtax2_tx, $fk_pa, $paht) +{ global $db, $conf; $marge_tx_ret=''; diff --git a/htdocs/margin/productMargins.php b/htdocs/margin/productMargins.php index e43341ef7fc..ca6de009da3 100644 --- a/htdocs/margin/productMargins.php +++ b/htdocs/margin/productMargins.php @@ -47,12 +47,16 @@ $mesg = ''; $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); +if (! $sortorder) $sortorder="ASC"; +if (! $sortfield) $sortfield="p.ref"; $page = GETPOST("page",'int'); if ($page == -1) { $page = 0; } $offset = $conf->liste_limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; +$startdate=$enddate=''; + if (!empty($_POST['startdatemonth'])) $startdate = date('Y-m-d', dol_mktime(12, 0, 0, $_POST['startdatemonth'], $_POST['startdateday'], $_POST['startdateyear'])); if (!empty($_POST['enddatemonth'])) @@ -76,7 +80,7 @@ print_fiche_titre($text); // Show tabs $head=marges_prepare_head($user); $titre=$langs->trans("Margins"); -$picto='marges'; +$picto='margin'; dol_fiche_head($head, 'productMargins', $titre, 0, $picto); print ''; @@ -84,12 +88,9 @@ print '
".price($objp->selling_price)."".price($objp->buying_price)."".price($objp->marge)."".(($marginRate === '')?'n/a':price($marginRate)."%")."".(($markRate === '')?'n/a':price($markRate)."%")."
".price($cumul_vente)."".price($cumul_achat)."".price($totalMargin)."".(($marginRate === '')?'n/a':price($marginRate)."%")."".(($markRate === '')?'n/a':price($markRate)."%")."
'; if ($id > 0) { - $societe = new Societe($db, $socid); - $societe->fetch($socid); - print ''; print ''; print ''; @@ -99,12 +100,11 @@ if ($id > 0) { if (! $sortfield) $sortfield="f.datef"; } else { - print ''; - print ''; - if (! $sortorder) $sortorder="ASC"; - if (! $sortfield) $sortfield="p.ref"; + print ''; + print ''; + } // Start date @@ -126,14 +126,14 @@ print ''; // set by jquery (see below) print ''; // Margin Rate -if ($conf->global->DISPLAY_MARGIN_RATES) { +if (! empty($conf->global->DISPLAY_MARGIN_RATES)) { print ''; } // Mark Rate -if ($conf->global->DISPLAY_MARK_RATES) { +if (! empty($conf->global->DISPLAY_MARK_RATES)) { print ''; @@ -142,7 +142,7 @@ if ($conf->global->DISPLAY_MARK_RATES) { print "
'.$langs->trans('ChooseProduct/Service').''; - print $form->select_produits($selected=$id, $htmlname='id', $filtertype='', $limit=20, $price_level=0, $status=1, $finished=2, $selected_input_value='', $hidelabel=1); + print $form->select_produits($id,'id','',20,0,1,2,'',1); print '
'.$langs->trans('AllProducts').'
'.$langs->trans('ChooseProduct/Service').''; - print $form->select_produits($selected='', $htmlname='id', $filtertype='', $limit=20, $price_level=0, $status=1, $finished=2, $selected_input_value='', $hidelabel=1); - print '
'.$langs->trans('ChooseProduct/Service').''; + print $form->select_produits('','id','',20,0,1,2,'',1); + print '
'.$langs->trans("MarginRate").''; print ''; // set by jquery (see below) print '
'.$langs->trans("MarkRate").''; print ''; // set by jquery (see below) print '
"; print '
'; -$sql = "SELECT distinct d.fk_product, p.label, p.rowid, p.fk_product_type, p.ref,"; +$sql = "SELECT DISTINCT d.fk_product, p.label, p.rowid, p.fk_product_type, p.ref,"; $sql.= " f.facnumber, f.total as total_ht,"; $sql.= " sum(d.subprice * d.qty * (1 - d.remise_percent / 100)) as selling_price,"; $sql.= " sum(d.buy_price_ht * d.qty) as buying_price, sum(((d.subprice * (1 - d.remise_percent / 100)) - d.buy_price_ht) * d.qty) as marge," ; @@ -151,10 +151,10 @@ $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql.= ", ".MAIN_DB_PREFIX."product as p"; $sql.= ", ".MAIN_DB_PREFIX."facture as f"; $sql.= ", ".MAIN_DB_PREFIX."facturedet as d"; -$sql.= " WHERE f.fk_soc = s.rowid"; +$sql.= " WHERE f.entity = ".$conf->entity; +$sql.= " AND f.fk_soc = s.rowid"; $sql.= " AND d.fk_product = p.rowid"; $sql.= " AND f.fk_statut > 0"; -$sql.= " AND s.entity = ".$conf->entity; $sql.= " AND d.fk_facture = f.rowid"; if ($id > 0) $sql.= " AND d.fk_product =".$id; @@ -174,26 +174,26 @@ if ($result) { $num = $db->num_rows($result); - print '
'; - print_barre_liste($langs->trans("MarginDetails"),$page,$_SERVER["PHP_SELF"],"&id=$product->id",$sortfield,$sortorder,'',$num,0,''); + print '
'; + print_barre_liste($langs->trans("MarginDetails"),$page,$_SERVER["PHP_SELF"],"&id=".$id,$sortfield,$sortorder,'',$num,0,''); $i = 0; print ""; print ''; if ($id > 0) { - print_liste_field_titre($langs->trans("Invoice"),$_SERVER["PHP_SELF"],"f.facnumber","","&id=".$_REQUEST["id"],'',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("DateInvoice"),$_SERVER["PHP_SELF"],"f.datef","","&id=".$_REQUEST["id"],'align="center"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Invoice"),$_SERVER["PHP_SELF"],"f.facnumber","","&id=".$id,'',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("DateInvoice"),$_SERVER["PHP_SELF"],"f.datef","","",'align="center"',$sortfield,$sortorder); } else - print_liste_field_titre($langs->trans("ProductService"),$_SERVER["PHP_SELF"],"p.ref","","&id=".$_REQUEST["id"],'align="center"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("SellingPrice"),$_SERVER["PHP_SELF"],"selling_price","","&id=".$_REQUEST["id"],'align="right"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("BuyingPrice"),$_SERVER["PHP_SELF"],"buyng_price","","&id=".$_REQUEST["id"],'align="right"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("Margin"),$_SERVER["PHP_SELF"],"marge","","&id=".$_REQUEST["id"],'align="right"',$sortfield,$sortorder); - if ($conf->global->DISPLAY_MARGIN_RATES) - print_liste_field_titre($langs->trans("MarginRate"),$_SERVER["PHP_SELF"],"d.marge_tx","","&id=".$_REQUEST["id"],'align="right"',$sortfield,$sortorder); - if ($conf->global->DISPLAY_MARK_RATES) - print_liste_field_titre($langs->trans("MarkRate"),$_SERVER["PHP_SELF"],"d.marque_tx","","&id=".$_REQUEST["id"],'align="right"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("ProductService"),$_SERVER["PHP_SELF"],"p.ref","","&id=".$id,'align="center"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("SellingPrice"),$_SERVER["PHP_SELF"],"selling_price","","&id=".$id,'align="right"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("BuyingPrice"),$_SERVER["PHP_SELF"],"buyng_price","","&id=".$id,'align="right"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Margin"),$_SERVER["PHP_SELF"],"marge","","&id=".$id,'align="right"',$sortfield,$sortorder); + if (! empty($conf->global->DISPLAY_MARGIN_RATES)) + print_liste_field_titre($langs->trans("MarginRate"),$_SERVER["PHP_SELF"],"d.marge_tx","","&id=".$id,'align="right"',$sortfield,$sortorder); + if (! empty($conf->global->DISPLAY_MARK_RATES)) + print_liste_field_titre($langs->trans("MarkRate"),$_SERVER["PHP_SELF"],"d.marque_tx","","&id=".$id,'align="right"',$sortfield,$sortorder); print "\n"; $cumul_achat = 0; @@ -213,29 +213,29 @@ if ($result) print ""; if ($id > 0) { - print '\n"; - print ""; - } - else { + print '\n"; + print ""; + } + else { $product_static->type=$objp->fk_product_type; - $product_static->id=$objp->fk_product; + $product_static->id=$objp->fk_product; $product_static->ref=$objp->ref; - $product_static->libelle=$objp->label; + $product_static->libelle=$objp->label; $text=$product_static->getNomUrl(1); $text.= ' - '.$objp->label; - print "\n"; - } + print "\n"; + } print "\n"; print "\n"; print "\n"; - if ($conf->global->DISPLAY_MARGIN_RATES) + if (! empty($conf->global->DISPLAY_MARGIN_RATES)) print "\n"; - if ($conf->global->DISPLAY_MARK_RATES) + if (! empty($conf->global->DISPLAY_MARK_RATES)) print "\n"; print "\n"; $i++; @@ -251,20 +251,20 @@ if ($result) $markRate = ($cumul_vente != 0)?(100 * round($totalMargin / $cumul_vente, 5)):'' ; print ''; if ($id > 0) - print '"; + print '"; print "\n"; print "\n"; print "\n"; - if ($conf->global->DISPLAY_MARGIN_RATES) + if (! empty($conf->global->DISPLAY_MARGIN_RATES)) print "\n"; - if ($conf->global->DISPLAY_MARK_RATES) + if (! empty($conf->global->DISPLAY_MARK_RATES)) print "\n"; print "\n"; - print "
'; - $invoicestatic->id=$objp->facid; - $invoicestatic->ref=$objp->facnumber; - print $invoicestatic->getNomUrl(1); - print ""; - print dol_print_date($db->jdate($objp->datef),'day')."'; + $invoicestatic->id=$objp->facid; + $invoicestatic->ref=$objp->facnumber; + print $invoicestatic->getNomUrl(1); + print ""; + print dol_print_date($db->jdate($objp->datef),'day')."".$product_static->getNomUrl(1)."".$product_static->getNomUrl(1)."".price($objp->selling_price)."".price($objp->buying_price)."".price($objp->marge)."".(($marginRate === '')?'n/a':price($marginRate)."%")."".(($markRate === '')?'n/a':price($markRate)."%")."
'; - else - print ''; - print $langs->trans('TotalMargin')."'; + else + print ''; + print $langs->trans('TotalMargin')."".price($cumul_vente)."".price($cumul_achat)."".price($totalMargin)."".(($marginRate === '')?'n/a':price($marginRate)."%")."".(($markRate === '')?'n/a':price($markRate)."%")."
"; + print ""; } else { @@ -287,9 +287,9 @@ $(document).ready(function() { $("div.fiche form").submit(); }); - $("#totalMargin").html(""); - $("#marginRate").html(""); - $("#markRate").html(""); + $("#totalMargin").html(""); + $("#marginRate").html(""); + $("#markRate").html(""); }); \ No newline at end of file diff --git a/htdocs/margin/tabs/productMargins.php b/htdocs/margin/tabs/productMargins.php index e13e6b036d8..04495eb5e7a 100644 --- a/htdocs/margin/tabs/productMargins.php +++ b/htdocs/margin/tabs/productMargins.php @@ -80,7 +80,7 @@ if ($id > 0 || ! empty($ref)) $head=product_prepare_head($object, $user); $titre=$langs->trans("CardProduct".$object->type); $picto=($object->type==1?'service':'product'); - dol_fiche_head($head, 'marges', $titre, 0, $picto); + dol_fiche_head($head, 'margin', $titre, 0, $picto); print ''; @@ -111,14 +111,14 @@ if ($id > 0 || ! empty($ref)) print ''; // Margin Rate - if ($conf->global->DISPLAY_MARGIN_RATES) { + if (! empty($conf->global->DISPLAY_MARGIN_RATES)) { print ''; } // Mark Rate - if ($conf->global->DISPLAY_MARK_RATES) { + if (! empty($conf->global->DISPLAY_MARK_RATES)) { print ''; @@ -128,7 +128,7 @@ if ($id > 0 || ! empty($ref)) print ''; - $sql = "SELECT distinct s.nom, s.rowid as socid, s.code_client,"; + $sql = "SELECT DISTINCT s.nom, s.rowid as socid, s.code_client,"; $sql.= " f.facnumber, f.total as total_ht,"; $sql.= " (d.subprice * d.qty * (1 - d.remise_percent / 100)) as selling_price, (d.buy_price_ht * d.qty) as buying_price, d.qty, ((d.subprice - d.buy_price_ht) * d.qty) as marge," ; $sql.= " f.datef, f.paye, f.fk_statut as statut, f.rowid as facid"; @@ -143,7 +143,7 @@ if ($id > 0 || ! empty($ref)) $sql.= " AND d.fk_facture = f.rowid"; $sql.= " AND d.fk_product =".$object->id; if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; - if ($socid) $sql.= " AND f.fk_soc = $socid"; + if (! empty($socid)) $sql.= " AND f.fk_soc = $socid"; $sql.= " ORDER BY $sortfield $sortorder "; $sql.= $db->plimit($conf->liste_limit +1, $offset); @@ -158,19 +158,19 @@ if ($id > 0 || ! empty($ref)) print "
'.$langs->trans("MarginRate").''; print ''; // set by jquery (see below) print '
'.$langs->trans("MarkRate").''; print ''; // set by jquery (see below) print '
"; print ''; - print_liste_field_titre($langs->trans("Invoice"),$_SERVER["PHP_SELF"],"f.facnumber","","&id=".$_GET["id"],'',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("Company"),$_SERVER["PHP_SELF"],"s.nom","","&id=".$_GET["id"],'',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("CustomerCode"),$_SERVER["PHP_SELF"],"s.code_client","","&id=".$_GET["id"],'',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("DateInvoice"),$_SERVER["PHP_SELF"],"f.datef","","&id=".$_GET["id"],'align="center"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("SellingPrice"),$_SERVER["PHP_SELF"],"selling_price","","&id=".$_GET["id"],'align="right"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("BuyingPrice"),$_SERVER["PHP_SELF"],"buyng_price","","&id=".$_GET["id"],'align="right"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("Qty"),$_SERVER["PHP_SELF"],"d.qty","","&id=".$_GET["id"],'align="right"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("Margin"),$_SERVER["PHP_SELF"],"marge","","&id=".$_GET["id"],'align="right"',$sortfield,$sortorder); - if ($conf->global->DISPLAY_MARGIN_RATES) - print_liste_field_titre($langs->trans("MarginRate"),$_SERVER["PHP_SELF"],"d.marge_tx","","&id=".$_GET["id"],'align="right"',$sortfield,$sortorder); - if ($conf->global->DISPLAY_MARK_RATES) - print_liste_field_titre($langs->trans("MarkRate"),$_SERVER["PHP_SELF"],"d.marque_tx","","&id=".$_GET["id"],'align="right"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"f.paye,f.fk_statut","","&id=".$_GET["id"],'align="right"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Invoice"),$_SERVER["PHP_SELF"],"f.facnumber","","&id=".$object->id,'',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Company"),$_SERVER["PHP_SELF"],"s.nom","","&id=".$object->id,'',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("CustomerCode"),$_SERVER["PHP_SELF"],"s.code_client","","&id=".$object->id,'',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("DateInvoice"),$_SERVER["PHP_SELF"],"f.datef","","&id=".$object->id,'align="center"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("SellingPrice"),$_SERVER["PHP_SELF"],"selling_price","","&id=".$object->id,'align="right"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("BuyingPrice"),$_SERVER["PHP_SELF"],"buyng_price","","&id=".$object->id,'align="right"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Qty"),$_SERVER["PHP_SELF"],"d.qty","","&id=".$object->id,'align="right"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Margin"),$_SERVER["PHP_SELF"],"marge","","&id=".$object->id,'align="right"',$sortfield,$sortorder); + if (! empty($conf->global->DISPLAY_MARGIN_RATES)) + print_liste_field_titre($langs->trans("MarginRate"),$_SERVER["PHP_SELF"],"d.marge_tx","","&id=".$object->id,'align="right"',$sortfield,$sortorder); + if (! empty($conf->global->DISPLAY_MARK_RATES)) + print_liste_field_titre($langs->trans("MarkRate"),$_SERVER["PHP_SELF"],"d.marque_tx","","&id=".$object->id,'align="right"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"f.paye,f.fk_statut","","&id=".$object->id,'align="right"',$sortfield,$sortorder); print "\n"; $cumul_achat = 0; @@ -184,8 +184,8 @@ if ($id > 0 || ! empty($ref)) $objp = $db->fetch_object($result); $var=!$var; - $marginRate = ($objp->buying_price != 0)?(100 * round($objp->marge / $objp->buying_price ,5)):'' ; - $markRate = ($objp->selling_price != 0)?(100 * round($objp->marge / $objp->selling_price ,5)):'' ; + $marginRate = ($objp->buying_price != 0)?(100 * round($objp->marge / $objp->buying_price, 5)):'' ; + $markRate = ($objp->selling_price != 0)?(100 * round($objp->marge / $objp->selling_price, 5)):'' ; print ""; print '\n"; print "\n"; print "\n"; - if ($conf->global->DISPLAY_MARGIN_RATES) + if (! empty($conf->global->DISPLAY_MARGIN_RATES)) print "\n"; - if ($conf->global->DISPLAY_MARK_RATES) + if (! empty($conf->global->DISPLAY_MARK_RATES)) print "\n"; print ''; print "\n"; @@ -217,16 +217,16 @@ if ($id > 0 || ! empty($ref)) $var=!$var; $totalMargin = $cumul_vente - $cumul_achat; $marginRate = ($cumul_achat != 0)?(100 * round($totalMargin / $cumul_achat, 5)):''; - $markRate = ($cumul_vente != 0)?(100 * round($totalMargin / $cumul_vente ,5)):''; + $markRate = ($cumul_vente != 0)?(100 * round($totalMargin / $cumul_vente, 5)):''; print ''; print '"; print "\n"; print "\n"; print "\n"; print "\n"; - if ($conf->global->DISPLAY_MARGIN_RATES) + if (! empty($conf->global->DISPLAY_MARGIN_RATES)) print "\n"; - if ($conf->global->DISPLAY_MARK_RATES) + if (! empty($conf->global->DISPLAY_MARK_RATES)) print "\n"; print ''; print "\n"; diff --git a/htdocs/margin/tabs/thirdpartyMargins.php b/htdocs/margin/tabs/thirdpartyMargins.php index 2e94ed9b1e0..9b1e712794b 100644 --- a/htdocs/margin/tabs/thirdpartyMargins.php +++ b/htdocs/margin/tabs/thirdpartyMargins.php @@ -71,7 +71,7 @@ if ($socid > 0) $head = societe_prepare_head($societe); - dol_fiche_head($head, 'marges', $langs->trans("ThirdParty"),0,'company'); + dol_fiche_head($head, 'margin', $langs->trans("ThirdParty"),0,'company'); print '
'; $invoicestatic->id=$objp->facid; @@ -200,9 +200,9 @@ if ($id > 0 || ! empty($ref)) print "".price($objp->buying_price)."".price($objp->qty)."".price($objp->marge)."".(($marginRate === '')?'n/a':price($marginRate)."%")."".(($markRate === '')?'n/a':price($markRate)."%")."'.$invoicestatic->LibStatut($objp->paye,$objp->statut,5).'
'.$langs->trans('TotalMargin')."".price($cumul_vente)."".price($cumul_achat)."".price($cumul_qty)."".price($totalMargin)."".(($marginRate === '')?'n/a':price($marginRate)."%")."".(($markRate === '')?'n/a':price($markRate)."%")." 
'; @@ -109,14 +109,14 @@ if ($socid > 0) print ''; // Margin Rate - if ($conf->global->DISPLAY_MARGIN_RATES) { + if (! empty($conf->global->DISPLAY_MARGIN_RATES)) { print ''; } // Mark Rate - if ($conf->global->DISPLAY_MARK_RATES) { + if (! empty($conf->global->DISPLAY_MARK_RATES)) { print ''; @@ -158,9 +158,9 @@ if ($socid > 0) print_liste_field_titre($langs->trans("SellingPrice"),$_SERVER["PHP_SELF"],"selling_price","","&socid=".$_REQUEST["socid"],'align="right"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("BuyingPrice"),$_SERVER["PHP_SELF"],"buyng_price","","&socid=".$_REQUEST["socid"],'align="right"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("Margin"),$_SERVER["PHP_SELF"],"marge","","&socid=".$_REQUEST["socid"],'align="right"',$sortfield,$sortorder); - if ($conf->global->DISPLAY_MARGIN_RATES) + if (! empty($conf->global->DISPLAY_MARGIN_RATES)) print_liste_field_titre($langs->trans("MarginRate"),$_SERVER["PHP_SELF"],"d.marge_tx","","&socid=".$_REQUEST["socid"],'align="right"',$sortfield,$sortorder); - if ($conf->global->DISPLAY_MARK_RATES) + if (! empty($conf->global->DISPLAY_MARK_RATES)) print_liste_field_titre($langs->trans("MarkRate"),$_SERVER["PHP_SELF"],"d.marque_tx","","&socid=".$_REQUEST["socid"],'align="right"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"f.paye,f.fk_statut","","&socid=".$_REQUEST["socid"],'align="right"',$sortfield,$sortorder); print "\n"; @@ -175,8 +175,8 @@ if ($socid > 0) { $objp = $db->fetch_object($result); - $marginRate = ($objp->buying_price != 0)?(100 * round($objp->marge / $objp->buying_price ,5)):'' ; - $markRate = ($objp->selling_price != 0)?(100 * round($objp->marge / $objp->selling_price ,5)):'' ; + $marginRate = ($objp->buying_price != 0)?(100 * round($objp->marge / $objp->buying_price, 5)):'' ; + $markRate = ($objp->selling_price != 0)?(100 * round($objp->marge / $objp->selling_price, 5)):'' ; $var=!$var; @@ -191,9 +191,9 @@ if ($socid > 0) print "\n"; print "\n"; print "\n"; - if ($conf->global->DISPLAY_MARGIN_RATES) + if (! empty($conf->global->DISPLAY_MARGIN_RATES)) print "\n"; - if ($conf->global->DISPLAY_MARK_RATES) + if (! empty($conf->global->DISPLAY_MARK_RATES)) print "\n"; print ''; print "\n"; @@ -213,9 +213,9 @@ if ($socid > 0) print "\n"; print "\n"; print "\n"; - if ($conf->global->DISPLAY_MARGIN_RATES) + if (! empty($conf->global->DISPLAY_MARGIN_RATES)) print "\n"; - if ($conf->global->DISPLAY_MARK_RATES) + if (! empty($conf->global->DISPLAY_MARK_RATES)) print "\n"; print ''; print "\n"; diff --git a/htdocs/product/ajaxproducts.php b/htdocs/product/ajaxproducts.php index 7f209839da5..1e99dcb7a8c 100644 --- a/htdocs/product/ajaxproducts.php +++ b/htdocs/product/ajaxproducts.php @@ -1,6 +1,6 @@ - * Copyright (C) 2005-2011 Regis Houssin + * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2007-2011 Laurent Destailleur * * This program is free software; you can redistribute it and/or modify @@ -60,12 +60,12 @@ if (! isset($_GET['htmlname'])) return; $htmlname = $_GET['htmlname']; $match = preg_grep('/('.$htmlname.'[0-9]+)/',array_keys($_GET)); sort($match); -$idprod = $match[0]; +$idprod = (! empty($match[0]) ? $match[0] : ''); if (! isset($_GET[$htmlname]) && ! isset($_GET[$idprod])) return; // When used from jQuery, the search term is added as GET param "term". -$searchkey=$_GET[$idprod]; +$searchkey=(! empty($_GET[$idprod])?$_GET[$idprod]:''); if (empty($searchkey)) $searchkey=$_GET[$htmlname]; $outjson=isset($_GET['outjson'])?$_GET['outjson']:0; diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 4d4a9e03e98..68b26800d75 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -700,7 +700,7 @@ class Product extends CommonObject } if (!$this->db->query($sql2)) return -1; } - else + else if (isset($this->multilangs["$key"])) { if ($this->db->num_rows($result)) // si aucune ligne dans la base { @@ -2082,13 +2082,12 @@ class Product extends CommonObject function get_arbo_each_prod($multiply=1) { $this->res = array(); - if (is_array($this -> sousprods)) + if (isset($this->sousprods) && is_array($this->sousprods)) { - foreach($this -> sousprods as $nom_pere => $desc_pere) + foreach($this->sousprods as $nom_pere => $desc_pere) { if (is_array($desc_pere)) $this->fetch_prod_arbo($desc_pere,"",$multiply); } - // dol_sort($this->res,); } return $this->res; } diff --git a/htdocs/product/fiche.php b/htdocs/product/fiche.php index 58a62e9496b..b7694adb377 100644 --- a/htdocs/product/fiche.php +++ b/htdocs/product/fiche.php @@ -34,23 +34,24 @@ require_once(DOL_DOCUMENT_ROOT."/product/class/html.formproduct.class.php"); require_once(DOL_DOCUMENT_ROOT."/core/class/extrafields.class.php"); require_once(DOL_DOCUMENT_ROOT."/core/lib/product.lib.php"); require_once(DOL_DOCUMENT_ROOT."/core/lib/company.lib.php"); -if ($conf->propal->enabled) require_once(DOL_DOCUMENT_ROOT."/comm/propal/class/propal.class.php"); -if ($conf->facture->enabled) require_once(DOL_DOCUMENT_ROOT."/compta/facture/class/facture.class.php"); -if ($conf->commande->enabled) require_once(DOL_DOCUMENT_ROOT."/commande/class/commande.class.php"); +if (! empty($conf->propal->enabled)) require_once(DOL_DOCUMENT_ROOT."/comm/propal/class/propal.class.php"); +if (! empty($conf->facture->enabled)) require_once(DOL_DOCUMENT_ROOT."/compta/facture/class/facture.class.php"); +if (! empty($conf->commande->enabled)) require_once(DOL_DOCUMENT_ROOT."/commande/class/commande.class.php"); $langs->load("products"); $langs->load("other"); -if ($conf->stock->enabled) $langs->load("stocks"); -if ($conf->facture->enabled) $langs->load("bills"); +if (! empty($conf->stock->enabled)) $langs->load("stocks"); +if (! empty($conf->facture->enabled)) $langs->load("bills"); -$mesg=''; $error=0; $errors=array(); +$mesg=''; $error=0; $errors=array(); $_error=0; -$id = GETPOST('id', 'int'); -$ref = GETPOST('ref', 'alpha'); +$id=GETPOST('id', 'int'); +$ref=GETPOST('ref', 'alpha'); +$type=GETPOST('type','int'); $action=(GETPOST('action','alpha') ? GETPOST('action','alpha') : 'view'); $confirm=GETPOST('confirm','alpha'); $socid=GETPOST('socid','int'); -if ($user->societe_id) $socid=$user->societe_id; +if (! empty($user->societe_id)) $socid=$user->societe_id; $object = new Product($db); $extrafields = new ExtraFields($db); @@ -58,6 +59,7 @@ $extrafields = new ExtraFields($db); // Get object canvas (By default, this is not defined, so standard usage of dolibarr) $object->getCanvas($id,$ref); $canvas = $object->canvas?$object->canvas:GETPOST("canvas"); +$objcanvas=''; if (! empty($canvas)) { require_once(DOL_DOCUMENT_ROOT."/core/class/canvas.class.php"); @@ -91,7 +93,7 @@ if (empty($reshook)) if ($action == 'setfk_product_type' && $user->rights->produit->creer) { $object->fetch($id); - $result = $object->setValueFrom('fk_product_type', $_POST['fk_product_type']); + $result = $object->setValueFrom('fk_product_type', GETPOST('fk_product_type')); Header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); exit; } @@ -100,7 +102,7 @@ if (empty($reshook)) if ($action == 'setfk_barcode_type' && $user->rights->barcode->creer) { $object->fetch($id); - $result = $object->setValueFrom('fk_barcode_type', $_POST['fk_barcode_type']); + $result = $object->setValueFrom('fk_barcode_type', GETPOST('fk_barcode_type')); Header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); exit; } @@ -110,7 +112,7 @@ if (empty($reshook)) { $object->fetch($id); //Todo: ajout verification de la validite du code barre en fonction du type - $result = $object->setValueFrom('barcode', $_POST['barcode']); + $result = $object->setValueFrom('barcode', GETPOST('barcode')); Header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); exit; } @@ -118,7 +120,7 @@ if (empty($reshook)) if ($action == 'setaccountancy_code_buy') { $object->fetch($id,$ref); - $result = $object->setValueFrom('accountancy_code_buy', $_POST['accountancy_code_buy']); + $result = $object->setValueFrom('accountancy_code_buy', GETPOST('accountancy_code_buy')); if ($result < 0) { $mesg=join(',',$object->errors); @@ -129,7 +131,7 @@ if (empty($reshook)) if ($action == 'setaccountancy_code_sell') { $object->fetch($id,$ref); - $result = $object->setValueFrom('accountancy_code_sell', $_POST['accountancy_code_sell']); + $result = $object->setValueFrom('accountancy_code_sell', GETPOST('accountancy_code_sell')); if ($result < 0) { $mesg=join(',',$object->errors); @@ -142,63 +144,59 @@ if (empty($reshook)) { $error=0; - if (empty($_POST["libelle"])) + if (GETPOST('libelle')) { $mesg='
'.$langs->trans('ErrorFieldRequired',$langs->transnoentities('Label')).'
'; $action = "create"; - $_GET["canvas"] = $_POST["canvas"]; - $_GET["type"] = $_POST["type"]; $error++; } if (empty($ref)) { $mesg='
'.$langs->trans('ErrorFieldRequired',$langs->transnoentities('Ref')).'
'; $action = "create"; - $_GET["canvas"] = $_POST["canvas"]; - $_GET["type"] = $_POST["type"]; $error++; } if (! $error) { $object->ref = $ref; - $object->libelle = $_POST["libelle"]; - $object->price_base_type = $_POST["price_base_type"]; - if ($object->price_base_type == 'TTC') $object->price_ttc = $_POST["price"]; - else $object->price = $_POST["price"]; - if ($object->price_base_type == 'TTC') $object->price_min_ttc = $_POST["price_min"]; - else $object->price_min = $_POST["price_min"]; - $object->tva_tx = str_replace('*','',$_POST['tva_tx']); - $object->tva_npr = preg_match('/\*/',$_POST['tva_tx'])?1:0; + $object->libelle = GETPOST('libelle'); + $object->price_base_type = GETPOST('price_base_type'); + if ($object->price_base_type == 'TTC') $object->price_ttc = GETPOST('price'); + else $object->price = GETPOST('price'); + if ($object->price_base_type == 'TTC') $object->price_min_ttc = GETPOST('price_min'); + else $object->price_min = GETPOST('price_min'); + $object->tva_tx = str_replace('*','',GETPOST('tva_tx')); + $object->tva_npr = preg_match('/\*/',GETPOST('tva_tx'))?1:0; // local taxes. $object->localtax1_tx = get_localtax($object->tva_tx,1); $object->localtax2_tx = get_localtax($object->tva_tx,2); - $object->type = $_POST["type"]; - $object->status = $_POST["statut"]; - $object->status_buy = $_POST["statut_buy"]; - $object->description = dol_htmlcleanlastbr($_POST["desc"]); - $object->note = dol_htmlcleanlastbr($_POST["note"]); - $object->customcode = $_POST["customcode"]; - $object->country_id = $_POST["country_id"]; - $object->duration_value = $_POST["duration_value"]; - $object->duration_unit = $_POST["duration_unit"]; - $object->seuil_stock_alerte = $_POST["seuil_stock_alerte"]?$_POST["seuil_stock_alerte"]:0; - $object->canvas = $_POST["canvas"]; - $object->weight = $_POST["weight"]; - $object->weight_units = $_POST["weight_units"]; - $object->length = $_POST["size"]; - $object->length_units = $_POST["size_units"]; - $object->surface = $_POST["surface"]; - $object->surface_units = $_POST["surface_units"]; - $object->volume = $_POST["volume"]; - $object->volume_units = $_POST["volume_units"]; - $object->finished = $_POST["finished"]; - $object->hidden = $_POST["hidden"]=='yes'?1:0; + $object->type = $type; + $object->status = GETPOST('statut'); + $object->status_buy = GETPOST('statut_buy'); + $object->description = dol_htmlcleanlastbr(GETPOST('desc')); + $object->note = dol_htmlcleanlastbr(GETPOST('note')); + $object->customcode = GETPOST('customcode'); + $object->country_id = GETPOST('country_id'); + $object->duration_value = GETPOST('duration_value'); + $object->duration_unit = GETPOST('duration_unit'); + $object->seuil_stock_alerte = GETPOST('seuil_stock_alerte')?GETPOST('seuil_stock_alerte'):0; + $object->canvas = GETPOST('canvas'); + $object->weight = GETPOST('weight'); + $object->weight_units = GETPOST('weight_units'); + $object->length = GETPOST('size'); + $object->length_units = GETPOST('size_units'); + $object->surface = GETPOST('surface'); + $object->surface_units = GETPOST('surface_units'); + $object->volume = GETPOST('volume'); + $object->volume_units = GETPOST('volume_units'); + $object->finished = GETPOST('finished'); + $object->hidden = GETPOST('hidden')=='yes'?1:0; // MultiPrix - if($conf->global->PRODUIT_MULTIPRICES) + if (! empty($conf->global->PRODUIT_MULTIPRICES)) { for($i=2;$i<=$conf->global->PRODUIT_MULTIPRICES_LIMIT;$i++) { @@ -234,7 +232,6 @@ if (empty($reshook)) { $mesg='
'.$langs->trans($object->error).'
'; $action = "create"; - $_GET["type"] = $_POST["type"]; } } } @@ -242,7 +239,7 @@ if (empty($reshook)) // Update a product or service if ($action == 'update' && ($user->rights->produit->creer || $user->rights->service->creer)) { - if (! empty($_POST["cancel"])) + if (GETPOST('cancel')) { $action = ''; } @@ -253,27 +250,27 @@ if (empty($reshook)) $object->oldcopy=dol_clone($object); $object->ref = $ref; - $object->libelle = $_POST["libelle"]; - $object->description = dol_htmlcleanlastbr($_POST["desc"]); - $object->note = dol_htmlcleanlastbr($_POST["note"]); - $object->customcode = $_POST["customcode"]; - $object->country_id = $_POST["country_id"]; - $object->status = $_POST["statut"]; - $object->status_buy = $_POST["statut_buy"]; - $object->seuil_stock_alerte = $_POST["seuil_stock_alerte"]; - $object->duration_value = $_POST["duration_value"]; - $object->duration_unit = $_POST["duration_unit"]; - $object->canvas = $_POST["canvas"]; - $object->weight = $_POST["weight"]; - $object->weight_units = $_POST["weight_units"]; - $object->length = $_POST["size"]; - $object->length_units = $_POST["size_units"]; - $object->surface = $_POST["surface"]; - $object->surface_units = $_POST["surface_units"]; - $object->volume = $_POST["volume"]; - $object->volume_units = $_POST["volume_units"]; - $object->finished = $_POST["finished"]; - $object->hidden = $_POST["hidden"]=='yes'?1:0; + $object->libelle = GETPOST('libelle'); + $object->description = dol_htmlcleanlastbr(GETPOST('desc')); + $object->note = dol_htmlcleanlastbr(GETPOST('note')); + $object->customcode = GETPOST('customcode'); + $object->country_id = GETPOST('country_id'); + $object->status = GETPOST('statut'); + $object->status_buy = GETPOST('statut_buy'); + $object->seuil_stock_alerte = GETPOST('seuil_stock_alerte'); + $object->duration_value = GETPOST('duration_value'); + $object->duration_unit = GETPOST('duration_unit'); + $object->canvas = GETPOST('canvas'); + $object->weight = GETPOST('weight'); + $object->weight_units = GETPOST('weight_units'); + $object->length = GETPOST('size'); + $object->length_units = GETPOST('size_units'); + $object->surface = GETPOST('surface'); + $object->surface_units = GETPOST('surface_units'); + $object->volume = GETPOST('volume'); + $object->volume_units = GETPOST('volume_units'); + $object->finished = GETPOST('finished'); + $object->hidden = GETPOST('hidden')=='yes'?1:0; // Get extra fields foreach($_POST as $key => $value) @@ -348,7 +345,7 @@ if (empty($reshook)) { $db->rollback(); - $_error = 1; + $_error++; $action = ""; $mesg='
'.$langs->trans("ErrorProductAlreadyExists",$object->ref); @@ -403,7 +400,7 @@ if (empty($reshook)) if ($action == 'addinpropal') { $propal = new Propal($db); - $result=$propal->fetch($_POST["propalid"]); + $result=$propal->fetch(GETPOST('propalid')); if ($result <= 0) { dol_print_error($db,$propal->error); @@ -462,12 +459,12 @@ if (empty($reshook)) $propal->id, $desc, $pu_ht, - $_POST["qty"], + GETPOST('qty'), $tva_tx, $localtax1_tx, // localtax1 $localtax2_tx, // localtax2 $prod->id, - $_POST["remise_percent"], + GETPOST('remise_percent'), $price_base_type, $pu_ttc ); @@ -484,7 +481,7 @@ if (empty($reshook)) if ($action == 'addincommande') { $commande = new Commande($db); - $result=$commande->fetch($_POST["commandeid"]); + $result=$commande->fetch(GETPOST('commandeid')); if ($result <= 0) { dol_print_error($db,$commande->error); @@ -544,12 +541,12 @@ if (empty($reshook)) $commande->id, $desc, $pu_ht, - $_POST["qty"], + GETPOST('qty'), $tva_tx, $localtax1_tx, // localtax1 $localtax2_tx, // localtax2 $prod->id, - $_POST["remise_percent"], + GETPOST('remise_percent'), '', '', // TODO voir si fk_remise_except est encore valable car n'apparait plus dans les propales $price_base_type, @@ -567,7 +564,7 @@ if (empty($reshook)) if ($action == 'addinfacture' && $user->rights->facture->creer) { $facture = New Facture($db); - $result=$facture->fetch($_POST["factureid"]); + $result=$facture->fetch(GETPOST('factureid')); if ($result <= 0) { dol_print_error($db,$facture->error); @@ -626,12 +623,12 @@ if (empty($reshook)) $facture->id, $desc, $pu_ht, - $_POST["qty"], + GETPOST('qty'), $tva_tx, $localtax1_tx, $localtax2_tx, $prod->id, - $_POST["remise_percent"], + GETPOST('remise_percent'), '', '', '', @@ -697,9 +694,9 @@ else print '
'; print ''; print ''; - print ''."\n"; + print ''."\n"; - if ($_GET["type"]==1) $title=$langs->trans("NewService"); + if ($type==1) $title=$langs->trans("NewService"); else $title=$langs->trans("NewProduct"); print_fiche_titre($title); @@ -708,32 +705,32 @@ else print '
'.$langs->trans("MarginRate").''; print ''; // set by jquery (see below) print '
'.$langs->trans("MarkRate").''; print ''; // set by jquery (see below) print '
".price($objp->selling_price)."".price($objp->buying_price)."".price($objp->marge)."".(($marginRate === '')?'n/a':price($marginRate)."%")."".(($markRate === '')?'n/a':price($markRate)."%")."'.$invoicestatic->LibStatut($objp->paye,$objp->statut,5).'
".price($cumul_vente)."".price($cumul_achat)."".price($totalMargin)."".(($marginRate === '')?'n/a':price($marginRate)."%")."".(($markRate === '')?'n/a':price($markRate)."%")." 
'; print ''; print ''; // Label - print ''; + print ''; // On sell print ''; // To buy print ''; // Stock min level - if ($_GET["type"] != 1 && $conf->stock->enabled) + if ($type != 1 && $conf->stock->enabled) { print ''; } else @@ -745,24 +742,24 @@ else print '"; // Nature - if ($_GET["type"] != 1) + if ($type != 1) { print ''; } // Duration - if ($_GET["type"] == 1) + if ($type == 1) { - print ''; } - if ($_GET["type"] != 1) // Le poids et le volume ne concerne que les produits et pas les services + if ($type != 1) // Le poids et le volume ne concerne que les produits et pas les services { // Weight print ''; // Length print ''; // Surface print ''; // Volume print ''; } // Customs code - print ''; + print ''; // Origin country print ''; @@ -811,7 +808,7 @@ else { foreach($extrafields->attribute_label as $key=>$label) { - $value=(isset($_POST["options_".$key])?$_POST["options_".$key]:$object->array_options["options_".$key]); + $value=(GETPOST('options_'.$key)?GETPOST('options_'.$key):$object->array_options["options_".$key]); print ''."\n"; @@ -821,7 +818,7 @@ else // Note (private, no output on invoices, propales...) print '"; diff --git a/htdocs/product/liste.php b/htdocs/product/liste.php index 11c9b8eb456..2c2a0a5b469 100644 --- a/htdocs/product/liste.php +++ b/htdocs/product/liste.php @@ -1,7 +1,7 @@ * Copyright (C) 2004-2011 Laurent Destailleur - * Copyright (C) 2005-2011 Regis Houssin + * Copyright (C) 2005-2012 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 @@ -27,7 +27,8 @@ require("../main.inc.php"); require_once(DOL_DOCUMENT_ROOT.'/product/class/product.class.php'); require_once(DOL_DOCUMENT_ROOT."/fourn/class/fournisseur.product.class.php"); require_once(DOL_DOCUMENT_ROOT."/core/class/html.formother.class.php"); -if ($conf->categorie->enabled) require_once(DOL_DOCUMENT_ROOT."/categories/class/categorie.class.php"); +if (! empty($conf->categorie->enabled)) + require_once(DOL_DOCUMENT_ROOT."/categories/class/categorie.class.php"); $langs->load("products"); $langs->load("stocks"); @@ -43,6 +44,7 @@ $search_categ = GETPOST("search_categ",'int'); $tosell = GETPOST("tosell"); $tobuy = GETPOST("tobuy"); $fourn_id = GETPOST("fourn_id",'int'); +$catid = GETPOST('catid','int'); $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); @@ -59,7 +61,8 @@ $limit = $conf->liste_limit; // Get object canvas (By default, this is not defined, so standard usage of dolibarr) //$object->getCanvas($id); -$canvas = GETPOST("canvas"); +$canvas=GETPOST("canvas"); +$objcanvas=''; if (! empty($canvas)) { require_once(DOL_DOCUMENT_ROOT."/core/class/canvas.class.php"); @@ -85,12 +88,6 @@ if (isset($_POST["button_removefilter_x"])) $search_categ=0; } -if ($conf->categorie->enabled && GETPOST('catid')) -{ - $catid = GETPOST('catid','int'); -} - - /* * View @@ -108,7 +105,7 @@ else { $title=$langs->trans("ProductsAndServices"); - if (isset($_GET["type"])) + if (isset($type)) { if ($type==1) { @@ -129,7 +126,7 @@ else $sql.= ' p.duration, p.tosell, p.tobuy, p.seuil_stock_alerte,'; $sql.= ' MIN(pfp.unitprice) as minsellprice'; $sql.= ' FROM '.MAIN_DB_PREFIX.'product as p'; - if ($search_categ || $catid) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_product as cp ON p.rowid = cp.fk_product"; // We'll need this table joined to the select in order to filter by categ + if (! empty($search_categ) || ! empty($catid)) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_product as cp ON p.rowid = cp.fk_product"; // We'll need this table joined to the select in order to filter by categ $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_fournisseur_price as pfp ON p.rowid = pfp.fk_product"; $sql.= ' WHERE p.entity IN ('.getEntity('product', 1).')'; if ($sall) $sql.= " AND (p.ref LIKE '%".$db->escape($sall)."%' OR p.label LIKE '%".$db->escape($sall)."%' OR p.description LIKE '%".$db->escape($sall)."%' OR p.note LIKE '%".$db->escape($sall)."%')"; @@ -146,7 +143,7 @@ else if (isset($tobuy) && dol_strlen($tobuy) > 0) $sql.= " AND p.tobuy = ".$db->escape($tobuy); if (dol_strlen($canvas) > 0) $sql.= " AND p.canvas = '".$db->escape($canvas)."'"; if ($catid > 0) $sql.= " AND cp.fk_categorie = ".$catid; - if ($catid == -2) $sql.= " AND cp.fk_categorie IS NULL"; + if ($catid == -2) $sql.= " AND cp.fk_categorie IS NULL"; if ($search_categ > 0) $sql.= " AND cp.fk_categorie = ".$search_categ; if ($search_categ == -2) $sql.= " AND cp.fk_categorie IS NULL"; if ($fourn_id > 0) $sql.= " AND pfp.fk_soc = ".$fourn_id; @@ -173,13 +170,16 @@ else } $helpurl=''; - if (isset($_GET["type"]) && $_GET["type"] == 0) + if (isset($type)) { - $helpurl='EN:Module_Products|FR:Module_Produits|ES:Módulo_Productos'; - } - if (isset($_GET["type"]) && $_GET["type"] == 1) - { - $helpurl='EN:Module_Services_En|FR:Module_Services|ES:Módulo_Servicios'; + if ($type == 0) + { + $helpurl='EN:Module_Products|FR:Module_Produits|ES:Módulo_Productos'; + } + else if ($type == 1) + { + $helpurl='EN:Module_Services_En|FR:Module_Services|ES:Módulo_Servicios'; + } } llxHeader('',$title,$helpurl,''); @@ -193,16 +193,16 @@ else $param.=isset($type)?"&type=".$type:""; print_barre_liste($texte, $page, "liste.php", $param, $sortfield, $sortorder,'',$num); - if (isset($catid)) + if (! empty($catid)) { print "
"; - $c = new Categorie($db, $catid); + $c = new Categorie($db); $ways = $c->print_all_ways(' > ','product/liste.php'); print " > ".$ways[0]."
\n"; print "

"; } - if (!empty($_GET["canvas"]) && file_exists(DOL_DOCUMENT_ROOT.'/product/canvas/'.$_GET["canvas"].'/actions_card_'.$_GET["canvas"].'.class.php')) + if (! empty($canvas) && file_exists(DOL_DOCUMENT_ROOT.'/product/canvas/'.$canvas.'/actions_card_'.$canvas.'.class.php')) { $fieldlist = $object->field_list; $datas = $object->list_datas; @@ -211,14 +211,14 @@ else $title_text = $title; // Default templates directory - $template_dir = DOL_DOCUMENT_ROOT . '/product/canvas/'.$_GET["canvas"].'/tpl/'; + $template_dir = DOL_DOCUMENT_ROOT . '/product/canvas/'.$canvas.'/tpl/'; // Check if a custom template is present - if (file_exists(DOL_DOCUMENT_ROOT . '/theme/'.$conf->theme.'/tpl/product/'.$_GET["canvas"].'/list.tpl.php')) + if (file_exists(DOL_DOCUMENT_ROOT . '/theme/'.$conf->theme.'/tpl/product/'.$canvas.'/list.tpl.php')) { - $template_dir = DOL_DOCUMENT_ROOT . '/theme/'.$conf->theme.'/tpl/product/'.$_GET["canvas"].'/'; + $template_dir = DOL_DOCUMENT_ROOT . '/theme/'.$conf->theme.'/tpl/product/'.$canvas.'/'; } - include($template_dir.'list.tpl.php'); // Include native PHP templates + include($template_dir.'list.tpl.php'); // Include native PHP templates } else { @@ -233,7 +233,7 @@ else // Filter on categories $moreforfilter=''; - if ($conf->categorie->enabled) + if (! empty($conf->categorie->enabled)) { $moreforfilter.=$langs->trans('Categories'). ': '; $moreforfilter.=$htmlother->select_categories(0,$search_categ,'search_categ',1); @@ -251,12 +251,12 @@ else print "
"; print_liste_field_titre($langs->trans("Ref"), $_SERVER["PHP_SELF"], "p.ref",$param,"","",$sortfield,$sortorder); print_liste_field_titre($langs->trans("Label"), $_SERVER["PHP_SELF"], "p.label",$param,"","",$sortfield,$sortorder); - if ($conf->barcode->enabled) print_liste_field_titre($langs->trans("BarCode"), $_SERVER["PHP_SELF"], "p.barcode",$param,'','',$sortfield,$sortorder); + if (! empty($conf->barcode->enabled)) print_liste_field_titre($langs->trans("BarCode"), $_SERVER["PHP_SELF"], "p.barcode",$param,'','',$sortfield,$sortorder); print_liste_field_titre($langs->trans("DateModification"), $_SERVER["PHP_SELF"], "p.tms",$param,"",'align="center"',$sortfield,$sortorder); - if ($conf->service->enabled && $type != 0) print_liste_field_titre($langs->trans("Duration"), $_SERVER["PHP_SELF"], "p.duration",$param,"",'align="center"',$sortfield,$sortorder); + if (! empty($conf->service->enabled) && $type != 0) print_liste_field_titre($langs->trans("Duration"), $_SERVER["PHP_SELF"], "p.duration",$param,"",'align="center"',$sortfield,$sortorder); if (empty($conf->global->PRODUIT_MULTIPRICES)) print_liste_field_titre($langs->trans("SellingPrice"), $_SERVER["PHP_SELF"], "p.price",$param,"",'align="right"',$sortfield,$sortorder); print ''; - if ($conf->stock->enabled && $user->rights->stock->lire && $type != 1) print ''; + if (! empty($conf->stock->enabled) && $user->rights->stock->lire && $type != 1) print ''; print_liste_field_titre($langs->trans("Sell"), $_SERVER["PHP_SELF"], "p.tosell",$param,"",'align="right"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("Buy"), $_SERVER["PHP_SELF"], "p.tobuy",$param,"",'align="right"',$sortfield,$sortorder); print "\n"; @@ -269,7 +269,7 @@ else print ''; - if ($conf->barcode->enabled) + if (! empty($conf->barcode->enabled)) { print ''; // Duration - if ($conf->service->enabled && $type != 0) + if (! empty($conf->service->enabled) && $type != 0) { print ''; // Stock - if ($conf->stock->enabled && $user->rights->stock->lire && $type != 1) + if (! empty($conf->stock->enabled) && $user->rights->stock->lire && $type != 1) { print ''; // Barcode - if ($conf->barcode->enabled) + if (! empty($conf->barcode->enabled)) { print ''; } @@ -368,7 +368,7 @@ else print '\n"; // Duration - if ($conf->service->enabled && $type != 0) + if (! empty($conf->service->enabled) && $type != 0) { print ''; // Show stock - if ($conf->stock->enabled && $user->rights->stock->lire && $type != 1) + if (! empty($conf->stock->enabled) && $user->rights->stock->lire && $type != 1) { if ($objp->fk_product_type != 1) { @@ -435,7 +435,7 @@ else if ($num > $conf->liste_limit) { - if ($sref || $snom || $sall || $sbarcode || $_POST["search"]) + if ($sref || $snom || $sall || $sbarcode || GETPOST('search')) { print_barre_liste('', $page, "liste.php", "&sref=".$sref."&snom=".$snom."&sall=".$sall."&tosell=".$tosell."&tobuy=".$tobuy, $sortfield, $sortorder,'',$num); } @@ -458,7 +458,6 @@ else } -$db->close(); - llxFooter(); +$db->close(); ?> diff --git a/htdocs/product/popuprop.php b/htdocs/product/popuprop.php index af75586dc21..70ca91c4f8c 100644 --- a/htdocs/product/popuprop.php +++ b/htdocs/product/popuprop.php @@ -2,7 +2,7 @@ /* Copyright (C) 2001-2003 Rodolphe Quiedeville * Copyright (C) 2004-2005 Laurent Destailleur * Copyright (C) 2004 Eric Seigne - * Copyright (C) 2005-2010 Regis Houssin + * Copyright (C) 2005-2012 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 @@ -27,13 +27,15 @@ require("../main.inc.php"); require_once(DOL_DOCUMENT_ROOT.'/product/class/product.class.php'); +$type=GETPOST("type","int"); + // Security check -if ($user->societe_id) $socid=$user->societe_id; +if (! empty($user->societe_id)) $socid=$user->societe_id; $result=restrictedArea($user,'produit|service'); -$sortfield = isset($_GET["sortfield"])?$_GET["sortfield"]:$_POST["sortfield"]; -$sortorder = isset($_GET["sortorder"])?$_GET["sortorder"]:$_POST["sortorder"]; -$page = $_GET["page"]; +$sortfield = GETPOST("sortfield",'alpha'); +$sortorder = GETPOST("sortorder",'alpha'); +$page = GETPOST("page",'int'); if ($page < 0) $page = 0; if (! $sortfield) $sortfield="c"; if (! $sortorder) $sortorder="DESC"; @@ -51,22 +53,22 @@ $staticproduct=new Product($db); */ $helpurl=''; -if (isset($_GET["type"]) && $_GET["type"] == 0) +if ($type == 0) { $helpurl='EN:Module_Products|FR:Module_Produits|ES:Módulo_Productos'; } -if (isset($_GET["type"]) && $_GET["type"] == 1) +else if ($type == 1) { $helpurl='EN:Module_Services_En|FR:Module_Services|ES:Módulo_Servicios'; } -llxHeader('',$title,$helpurl,''); +llxHeader('','',$helpurl); //On n'affiche le lien page suivante que s'il y a une page suivante ... $sql = "SELECT count(*) as c"; $sql.= " FROM ".MAIN_DB_PREFIX."product"; $sql.= ' WHERE entity IN ('.getEntity('product', 1).')'; -if (isset($_GET['type'])) $sql.= " AND fk_product_type = ".$_GET['type']; +if (isset($type)) $sql.= " AND fk_product_type = ".$type; $result=$db->query($sql); if ($result) @@ -77,11 +79,11 @@ if ($result) $param = ''; $title = $langs->trans("ListProductServiceByPopularity"); -if (isset($_GET['type'])) +if (isset($type)) { - $param = '&type='.$_GET['type']; + $param = '&type='.$type; $title = $langs->trans("ListProductByPopularity"); - if ($_GET['type'] == 1) $title = $langs->trans("ListServiceByPopularity"); + if ($type == 1) $title = $langs->trans("ListServiceByPopularity"); } print_barre_liste($title, $page, "popuprop.php",$param,"","","",$num); @@ -101,7 +103,7 @@ $sql.= " FROM ".MAIN_DB_PREFIX."propaldet as pd"; $sql.= ", ".MAIN_DB_PREFIX."product as p"; $sql.= ' WHERE p.entity IN ('.getEntity('product', 1).')'; $sql.= " AND p.rowid = pd.fk_product"; -if (isset($_GET['type'])) $sql.= " AND fk_product_type = ".$_GET['type']; +if (isset($type)) $sql.= " AND fk_product_type = ".$type; $sql.= " GROUP BY (p.rowid)"; $sql.= $db->order($sortfield,$sortorder); $sql.= $db->plimit($limit, $offset); @@ -109,52 +111,54 @@ $sql.= $db->plimit($limit, $offset); $result=$db->query($sql); if ($result) { - $num = $db->num_rows($result); - $i = 0; + $num = $db->num_rows($result); + $i = 0; - $var=True; - while ($i < $num) - { - $objp = $db->fetch_object($result); + $var=True; + while ($i < $num) + { + $objp = $db->fetch_object($result); - // Multilangs - if ($conf->global->MAIN_MULTILANGS) // si l'option est active - { - $sql = "SELECT label"; - $sql.= " FROM ".MAIN_DB_PREFIX."product_lang"; - $sql.= " WHERE fk_product=".$objp->rowid; - $sql.= " AND lang='". $langs->getDefaultLang() ."'"; - $sql.= " LIMIT 1"; + // Multilangs + if (! empty($conf->global->MAIN_MULTILANGS)) // si l'option est active + { + $sql = "SELECT label"; + $sql.= " FROM ".MAIN_DB_PREFIX."product_lang"; + $sql.= " WHERE fk_product=".$objp->rowid; + $sql.= " AND lang='". $langs->getDefaultLang() ."'"; + $sql.= " LIMIT 1"; - $resultp = $db->query($sql); - if ($resultp) - { - $objtp = $db->fetch_object($resultp); - if ($objtp->label != '') $objp->label = $objtp->label; - } - } + $resultp = $db->query($sql); + if ($resultp) + { + $objtp = $db->fetch_object($resultp); + if (! empty($objtp->label)) $objp->label = $objtp->label; + } + } - $var=!$var; - print ""; - print ''; - print ''; - print ''; - print ''; - print "\n"; - $i++; - } - $db->free(); + $var=!$var; + print ""; + print ''; + print ''; + print ''; + print ''; + print "\n"; + $i++; + } + + $db->free(); } + print "
'.$langs->trans("Ref").''; - if ($_error == 1) + if ($_error) { print $langs->trans("RefAlreadyExists"); } print '
'.$langs->trans("Label").'
'.$langs->trans("Label").'
'.$langs->trans("Status").' ('.$langs->trans("Sell").')'; $statutarray=array('1' => $langs->trans("OnSell"), '0' => $langs->trans("NotOnSell")); - print $form->selectarray('statut',$statutarray,$_POST["statut"]); + print $form->selectarray('statut',$statutarray,GETPOST('statut')); print '
'.$langs->trans("Status").' ('.$langs->trans("Buy").')'; $statutarray=array('1' => $langs->trans("ProductStatusOnBuy"), '0' => $langs->trans("ProductStatusNotOnBuy")); - print $form->selectarray('statut_buy',$statutarray,$_POST["statut_buy"]); + print $form->selectarray('statut_buy',$statutarray,GETPOST('statut_buy"')); print '
'.$langs->trans("StockLimit").''; - print ''; + print ''; print '
'.$langs->trans("Description").''; require_once(DOL_DOCUMENT_ROOT."/core/class/doleditor.class.php"); - $doleditor=new DolEditor('desc',$_POST["desc"],'',160,'dolibarr_details','',false,true,$conf->global->FCKEDITOR_ENABLE_PRODUCTDESC,4,90); + $doleditor=new DolEditor('desc',GETPOST('desc'),'',160,'dolibarr_details','',false,true,$conf->global->FCKEDITOR_ENABLE_PRODUCTDESC,4,90); $doleditor->Create(); print "
'.$langs->trans("Nature").''; $statutarray=array('1' => $langs->trans("Finished"), '0' => $langs->trans("RowMaterial")); - print $form->selectarray('finished',$statutarray,$_POST["finished"]); + print $form->selectarray('finished',$statutarray,GETPOST('finished')); print '
'.$langs->trans("Duration").'  '; + print '
'.$langs->trans("Duration").'  '; print ''.$langs->trans("Hour").' '; print ''.$langs->trans("Day").' '; print ''.$langs->trans("Week").' '; @@ -771,36 +768,36 @@ else print '
'.$langs->trans("Weight").''; - print ''; + print ''; print $formproduct->select_measuring_units("weight_units","weight"); print '
'.$langs->trans("Length").''; - print ''; + print ''; print $formproduct->select_measuring_units("size_units","size"); print '
'.$langs->trans("Surface").''; - print ''; + print ''; print $formproduct->select_measuring_units("surface_units","surface"); print '
'.$langs->trans("Volume").''; - print ''; + print ''; print $formproduct->select_measuring_units("volume_units","volume"); print '
'.$langs->trans("CustomCode").'
'.$langs->trans("CustomCode").'
'.$langs->trans("CountryOrigin").''; - print $form->select_country($_POST["country_id"],'country_id'); + print $form->select_country(GETPOST('country_id','int'),'country_id'); if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionnarySetup"),1); print '
'.$label.''; print $extrafields->showInputField($key,$value); print '
'.$langs->trans("NoteNotVisibleOnBill").''; require_once(DOL_DOCUMENT_ROOT."/core/class/doleditor.class.php"); - $doleditor=new DolEditor('note',$_POST["note"],'',180,'dolibarr_notes','',false,true,$conf->global->FCKEDITOR_ENABLE_PRODUCTDESC,8,70); + $doleditor=new DolEditor('note',GETPOST('note'),'',180,'dolibarr_notes','',false,true,$conf->global->FCKEDITOR_ENABLE_PRODUCTDESC,8,70); $doleditor->Create(); print "
'.$langs->trans("BuyingPriceMinShort").''.$langs->trans("PhysicalStock").''.$langs->trans("PhysicalStock").'
'; print ''; print ''; print ''; @@ -280,7 +280,7 @@ else print ''; print ' '; @@ -301,7 +301,7 @@ else print ''; print ' '; @@ -328,7 +328,7 @@ else $objp = $db->fetch_object($resql); // Multilangs - if ($conf->global->MAIN_MULTILANGS) // si l'option est active + if (! empty($conf->global->MAIN_MULTILANGS)) // si l'option est active { $sql = "SELECT label"; $sql.= " FROM ".MAIN_DB_PREFIX."product_lang"; @@ -340,7 +340,7 @@ else if ($result) { $objtp = $db->fetch_object($result); - if ($objtp->label != '') $objp->label = $objtp->label; + if (! empty($objtp->label)) $objp->label = $objtp->label; } } @@ -359,7 +359,7 @@ else print ''.dol_trunc($objp->label,40).''.$objp->barcode.''.dol_print_date($db->jdate($objp->datem),'day')."'; if (preg_match('/([0-9]+)y/i',$objp->duration,$regs)) print $regs[1].' '.$langs->trans("DurationYear"); @@ -406,7 +406,7 @@ else print '
'; - if ($objp->type==1) print img_object($langs->trans("ShowService"),"service"); - else print img_object($langs->trans("ShowProduct"),"product"); - print " "; - print $objp->ref.''; - if ($objp->type==1) print $langs->trans("ShowService"); - else print $langs->trans("ShowProduct"); - print ''.$objp->label.''.$objp->c.'
'; + if ($objp->type==1) print img_object($langs->trans("ShowService"),"service"); + else print img_object($langs->trans("ShowProduct"),"product"); + print " "; + print $objp->ref.''; + if ($objp->type==1) print $langs->trans("ShowService"); + else print $langs->trans("ShowProduct"); + print ''.$objp->label.''.$objp->c.'
"; -$db->close(); llxFooter(); +$db->close(); ?> diff --git a/htdocs/product/reassort.php b/htdocs/product/reassort.php index 5d77302d953..b3f229c5ffb 100644 --- a/htdocs/product/reassort.php +++ b/htdocs/product/reassort.php @@ -1,7 +1,7 @@ * Copyright (C) 2004-2011 Laurent Destailleur - * Copyright (C) 2005-2009 Regis Houssin + * Copyright (C) 2005-2012 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 @@ -36,30 +36,41 @@ if ($user->societe_id) $socid=$user->societe_id; $result=restrictedArea($user,'produit|service'); -$sref=isset($_GET["sref"])?$_GET["sref"]:$_POST["sref"]; -$snom=isset($_GET["snom"])?$_GET["snom"]:$_POST["snom"]; -$sall=isset($_GET["sall"])?$_GET["sall"]:$_POST["sall"]; -$type=isset($_GET["type"])?$_GET["type"]:$_POST["type"]; -$sref=trim($sref); -$snom=trim($snom); -$sall=trim($sall); -$type=trim($type); +$action=GETPOST('action','alpha'); +$sref=GETPOST("sref"); +$snom=GETPOST("snom"); +$sall=GETPOST("sall"); +$type=GETPOST("type","int"); +$sbarcode=GETPOST("sbarcode"); +$catid=GETPOST('catid','int'); +$toolowstock=GETPOST('toolowstock'); +$tosell = GETPOST("tosell"); +$tobuy = GETPOST("tobuy"); +$fourn_id = GETPOST("fourn_id",'int'); -$sortfield = isset($_GET["sortfield"])?$_GET["sortfield"]:$_POST["sortfield"]; -$sortorder = isset($_GET["sortorder"])?$_GET["sortorder"]:$_POST["sortorder"]; +$sortfield = GETPOST("sortfield",'alpha'); +$sortorder = GETPOST("sortorder",'alpha'); +$page = GETPOST("page",'int'); if (! $sortfield) $sortfield="stock_physique"; if (! $sortorder) $sortorder="ASC"; -$page = $_GET["page"]; $limit = $conf->liste_limit; $offset = $limit * $page ; -$catid=GETPOST('catid'); -$toolowstock=GETPOST('toolowstock'); - // Load sale and categ filters $search_sale = GETPOST("search_sale"); $search_categ = GETPOST("search_categ"); +// Get object canvas (By default, this is not defined, so standard usage of dolibarr) +//$object->getCanvas($id); +$canvas=GETPOST("canvas"); +$objcanvas=''; +if (! empty($canvas)) +{ + require_once(DOL_DOCUMENT_ROOT."/core/class/canvas.class.php"); + $objcanvas = new Canvas($db,$action); + $objcanvas->getCanvas('product','list',$canvas); +} + if (! empty($_POST["button_removefilter_x"])) { $sref=""; @@ -118,15 +129,15 @@ if (dol_strlen($type)) if ($sref) $sql.= " AND p.ref LIKE '%".$sref."%'"; if ($sbarcode) $sql.= " AND p.barcode LIKE '%".$sbarcode."%'"; if ($snom) $sql.= " AND p.label LIKE '%".$db->escape($snom)."%'"; -if (isset($_GET["tosell"]) && dol_strlen($_GET["tosell"]) > 0) +if (! empty($tosell)) { - $sql.= " AND p.tosell = ".$_GET["tosell"]; + $sql.= " AND p.tosell = ".$tosell; } -if (isset($_GET["tobuy"]) && dol_strlen($_GET["tobuy"]) > 0) +if (! empty($tobuy)) { - $sql.= " AND p.tobuy = ".$_GET["tobuy"]; + $sql.= " AND p.tobuy = ".$tobuy; } -if (dol_strlen($canvas) > 0) +if (! empty($canvas)) { $sql.= " AND p.canvas = '".$db->escape($canvas)."'"; } @@ -164,21 +175,10 @@ if ($resql) exit; } - if (isset($_GET["tosell"]) || isset($_POST["tosell"])) - { - $tosell = (isset($_GET["tosell"])?$_GET["tosell"]:$_POST["tosell"]); - } - if (isset($_GET["tobuy"]) || isset($_POST["tobuy"])) - { - $tobuy = (isset($_GET["tobuy"])?$_GET["tobuy"]:$_POST["tobuy"]); - } - - - $helpurl=''; $helpurl='EN:Module_Stocks_En|FR:Module_Stock|ES:Módulo_Stocks'; - if (isset($_GET["type"]) || isset($_POST["type"])) + if (isset($type)) { if ($type==1) { $texte = $langs->trans("Services"); } else { $texte = $langs->trans("Products"); } @@ -190,16 +190,16 @@ if ($resql) llxHeader("",$title,$helpurl,$texte); - if ($sref || $snom || $sall || $_POST["search"]) + if ($sref || $snom || $sall || GETPOST('search')) { - print_barre_liste($texte, $page, "reassort.php", "&sref=".$sref."&snom=".$snom."&sall=".$sall."&tosell=".$_POST["tosell"]."&tobuy=".$_POST["tobuy"], $sortfield, $sortorder,'',$num); + print_barre_liste($texte, $page, "reassort.php", "&sref=".$sref."&snom=".$snom."&sall=".$sall."&tosell=".$tosell."&tobuy=".$tobuy, $sortfield, $sortorder,'',$num); } else { print_barre_liste($texte, $page, "reassort.php", "&sref=$sref&snom=$snom&fourn_id=$fourn_id".(isset($type)?"&type=$type":""), $sortfield, $sortorder,'',$num); } - if ($catid) + if (! empty($catid)) { print "
"; $c = new Categorie($db); @@ -219,7 +219,7 @@ if ($resql) // Filter on categories $moreforfilter=''; - if ($conf->categorie->enabled) + if (! empty($conf->categorie->enabled)) { $moreforfilter.=$langs->trans('Categories'). ': '; $moreforfilter.=$htmlother->select_categories(0,$search_categ,'search_categ'); @@ -258,7 +258,7 @@ if ($resql) print ''; print ''; print ''; - if ($conf->service->enabled && $type == 1) + if (! empty($conf->service->enabled) && $type == 1) { print ''; print ' '; @@ -282,7 +282,7 @@ if ($resql) $objp = $db->fetch_object($resql); // Multilangs - if ($conf->global->MAIN_MULTILANGS) // si l'option est active + if (! empty($conf->global->MAIN_MULTILANGS)) // si l'option est active { $sql = "SELECT label"; $sql.= " FROM ".MAIN_DB_PREFIX."product_lang"; @@ -294,7 +294,7 @@ if ($resql) if ($result) { $objtp = $db->fetch_object($result); - if ($objtp->label != '') $objp->label = $objtp->label; + if (! empty($objtp->label)) $objp->label = $objtp->label; } } @@ -308,7 +308,7 @@ if ($resql) print ''; print ''.$objp->label.''; - if ($conf->service->enabled && $type == 1) + if (! empty($conf->service->enabled) && $type == 1) { print ''; if (preg_match('/([0-9]+)y/i',$objp->duration,$regs)) print $regs[1].' '.$langs->trans("DurationYear"); @@ -335,7 +335,7 @@ if ($resql) if ($num > $conf->liste_limit) { - if ($sref || $snom || $sall || $_POST["search"]) + if ($sref || $snom || $sall || GETPOST('search')) { print_barre_liste('', $page, "reassort.php", "&sref=".$sref."&snom=".$snom."&sall=".$sall."&tosell=".$tosell."&tobuy=".$tobuy, $sortfield, $sortorder,'',$num, 0, ''); } @@ -354,7 +354,6 @@ else } -$db->close(); - llxFooter(); +$db->close(); ?> \ No newline at end of file diff --git a/htdocs/projet/document.php b/htdocs/projet/document.php index 7386bf62719..ee07aed7804 100644 --- a/htdocs/projet/document.php +++ b/htdocs/projet/document.php @@ -39,13 +39,6 @@ $ref = GETPOST('ref','alpha'); $mine = (GETPOST('mode','alpha') == 'mine' ? 1 : 0); //if (! $user->rights->projet->all->lire) $mine=1; // Special for projects -$mesg=''; -if (isset($_SESSION['DolMessage'])) -{ - $mesg=$_SESSION['DolMessage']; - unset($_SESSION['DolMessage']); -} - // Security check $socid=0; if ($user->societe_id > 0) $socid=$user->societe_id; @@ -122,7 +115,7 @@ if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->projet->s $upload_dir = $conf->projet->dir_output . "/" . dol_sanitizeFileName($object->ref); $file = $upload_dir . '/' . GETPOST('urlfile'); // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP). dol_delete_file($file,0,0,0,$object); - $_SESSION['DolMessage'] = '
'.$langs->trans("FileWasRemoved",GETPOST('urlfile')).'
'; + $_SESSION['dol_message'] = '
'.$langs->trans("FileWasRemoved",GETPOST('urlfile')).'
'; Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id); exit; } diff --git a/htdocs/projet/tasks/document.php b/htdocs/projet/tasks/document.php index b4611588775..7f9755fda37 100644 --- a/htdocs/projet/tasks/document.php +++ b/htdocs/projet/tasks/document.php @@ -44,13 +44,6 @@ $ref= GETPOST('ref','alpha'); $withproject=GETPOST('withproject','int'); $project_ref = GETPOST('project_ref','alpha'); -$mesg=''; -if (isset($_SESSION['DolMessage'])) -{ - $mesg=$_SESSION['DolMessage']; - unset($_SESSION['DolMessage']); -} - // Security check $socid=0; if ($user->societe_id > 0) $socid = $user->societe_id; @@ -119,7 +112,7 @@ if ($action=='delete') $langs->load("other"); $file = $upload_dir . '/' . GETPOST('urlfile'); // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP). dol_delete_file($file); - $_SESSION['DolMessage'] = '
'.$langs->trans("FileWasRemoved",GETPOST('urlfile')).'
'; + $_SESSION['dol_message'] = '
'.$langs->trans("FileWasRemoved",GETPOST('urlfile')).'
'; Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id); exit; } diff --git a/htdocs/societe/document.php b/htdocs/societe/document.php index 26aad2de1dd..a5cdd9efb0e 100644 --- a/htdocs/societe/document.php +++ b/htdocs/societe/document.php @@ -39,13 +39,6 @@ $confirm=GETPOST('confirm'); $id=(GETPOST('socid','int') ? GETPOST('socid','int') : GETPOST('id','int')); $ref = GETPOST('ref', 'alpha'); -$mesg=''; -if (isset($_SESSION['DolMessage'])) -{ - $mesg=$_SESSION['DolMessage']; - unset($_SESSION['DolMessage']); -} - // Security check if ($user->societe_id > 0) { @@ -131,7 +124,7 @@ if ($action == 'confirm_deletefile' && $confirm == 'yes') $file = $upload_dir . "/" . GETPOST('urlfile'); // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP). dol_delete_file($file,0,0,0,$object); - $_SESSION['DolMessage'] = '
'.$langs->trans("FileWasRemoved",GETPOST('urlfile')).'
'; + $_SESSION['dol_message'] = '
'.$langs->trans("FileWasRemoved",GETPOST('urlfile')).'
'; Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id); exit; } diff --git a/htdocs/societe/soc.php b/htdocs/societe/soc.php index 012aff5818f..ca9ac156ad9 100644 --- a/htdocs/societe/soc.php +++ b/htdocs/societe/soc.php @@ -84,20 +84,20 @@ $error=$hookmanager->error; $errors=array_merge($errors, (array) $hookmanager->e if (empty($reshook)) { - if ($_POST["getcustomercode"]) + if (GETPOST('getcustomercode')) { // We defined value code_client $_POST["code_client"]="Acompleter"; } - if ($_POST["getsuppliercode"]) + if (GETPOST('getsuppliercode')) { // We defined value code_fournisseur $_POST["code_fournisseur"]="Acompleter"; } // Add new third party - if ((! $_POST["getcustomercode"] && ! $_POST["getsuppliercode"]) + if ((! GETPOST('getcustomercode') && ! GETPOST('getsuppliercode')) && ($action == 'add' || $action == 'update') && $user->rights->societe->creer) { require_once(DOL_DOCUMENT_ROOT."/core/lib/functions2.lib.php"); @@ -1444,7 +1444,7 @@ else dol_htmloutput_errors($error,$errors); $showlogo=$object->logo; - $showbarcode=($conf->barcode->enabled && $user->rights->barcode->lire); + $showbarcode=(! empty($conf->barcode->enabled) && $user->rights->barcode->lire); print ''; @@ -1467,9 +1467,9 @@ else // Logo+barcode $rowspan=4; if (! empty($conf->global->SOCIETE_USEPREFIX)) $rowspan++; - if ($object->client) $rowspan++; - if ($conf->fournisseur->enabled && $object->fournisseur && ! empty($user->rights->fournisseur->lire)) $rowspan++; - if ($conf->global->MAIN_MODULE_BARCODE) $rowspan++; + if (! empty($object->client)) $rowspan++; + if (! empty($conf->fournisseur->enabled) && $object->fournisseur && ! empty($user->rights->fournisseur->lire)) $rowspan++; + if (! empty($conf->global->MAIN_MODULE_BARCODE)) $rowspan++; if (empty($conf->global->SOCIETE_DISABLE_STATE)) $rowspan++; $htmllogobar=''; if ($showlogo || $showbarcode) @@ -1502,7 +1502,7 @@ else } // Supplier code - if ($conf->fournisseur->enabled && $object->fournisseur && ! empty($user->rights->fournisseur->lire)) + if (! empty($conf->fournisseur->enabled) && $object->fournisseur && ! empty($user->rights->fournisseur->lire)) { print '
'; print $langs->trans('SupplierCode').''; @@ -1514,7 +1514,7 @@ else } // Barcode - if ($conf->global->MAIN_MODULE_BARCODE) + if (! empty($conf->global->MAIN_MODULE_BARCODE)) { print '
'; print $langs->trans('Gencod').''.$object->barcode; diff --git a/htdocs/theme/amarok/img/commissions.png b/htdocs/theme/amarok/img/commissions.png deleted file mode 100644 index b1e139e3fba..00000000000 Binary files a/htdocs/theme/amarok/img/commissions.png and /dev/null differ diff --git a/htdocs/theme/amarok/img/marges.png b/htdocs/theme/amarok/img/marges.png deleted file mode 100644 index 4746f0fc779..00000000000 Binary files a/htdocs/theme/amarok/img/marges.png and /dev/null differ diff --git a/htdocs/theme/amarok/img/object_marges.png b/htdocs/theme/amarok/img/object_margin.png similarity index 100% rename from htdocs/theme/amarok/img/object_marges.png rename to htdocs/theme/amarok/img/object_margin.png diff --git a/htdocs/theme/auguria/img/commissions.png b/htdocs/theme/auguria/img/commissions.png deleted file mode 100644 index b1e139e3fba..00000000000 Binary files a/htdocs/theme/auguria/img/commissions.png and /dev/null differ diff --git a/htdocs/theme/auguria/img/marges.png b/htdocs/theme/auguria/img/marges.png deleted file mode 100644 index 4746f0fc779..00000000000 Binary files a/htdocs/theme/auguria/img/marges.png and /dev/null differ diff --git a/htdocs/theme/auguria/img/object_marges.png b/htdocs/theme/auguria/img/object_margin.png similarity index 100% rename from htdocs/theme/auguria/img/object_marges.png rename to htdocs/theme/auguria/img/object_margin.png diff --git a/htdocs/theme/auguria/style.css.php b/htdocs/theme/auguria/style.css.php index 40d0578c68e..b7340ef3e2b 100644 --- a/htdocs/theme/auguria/style.css.php +++ b/htdocs/theme/auguria/style.css.php @@ -320,7 +320,7 @@ $moduletomainmenu=array('user'=>'','syslog'=>'','societe'=>'companies','projet'= 'barcode'=>'','fckeditor'=>'','categorie'=>'', ); $mainmenuused='home'; -foreach($conf->modules as $key => $val) +foreach($conf->modules as $val) { $mainmenuused.=','.(isset($moduletomainmenu[$val])?$moduletomainmenu[$val]:$val); } @@ -331,7 +331,7 @@ $mainmenuusedarray=array(); // Disable $generic=1; $divalreadydefined=array('home','companies','products','commercial','accountancy','project','tools','members','shop','agenda','ecm','cashdesk'); -foreach($mainmenuusedarray as $key => $val) +foreach($mainmenuusedarray as $val) { if (empty($val) || in_array($val,$divalreadydefined)) continue; //print "XXX".$val; diff --git a/htdocs/theme/bureau2crea/img/commissions.png b/htdocs/theme/bureau2crea/img/commissions.png deleted file mode 100644 index b1e139e3fba..00000000000 Binary files a/htdocs/theme/bureau2crea/img/commissions.png and /dev/null differ diff --git a/htdocs/theme/bureau2crea/img/marges.png b/htdocs/theme/bureau2crea/img/marges.png deleted file mode 100644 index 4746f0fc779..00000000000 Binary files a/htdocs/theme/bureau2crea/img/marges.png and /dev/null differ diff --git a/htdocs/theme/bureau2crea/img/object_marges.png b/htdocs/theme/bureau2crea/img/object_margin.png similarity index 100% rename from htdocs/theme/bureau2crea/img/object_marges.png rename to htdocs/theme/bureau2crea/img/object_margin.png diff --git a/htdocs/theme/bureau2crea/style.css.php b/htdocs/theme/bureau2crea/style.css.php index 6183a246a83..d8ab2f33920 100644 --- a/htdocs/theme/bureau2crea/style.css.php +++ b/htdocs/theme/bureau2crea/style.css.php @@ -383,7 +383,7 @@ $moduletomainmenu=array('user'=>'','syslog'=>'','societe'=>'companies','projet'= 'barcode'=>'','fckeditor'=>'','categorie'=>'', ); $mainmenuused='home'; -foreach($conf->modules as $key => $val) +foreach($conf->modules as $val) { $mainmenuused.=','.(isset($moduletomainmenu[$val])?$moduletomainmenu[$val]:$val); } @@ -394,7 +394,7 @@ $mainmenuusedarray=array(); // Disable $generic=1; $divalreadydefined=array('home','companies','products','commercial','accountancy','project','tools','members','shop','agenda','ecm','cashdesk'); -foreach($mainmenuusedarray as $key => $val) +foreach($mainmenuusedarray as $val) { if (empty($val) || in_array($val,$divalreadydefined)) continue; //print "XXX".$val; diff --git a/htdocs/theme/cameleo/img/commissions.png b/htdocs/theme/cameleo/img/commissions.png deleted file mode 100644 index b1e139e3fba..00000000000 Binary files a/htdocs/theme/cameleo/img/commissions.png and /dev/null differ diff --git a/htdocs/theme/cameleo/img/marges.png b/htdocs/theme/cameleo/img/marges.png deleted file mode 100644 index 4746f0fc779..00000000000 Binary files a/htdocs/theme/cameleo/img/marges.png and /dev/null differ diff --git a/htdocs/theme/cameleo/img/object_marges.png b/htdocs/theme/cameleo/img/object_margin.png similarity index 100% rename from htdocs/theme/cameleo/img/object_marges.png rename to htdocs/theme/cameleo/img/object_margin.png diff --git a/htdocs/theme/cameleo/style.css.php b/htdocs/theme/cameleo/style.css.php index a63f1e04636..78121b403c0 100644 --- a/htdocs/theme/cameleo/style.css.php +++ b/htdocs/theme/cameleo/style.css.php @@ -467,7 +467,7 @@ $moduletomainmenu=array('user'=>'','syslog'=>'','societe'=>'companies','projet'= 'barcode'=>'','fckeditor'=>'','categorie'=>'', ); $mainmenuused='home'; -foreach($conf->modules as $key => $val) +foreach($conf->modules as $val) { $mainmenuused.=','.(isset($moduletomainmenu[$val])?$moduletomainmenu[$val]:$val); } @@ -476,7 +476,7 @@ $mainmenuusedarray=array_unique(explode(',',$mainmenuused)); $generic=1; $divalreadydefined=array('home','companies','products','commercial','accountancy','project','tools','members','shop','agenda','ecm','bookmark','cashdesk','geoipmaxmind','gravatar','clicktodial','paypal','webservices'); -foreach($mainmenuusedarray as $key => $val) +foreach($mainmenuusedarray as $val) { if (empty($val) || in_array($val,$divalreadydefined)) continue; //print "XXX".$val; diff --git a/htdocs/theme/eldy/img/commissions.png b/htdocs/theme/eldy/img/commissions.png deleted file mode 100644 index b1e139e3fba..00000000000 Binary files a/htdocs/theme/eldy/img/commissions.png and /dev/null differ diff --git a/htdocs/theme/eldy/img/marges.png b/htdocs/theme/eldy/img/marges.png deleted file mode 100644 index 4746f0fc779..00000000000 Binary files a/htdocs/theme/eldy/img/marges.png and /dev/null differ diff --git a/htdocs/theme/eldy/img/menus/marges.png b/htdocs/theme/eldy/img/menus/marges.png deleted file mode 100644 index 4746f0fc779..00000000000 Binary files a/htdocs/theme/eldy/img/menus/marges.png and /dev/null differ diff --git a/htdocs/theme/eldy/img/object_marges.png b/htdocs/theme/eldy/img/object_margin.png similarity index 100% rename from htdocs/theme/eldy/img/object_marges.png rename to htdocs/theme/eldy/img/object_margin.png diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index 326da714425..b8470e3c090 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -628,7 +628,7 @@ $moduletomainmenu=array('user'=>'','syslog'=>'','societe'=>'companies','projet'= 'barcode'=>'','fckeditor'=>'','categorie'=>'', ); $mainmenuused='home'; -foreach($conf->modules as $key => $val) +foreach($conf->modules as $val) { $mainmenuused.=','.(isset($moduletomainmenu[$val])?$moduletomainmenu[$val]:$val); } @@ -637,7 +637,7 @@ $mainmenuusedarray=array_unique(explode(',',$mainmenuused)); $generic=1; $divalreadydefined=array('home','companies','products','commercial','accountancy','project','tools','members','shop','agenda','bookmark','cashdesk','ecm','geoipmaxmind','gravatar','clicktodial','paypal','webservices'); -foreach($mainmenuusedarray as $key => $val) +foreach($mainmenuusedarray as $val) { if (empty($val) || in_array($val,$divalreadydefined)) continue; //print "XXX".$val; diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index fe6650d4203..a78b4a91f55 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -531,7 +531,7 @@ class User extends CommonObject if ($perms) { - if (! isset($this->rights)) $this->rights = (object) array(); // For avoid error + if (! isset($this->rights) || ! is_object($this->rights)) $this->rights = (object) array(); // For avoid error if (! isset($this->rights->$module) || ! is_object($this->rights->$module)) $this->rights->$module = (object) array(); if ($subperms) { @@ -578,7 +578,7 @@ class User extends CommonObject if ($perms) { - if (! isset($this->rights)) $this->rights = (object) array(); // For avoid error + if (! isset($this->rights) || ! is_object($this->rights)) $this->rights = (object) array(); // For avoid error if (! isset($this->rights->$module) || ! is_object($this->rights->$module)) $this->rights->$module = (object) array(); if ($subperms) { diff --git a/htdocs/webservices/server_invoice.php b/htdocs/webservices/server_invoice.php index 9e67019dacc..1cc04f3c1a7 100755 --- a/htdocs/webservices/server_invoice.php +++ b/htdocs/webservices/server_invoice.php @@ -34,7 +34,7 @@ require_once(DOL_DOCUMENT_ROOT."/compta/facture/class/facture.class.php"); dol_syslog("Call Dolibarr webservices interfaces"); -$langs->load("main"); +$langs->load("main"); // Enable and test if module web services is enabled if (empty($conf->global->MAIN_MODULE_WEBSERVICES)) diff --git a/scripts/emailings/cron-mailing-send.php b/scripts/emailings/cron-mailing-send.php index a100a415651..61ba222e2ef 100644 --- a/scripts/emailings/cron-mailing-send.php +++ b/scripts/emailings/cron-mailing-send.php @@ -133,7 +133,7 @@ if ($resql) '__ID__' => $obj2->source_id, '__EMAIL__' => $obj2->email, '__CHECK_READ__' => '', - '__UNSUSCRIBE__' => ''.$langs->trans("MailUnsubcribe").'', + '__UNSUBSCRIBE__' => ''.$langs->trans("MailUnsubcribe").'', '__MAILTOEMAIL__' => ''.$obj2->email.'', '__LASTNAME__' => $obj2->lastname, '__FIRSTNAME__' => $obj2->firstname, diff --git a/scripts/emailings/mailing-send.php b/scripts/emailings/mailing-send.php index b7de64e74ca..abb2667f458 100644 --- a/scripts/emailings/mailing-send.php +++ b/scripts/emailings/mailing-send.php @@ -140,7 +140,7 @@ if ($resql) '__ID__' => $obj->source_id, '__EMAIL__' => $obj->email, '__CHECK_READ__' => '', - '__UNSUSCRIBE__' => ''.$langs->trans("MailUnsubcribe").'', + '__UNSUBSCRIBE__' => ''.$langs->trans("MailUnsubcribe").'', '__MAILTOEMAIL__' => ''.$obj->email.'', '__LASTNAME__' => $obj->lastname, '__FIRSTNAME__' => $obj->firstname,