2
0
forked from Wavyzz/dolibarr

Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into

develop

Conflicts:
	htdocs/core/lib/functions2.lib.php
	htdocs/install/lib/repair.lib.php
	htdocs/install/mysql/migration/3.2.0-3.3.0.sql
This commit is contained in:
Laurent Destailleur
2012-07-25 12:20:45 +02:00
84 changed files with 2932 additions and 3005 deletions

View File

@@ -203,11 +203,15 @@
<rule ref="PEAR.NamingConventions.ValidClassName.Invalid">
<severity>0</severity>
</rule>
<rule ref="PEAR.NamingConventions.ValidClassName.StartWithCaptial">
<severity>0</severity>
</rule>
<rule ref="PEAR.NamingConventions.ValidFunctionName" />
<rule ref="PEAR.NamingConventions.ValidFunctionName.FunctionNameInvalid">
<severity>0</severity>
</rule>
<rule ref="PEAR.NamingConventions.ValidFunctionName.FunctionNoCaptial">
<severity>0</severity>
</rule>

View File

@@ -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();

View File

@@ -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'] = '<div class="ok">'.$langs->trans("FileWasRemoved",GETPOST('urlfile')).'</div>';
$_SESSION['dol_message'] = '<div class="ok">'.$langs->trans("FileWasRemoved",GETPOST('urlfile')).'</div>';
Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id);
exit;
}

View File

@@ -740,7 +740,7 @@ else
// Forme juridique
$var=!$var;
print '<tr '.$bc[$var].'><td width="35%">'.$langs->trans("JuridicalStatus").'</td><td>';
print getFormeJuridiqueLabel($conf->global->MAIN_INFO_SOCIETE_FORME_JURIDIQUE,1);
print getFormeJuridiqueLabel($conf->global->MAIN_INFO_SOCIETE_FORME_JURIDIQUE);
print '</td></tr>';
// ProfId1

View File

@@ -77,34 +77,40 @@ print "</tr>\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 "<tr ".$bc[$var].">\n";
print "<td>".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 "</td>\n";
print '<td align="center">';
if ($conf->use_javascript_ajax)
if (! empty($conf->use_javascript_ajax))
{
print ajax_constantonoff($key);
}

View File

@@ -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)
{
$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;
}
return $ways;
}

View File

@@ -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 "<b>".$errmesg."</b><br>";
}
/*
* Affichage onglets
*/
@@ -821,6 +816,7 @@ else
dol_print_error($db,'Bad value for socid parameter');
}
dol_htmloutput_mesg('',$mesgs);
// End of page
llxFooter();

View File

@@ -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__' => '<img src="'.DOL_MAIN_URL_ROOT.'/public/emailing/mailing-read.php?tag='.$obj->tag.'" width="1" height="1" style="width:1px;height:1px" border="0"/>',
'__UNSUSCRIBE__' => '<a href="'.DOL_MAIN_URL_ROOT.'/public/emailing/mailing-unsubscribe.php?tag='.$obj->tag.'&unsuscrib=1" target="_blank">'.$langs->trans("MailUnsubcribe").'</a>',
'__UNSUBSCRIBE__' => '<a href="'.DOL_MAIN_URL_ROOT.'/public/emailing/mailing-unsubscribe.php?tag='.$obj->tag.'&unsuscrib=1" target="_blank">'.$langs->trans("MailUnsubcribe").'</a>',
'__MAILTOEMAIL__' => '<a href="mailto:'.$obj->email.'">'.$obj->email.'</a>',
'__LASTNAME__' => $obj->nom,
'__FIRSTNAME__' => $obj->prenom,
@@ -562,7 +555,7 @@ if ($action == 'confirm_valid' && $confirm == 'yes')
{
$object->valid($user);
$_SESSION['DolMessage']='<div class="ok">'.$langs->trans("MailingSuccessfullyValidated").'</div>';
$_SESSION['dol_message']='<div class="ok">'.$langs->trans("MailingSuccessfullyValidated").'</div>';
Header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
exit;

View File

@@ -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 '<table class="border" width="100%">';
$linkback='<a href="'.DOL_URL_ROOT.'/comm/propal/list.php?page='.$page.'&socid='.$socid.'&viewstatut='.$viewstatut.'&sortfield='.$sortfield.'&sortorder='.$sortorder.'">'.$langs->trans("BackToList").'</a>';
$linkback='<a href="'.DOL_URL_ROOT.'/comm/propal/list.php'.(! empty($socid)?'?socid='.$socid:'').'">'.$langs->trans("BackToList").'</a>';
// Ref
print '<tr><td>'.$langs->trans('Ref').'</td><td colspan="5">';
@@ -1278,7 +1279,7 @@ print '<tr><td>';
print '<table class="nobordernopadding" width="100%"><tr><td nowrap="nowrap">';
print $langs->trans('RefCustomer').'</td><td align="left">';
print '</td>';
if ($action != 'refclient' && $object->brouillon) print '<td align="right"><a href="'.$_SERVER['PHP_SELF'].'?action=refclient&amp;id='.$object->id.'">'.img_edit($langs->trans('Modify')).'</a></td>';
if ($action != 'refclient' && ! empty($object->brouillon)) print '<td align="right"><a href="'.$_SERVER['PHP_SELF'].'?action=refclient&amp;id='.$object->id.'">'.img_edit($langs->trans('Modify')).'</a></td>';
print '</tr></table>';
print '</td><td colspan="5">';
if ($user->rights->propale->creer && $action == 'refclient')
@@ -1337,10 +1338,10 @@ print '<td>';
print '<table class="nobordernopadding" width="100%"><tr><td>';
print $langs->trans('Date');
print '</td>';
if ($action != 'editdate' && $object->brouillon) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editdate&amp;id='.$object->id.'">'.img_edit($langs->trans('SetDate'),1).'</a></td>';
if ($action != 'editdate' && ! empty($object->brouillon)) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editdate&amp;id='.$object->id.'">'.img_edit($langs->trans('SetDate'),1).'</a></td>';
print '</tr></table>';
print '</td><td colspan="3">';
if ($object->brouillon && $action == 'editdate')
if (! empty($object->brouillon) && $action == 'editdate')
{
print '<form name="editdate" action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'" method="post">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
@@ -1368,10 +1369,10 @@ print '<td>';
print '<table class="nobordernopadding" width="100%"><tr><td>';
print $langs->trans('DateEndPropal');
print '</td>';
if ($action != 'editecheance' && $object->brouillon) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editecheance&amp;id='.$object->id.'">'.img_edit($langs->trans('SetConditions'),1).'</a></td>';
if ($action != 'editecheance' && ! empty($object->brouillon)) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editecheance&amp;id='.$object->id.'">'.img_edit($langs->trans('SetConditions'),1).'</a></td>';
print '</tr></table>';
print '</td><td colspan="3">';
if ($object->brouillon && $action == 'editecheance')
if (! empty($object->brouillon) && $action == 'editecheance')
{
print '<form name="editecheance" action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'" method="post">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
@@ -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 '<tr><td>';
print '<table class="nobordernopadding" width="100%"><tr><td>';
print $langs->trans('PaymentConditionsShort');
print '</td>';
if ($action != 'editconditions' && $object->brouillon) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editconditions&amp;id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetConditions'),1).'</a></td>';
if ($action != 'editconditions' && ! empty($object->brouillon)) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editconditions&amp;id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetConditions'),1).'</a></td>';
print '</tr></table>';
print '</td><td colspan="3">';
if ($action == 'editconditions')
@@ -1420,7 +1421,7 @@ print '<tr><td>';
print '<table class="nobordernopadding" width="100%"><tr><td>';
print $langs->trans('DeliveryDate');
print '</td>';
if ($action != 'editdate_livraison' && $object->brouillon) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editdate_livraison&amp;id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetDeliveryDate'),1).'</a></td>';
if ($action != 'editdate_livraison' && ! empty($object->brouillon)) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editdate_livraison&amp;id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetDeliveryDate'),1).'</a></td>';
print '</tr></table>';
print '</td><td colspan="3">';
if ($action == 'editdate_livraison')
@@ -1443,9 +1444,9 @@ print '</tr>';
print '<tr><td>';
print '<table class="nobordernopadding" width="100%"><tr><td>';
print $langs->trans('AvailabilityPeriod');
if ($conf->commande->enabled) print ' ('.$langs->trans('AfterOrder').')';
if (! empty($conf->commande->enabled)) print ' ('.$langs->trans('AfterOrder').')';
print '</td>';
if ($action != 'editavailability' && $object->brouillon) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editavailability&amp;id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetAvailability'),1).'</a></td>';
if ($action != 'editavailability' && ! empty($object->brouillon)) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editavailability&amp;id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetAvailability'),1).'</a></td>';
print '</tr></table>';
print '</td><td colspan="3">';
if ($action == 'editavailability')
@@ -1465,7 +1466,7 @@ print '<tr><td>';
print '<table class="nobordernopadding" width="100%"><tr><td>';
print $langs->trans('Source');
print '</td>';
if ($action != 'editdemandreason' && $object->brouillon) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editdemandreason&amp;id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetDemandReason'),1).'</a></td>';
if ($action != 'editdemandreason' && ! empty($object->brouillon)) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editdemandreason&amp;id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetDemandReason'),1).'</a></td>';
print '</tr></table>';
print '</td><td colspan="3">';
//print $object->demand_reason_id;
@@ -1487,7 +1488,7 @@ print '<td width="25%">';
print '<table class="nobordernopadding" width="100%"><tr><td>';
print $langs->trans('PaymentMode');
print '</td>';
if ($action != 'editmode' && $object->brouillon) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editmode&amp;id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetMode'),1).'</a></td>';
if ($action != 'editmode' && ! empty($object->brouillon)) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editmode&amp;id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetMode'),1).'</a></td>';
print '</tr></table>';
print '</td><td colspan="3">';
if ($action == 'editmode')
@@ -1501,7 +1502,7 @@ else
print '</td></tr>';
// Project
if ($conf->projet->enabled)
if (! empty($conf->projet->enabled))
{
$langs->load("projects");
print '<tr><td>';
@@ -1525,7 +1526,7 @@ if ($conf->projet->enabled)
else
{
print '</td></tr></table>';
if (!empty($object->fk_project))
if (! empty($object->fk_project))
{
print '<td colspan="3">';
$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 '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&amp;socid='.$object->socid.'&amp;action=clone&amp;object=propal">'.$langs->trans("ToClone").'</a>';
print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&amp;socid='.$object->socid.'&amp;action=clone&amp;object='.$object->element.'">'.$langs->trans("ToClone").'</a>';
}
// Delete

View File

@@ -2,7 +2,7 @@
/* Copyright (C) 2003-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2009 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005 Marc Barilley / Ocebo <marc@ocebo.com>
* Copyright (C) 2005-2011 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2005-2012 Regis Houssin <regis@dolibarr.fr>
*
* 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'] = '<div class="ok">'.$langs->trans("FileWasRemoved",GETPOST('urlfile')).'</div>';
$_SESSION['dol_message'] = '<div class="ok">'.$langs->trans("FileWasRemoved",GETPOST('urlfile')).'</div>';
Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id);
exit;
}
@@ -165,7 +159,7 @@ if ($object->id > 0)
print '<table class="border"width="100%">';
$linkback='<a href="'.DOL_URL_ROOT.'/comm/propal/list.php'."?page=$page&socid=$socid&viewstatut=$viewstatut&sortfield=$sortfield&$sortorder".'">'.$langs->trans("BackToList").'</a>';
$linkback='<a href="'.DOL_URL_ROOT.'/comm/propal/list.php'.(! empty($socid)?'?socid='.$socid:'').'">'.$langs->trans("BackToList").'</a>';
// Ref
print '<tr><td width="25%">'.$langs->trans('Ref').'</td><td colspan="3">';
@@ -201,13 +195,13 @@ if ($object->id > 0)
*/
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 '<br>';
}
// 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
@@ -219,7 +213,6 @@ else
print $langs->trans("UnkownError");
}
$db->close();
llxFooter();
$db->close();
?>

View File

@@ -2,7 +2,7 @@
/* Copyright (C) 2003-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2008 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005 Marc Barilley / Ocebo <marc@ocebo.com>
* Copyright (C) 2005-2011 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2005-2012 Regis Houssin <regis@dolibarr.fr>
*
* 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'] = '<div class="ok">'.$langs->trans("FileWasRemoved",GETPOST('urlfile')).'</div>';
$_SESSION['dol_message'] = '<div class="ok">'.$langs->trans("FileWasRemoved",GETPOST('urlfile')).'</div>';
Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id);
exit;
}

View File

@@ -1,32 +1,32 @@
<?php
/* Copyright (C) 2003-2006 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2012 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005 Marc Barilley / Ocebo <marc@ocebo.com>
* Copyright (C) 2005-2012 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr>
* Copyright (C) 2010-2012 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2011 Philippe Grand <philippe.grand@atoo-net.com>
* Copyright (C) 2012 Christophe Battarel <christophe.battarel@altairis.fr>
*
* 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 <http://www.gnu.org/licenses/>.
*/
* Copyright (C) 2005 Marc Barilley / Ocebo <marc@ocebo.com>
* Copyright (C) 2005-2012 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr>
* Copyright (C) 2010-2012 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2011 Philippe Grand <philippe.grand@atoo-net.com>
* Copyright (C) 2012 Christophe Battarel <christophe.battarel@altairis.fr>
*
* 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 <http://www.gnu.org/licenses/>.
*/
/**
* \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');
@@ -52,12 +52,15 @@ $langs->load('products');
if (! empty($conf->margin->enabled))
$langs->load('margins');
$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');
$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');
$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);
@@ -125,7 +128,7 @@ else if ($action == 'reopen' && $user->rights->commande->creer)
$result = $object->set_reopen($user);
if ($result > 0)
{
Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id);
Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id);
exit;
}
else
@@ -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,14 +187,14 @@ 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();
@@ -199,44 +202,51 @@ else if ($action == 'add' && $user->rights->commande->creer)
$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->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 = $_POST['fk_address'];
$object->contactid = $_POST['contactidp'];
$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'])
if ($origin && $originid)
{
// Parse element/subelement (ex: project_task)
$element = $subelement = $_POST['origin'];
if (preg_match('/^([^_]+)_([^_]+)/i',$_POST['origin'],$regs))
$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'; }
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']))
$other_linked_objects=GETPOST('other_linked_objects','array');
if (! empty($other_linked_objects))
{
$object->linked_objects = array_merge($object->linked_objects, $_POST['other_linked_objects']);
$object->linked_objects = array_merge($object->linked_objects, $other_linked_objects);
}
$object_id = $object->create($user);
@@ -351,10 +361,9 @@ else if ($action == 'add' && $user->rights->commande->creer)
// Insert default contacts if defined
if ($object_id > 0)
{
if ($_POST["contactidp"])
if (GETPOST('contactidp'))
{
$result=$object->add_contact($_POST["contactidp"],'CUSTOMER','external');
$result=$object->add_contact(GETPOST('contactidp'),'CUSTOMER','external');
if ($result < 0)
{
$mesg = '<div class="error">'.$langs->trans("ErrorFailedToAddContact").'</div>';
@@ -377,10 +386,8 @@ else if ($action == 'add' && $user->rights->commande->creer)
{
$db->rollback();
$action='create';
$socid=$_POST['socid'];
if (! $mesg) $mesg='<div class="error">'.$object->error.'</div>';
}
}
else if ($action == 'classifybilled' && $user->rights->commande->creer)
@@ -391,21 +398,21 @@ else if ($action == 'classifybilled' && $user->rights->commande->creer)
// 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 (GETPOST('remise_id'))
{
if ($object->id > 0)
{
$object->insert_discount($_POST["remise_id"]);
$object->insert_discount(GETPOST('remise_id'));
}
else
{
@@ -417,7 +424,7 @@ else if ($action == 'setabsolutediscount' && $user->rights->commande->creer)
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']);
$date=dol_mktime(0, 0, 0, GETPOST('order_month'), GETPOST('order_day'), GETPOST('order_year'));
$result=$object->set_date($user,$date);
if ($result < 0)
@@ -429,7 +436,7 @@ else if ($action == 'setdate' && $user->rights->commande->creer)
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']);
$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)
@@ -446,13 +453,13 @@ else if ($action == 'setmode' && $user->rights->commande->creer)
else if ($action == 'setavailability' && $user->rights->commande->creer)
{
$result=$object->availability($_POST['availability_id']);
$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']);
$result=$object->demand_reason(GETPOST('demand_reason_id'));
if ($result < 0) dol_print_error($db,$object->error);
}
@@ -477,7 +484,7 @@ else if ($action == 'setconditions' && $user->rights->commande->creer)
$outputlangs->setDefaultLang($newlang);
}
$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);
}
}
@@ -485,12 +492,12 @@ else if ($action == 'setconditions' && $user->rights->commande->creer)
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,38 +514,38 @@ 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;
if (empty($_POST['idprod']) && $_POST["type"] < 0)
if (! GETPOST('idprod') && GETPOST('type') < 0)
{
$mesg = '<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Type")).'</div>';
$result = -1 ;
}
if (empty($_POST['idprod']) && (! isset($_POST["np_price"]) || $_POST["np_price"]=='')) // Unit price can be 0 but not ''
if (! GETPOST('idprod') && GETPOST('np_price')=='') // Unit price can be 0 but not ''
{
$mesg = '<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("UnitPriceHT")).'</div>';
$result = -1 ;
}
if ($result >= 0 && $_POST['qty'] && (($_POST['np_price'] != '' && ($_POST['np_desc'] || $_POST['dp_desc'])) || $_POST['idprod']))
if ($result >= 0 && GETPOST('qty') && ((GETPOST('np_price') != '' && (GETPOST('np_desc') || GETPOST('dp_desc'))) || GETPOST('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']);
$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'])
if (GETPOST('idprod'))
{
$prod = new Product($db);
$prod->fetch($_POST['idprod']);
$prod->fetch(GETPOST('idprod'));
$tva_tx = get_default_tva($mysoc,$object->client,$prod->id);
@@ -592,17 +599,17 @@ else if ($action == 'addline' && $user->rights->commande->creer)
$desc = $prod->description;
}
$desc.= ($desc && $_POST['np_desc']) ? ((dol_textishtml($desc) || dol_textishtml($_POST['np_desc']))?"<br />\n":"\n") : "";
$desc.= $_POST['np_desc'];
$desc.= ($desc && GETPOST('np_desc')) ? ((dol_textishtml($desc) || dol_textishtml(GETPOST('np_desc')))?"<br />\n":"\n") : "";
$desc.= GETPOST('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"];
$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
@@ -612,9 +619,9 @@ else if ($action == 'addline' && $user->rights->commande->creer)
$desc=dol_htmlcleanlastbr($desc);
// ajout prix achat
$fk_fournprice = $_POST['np_fournprice'];
if ( ! empty($_POST['np_buying_price']) )
$pa_ht = $_POST['np_buying_price'];
$fk_fournprice = GETPOST('np_fournprice');
if (GETPOST('np_buying_price'))
$pa_ht = GETPOST('np_buying_price');
else
$pa_ht = null;
@@ -623,7 +630,7 @@ else if ($action == 'addline' && $user->rights->commande->creer)
if ($result >= 0)
{
if($price_min && (price2num($pu_ht)*(1-price2num($_POST['remise_percent'])/100) < price2num($price_min)))
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 = '<div class="error">'.$langs->trans("CantBeLessThanMinPrice",price2num($price_min,'MU').' '.$langs->trans("Currency".$conf->currency)).'</div>' ;
@@ -632,15 +639,15 @@ else if ($action == 'addline' && $user->rights->commande->creer)
{
// Insert line
$result = $object->addline(
$id,
$object->id,
$desc,
$pu_ht,
$_POST['qty'],
GETPOST('qty'),
$tva_tx,
$localtax1_tx,
$localtax2_tx,
$_POST['idprod'],
$_POST['remise_percent'],
GETPOST('idprod'),
GETPOST('remise_percent'),
$info_bits,
0,
$price_base_type,
@@ -650,7 +657,7 @@ else if ($action == 'addline' && $user->rights->commande->creer)
$type,
-1,
'',
$_POST['fk_parent_line'],
GETPOST('fk_parent_line'),
$fk_fournprice,
$pa_ht
);
@@ -669,7 +676,7 @@ else if ($action == 'addline' && $user->rights->commande->creer)
$outputlangs->setDefaultLang($newlang);
}
$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);
}
@@ -694,75 +701,70 @@ else if ($action == 'addline' && $user->rights->commande->creer)
/*
* 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']);
$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;
if (preg_match('/\*/',GETPOST('tva_tx'))) $info_bits |= 0x01;
// Define vat_rate
$vat_rate=$_POST['tva_tx'];
$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'];
$fk_fournprice = GETPOST('fournprice');
if (GETPOST('buying_price'))
$pa_ht = GETPOST('buying_price');
else
$pa_ht = null;
// Check parameters
if (empty($_POST['productid']) && $_POST["type"] < 0)
{
$mesg = '<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Type")).'</div>';
$result = -1 ;
}
// Check minimum price
if(! empty($_POST['productid']))
if (GETPOST('productid'))
{
$productid = $_POST['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 ($price_min && GETPOST('productid') && (price2num($up_ht)*(1-price2num($_POST['remise_percent'])/100) < price2num($price_min)))
if ($price_min && (price2num($up_ht)*(1-price2num(GETPOST('remise_percent'))/100) < price2num($price_min)))
{
$mesg = '<div class="error">'.$langs->trans("CantBeLessThanMinPrice",price2num($price_min,'MU').' '.$langs->trans("Currency".$conf->currency)).'</div>' ;
$result=-1;
$error++;
}
// Define params
if (! empty($_POST['productid']))
{
$type=$product->type;
}
else
{
$type=$_POST["type"];
$type=GETPOST('type');
// Check parameters
if (GETPOST('type') < 0) {
$mesg = '<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Type")).'</div>';
$error++;
}
}
if ($result >= 0)
if (! $error)
{
$result = $object->updateline(
$_POST['lineid'],
GETPOST('lineid'),
$description,
$up_ht,
$_POST['qty'],
$_POST['remise_percent'],
GETPOST('qty'),
GETPOST('remise_percent'),
$vat_rate,
$localtax1_rate,
$localtax2_rate,
@@ -771,7 +773,7 @@ else if ($action == 'updateligne' && $user->rights->commande->creer && $_POST['s
$date_start,
$date_end,
$type,
$_POST['fk_parent_line'],
GETPOST('fk_parent_line'),
0,
$fk_fournprice,
$pa_ht
@@ -782,7 +784,7 @@ else if ($action == 'updateligne' && $user->rights->commande->creer && $_POST['s
// 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))
{
@@ -809,7 +811,7 @@ else if ($action == 'updateligne' && $user->rights->commande->creer && $_POST['s
}
}
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;
@@ -825,7 +827,7 @@ else if ($action == 'confirm_validate' && $confirm == 'yes' && $user->rights->co
if (! $idwarehouse || $idwarehouse == -1)
{
$error++;
$errors[]=$langs->trans('ErrorFieldRequired',$langs->transnoentitiesnoconv("Warehouse"));
$mesgs[]='<div class="error">'.$langs->trans('ErrorFieldRequired',$langs->transnoentitiesnoconv("Warehouse")).'</div>';
$action='';
}
}
@@ -861,7 +863,7 @@ else if ($action == 'confirm_modif' && $user->rights->commande->creer)
if (! $idwarehouse || $idwarehouse == -1)
{
$error++;
$errors[]=$langs->trans('ErrorFieldRequired',$langs->transnoentitiesnoconv("Warehouse"));
$mesgs[]='<div class="error">'.$langs->trans('ErrorFieldRequired',$langs->transnoentitiesnoconv("Warehouse")).'</div>';
$action='';
}
}
@@ -906,7 +908,7 @@ else if ($action == 'confirm_cancel' && $confirm == 'yes' && $user->rights->comm
if (! $idwarehouse || $idwarehouse == -1)
{
$error++;
$errors[]=$langs->trans('ErrorFieldRequired',$langs->transnoentitiesnoconv("Warehouse"));
$mesgs[]='<div class="error">'.$langs->trans('ErrorFieldRequired',$langs->transnoentitiesnoconv("Warehouse")).'</div>';
$action='';
}
}
@@ -920,11 +922,11 @@ else if ($action == 'confirm_cancel' && $confirm == 'yes' && $user->rights->comm
/*
* 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;
@@ -939,13 +941,13 @@ else if ($action == 'up' && $user->rights->commande->creer)
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']);
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;
@@ -959,7 +961,7 @@ else if ($action == 'down' && $user->rights->commande->creer)
}
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']);
Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id.'#'.GETPOST('rowid'));
exit;
}
@@ -1016,8 +1018,8 @@ 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");
@@ -1032,8 +1034,8 @@ if ($_POST['addfile'])
/*
* Remove file in email form
*/
if (! empty($_POST['removedfile']))
*/
if (GETPOST('removedfile'))
{
require_once(DOL_DOCUMENT_ROOT."/core/lib/files.lib.php");
@@ -1042,43 +1044,43 @@ 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);
$mesg=dol_remove_file_process(GETPOST('removedfile'),0);
$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');
if ($object->id > 0)
{
// $ref = dol_sanitizeFileName($object->ref);
// $file = $conf->commande->dir_output . '/' . $ref . '/' . $ref . '.pdf';
// $ref = dol_sanitizeFileName($object->ref);
// $file = $conf->commande->dir_output . '/' . $ref . '/' . $ref . '.pdf';
// if (is_readable($file))
// {
if ($_POST['sendto'])
// if (is_readable($file))
// {
if (GETPOST('sendto'))
{
// Le destinataire a ete fourni via le champ libre
$sendto = $_POST['sendto'];
$sendto = GETPOST('sendto');
$sendtoid = 0;
}
elseif ($_POST['receiver'] != '-1')
elseif (GETPOST('receiver') != '-1')
{
// Recipient was provided from combo list
if ($_POST['receiver'] == 'thirdparty') // Id of third party
if (GETPOST('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'];
$sendto = $object->client->contact_get_property(GETPOST('receiver'),'email');
$sendtoid = GETPOST('receiver');
}
}
@@ -1086,15 +1088,15 @@ if ($action == 'send' && ! $_POST['addfile'] && ! $_POST['removedfile'] && ! $_P
{
$langs->load("commercial");
$from = $_POST['fromname'] . ' <' . $_POST['frommail'] .'>';
$replyto = $_POST['replytoname']. ' <' . $_POST['replytomail'].'>';
$message = $_POST['message'];
$sendtocc = $_POST['sendtocc'];
$deliveryreceipt = $_POST['deliveryreceipt'];
$from = GETPOST('fromname') . ' <' . GETPOST('frommail') .'>';
$replyto = GETPOST('replytoname'). ' <' . GETPOST('replytomail').'>';
$message = GETPOST('message');
$sendtocc = GETPOST('sendtocc');
$deliveryreceipt = GETPOST('deliveryreceipt');
if ($_POST['action'] == 'send')
if ($action == 'send')
{
if (dol_strlen($_POST['subject'])) $subject=$_POST['subject'];
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";
@@ -1144,7 +1146,9 @@ if ($action == 'send' && ! $_POST['addfile'] && ! $_POST['removedfile'] && ! $_P
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; }
if ($result < 0) {
$error++; $this->errors=$interface->errors;
}
// Fin appel triggers
if ($error)
@@ -1175,7 +1179,7 @@ if ($action == 'send' && ! $_POST['addfile'] && ! $_POST['removedfile'] && ! $_P
$mesg.='</div>';
}
}
/* }
/* }
else
{
$langs->load("other");
@@ -1197,16 +1201,16 @@ if ($action == 'send' && ! $_POST['addfile'] && ! $_POST['removedfile'] && ! $_P
$mesg='<div class="error">'.$langs->trans('ErrorFailedToReadEntity',$langs->trans("Order")).'</div>';
dol_syslog($langs->trans('ErrorFailedToReadEntity', $langs->trans("Order")));
}
}
}
if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB))
{
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, $_POST["type"], $_POST["source"]);
$result = $object->add_contact($contactid, GETPOST('type'), GETPOST('source'));
}
if ($result >= 0)
@@ -1255,27 +1259,27 @@ if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB))
dol_print_error($db);
}
}
}
}
/*
/*
* View
*/
llxHeader('',$langs->trans('Order'),'EN:Customers_Orders|FR:Commandes_Clients|ES:Pedidos de clientes');
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);
$form = new Form($db);
$formfile = new FormFile($db);
$formorder = new FormOrder($db);
/*********************************************************************
/*********************************************************************
*
* Mode creation
*
*********************************************************************/
if ($action == 'create' && $user->rights->commande->creer)
{
if ($action == 'create' && $user->rights->commande->creer)
{
print_fiche_titre($langs->trans('CreateOrder'));
dol_htmloutput_mesg($mesg,$mesgs,'error');
@@ -1283,11 +1287,11 @@ if ($action == 'create' && $user->rights->commande->creer)
$soc = new Societe($db);
if ($socid) $res=$soc->fetch($socid);
if (GETPOST('origin') && GETPOST('originid'))
if ($origin && $originid)
{
// Parse element/subelement (ex: project_task)
$element = $subelement = GETPOST('origin');
if (preg_match('/^([^_]+)_([^_]+)/i',GETPOST('origin'),$regs))
$element = $subelement = $origin;
if (preg_match('/^([^_]+)_([^_]+)/i',$origin,$regs))
{
$element = $regs[1];
$subelement = $regs[2];
@@ -1295,20 +1299,26 @@ if ($action == 'create' && $user->rights->commande->creer)
if ($element == 'project')
{
$projectid=GETPOST('originid');
$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'; }
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'));
$objectsrc->fetch($originid);
if (empty($objectsrc->lines) && method_exists($objectsrc,'fetch_lines')) $objectsrc->fetch_lines();
$objectsrc->fetch_thirdparty();
@@ -1353,8 +1363,8 @@ if ($action == 'create' && $user->rights->commande->creer)
print '<input type="hidden" name="socid" value="'.$soc->id.'">' ."\n";
print '<input type="hidden" name="remise_percent" value="'.$soc->remise_client.'">';
print '<input name="facnumber" type="hidden" value="provisoire">';
print '<input type="hidden" name="origin" value="'.GETPOST('origin').'">';
print '<input type="hidden" name="originid" value="'.GETPOST('originid').'">';
print '<input type="hidden" name="origin" value="'.$origin.'">';
print '<input type="hidden" name="originid" value="'.$originid.'">';
print '<table class="border" width="100%">';
@@ -1422,14 +1432,14 @@ if ($action == 'create' && $user->rights->commande->creer)
// What trigger creation
print '<tr><td>'.$langs->trans('Source').'</td><td colspan="2">';
$form->select_demand_reason((GETPOST("origin")=='propal'?'SRC_COMM':''),'demand_reason_id','',1);
$form->select_demand_reason(($origin=='propal'?'SRC_COMM':''),'demand_reason_id','',1);
print '</td></tr>';
// Project
if ($conf->projet->enabled)
if (! empty($conf->projet->enabled))
{
$projectid = 0;
if (isset($_GET["origin"]) && $_GET["origin"] == 'project') $projectid = ($_GET["originid"]?$_GET["originid"]:0);
if ($origin == 'project') $projectid = ($originid?$originid:0);
print '<tr><td>'.$langs->trans('Project').'</td><td colspan="2">';
$numprojet=select_projects($soc->id,$projectid);
@@ -1489,7 +1499,7 @@ if ($action == 'create' && $user->rights->commande->creer)
if (is_object($objectsrc))
{
// TODO for compatibility
if ($_GET['origin'] == 'contrat')
if ($origin == 'contrat')
{
// Calcul contrat->price (HT), contrat->total (TTC), contrat->tva
$objectsrc->remise_absolue=$remise_absolue;
@@ -1579,9 +1589,9 @@ if ($action == 'create' && $user->rights->commande->creer)
print '</table>';
}
}
else
{
}
else
{
/* *************************************************************************** */
/* */
/* Mode vue et edition */
@@ -1592,7 +1602,6 @@ else
if ($object->id > 0)
{
dol_htmloutput_mesg($mesg,$mesgs);
dol_htmloutput_errors('',$errors);
$product_static=new Product($db);
@@ -1929,10 +1938,10 @@ else
print '<table class="nobordernopadding" width="100%"><tr><td>';
print $langs->trans('Source');
print '</td>';
if ($_GET['action'] != 'editdemandreason' && $object->brouillon) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editdemandreason&amp;id='.$object->id.'">'.img_edit($langs->trans('SetDemandReason'),1).'</a></td>';
if ($action != 'editdemandreason' && ! empty($object->brouillon)) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editdemandreason&amp;id='.$object->id.'">'.img_edit($langs->trans('SetDemandReason'),1).'</a></td>';
print '</tr></table>';
print '</td><td colspan="2">';
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 +1956,7 @@ else
print '</td></tr>';
// Project
if ($conf->projet->enabled)
if (! empty($conf->projet->enabled))
{
$langs->load('projects');
print '<tr><td height="10">';
@@ -2286,7 +2295,7 @@ else
$formmail->fromname = $user->getFullName($langs);
$formmail->frommail = $user->email;
$formmail->withfrom=1;
$formmail->withto=empty($_POST["sendto"])?1:$_POST["sendto"];
$formmail->withto=GETPOST('sendto')?GETPOST('sendto'):1;
$formmail->withtosocid=$soc->id;
$formmail->withtocc=1;
$formmail->withtoccsocid=0;
@@ -2320,9 +2329,9 @@ else
print '<br>';
}
}
}
}
llxFooter();
$db->close();
?>
llxFooter();
$db->close();
?>

View File

@@ -62,7 +62,7 @@ if ($action == 'create')
{
if (! is_array($selected))
{
$mesg='<div class="error">'.$langs->trans('Error_OrderNotChecked').'</div>';
$mesgs[]='<div class="error">'.$langs->trans('Error_OrderNotChecked').'</div>';
}
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='<div class="error">'.$object->error.'</div>';
$mesgs[]='<div class="error">'.$object->error.'</div>';
}
}
@@ -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 "</form>\n";
}
//Mode liste
else
{
@@ -669,8 +670,8 @@ else
}
$db->close();
dol_htmloutput_mesg($mesg);
llxFooter();
dol_htmloutput_mesg($mesg,$mesgs);
llxFooter();
$db->close();
?>

View File

@@ -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 <http://www.gnu.org/licenses/>.
*/
/**
@@ -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='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$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 '<form method="post">';
// COMMISSION BASE (CA / MARGES)
// COMMISSION BASE (TURNOVER / MARGIN)
$var=!$var;
print '<tr '.$bc[$var].'>';
print '<td>'.$langs->trans("CommissionBase").'</td>';
print '<td align="left">';
print '<input type="radio" name="commissionBase" value="CA" ';
if ($conf->global->COMMISSION_BASE == "CA")
print '<input type="radio" name="commissionBase" value="TURNOVER" ';
if (isset($conf->global->COMMISSION_BASE) && $conf->global->COMMISSION_BASE == "TURNOVER")
print 'checked';
print ' />';
print $langs->trans("CommissionBasedOnCA");
print $langs->trans("CommissionBasedOnTurnover");
print '<br/>';
print '<input type="radio" name="commissionBase" value="MARGES" ';
if (!$conf->marges->enabled)
print '<input type="radio" name="commissionBase" value="MARGIN" ';
if (empty($conf->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 '<tr '.$bc[$var].'>';
print '<td>'.$langs->trans("ProductCommissionRate").'</td>';
print '<td align="left">';
print '<input type="text" name="productCommissionRate" value="'.$conf->global->PRODUCT_COMMISSION_RATE.'" size=6 />&nbsp; %';
print '<input type="text" name="productCommissionRate" value="'.(! empty($conf->global->PRODUCT_COMMISSION_RATE)?$conf->global->PRODUCT_COMMISSION_RATE:'').'" size=6 />&nbsp; %';
print '</td>';
print '<td>'.$langs->trans('ProductCommissionRateDetails').'</td>';
print '</tr>';
@@ -151,7 +140,7 @@ $var=!$var;
print '<tr '.$bc[$var].'>';
print '<td>'.$langs->trans("ServiceCommissionRate").'</td>';
print '<td align="left">';
print '<input type="text" name="serviceCommissionRate" value="'.$conf->global->SERVICE_COMMISSION_RATE.'" size=6 />&nbsp; %';
print '<input type="text" name="serviceCommissionRate" value="'.(! empty($conf->global->SERVICE_COMMISSION_RATE)?$conf->global->SERVICE_COMMISSION_RATE:'').'" size=6 />&nbsp; %';
print '</td>';
print '<td>'.$langs->trans('ServiceCommissionRateDetails').'</td>';
print '</tr>';
@@ -169,7 +158,7 @@ print '<br>';
print '</form>';
$db->close();
llxFooter('$Date: 2011/07/31 22:23:21 $ - $Revision: 1.6 $');
llxFooter();
$db->close();
?>

View File

@@ -48,6 +48,8 @@ $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']))
@@ -90,7 +92,7 @@ else {
if (! $sortfield) $sortfield="u.login";
}
// Date d<>but
// Start date
print '<td>'.$langs->trans('StartDate').'</td>';
print '<td width="20%">';
$form->select_date($startdate,'startdate','','',1,"sel",1,1);
@@ -106,20 +108,20 @@ print '</td></tr>';
// Include unpayed invoices
print '<tr><td>'.$langs->trans("IncludeUnpayedInvoices").'</td><td colspan="4">';
print '<input id="selIncluded" type="checkbox" name="unpayed" ';
if ($_REQUEST['unpayed'] == 'on')
if (GETPOST('unpayed') == 'on')
print 'checked ';
print '/>';
print '</td></tr>';
// Total Margin
if ($conf->global->COMMISSION_BASE == "MARGES") {
if ($conf->global->COMMISSION_BASE == "MARGIN") {
print '<tr style="font-weight: bold"><td>'.$langs->trans("TotalMargin").'</td><td colspan="4">';
print '<span id="totalBase"></span>'; // set by jquery (see below)
print '</td></tr>';
}
elseif ($conf->global->COMMISSION_BASE == "CA") {
print '<tr style="font-weight: bold"><td>'.$langs->trans("CATotal").'</td><td colspan="4">';
elseif ($conf->global->COMMISSION_BASE == "TURNOVER") {
print '<tr style="font-weight: bold"><td>'.$langs->trans("TurnoverTotal").'</td><td colspan="4">';
print '<span id="totalBase"></span>'; // set by jquery (see below)
print '</td></tr>';
}
@@ -135,11 +137,11 @@ print '</form>';
$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") {
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") {
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," ;
}
@@ -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";
@@ -179,36 +181,37 @@ if ($result)
$num = $db->num_rows($result);
print '<br>';
print_barre_liste($langs->trans("CommissionDetails"),$page,$_SERVER["PHP_SELF"],"&amp;socid=$societe->id",$sortfield,$sortorder,'',$num,0,'');
print_barre_liste($langs->trans("CommissionDetails"),$page,$_SERVER["PHP_SELF"],"",$sortfield,$sortorder,'',$num,0,'');
$i = 0;
print "<table class=\"noborder\" width=\"100%\">";
print '<tr class="liste_titre">';
if ($agentid > 0)
print_liste_field_titre($langs->trans("Customer"),$_SERVER["PHP_SELF"],"s.nom","","&amp;agentid=".$_REQUEST["agentid"],'align="center"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Customer"),$_SERVER["PHP_SELF"],"s.nom","","&amp;agentid=".$agentid,'align="center"',$sortfield,$sortorder);
else
print_liste_field_titre($langs->trans("CommercialAgent"),$_SERVER["PHP_SELF"],"u.login","","&amp;agentid=".$_REQUEST["agentid"],'align="center"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("CommercialAgent"),$_SERVER["PHP_SELF"],"u.login","","&amp;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","","&amp;agentid=".$_REQUEST["agentid"],'align="right"',$sortfield,$sortorder);
elseif ($conf->global->COMMISSION_BASE == "CA")
print_liste_field_titre($langs->trans("ProductCA"),$_SERVER["PHP_SELF"],"productBase","","&amp;agentid=".$_REQUEST["agentid"],'align="right"',$sortfield,$sortorder);
if ($conf->global->COMMISSION_BASE == "MARGIN")
print_liste_field_titre($langs->trans("ProductMargin"),$_SERVER["PHP_SELF"],"productBase","","&amp;agentid=".$agentid,'align="right"',$sortfield,$sortorder);
elseif ($conf->global->COMMISSION_BASE == "TURNOVER")
print_liste_field_titre($langs->trans("ProductTurnover"),$_SERVER["PHP_SELF"],"productBase","","&amp;agentid=".$agentid,'align="right"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("CommissionRate"),$_SERVER["PHP_SELF"],"","","&amp;agentid=".$_REQUEST["agentid"],'align="right"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("ProductCommission"),$_SERVER["PHP_SELF"],"","","&amp;agentid=".$_REQUEST["agentid"],'align="right"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("CommissionRate"),$_SERVER["PHP_SELF"],"","","&amp;agentid=".$agentid,'align="right"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("ProductCommission"),$_SERVER["PHP_SELF"],"","","&amp;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","","&amp;agentid=".$_REQUEST["agentid"],'align="right"',$sortfield,$sortorder);
elseif ($conf->global->COMMISSION_BASE == "CA")
print_liste_field_titre($langs->trans("ServiceCA"),$_SERVER["PHP_SELF"],"serviceBase","","&amp;agentid=".$_REQUEST["agentid"],'align="right"',$sortfield,$sortorder);
if ($conf->global->COMMISSION_BASE == "MARGIN")
print_liste_field_titre($langs->trans("ServiceMargin"),$_SERVER["PHP_SELF"],"serviceBase","","&amp;agentid=".$agentid,'align="right"',$sortfield,$sortorder);
elseif ($conf->global->COMMISSION_BASE == "TURNOVER")
print_liste_field_titre($langs->trans("ServiceTurnover"),$_SERVER["PHP_SELF"],"serviceBase","","&amp;agentid=".$agentid,'align="right"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("CommissionRate"),$_SERVER["PHP_SELF"],"","","&amp;agentid=".$agentid,'align="right"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("ServiceCommission"),$_SERVER["PHP_SELF"],"","","&amp;agentid=".$agentid,'align="right"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("CommissionRate"),$_SERVER["PHP_SELF"],"","","&amp;agentid=".$_REQUEST["agentid"],'align="right"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("ServiceCommission"),$_SERVER["PHP_SELF"],"","","&amp;agentid=".$_REQUEST["agentid"],'align="right"',$sortfield,$sortorder);
// total commission
print_liste_field_titre($langs->trans("TotalCommission"),$_SERVER["PHP_SELF"],"","","&amp;agentid=".$_REQUEST["agentid"],'align="right"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("TotalCommission"),$_SERVER["PHP_SELF"],"","","&amp;agentid=".$agentid,'align="right"',$sortfield,$sortorder);
print "</tr>\n";
@@ -237,22 +240,29 @@ if ($result)
$userstatic->login=$objp->login;
print "<td>".$userstatic->getLoginUrl(1)."</td>\n";
}
// product commission
$productCommission = $conf->global->PRODUCT_COMMISSION_RATE * $objp->productBase / 100;
print "<td align=\"right\">".price($objp->productBase)."</td>\n";
print "<td align=\"right\">".price($conf->global->PRODUCT_COMMISSION_RATE)."</td>\n";
$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 "<td align=\"right\">".price($productBase)."</td>\n";
print "<td align=\"right\">".price($productCommissionRate)."</td>\n";
print "<td align=\"right\">".price($productCommission)."</td>\n";
// service commission
$serviceCommission = $conf->global->SERVICE_COMMISSION_RATE * $objp->serviceBase / 100;
print "<td align=\"right\">".price($objp->serviceBase)."</td>\n";
print "<td align=\"right\">".price($conf->global->SERVICE_COMMISSION_RATE)."</td>\n";
$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 "<td align=\"right\">".price($serviceBase)."</td>\n";
print "<td align=\"right\">".price($serviceCommissionRate)."</td>\n";
print "<td align=\"right\">".price($serviceCommission)."</td>\n";
// total commission
print "<td align=\"right\">".price($productCommission + $serviceCommission)."</td>\n";
print "</tr>\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,18 +271,18 @@ if ($result)
// affichage totaux commission
$var=!$var;
print '<tr '.$bc[$var].' style="border-top: 1px solid #ccc; font-weight: bold">';
if ($client)
if (! empty($client))
print '<td colspan=2>';
else
print '<td>';
print $langs->trans('TotalCommission')."</td>";
// product commission
print "<td align=\"right\">".price($cumul_base_produit)."</td>\n";
print "<td align=\"right\">".price($conf->global->PRODUCT_COMMISSION_RATE)."</td>\n";
print "<td align=\"right\">".price((! empty($conf->global->PRODUCT_COMMISSION_RATE)?$conf->global->PRODUCT_COMMISSION_RATE:0))."</td>\n";
print "<td align=\"right\">".price($cumul_commission_produit)."</td>\n";
// service commission
print "<td align=\"right\">".price($cumul_base_service)."</td>\n";
print "<td align=\"right\">".price($conf->global->SERVICE_COMMISSION_RATE)."</td>\n";
print "<td align=\"right\">".price((! empty($conf->global->SERVICE_COMMISSION_RATE)?$conf->global->SERVICE_COMMISSION_RATE:0))."</td>\n";
print "<td align=\"right\">".price($cumul_commission_service)."</td>\n";
// total commission
print "<td align=\"right\">".price($cumul_commission_produit + $cumul_commission_service)."</td>\n";

View File

@@ -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;
}

View File

@@ -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='<div class="error">'.$langs->trans("NoCloneOptionsSpecified").'</div>';
$mesgs[]='<div class="error">'.$langs->trans("NoCloneOptionsSpecified").'</div>';
}
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='<div class="error">'.$object->error.'</div>';
$mesgs[]='<div class="error">'.$object->error.'</div>';
}
}
}
@@ -170,7 +165,7 @@ else if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->fact
}
else
{
$mesg='<div class="error">'.$object->error.'</div>';
$mesgs[]='<div class="error">'.$object->error.'</div>';
}
}
@@ -206,7 +201,7 @@ else if ($action == 'confirm_deleteline' && $confirm == 'yes' && $user->rights->
}
else
{
$mesg='<div clas="error">'.$object->error.'</div>';
$mesgs[]='<div clas="error">'.$object->error.'</div>';
$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='<div class="error">'.$langs->trans("ErrorInvoiceAvoirMustBeNegative").'</div>';
$mesgs[]='<div class="error">'.$langs->trans("ErrorInvoiceAvoirMustBeNegative").'</div>';
$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='<div class="error">'.$langs->trans("ErrorInvoiceOfThisTypeMustBePositive").'</div>';
$mesgs[]='<div class="error">'.$langs->trans("ErrorInvoiceOfThisTypeMustBePositive").'</div>';
$action='';
}
}
@@ -306,7 +301,7 @@ else if ($action == "setabsolutediscount" && $user->rights->facture->creer)
$result=$object->insert_discount($_POST["remise_id"]);
if ($result < 0)
{
$mesg='<div class="error">'.$object->error.'</div>';
$mesgs[]='<div class="error">'.$object->error.'</div>';
}
}
else
@@ -323,7 +318,7 @@ else if ($action == "setabsolutediscount" && $user->rights->facture->creer)
$result=$discount->link_to_invoice(0,$id);
if ($result < 0)
{
$mesg='<div class="error">'.$discount->error.'</div>';
$mesgs[]='<div class="error">'.$discount->error.'</div>';
}
}
}
@@ -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='<div class="error">'.$object->error.'</div>';
$mesgs[]='<div class="error">'.$object->error.'</div>';
}
}
}
@@ -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='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->trans("Reason")).'</div>';
$mesgs[]='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->trans("Reason")).'</div>';
}
}
// Classify "abandoned"
@@ -501,7 +496,7 @@ else if ($action == 'confirm_canceled' && $confirm == 'yes')
}
else
{
$mesg='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->trans("Reason")).'</div>';
$mesgs[]='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->trans("Reason")).'</div>';
}
}
@@ -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='<div class="error">'.$object->error.'</div>';
$mesgs[]='<div class="error">'.$object->error.'</div>';
$db->rollback();
}
}
else
{
$mesg='<div class="error">'.$discount->error.'</div>';
$mesgs[]='<div class="error">'.$discount->error.'</div>';
$db->rollback();
}
}
@@ -595,13 +590,13 @@ else if ($action == 'add' && $user->rights->facture->creer)
if (empty($datefacture))
{
$error++;
$mesg='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->trans("Date")).'</div>';
$mesgs[]='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->trans("Date")).'</div>';
}
if (! ($_POST['fac_replacement'] > 0))
{
$error++;
$mesg='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->trans("ReplaceInvoice")).'</div>';
$mesgs[]='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->trans("ReplaceInvoice")).'</div>';
}
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='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->trans("CorrectInvoice")).'</div>';
$mesgs[]='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->trans("CorrectInvoice")).'</div>';
}
$datefacture = dol_mktime(12, 0, 0, $_POST['remonth'], $_POST['reday'], $_POST['reyear']);
if (empty($datefacture))
{
$error++;
$mesg='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->trans("Date")).'</div>';
$mesgs[]='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->trans("Date")).'</div>';
}
if (! $error)
@@ -696,7 +691,7 @@ else if ($action == 'add' && $user->rights->facture->creer)
if (empty($datefacture))
{
$error++;
$mesg='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->trans("Date")).'</div>';
$mesgs[]='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->trans("Date")).'</div>';
}
if (! $error)
@@ -725,7 +720,7 @@ else if ($action == 'add' && $user->rights->facture->creer)
if (empty($datefacture))
{
$error++;
$mesg='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->trans("Date")).'</div>';
$mesgs[]='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->trans("Date")).'</div>';
}
if (! $error)
@@ -816,7 +811,7 @@ else if ($action == 'add' && $user->rights->facture->creer)
}
else
{
$mesg=$discount->error;
$mesgs[]=$discount->error;
$error++;
break;
}
@@ -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='<div class="error">'.$object->error.'</div>';
$mesgs[]='<div class="error">'.$object->error.'</div>';
}
}
@@ -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='<div class="error">'.$langs->trans("ErrorBothFieldCantBeNegative",$langs->transnoentitiesnoconv("UnitPriceHT"),$langs->transnoentitiesnoconv("Qty")).'</div>';
$mesgs[]='<div class="error">'.$langs->trans("ErrorBothFieldCantBeNegative",$langs->transnoentitiesnoconv("UnitPriceHT"),$langs->transnoentitiesnoconv("Qty")).'</div>';
$result = -1 ;
}
if (empty($_POST['idprod']) && $_POST["type"] < 0)
{
$mesg='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Type")).'</div>';
$mesgs[]='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Type")).'</div>';
$result = -1 ;
}
if (empty($_POST['idprod']) && (! isset($_POST["np_price"]) || $_POST["np_price"]=='')) // Unit price can be 0 but not ''
{
$mesg='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("UnitPriceHT")).'</div>';
$mesgs[]='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("UnitPriceHT")).'</div>';
$result = -1 ;
}
if (empty($_POST['idprod']) && empty($_POST["np_desc"]) && empty($_POST["dp_desc"]))
{
$mesg='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Description")).'</div>';
$mesgs[]='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Description")).'</div>';
$result = -1 ;
}
if (! isset($_POST['qty']) || $_POST['qty']=='')
{
$mesg='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv('Qty')).'</div>';
$mesgs[]='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv('Qty')).'</div>';
$result = -1 ;
}
if ($result >= 0 && ( ($_POST['np_price']!='' && ($_POST['np_desc'] || $_POST['dp_desc'])) || $_POST['idprod'] ) )
@@ -1155,7 +1150,7 @@ else if (($action == 'addline' || $action == 'addline_predef') && $user->rights-
}
else
{
if (empty($mesg)) $mesg='<div class="error">'.$object->error.'</div>';
$mesgs[]='<div class="error">'.$object->error.'</div>';
}
$action='';
@@ -1194,7 +1189,7 @@ else if ($action == 'updateligne' && $user->rights->facture->creer && $_POST['sa
// Check parameters
if (! GETPOST('productid') && GETPOST("type") < 0)
{
$mesg = '<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Type")).'</div>';
$mesgs[] = '<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Type")).'</div>';
$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 = '<div class="error">'.$langs->trans("CantBeLessThanMinPrice",price2num($price_min,'MU').' '.$langs->trans("Currency".$conf->currency)).'</div>';
$mesgs[] = '<div class="error">'.$langs->trans("CantBeLessThanMinPrice",price2num($price_min,'MU').' '.$langs->trans("Currency".$conf->currency)).'</div>';
$result=-1;
}
@@ -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.='</div>';
$mesgs[]=$mesg;
}
}
/* }
else
{
$langs->load("other");
$mesg='<div class="error">'.$langs->trans('ErrorMailRecipientIsEmpty').'</div>';
$mesgs[]='<div class="error">'.$langs->trans('ErrorMailRecipientIsEmpty').'</div>';
dol_syslog('Recipient email is empty');
}*/
}
else
{
$langs->load("errors");
$mesg='<div class="error">'.$langs->trans('ErrorCantReadFile',$file).'</div>';
$mesgs[]='<div class="error">'.$langs->trans('ErrorCantReadFile',$file).'</div>';
dol_syslog('Failed to read file: '.$file);
}
}
else
{
$langs->load("other");
$mesg='<div class="error">'.$langs->trans('ErrorFailedToReadEntity',$langs->trans("Invoice")).'</div>';
$mesgs[]='<div class="error">'.$langs->trans('ErrorFailedToReadEntity',$langs->trans("Invoice")).'</div>';
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 = '<div class="ok">'.$langs->trans("FileWasRemoved",GETPOST('file')).'</div>';
$mesgs[] = '<div class="ok">'.$langs->trans("FileWasRemoved",GETPOST('file')).'</div>';
}
}
@@ -1597,11 +1593,11 @@ if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB))
if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS')
{
$langs->load("errors");
$mesg = '<div class="error">'.$langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType").'</div>';
$mesgs[] = '<div class="error">'.$langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType").'</div>';
}
else
{
$mesg = '<div class="error">'.$object->error.'</div>';
$mesgs[] = '<div class="error">'.$object->error.'</div>';
}
}
}
@@ -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,6 +3323,7 @@ else if ($id > 0 || ! empty($ref))
}
}
dol_htmloutput_mesg('',$mesgs);
llxFooter();
$db->close();

View File

@@ -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'] = '<div class="ok">'.$langs->trans("FileWasRemoved",GETPOST('urlfile')).'</div>';
$_SESSION['dol_message'] = '<div class="ok">'.$langs->trans("FileWasRemoved",GETPOST('urlfile')).'</div>';
Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id);
exit;
}

View File

@@ -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 '<table class="liste" width="100%">';
// 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))

View File

@@ -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);

View File

@@ -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'] = '<div class="ok">'.$langs->trans("FileWasRemoved",GETPOST('urlfile')).'</div>';
$_SESSION['dol_message'] = '<div class="ok">'.$langs->trans("FileWasRemoved",GETPOST('urlfile')).'</div>';
Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id);
exit;
}

View File

@@ -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');
@@ -2865,25 +2865,25 @@ abstract class CommonObject
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<EFBFBD> et devrait l'<EFBFBD>tre, alors prix achat = prix vente
if ((!isset($line->pa_ht) || $line->pa_ht == 0) && ($conf->global->ForceBuyingPriceIfNull == 1)) {
// 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<EFBFBD>r<EFBFBD>e comme produit
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['pv_total'] += $line->subprice * (1 - $line->remise_percent / 100);
}
elseif ($conf->global->MARGIN_METHODE_FOR_DISCOUNT == '2') { // remise globale consid<EFBFBD>r<EFBFBD>e comme service
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);

View File

@@ -2184,7 +2184,7 @@ class Form
$more.='<input type="checkbox" class="flat" id="'.$input['name'].'" name="'.$input['name'].'"';
if (! is_bool($input['value']) && $input['value'] != 'false') $more.=' checked="checked"';
if (is_bool($input['value']) && $input['value']) $more.=' checked="checked"';
if ($input['disabled']) $more.=' disabled="disabled"';
if (isset($input['disabled'])) $more.=' disabled="disabled"';
$more.=' /></td>';
$more.='<td valign="top" align="left">&nbsp;</td>';
$more.='</tr>'."\n";
@@ -3067,11 +3067,11 @@ class Form
if (preg_match('/^([0-9]+)\-([0-9]+)\-([0-9]+)\s?([0-9]+)?:?([0-9]+)?/',$set_time,$reg))
{
// Date format 'YYYY-MM-DD' or 'YYYY-MM-DD HH:MM:SS'
$syear = $reg[1];
$smonth = $reg[2];
$sday = $reg[3];
$shour = $reg[4];
$smin = $reg[5];
$syear = (! empty($reg[1])?$reg[1]:'');
$smonth = (! empty($reg[2])?$reg[2]:'');
$sday = (! empty($reg[3])?$reg[3]:'');
$shour = (! empty($reg[4])?$reg[4]:'');
$smin = (! empty($reg[5])?$reg[5]:'');
}
elseif (strval($set_time) != '' && $set_time != -1)
{

View File

@@ -389,6 +389,7 @@ function getFormeJuridiqueLabel($code)
function show_projects($conf,$langs,$db,$object,$backtopage='')
{
global $user;
global $bc;
$i = -1 ;
@@ -517,13 +518,13 @@ function show_contacts($conf,$langs,$db,$object,$backtopage='')
print '<td>'.$langs->trans("Poste").'</td><td>'.$langs->trans("Tel").'</td>';
print '<td>'.$langs->trans("Fax").'</td><td>'.$langs->trans("EMail").'</td>';
print "<td>&nbsp;</td>";
if ($conf->agenda->enabled && $user->rights->agenda->myactions->create)
if (! empty($conf->agenda->enabled) && $user->rights->agenda->myactions->create)
{
print '<td>&nbsp;</td>';
}
print "</tr>";
$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 '<td>'.$obj->poste.'</td>';
$country_code = getCountry($obj->fk_pays, 2);
// Lien click to dial
print '<td>';
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 '</td>';
print '<td>';
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 '</td>';
print '<td>';
print dol_print_email($obj->email,$obj->rowid,$object->id,'AC_EMAIL');

View File

@@ -1,6 +1,6 @@
<?php
/* Copyright (C) 2008-2011 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2008-2011 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2008-2012 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2008 Raphael Bertrand (Resultic) <raphael.bertrand@resultic.fr>
*
* This program is free software; you can redistribute it and/or modify

View File

@@ -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'

View File

@@ -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

View File

@@ -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';

View File

@@ -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++;
}
/**

View File

@@ -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;

View File

@@ -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");

View File

@@ -231,15 +231,7 @@ if ($id > 0 || ! empty($ref))
// Date
print '<tr><td>'.$langs->trans('Date').'</td>';
print '<td colspan="2">'.dol_print_date($commande->date,'daytext').'</td>';
print '<td width="50%">'.$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 ' -> <a href="'.DOL_URL_ROOT.'/comm/propal.php?id='.$propal->id.'">'.$propal->ref.'</a>';
}
print '</td>';
print '<td width="50%">'.$langs->trans('Source').' : '.$commande->getLabelSource().'</td>';
print '</tr>';
// Delivery date planned
@@ -276,7 +268,7 @@ if ($id > 0 || ! empty($ref))
print $langs->trans('PaymentConditionsShort');
print '</td>';
if ($action != 'editconditions' && $commande->brouillon) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editconditions&amp;id='.$commande->id.'">'.img_edit($langs->trans('SetConditions'),1).'</a></td>';
if ($action != 'editconditions' && ! empty($commande->brouillon)) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editconditions&amp;id='.$commande->id.'">'.img_edit($langs->trans('SetConditions'),1).'</a></td>';
print '</tr></table>';
print '</td><td colspan="2">';
if ($action == 'editconditions')
@@ -294,7 +286,7 @@ if ($id > 0 || ! empty($ref))
print '<table class="nobordernopadding" width="100%"><tr><td>';
print $langs->trans('PaymentMode');
print '</td>';
if ($actionº != 'editmode' && $commande->brouillon) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editmode&amp;id='.$commande->id.'">'.img_edit($langs->trans('SetMode'),1).'</a></td>';
if ($action != 'editmode' && ! empty($commande->brouillon)) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editmode&amp;id='.$commande->id.'">'.img_edit($langs->trans('SetMode'),1).'</a></td>';
print '</tr></table>';
print '</td><td colspan="2">';
if ($action == 'editmode')
@@ -394,7 +386,8 @@ if ($id > 0 || ! empty($ref))
print "</tr>\n";
$var=true;
$reste_a_livrer = array();
$toBeShipped=array();
$toBeShippedTotal=0;
while ($i < $num)
{
$objp = $db->fetch_object($resql);
@@ -475,17 +468,17 @@ if ($id > 0 || ! empty($ref))
$qtyProdCom=$objp->qty;
print '<td align="center">';
// 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 '</td>';
// Qty remains to ship
print '<td align="center">';
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 '<td align="center">';
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 '<a class="butAction" href="'.DOL_URL_ROOT.'/expedition/fiche.php?action=create&amp;origin=commande&amp;object_id='.$id.'">'.$langs->trans("NewSending").'</a>';
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 '<td align="center">';
print '<input type="submit" class="button" named="save" value="'.$langs->trans("NewSending").'">';
if ($reste_a_livrer_total <= 0)
if ($toBeShippedTotal <= 0)
{
print ' '.img_warning($langs->trans("WarningNoQtyLeftToSend"));
}

View File

@@ -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];

View File

@@ -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')
{
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;
}

View File

@@ -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'] = '<div class="ok">'.$langs->trans("FileWasRemoved",GETPOST('urlfile')).'</div>';
$_SESSION['dol_message'] = '<div class="ok">'.$langs->trans("FileWasRemoved",GETPOST('urlfile')).'</div>';
Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id);
exit;
}

View File

@@ -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'] = '<div class="ok">'.$langs->trans("FileWasRemoved",GETPOST('urlfile')).'</div>';
$_SESSION['dol_message'] = '<div class="ok">'.$langs->trans("FileWasRemoved",GETPOST('urlfile')).'</div>';
Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id);
exit;
}

View File

@@ -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...),<br>take a look at the Dolibarr Wiki:<br><b><a href="%s" target="_blank">%s</a></b>
ForDocumentationSeeWiki=For user or developer documentation (Doc, FAQs...),<br>take a look at the Dolibarr Wiki:<br><b><a href="%s" target="_blank">%s</a></b>
ForAnswersSeeForum=For any other questions/help, you can use the Dolibarr forum:<br><b><a href="%s" target="_blank">%s</a></b>
HelpCenterDesc1=This area can help you to get a Help support service on Dolibarr.
HelpCenterDesc2=Some part of this service are available in <b>english only</b>.
@@ -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...). <font class="warning">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.</font>
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

View File

@@ -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

View File

@@ -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))
{

View File

@@ -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 "<form method=\"post\" action=\"marges.php\">";
print '<form method="POST" action="'.$_SERVER['PHP_SELF'].'">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print "<input type=\"hidden\" name=\"action\" value=\"typemarges\">";
print '<tr '.$bc[$var].'>';
@@ -219,7 +219,7 @@ print '</tr>';
// GLOBAL DISCOUNT MANAGEMENT
$var=!$var;
print "<form method=\"post\" action=\"marges.php\">";
print '<form method="POST" action="'.$_SERVER['PHP_SELF'].'">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print "<input type=\"hidden\" name=\"action\" value=\"remises\">";
print '<tr '.$bc[$var].'>';

View File

@@ -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 '<form method="post" name="sel">';
print '<table class="border" width="100%">';
if ($agentid > 0) {
print '<tr><td width="20%">'.$langs->trans('CommercialAgent').'</td>';
print '<td colspan="4">';
print $form->select_dolusers($selected=$agentid,$htmlname='agentid',$show_empty=1,$exclude='',$disabled=0,$include='',$enableonly='');
print '</td></tr>';
if (! $sortorder) $sortorder="ASC";
if (! $sortfield) $sortfield="s.nom";
}
else {
print '<tr><td width="20%">'.$langs->trans('CommercialAgent').'</td>';
print '<td colspan="4">';
print $form->select_dolusers($selected='',$htmlname='agentid',$show_empty=1,$exclude='',$disabled=0,$include='',$enableonly='');
print '</td></tr>';
if (! $sortorder) $sortorder="ASC";
if (! $sortfield) $sortfield="u.login";
}
print '<tr><td width="20%">'.$langs->trans('CommercialAgent').'</td>';
print '<td colspan="4">';
print $form->select_dolusers($agentid,'agentid',1);
print '</td></tr>';
// Start date
print '<td>'.$langs->trans('StartDate').'</td>';
@@ -112,14 +102,14 @@ print '<span id="totalMargin"></span>'; // set by jquery (see below)
print '</td></tr>';
// Margin Rate
if ($conf->global->DISPLAY_MARGIN_RATES) {
if (! empty($conf->global->DISPLAY_MARGIN_RATES)) {
print '<tr style="font-weight: bold"><td>'.$langs->trans("MarginRate").'</td><td colspan="4">';
print '<span id="marginRate"></span>'; // set by jquery (see below)
print '</td></tr>';
}
// Mark Rate
if ($conf->global->DISPLAY_MARK_RATES) {
if (! empty($conf->global->DISPLAY_MARK_RATES)) {
print '<tr style="font-weight: bold"><td>'.$langs->trans("MarkRate").'</td><td colspan="4">';
print '<span id="markRate"></span>'; // set by jquery (see below)
print '</td></tr>';
@@ -164,23 +154,24 @@ if ($result)
$num = $db->num_rows($result);
print '<br>';
print_barre_liste($langs->trans("MarginDetails"),$page,$_SERVER["PHP_SELF"],"&amp;socid=$societe->id",$sortfield,$sortorder,'',$num,0,'');
print_barre_liste($langs->trans("MarginDetails"),$page,$_SERVER["PHP_SELF"],"",$sortfield,$sortorder,'',$num,0,'');
$i = 0;
print "<table class=\"noborder\" width=\"100%\">";
print '<tr class="liste_titre">';
if ($agentid > 0)
print_liste_field_titre($langs->trans("Customer"),$_SERVER["PHP_SELF"],"s.nom","","&amp;agentid=".$_REQUEST["agentid"],'align="center"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Customer"),$_SERVER["PHP_SELF"],"s.nom","","&amp;agentid=".$agentid,'align="center"',$sortfield,$sortorder);
else
print_liste_field_titre($langs->trans("CommercialAgent"),$_SERVER["PHP_SELF"],"u.login","","&amp;agentid=".$_REQUEST["agentid"],'align="center"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("SellingPrice"),$_SERVER["PHP_SELF"],"selling_price","","&amp;agentid=".$_REQUEST["agentid"],'align="right"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("BuyingPrice"),$_SERVER["PHP_SELF"],"buyng_price","","&amp;agentid=".$_REQUEST["agentid"],'align="right"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Margin"),$_SERVER["PHP_SELF"],"marge","","&amp;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","","&amp;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","","&amp;agentid=".$_REQUEST["agentid"],'align="right"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("CommercialAgent"),$_SERVER["PHP_SELF"],"u.login","","&amp;agentid=".$agentid,'align="center"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("SellingPrice"),$_SERVER["PHP_SELF"],"selling_price","","&amp;agentid=".$agentid,'align="right"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("BuyingPrice"),$_SERVER["PHP_SELF"],"buyng_price","","&amp;agentid=".$agentid,'align="right"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Margin"),$_SERVER["PHP_SELF"],"marge","","&amp;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","","&amp;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","","&amp;agentid=".$agentid,'align="right"',$sortfield,$sortorder);
print "</tr>\n";
$cumul_achat = 0;
@@ -188,13 +179,13 @@ 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;
@@ -213,9 +204,9 @@ if ($result)
print "<td align=\"right\">".price($objp->selling_price)."</td>\n";
print "<td align=\"right\">".price($objp->buying_price)."</td>\n";
print "<td align=\"right\">".price($objp->marge)."</td>\n";
if ($conf->global->DISPLAY_MARGIN_RATES)
if (! empty($conf->global->DISPLAY_MARGIN_RATES))
print "<td align=\"right\">".(($marginRate === '')?'n/a':price($marginRate)."%")."</td>\n";
if ($conf->global->DISPLAY_MARK_RATES)
if (! empty($conf->global->DISPLAY_MARK_RATES))
print "<td align=\"right\">".(($markRate === '')?'n/a':price($markRate)."%")."</td>\n";
print "</tr>\n";
$i++;
@@ -227,10 +218,10 @@ 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 '<tr '.$bc[$var].' style="border-top: 1px solid #ccc; font-weight: bold">';
if ($client)
if (! empty($client))
print '<td colspan=2>';
else
print '<td>';
@@ -238,9 +229,9 @@ if ($result)
print "<td align=\"right\">".price($cumul_vente)."</td>\n";
print "<td align=\"right\">".price($cumul_achat)."</td>\n";
print "<td align=\"right\">".price($totalMargin)."</td>\n";
if ($conf->global->DISPLAY_MARGIN_RATES)
if (! empty($conf->global->DISPLAY_MARGIN_RATES))
print "<td align=\"right\">".(($marginRate === '')?'n/a':price($marginRate)."%")."</td>\n";
if ($conf->global->DISPLAY_MARK_RATES)
if (! empty($conf->global->DISPLAY_MARK_RATES))
print "<td align=\"right\">".(($markRate === '')?'n/a':price($markRate)."%")."</td>\n";
print "</tr>\n";

View File

@@ -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,23 +74,23 @@ 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 '<form method="post" name="sel">';
print '<table class="border" width="100%">';
$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)
if ($soc->client)
{
print '<tr><td width="20%">'.$langs->trans('ThirdPartyName').'</td>';
print '<td colspan="4">';
$form->form_thirdparty($_SERVER['PHP_SELF'].'?socid='.$socid,$socid,'socid', $filter='client=1',$showempty=1, $showtype=0, $forcecombo=1);
$form->form_thirdparty($_SERVER['PHP_SELF'].'?socid='.$socid,$socid,'socid','client=1',1,0,1);
print '</td></tr>';
$client = true;
@@ -94,13 +98,11 @@ if ($socid > 0) {
if (! $sortfield) $sortfield="f.datef";
}
}
if (!$client) {
else {
print '<tr><td width="20%">'.$langs->trans('ThirdPartyName').'</td>';
print '<td colspan="4">';
$form->form_thirdparty($_SERVER['PHP_SELF'].'?socid='.$socid,null,'socid', $filter='client=1',$showempty=1, $showtype=0, $forcecombo=1);
$form->form_thirdparty($_SERVER['PHP_SELF'].'?socid='.$socid,null,'socid','client=1',1,0,1);
print '</td></tr>';
if (! $sortorder) $sortorder="ASC";
if (! $sortfield) $sortfield="s.nom";
}
// Start date
@@ -122,14 +124,14 @@ print '<span id="totalMargin"></span>'; // set by jquery (see below)
print '</td></tr>';
// Margin Rate
if ($conf->global->DISPLAY_MARGIN_RATES) {
if (! empty($conf->global->DISPLAY_MARGIN_RATES)) {
print '<tr style="font-weight: bold"><td>'.$langs->trans("MarginRate").'</td><td colspan="4">';
print '<span id="marginRate"></span>'; // set by jquery (see below)
print '</td></tr>';
}
// Mark Rate
if ($conf->global->DISPLAY_MARK_RATES) {
if (! empty($conf->global->DISPLAY_MARK_RATES)) {
print '<tr style="font-weight: bold"><td>'.$langs->trans("MarkRate").'</td><td colspan="4">';
print '<span id="markRate"></span>'; // set by jquery (see below)
print '</td></tr>';
@@ -169,25 +171,25 @@ if ($result)
$num = $db->num_rows($result);
print '<br>';
print_barre_liste($langs->trans("MarginDetails"),$page,$_SERVER["PHP_SELF"],"&amp;socid=$societe->id",$sortfield,$sortorder,'',$num,0,'');
print_barre_liste($langs->trans("MarginDetails"),$page,$_SERVER["PHP_SELF"],"",$sortfield,$sortorder,'',$num,0,'');
$i = 0;
print "<table class=\"noborder\" width=\"100%\">";
print '<tr class="liste_titre">';
if ($client) {
print_liste_field_titre($langs->trans("Invoice"),$_SERVER["PHP_SELF"],"f.facnumber","","&amp;socid=".$_REQUEST["socid"],'',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("DateInvoice"),$_SERVER["PHP_SELF"],"f.datef","","&amp;socid=".$_REQUEST["socid"],'align="center"',$sortfield,$sortorder);
if (! empty($client)) {
print_liste_field_titre($langs->trans("Invoice"),$_SERVER["PHP_SELF"],"f.facnumber","","&amp;socid=".$socid,'',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("DateInvoice"),$_SERVER["PHP_SELF"],"f.datef","","&amp;socid=".$socid,'align="center"',$sortfield,$sortorder);
}
else
print_liste_field_titre($langs->trans("Customer"),$_SERVER["PHP_SELF"],"s.nom","","&amp;socid=".$_REQUEST["socid"],'align="center"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("SellingPrice"),$_SERVER["PHP_SELF"],"selling_price","","&amp;socid=".$_REQUEST["socid"],'align="right"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("BuyingPrice"),$_SERVER["PHP_SELF"],"buyng_price","","&amp;socid=".$_REQUEST["socid"],'align="right"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Margin"),$_SERVER["PHP_SELF"],"marge","","&amp;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","","&amp;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","","&amp;socid=".$_REQUEST["socid"],'align="right"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Customer"),$_SERVER["PHP_SELF"],"s.nom","","&amp;socid=".$socid,'align="center"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("SellingPrice"),$_SERVER["PHP_SELF"],"selling_price","","&amp;socid=".$socid,'align="right"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("BuyingPrice"),$_SERVER["PHP_SELF"],"buyng_price","","&amp;socid=".$socid,'align="right"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Margin"),$_SERVER["PHP_SELF"],"marge","","&amp;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","","&amp;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","","&amp;socid=".$socid,'align="right"',$sortfield,$sortorder);
print "</tr>\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 "<td align=\"right\">".price($objp->selling_price)."</td>\n";
print "<td align=\"right\">".price($objp->buying_price)."</td>\n";
print "<td align=\"right\">".price($objp->marge)."</td>\n";
if ($conf->global->DISPLAY_MARGIN_RATES)
if (! empty($conf->global->DISPLAY_MARGIN_RATES))
print "<td align=\"right\">".(($marginRate === '')?'n/a':price($marginRate)."%")."</td>\n";
if ($conf->global->DISPLAY_MARK_RATES)
if (! empty($conf->global->DISPLAY_MARK_RATES))
print "<td align=\"right\">".(($markRate === '')?'n/a':price($markRate)."%")."</td>\n";
print "</tr>\n";
$i++;
@@ -249,9 +251,9 @@ if ($result)
print "<td align=\"right\">".price($cumul_vente)."</td>\n";
print "<td align=\"right\">".price($cumul_achat)."</td>\n";
print "<td align=\"right\">".price($totalMargin)."</td>\n";
if ($conf->global->DISPLAY_MARGIN_RATES)
if (! empty($conf->global->DISPLAY_MARGIN_RATES))
print "<td align=\"right\">".(($marginRate === '')?'n/a':price($marginRate)."%")."</td>\n";
if ($conf->global->DISPLAY_MARK_RATES)
if (! empty($conf->global->DISPLAY_MARK_RATES))
print "<td align=\"right\">".(($markRate === '')?'n/a':price($markRate)."%")."</td>\n";
print "</tr>\n";

View File

@@ -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='';

View File

@@ -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 '<form method="post" name="sel">';
@@ -84,12 +88,9 @@ print '<table class="border" width="100%">';
if ($id > 0) {
$societe = new Societe($db, $socid);
$societe->fetch($socid);
print '<tr><td width="20%">'.$langs->trans('ChooseProduct/Service').'</td>';
print '<td colspan="4">';
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 '</td></tr>';
print '<tr><td width="20%">'.$langs->trans('AllProducts').'</td>';
@@ -101,10 +102,9 @@ if ($id > 0) {
else {
print '<tr><td width="20%">'.$langs->trans('ChooseProduct/Service').'</td>';
print '<td colspan="4">';
print $form->select_produits($selected='', $htmlname='id', $filtertype='', $limit=20, $price_level=0, $status=1, $finished=2, $selected_input_value='', $hidelabel=1);
print $form->select_produits('','id','',20,0,1,2,'',1);
print '</td></tr>';
if (! $sortorder) $sortorder="ASC";
if (! $sortfield) $sortfield="p.ref";
}
// Start date
@@ -126,14 +126,14 @@ print '<span id="totalMargin"></span>'; // set by jquery (see below)
print '</td></tr>';
// Margin Rate
if ($conf->global->DISPLAY_MARGIN_RATES) {
if (! empty($conf->global->DISPLAY_MARGIN_RATES)) {
print '<tr style="font-weight: bold"><td>'.$langs->trans("MarginRate").'</td><td colspan="4">';
print '<span id="marginRate"></span>'; // set by jquery (see below)
print '</td></tr>';
}
// Mark Rate
if ($conf->global->DISPLAY_MARK_RATES) {
if (! empty($conf->global->DISPLAY_MARK_RATES)) {
print '<tr style="font-weight: bold"><td>'.$langs->trans("MarkRate").'</td><td colspan="4">';
print '<span id="markRate"></span>'; // set by jquery (see below)
print '</td></tr>';
@@ -142,7 +142,7 @@ if ($conf->global->DISPLAY_MARK_RATES) {
print "</table>";
print '</form>';
$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;
@@ -175,25 +175,25 @@ if ($result)
$num = $db->num_rows($result);
print '<br>';
print_barre_liste($langs->trans("MarginDetails"),$page,$_SERVER["PHP_SELF"],"&amp;id=$product->id",$sortfield,$sortorder,'',$num,0,'');
print_barre_liste($langs->trans("MarginDetails"),$page,$_SERVER["PHP_SELF"],"&amp;id=".$id,$sortfield,$sortorder,'',$num,0,'');
$i = 0;
print "<table class=\"noborder\" width=\"100%\">";
print '<tr class="liste_titre">';
if ($id > 0) {
print_liste_field_titre($langs->trans("Invoice"),$_SERVER["PHP_SELF"],"f.facnumber","","&amp;id=".$_REQUEST["id"],'',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("DateInvoice"),$_SERVER["PHP_SELF"],"f.datef","","&amp;id=".$_REQUEST["id"],'align="center"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Invoice"),$_SERVER["PHP_SELF"],"f.facnumber","","&amp;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","","&amp;id=".$_REQUEST["id"],'align="center"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("SellingPrice"),$_SERVER["PHP_SELF"],"selling_price","","&amp;id=".$_REQUEST["id"],'align="right"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("BuyingPrice"),$_SERVER["PHP_SELF"],"buyng_price","","&amp;id=".$_REQUEST["id"],'align="right"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Margin"),$_SERVER["PHP_SELF"],"marge","","&amp;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","","&amp;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","","&amp;id=".$_REQUEST["id"],'align="right"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("ProductService"),$_SERVER["PHP_SELF"],"p.ref","","&amp;id=".$id,'align="center"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("SellingPrice"),$_SERVER["PHP_SELF"],"selling_price","","&amp;id=".$id,'align="right"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("BuyingPrice"),$_SERVER["PHP_SELF"],"buyng_price","","&amp;id=".$id,'align="right"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Margin"),$_SERVER["PHP_SELF"],"marge","","&amp;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","","&amp;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","","&amp;id=".$id,'align="right"',$sortfield,$sortorder);
print "</tr>\n";
$cumul_achat = 0;
@@ -233,9 +233,9 @@ if ($result)
print "<td align=\"right\">".price($objp->selling_price)."</td>\n";
print "<td align=\"right\">".price($objp->buying_price)."</td>\n";
print "<td align=\"right\">".price($objp->marge)."</td>\n";
if ($conf->global->DISPLAY_MARGIN_RATES)
if (! empty($conf->global->DISPLAY_MARGIN_RATES))
print "<td align=\"right\">".(($marginRate === '')?'n/a':price($marginRate)."%")."</td>\n";
if ($conf->global->DISPLAY_MARK_RATES)
if (! empty($conf->global->DISPLAY_MARK_RATES))
print "<td align=\"right\">".(($markRate === '')?'n/a':price($markRate)."%")."</td>\n";
print "</tr>\n";
$i++;
@@ -258,9 +258,9 @@ if ($result)
print "<td align=\"right\">".price($cumul_vente)."</td>\n";
print "<td align=\"right\">".price($cumul_achat)."</td>\n";
print "<td align=\"right\">".price($totalMargin)."</td>\n";
if ($conf->global->DISPLAY_MARGIN_RATES)
if (! empty($conf->global->DISPLAY_MARGIN_RATES))
print "<td align=\"right\">".(($marginRate === '')?'n/a':price($marginRate)."%")."</td>\n";
if ($conf->global->DISPLAY_MARK_RATES)
if (! empty($conf->global->DISPLAY_MARK_RATES))
print "<td align=\"right\">".(($markRate === '')?'n/a':price($markRate)."%")."</td>\n";
print "</tr>\n";

View File

@@ -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 '<table class="border" width="100%">';
@@ -111,14 +111,14 @@ if ($id > 0 || ! empty($ref))
print '</td></tr>';
// Margin Rate
if ($conf->global->DISPLAY_MARGIN_RATES) {
if (! empty($conf->global->DISPLAY_MARGIN_RATES)) {
print '<tr style="font-weight: bold"><td>'.$langs->trans("MarginRate").'</td><td colspan="3">';
print '<span id="marginRate"></span>'; // set by jquery (see below)
print '</td></tr>';
}
// Mark Rate
if ($conf->global->DISPLAY_MARK_RATES) {
if (! empty($conf->global->DISPLAY_MARK_RATES)) {
print '<tr style="font-weight: bold"><td>'.$langs->trans("MarkRate").'</td><td colspan="3">';
print '<span id="markRate"></span>'; // set by jquery (see below)
print '</td></tr>';
@@ -128,7 +128,7 @@ if ($id > 0 || ! empty($ref))
print '</div>';
$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 "<table class=\"noborder\" width=\"100%\">";
print '<tr class="liste_titre">';
print_liste_field_titre($langs->trans("Invoice"),$_SERVER["PHP_SELF"],"f.facnumber","","&amp;id=".$_GET["id"],'',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Company"),$_SERVER["PHP_SELF"],"s.nom","","&amp;id=".$_GET["id"],'',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("CustomerCode"),$_SERVER["PHP_SELF"],"s.code_client","","&amp;id=".$_GET["id"],'',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("DateInvoice"),$_SERVER["PHP_SELF"],"f.datef","","&amp;id=".$_GET["id"],'align="center"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("SellingPrice"),$_SERVER["PHP_SELF"],"selling_price","","&amp;id=".$_GET["id"],'align="right"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("BuyingPrice"),$_SERVER["PHP_SELF"],"buyng_price","","&amp;id=".$_GET["id"],'align="right"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Qty"),$_SERVER["PHP_SELF"],"d.qty","","&amp;id=".$_GET["id"],'align="right"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Margin"),$_SERVER["PHP_SELF"],"marge","","&amp;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","","&amp;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","","&amp;id=".$_GET["id"],'align="right"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"f.paye,f.fk_statut","","&amp;id=".$_GET["id"],'align="right"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Invoice"),$_SERVER["PHP_SELF"],"f.facnumber","","&amp;id=".$object->id,'',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Company"),$_SERVER["PHP_SELF"],"s.nom","","&amp;id=".$object->id,'',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("CustomerCode"),$_SERVER["PHP_SELF"],"s.code_client","","&amp;id=".$object->id,'',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("DateInvoice"),$_SERVER["PHP_SELF"],"f.datef","","&amp;id=".$object->id,'align="center"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("SellingPrice"),$_SERVER["PHP_SELF"],"selling_price","","&amp;id=".$object->id,'align="right"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("BuyingPrice"),$_SERVER["PHP_SELF"],"buyng_price","","&amp;id=".$object->id,'align="right"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Qty"),$_SERVER["PHP_SELF"],"d.qty","","&amp;id=".$object->id,'align="right"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Margin"),$_SERVER["PHP_SELF"],"marge","","&amp;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","","&amp;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","","&amp;id=".$object->id,'align="right"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"f.paye,f.fk_statut","","&amp;id=".$object->id,'align="right"',$sortfield,$sortorder);
print "</tr>\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 "<tr $bc[$var]>";
print '<td>';
$invoicestatic->id=$objp->facid;
@@ -200,9 +200,9 @@ if ($id > 0 || ! empty($ref))
print "<td align=\"right\">".price($objp->buying_price)."</td>\n";
print "<td align=\"right\">".price($objp->qty)."</td>\n";
print "<td align=\"right\">".price($objp->marge)."</td>\n";
if ($conf->global->DISPLAY_MARGIN_RATES)
if (! empty($conf->global->DISPLAY_MARGIN_RATES))
print "<td align=\"right\">".(($marginRate === '')?'n/a':price($marginRate)."%")."</td>\n";
if ($conf->global->DISPLAY_MARK_RATES)
if (! empty($conf->global->DISPLAY_MARK_RATES))
print "<td align=\"right\">".(($markRate === '')?'n/a':price($markRate)."%")."</td>\n";
print '<td align="right">'.$invoicestatic->LibStatut($objp->paye,$objp->statut,5).'</td>';
print "</tr>\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 '<tr '.$bc[$var].' style="border-top: 1px solid #ccc; font-weight: bold">';
print '<td colspan=4>'.$langs->trans('TotalMargin')."</td>";
print "<td align=\"right\">".price($cumul_vente)."</td>\n";
print "<td align=\"right\">".price($cumul_achat)."</td>\n";
print "<td align=\"right\">".price($cumul_qty)."</td>\n";
print "<td align=\"right\">".price($totalMargin)."</td>\n";
if ($conf->global->DISPLAY_MARGIN_RATES)
if (! empty($conf->global->DISPLAY_MARGIN_RATES))
print "<td align=\"right\">".(($marginRate === '')?'n/a':price($marginRate)."%")."</td>\n";
if ($conf->global->DISPLAY_MARK_RATES)
if (! empty($conf->global->DISPLAY_MARK_RATES))
print "<td align=\"right\">".(($markRate === '')?'n/a':price($markRate)."%")."</td>\n";
print '<td align="right">&nbsp;</td>';
print "</tr>\n";

View File

@@ -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 '<table class="border" width="100%">';
@@ -109,14 +109,14 @@ if ($socid > 0)
print '</td></tr>';
// Margin Rate
if ($conf->global->DISPLAY_MARGIN_RATES) {
if (! empty($conf->global->DISPLAY_MARGIN_RATES)) {
print '<tr style="font-weight: bold"><td>'.$langs->trans("MarginRate").'</td><td colspan="3">';
print '<span id="marginRate"></span>'; // set by jquery (see below)
print '</td></tr>';
}
// Mark Rate
if ($conf->global->DISPLAY_MARK_RATES) {
if (! empty($conf->global->DISPLAY_MARK_RATES)) {
print '<tr style="font-weight: bold"><td>'.$langs->trans("MarkRate").'</td><td colspan="3">';
print '<span id="markRate"></span>'; // set by jquery (see below)
print '</td></tr>';
@@ -158,9 +158,9 @@ if ($socid > 0)
print_liste_field_titre($langs->trans("SellingPrice"),$_SERVER["PHP_SELF"],"selling_price","","&amp;socid=".$_REQUEST["socid"],'align="right"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("BuyingPrice"),$_SERVER["PHP_SELF"],"buyng_price","","&amp;socid=".$_REQUEST["socid"],'align="right"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Margin"),$_SERVER["PHP_SELF"],"marge","","&amp;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","","&amp;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","","&amp;socid=".$_REQUEST["socid"],'align="right"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"f.paye,f.fk_statut","","&amp;socid=".$_REQUEST["socid"],'align="right"',$sortfield,$sortorder);
print "</tr>\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 "<td align=\"right\">".price($objp->selling_price)."</td>\n";
print "<td align=\"right\">".price($objp->buying_price)."</td>\n";
print "<td align=\"right\">".price($objp->marge)."</td>\n";
if ($conf->global->DISPLAY_MARGIN_RATES)
if (! empty($conf->global->DISPLAY_MARGIN_RATES))
print "<td align=\"right\">".(($marginRate === '')?'n/a':price($marginRate)."%")."</td>\n";
if ($conf->global->DISPLAY_MARK_RATES)
if (! empty($conf->global->DISPLAY_MARK_RATES))
print "<td align=\"right\">".(($markRate === '')?'n/a':price($markRate)."%")."</td>\n";
print '<td align="right">'.$invoicestatic->LibStatut($objp->paye,$objp->statut,5).'</td>';
print "</tr>\n";
@@ -213,9 +213,9 @@ if ($socid > 0)
print "<td align=\"right\">".price($cumul_vente)."</td>\n";
print "<td align=\"right\">".price($cumul_achat)."</td>\n";
print "<td align=\"right\">".price($totalMargin)."</td>\n";
if ($conf->global->DISPLAY_MARGIN_RATES)
if (! empty($conf->global->DISPLAY_MARGIN_RATES))
print "<td align=\"right\">".(($marginRate === '')?'n/a':price($marginRate)."%")."</td>\n";
if ($conf->global->DISPLAY_MARK_RATES)
if (! empty($conf->global->DISPLAY_MARK_RATES))
print "<td align=\"right\">".(($markRate === '')?'n/a':price($markRate)."%")."</td>\n";
print '<td align="right">&nbsp;</td>';
print "</tr>\n";

View File

@@ -1,6 +1,6 @@
<?php
/* Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr>
* Copyright (C) 2005-2011 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2005-2012 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2007-2011 Laurent Destailleur <eldy@users.sourceforge.net>
*
* 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;

View File

@@ -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;
}

View File

@@ -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='<div class="error">'.$langs->trans('ErrorFieldRequired',$langs->transnoentities('Label')).'</div>';
$action = "create";
$_GET["canvas"] = $_POST["canvas"];
$_GET["type"] = $_POST["type"];
$error++;
}
if (empty($ref))
{
$mesg='<div class="error">'.$langs->trans('ErrorFieldRequired',$langs->transnoentities('Ref')).'</div>';
$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='<div class="error">'.$langs->trans($object->error).'</div>';
$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='<div class="error">'.$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 '<form action="fiche.php" method="post">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="add">';
print '<input type="hidden" name="type" value="'.$_GET["type"].'">'."\n";
print '<input type="hidden" name="type" value="'.$type.'">'."\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 '<table class="border" width="100%">';
print '<tr>';
print '<td class="fieldrequired" width="20%">'.$langs->trans("Ref").'</td><td><input name="ref" size="40" maxlength="32" value="'.$ref.'">';
if ($_error == 1)
if ($_error)
{
print $langs->trans("RefAlreadyExists");
}
print '</td></tr>';
// Label
print '<tr><td class="fieldrequired">'.$langs->trans("Label").'</td><td><input name="libelle" size="40" value="'.$_POST["libelle"].'"></td></tr>';
print '<tr><td class="fieldrequired">'.$langs->trans("Label").'</td><td><input name="libelle" size="40" value="'.GETPOST('libelle').'"></td></tr>';
// On sell
print '<tr><td class="fieldrequired">'.$langs->trans("Status").' ('.$langs->trans("Sell").')</td><td>';
$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 '</td></tr>';
// To buy
print '<tr><td class="fieldrequired">'.$langs->trans("Status").' ('.$langs->trans("Buy").')</td><td>';
$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 '</td></tr>';
// Stock min level
if ($_GET["type"] != 1 && $conf->stock->enabled)
if ($type != 1 && $conf->stock->enabled)
{
print '<tr><td>'.$langs->trans("StockLimit").'</td><td>';
print '<input name="seuil_stock_alerte" size="4" value="'.$_POST["seuil_stock_alerte"].'">';
print '<input name="seuil_stock_alerte" size="4" value="'.GETPOST('seuil_stock_alerte').'">';
print '</td></tr>';
}
else
@@ -745,24 +742,24 @@ else
print '<tr><td valign="top">'.$langs->trans("Description").'</td><td>';
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 "</td></tr>";
// Nature
if ($_GET["type"] != 1)
if ($type != 1)
{
print '<tr><td>'.$langs->trans("Nature").'</td><td>';
$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 '</td></tr>';
}
// Duration
if ($_GET["type"] == 1)
if ($type == 1)
{
print '<tr><td>'.$langs->trans("Duration").'</td><td><input name="duration_value" size="6" maxlength="5" value="'.$object->duree.'"> &nbsp;';
print '<tr><td>'.$langs->trans("Duration").'</td><td><input name="duration_value" size="6" maxlength="5" value="'.GETPOST('duration_value').'"> &nbsp;';
print '<input name="duration_unit" type="radio" value="h">'.$langs->trans("Hour").'&nbsp;';
print '<input name="duration_unit" type="radio" value="d">'.$langs->trans("Day").'&nbsp;';
print '<input name="duration_unit" type="radio" value="w">'.$langs->trans("Week").'&nbsp;';
@@ -771,36 +768,36 @@ else
print '</td></tr>';
}
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 '<tr><td>'.$langs->trans("Weight").'</td><td>';
print '<input name="weight" size="4" value="'.$_POST["weight"].'">';
print '<input name="weight" size="4" value="'.GETPOST('weight').'">';
print $formproduct->select_measuring_units("weight_units","weight");
print '</td></tr>';
// Length
print '<tr><td>'.$langs->trans("Length").'</td><td>';
print '<input name="size" size="4" value="'.$_POST["size"].'">';
print '<input name="size" size="4" value="'.GETPOST('size').'">';
print $formproduct->select_measuring_units("size_units","size");
print '</td></tr>';
// Surface
print '<tr><td>'.$langs->trans("Surface").'</td><td>';
print '<input name="surface" size="4" value="'.$_POST["surface"].'">';
print '<input name="surface" size="4" value="'.GETPOST('surface').'">';
print $formproduct->select_measuring_units("surface_units","surface");
print '</td></tr>';
// Volume
print '<tr><td>'.$langs->trans("Volume").'</td><td>';
print '<input name="volume" size="4" value="'.$_POST["volume"].'">';
print '<input name="volume" size="4" value="'.GETPOST('volume').'">';
print $formproduct->select_measuring_units("volume_units","volume");
print '</td></tr>';
}
// Customs code
print '<tr><td>'.$langs->trans("CustomCode").'</td><td><input name="customcode" size="10" value="'.$_POST["customcode"].'"></td></tr>';
print '<tr><td>'.$langs->trans("CustomCode").'</td><td><input name="customcode" size="10" value="'.GETPOST('customcode').'"></td></tr>';
// Origin country
print '<tr><td>'.$langs->trans("CountryOrigin").'</td><td>';
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 '</td></tr>';
@@ -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 '<tr><td>'.$label.'</td><td colspan="3">';
print $extrafields->showInputField($key,$value);
print '</td></tr>'."\n";
@@ -821,7 +818,7 @@ else
// Note (private, no output on invoices, propales...)
print '<tr><td valign="top">'.$langs->trans("NoteNotVisibleOnBill").'</td><td>';
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 "</td></tr>";

View File

@@ -1,7 +1,7 @@
<?php
/* Copyright (C) 2001-2006 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2011 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2005-2012 Regis Houssin <regis@dolibarr.fr>
*
* 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)."%')";
@@ -173,14 +170,17 @@ else
}
$helpurl='';
if (isset($_GET["type"]) && $_GET["type"] == 0)
if (isset($type))
{
if ($type == 0)
{
$helpurl='EN:Module_Products|FR:Module_Produits|ES:M&oacute;dulo_Productos';
}
if (isset($_GET["type"]) && $_GET["type"] == 1)
else if ($type == 1)
{
$helpurl='EN:Module_Services_En|FR:Module_Services|ES:M&oacute;dulo_Servicios';
}
}
llxHeader('',$title,$helpurl,'');
@@ -193,16 +193,16 @@ else
$param.=isset($type)?"&amp;type=".$type:"";
print_barre_liste($texte, $page, "liste.php", $param, $sortfield, $sortorder,'',$num);
if (isset($catid))
if (! empty($catid))
{
print "<div id='ways'>";
$c = new Categorie($db, $catid);
$c = new Categorie($db);
$ways = $c->print_all_ways(' &gt; ','product/liste.php');
print " &gt; ".$ways[0]."<br>\n";
print "</div><br>";
}
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,11 +211,11 @@ 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
@@ -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 "<tr class=\"liste_titre\">";
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 '<td class="liste_titre" align="right">'.$langs->trans("BuyingPriceMinShort").'</td>';
if ($conf->stock->enabled && $user->rights->stock->lire && $type != 1) print '<td class="liste_titre" align="right">'.$langs->trans("PhysicalStock").'</td>';
if (! empty($conf->stock->enabled) && $user->rights->stock->lire && $type != 1) print '<td class="liste_titre" align="right">'.$langs->trans("PhysicalStock").'</td>';
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 "</tr>\n";
@@ -269,7 +269,7 @@ else
print '<td class="liste_titre" align="left">';
print '<input class="flat" type="text" name="snom" size="12" value="'.$snom.'">';
print '</td>';
if ($conf->barcode->enabled)
if (! empty($conf->barcode->enabled))
{
print '<td class="liste_titre">';
print '<input class="flat" type="text" name="sbarcode" size="6" value="'.$sbarcode.'">';
@@ -280,7 +280,7 @@ else
print '</td>';
// Duration
if ($conf->service->enabled && $type != 0)
if (! empty($conf->service->enabled) && $type != 0)
{
print '<td class="liste_titre">';
print '&nbsp;';
@@ -301,7 +301,7 @@ else
print '</td>';
// Stock
if ($conf->stock->enabled && $user->rights->stock->lire && $type != 1)
if (! empty($conf->stock->enabled) && $user->rights->stock->lire && $type != 1)
{
print '<td class="liste_titre">';
print '&nbsp;';
@@ -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 '<td>'.dol_trunc($objp->label,40).'</td>';
// Barcode
if ($conf->barcode->enabled)
if (! empty($conf->barcode->enabled))
{
print '<td>'.$objp->barcode.'</td>';
}
@@ -368,7 +368,7 @@ else
print '<td align="center">'.dol_print_date($db->jdate($objp->datem),'day')."</td>\n";
// Duration
if ($conf->service->enabled && $type != 0)
if (! empty($conf->service->enabled) && $type != 0)
{
print '<td align="center">';
if (preg_match('/([0-9]+)y/i',$objp->duration,$regs)) print $regs[1].' '.$langs->trans("DurationYear");
@@ -406,7 +406,7 @@ else
print '</td>';
// 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", "&amp;sref=".$sref."&amp;snom=".$snom."&amp;sall=".$sall."&amp;tosell=".$tosell."&amp;tobuy=".$tobuy, $sortfield, $sortorder,'',$num);
}
@@ -458,7 +458,6 @@ else
}
$db->close();
llxFooter();
$db->close();
?>

View File

@@ -2,7 +2,7 @@
/* Copyright (C) 2001-2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2005 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
* Copyright (C) 2005-2010 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2005-2012 Regis Houssin <regis@dolibarr.fr>
*
* 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&oacute;dulo_Productos';
}
if (isset($_GET["type"]) && $_GET["type"] == 1)
else if ($type == 1)
{
$helpurl='EN:Module_Services_En|FR:Module_Services|ES:M&oacute;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 = '&amp;type='.$_GET['type'];
$param = '&amp;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);
@@ -118,7 +120,7 @@ if ($result)
$objp = $db->fetch_object($result);
// 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";
@@ -130,7 +132,7 @@ if ($result)
if ($resultp)
{
$objtp = $db->fetch_object($resultp);
if ($objtp->label != '') $objp->label = $objtp->label;
if (! empty($objtp->label)) $objp->label = $objtp->label;
}
}
@@ -150,11 +152,13 @@ if ($result)
print "</tr>\n";
$i++;
}
$db->free();
}
print "</table>";
$db->close();
llxFooter();
$db->close();
?>

View File

@@ -1,7 +1,7 @@
<?php
/* Copyright (C) 2001-2006 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2009 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2005-2012 Regis Houssin <regis@dolibarr.fr>
*
* 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&oacute;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."&amp;sall=".$sall."&amp;tosell=".$_POST["tosell"]."&amp;tobuy=".$_POST["tobuy"], $sortfield, $sortorder,'',$num);
print_barre_liste($texte, $page, "reassort.php", "&sref=".$sref."&snom=".$snom."&amp;sall=".$sall."&amp;tosell=".$tosell."&amp;tobuy=".$tobuy, $sortfield, $sortorder,'',$num);
}
else
{
print_barre_liste($texte, $page, "reassort.php", "&sref=$sref&snom=$snom&fourn_id=$fourn_id".(isset($type)?"&amp;type=$type":""), $sortfield, $sortorder,'',$num);
}
if ($catid)
if (! empty($catid))
{
print "<div id='ways'>";
$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 '<td class="liste_titre">';
print '<input class="flat" type="text" name="snom" value="'.$snom.'">';
print '</td>';
if ($conf->service->enabled && $type == 1)
if (! empty($conf->service->enabled) && $type == 1)
{
print '<td class="liste_titre">';
print '&nbsp;';
@@ -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 '</td>';
print '<td>'.$objp->label.'</td>';
if ($conf->service->enabled && $type == 1)
if (! empty($conf->service->enabled) && $type == 1)
{
print '<td align="center">';
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."&amp;sall=".$sall."&amp;tosell=".$tosell."&amp;tobuy=".$tobuy, $sortfield, $sortorder,'',$num, 0, '');
}
@@ -354,7 +354,6 @@ else
}
$db->close();
llxFooter();
$db->close();
?>

View File

@@ -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'] = '<div class="ok">'.$langs->trans("FileWasRemoved",GETPOST('urlfile')).'</div>';
$_SESSION['dol_message'] = '<div class="ok">'.$langs->trans("FileWasRemoved",GETPOST('urlfile')).'</div>';
Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id);
exit;
}

View File

@@ -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'] = '<div class="ok">'.$langs->trans("FileWasRemoved",GETPOST('urlfile')).'</div>';
$_SESSION['dol_message'] = '<div class="ok">'.$langs->trans("FileWasRemoved",GETPOST('urlfile')).'</div>';
Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id);
exit;
}

View File

@@ -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'] = '<div class="ok">'.$langs->trans("FileWasRemoved",GETPOST('urlfile')).'</div>';
$_SESSION['dol_message'] = '<div class="ok">'.$langs->trans("FileWasRemoved",GETPOST('urlfile')).'</div>';
Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id);
exit;
}

View File

@@ -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 '<table class="border" width="100%">';
@@ -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 '<tr><td>';
print $langs->trans('SupplierCode').'</td><td colspan="'.(2+(($showlogo || $showbarcode)?0:1)).'">';
@@ -1514,7 +1514,7 @@ else
}
// Barcode
if ($conf->global->MAIN_MODULE_BARCODE)
if (! empty($conf->global->MAIN_MODULE_BARCODE))
{
print '<tr><td>';
print $langs->trans('Gencod').'</td><td colspan="'.(2+(($showlogo || $showbarcode)?0:1)).'">'.$object->barcode;

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

View File

Before

Width:  |  Height:  |  Size: 579 B

After

Width:  |  Height:  |  Size: 579 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

View File

Before

Width:  |  Height:  |  Size: 579 B

After

Width:  |  Height:  |  Size: 579 B

View File

@@ -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;

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

View File

Before

Width:  |  Height:  |  Size: 579 B

After

Width:  |  Height:  |  Size: 579 B

View File

@@ -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;

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

View File

Before

Width:  |  Height:  |  Size: 579 B

After

Width:  |  Height:  |  Size: 579 B

View File

@@ -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;

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

View File

Before

Width:  |  Height:  |  Size: 579 B

After

Width:  |  Height:  |  Size: 579 B

View File

@@ -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;

View File

@@ -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)
{

View File

@@ -133,7 +133,7 @@ if ($resql)
'__ID__' => $obj2->source_id,
'__EMAIL__' => $obj2->email,
'__CHECK_READ__' => '<img src="'.DOL_MAIN_URL_ROOT.'/public/emailing/mailing-read.php?tag='.$obj2->tag.'" width="1" height="1" style="width:1px;height:1px" border="0"/>',
'__UNSUSCRIBE__' => '<a href="'.DOL_MAIN_URL_ROOT.'/public/emailing/mailing-unsubscribe.php?tag='.$obj2->tag.'&unsuscrib=1" target="_blank">'.$langs->trans("MailUnsubcribe").'</a>',
'__UNSUBSCRIBE__' => '<a href="'.DOL_MAIN_URL_ROOT.'/public/emailing/mailing-unsubscribe.php?tag='.$obj2->tag.'&unsuscrib=1" target="_blank">'.$langs->trans("MailUnsubcribe").'</a>',
'__MAILTOEMAIL__' => '<a href="mailto:'.$obj2->email.'">'.$obj2->email.'</a>',
'__LASTNAME__' => $obj2->lastname,
'__FIRSTNAME__' => $obj2->firstname,

View File

@@ -140,7 +140,7 @@ if ($resql)
'__ID__' => $obj->source_id,
'__EMAIL__' => $obj->email,
'__CHECK_READ__' => '<img src="'.DOL_MAIN_URL_ROOT.'/public/emailing/mailing-read.php?tag='.$obj->tag.'" width="1" height="1" style="width:1px;height:1px" border="0"/>',
'__UNSUSCRIBE__' => '<a href="'.DOL_MAIN_URL_ROOT.'/public/emailing/mailing-unsubscribe.php?tag='.$obj->tag.'&unsuscrib=1" target="_blank">'.$langs->trans("MailUnsubcribe").'</a>',
'__UNSUBSCRIBE__' => '<a href="'.DOL_MAIN_URL_ROOT.'/public/emailing/mailing-unsubscribe.php?tag='.$obj->tag.'&unsuscrib=1" target="_blank">'.$langs->trans("MailUnsubcribe").'</a>',
'__MAILTOEMAIL__' => '<a href="mailto:'.$obj->email.'">'.$obj->email.'</a>',
'__LASTNAME__' => $obj->lastname,
'__FIRSTNAME__' => $obj->firstname,