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/comm/mailing/fiche.php b/htdocs/comm/mailing/fiche.php index f39c64d872d..6fe06660139 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); @@ -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; diff --git a/htdocs/comm/propal.php b/htdocs/comm/propal.php index 01943653763..3ac7e56ae02 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"); @@ -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) { @@ -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 ''; // Project - if ($conf->projet->enabled) + if (! empty($conf->projet->enabled)) { $langs->load('projects'); 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..750da0afc82 100644 --- a/htdocs/commande/fiche.php +++ b/htdocs/commande/fiche.php @@ -617,7 +617,7 @@ else if ($action == 'addline' && $user->rights->commande->creer) $pa_ht = $_POST['np_buying_price']; else $pa_ht = null; - + $info_bits=0; if ($tva_npr) $info_bits |= 0x01; @@ -722,7 +722,7 @@ else if ($action == 'updateligne' && $user->rights->commande->creer && $_POST['s $pa_ht = $_POST['buying_price']; else $pa_ht = null; - + // Check parameters if (empty($_POST['productid']) && $_POST["type"] < 0) { @@ -825,7 +825,7 @@ else if ($action == 'confirm_validate' && $confirm == 'yes' && $user->rights->co if (! $idwarehouse || $idwarehouse == -1) { $error++; - $errors[]=$langs->trans('ErrorFieldRequired',$langs->transnoentitiesnoconv("Warehouse")); + $mesgs[]='
'.$langs->trans('ErrorFieldRequired',$langs->transnoentitiesnoconv("Warehouse")).'
'; $action=''; } } @@ -861,7 +861,7 @@ else if ($action == 'confirm_modif' && $user->rights->commande->creer) if (! $idwarehouse || $idwarehouse == -1) { $error++; - $errors[]=$langs->trans('ErrorFieldRequired',$langs->transnoentitiesnoconv("Warehouse")); + $mesgs[]='
'.$langs->trans('ErrorFieldRequired',$langs->transnoentitiesnoconv("Warehouse")).'
'; $action=''; } } @@ -906,7 +906,7 @@ else if ($action == 'confirm_cancel' && $confirm == 'yes' && $user->rights->comm if (! $idwarehouse || $idwarehouse == -1) { $error++; - $errors[]=$langs->trans('ErrorFieldRequired',$langs->transnoentitiesnoconv("Warehouse")); + $mesgs[]='
'.$langs->trans('ErrorFieldRequired',$langs->transnoentitiesnoconv("Warehouse")).'
'; $action=''; } } @@ -1017,7 +1017,7 @@ else if ($action == 'remove_file') /* * Add file in email form */ -if ($_POST['addfile']) +if (GETPOST('addfile')) { require_once(DOL_DOCUMENT_ROOT."/core/lib/files.lib.php"); @@ -1592,7 +1592,6 @@ else if ($object->id > 0) { dol_htmloutput_mesg($mesg,$mesgs); - dol_htmloutput_errors('',$errors); $product_static=new Product($db); @@ -1929,10 +1928,10 @@ else print ''; - if ($_GET['action'] != 'editdemandreason' && $object->brouillon) print ''; + if ($action != 'editdemandreason' && ! empty($object->brouillon)) print ''; print '
'; print $langs->trans('Source'); print 'id.'">'.img_edit($langs->trans('SetDemandReason'),1).'id.'">'.img_edit($langs->trans('SetDemandReason'),1).'
'; print '
'; - if ($_GET['action'] == 'editdemandreason') + if ($action == 'editdemandreason') { $form->form_demand_reason($_SERVER['PHP_SELF'].'?id='.$object->id,$object->demand_reason_id,'demand_reason_id',1); } @@ -1947,7 +1946,7 @@ else print '
'; 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/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..1811aa0575f 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -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/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 ''; 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('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/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/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/main.inc.php b/htdocs/main.inc.php index 7d8a41d5740..0f6378e880b 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'])) +{ + $mesg=$_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/product/class/product.class.php b/htdocs/product/class/product.class.php index 4d4a9e03e98..88ee6d23682 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -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/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; }