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

This commit is contained in:
Laurent Destailleur 2012-01-10 00:43:47 +01:00
commit 520aaa2238
6 changed files with 111 additions and 68 deletions

View File

@ -252,6 +252,54 @@ else
} }
// Important: can debug rounding, to simulate the rounded total
/*
print '<br><b>'.$langs->trans("VATRoundedByLine").' ('.$langs->trans("DolibarrDefault").')</b><br>';
foreach($vat_rates as $vat)
{
for ($qty=1; $qty<=2; $qty++)
{
$s1=10/3;
$s2=2/7;
// Round by line
$tmparray1=calcul_price_total(1,$qty*price2num($s1,'MU'),0,$vat,0,0,0,'HT',0);
$tmparray2=calcul_price_total(1,$qty*price2num($s2,'MU'),0,$vat,0,0,0,'HT',0);
$total_ht = $tmparray1[0] + $tmparray2[0];
$total_tva = $tmparray1[1] + $tmparray2[1];
$total_ttc = $tmparray1[2] + $tmparray2[2];
print $langs->trans("UnitPriceOfProduct").": ".(price2num($s1,'MU') + price2num($s2,'MU'));
print " x ".$langs->trans("Quantity").": ".$qty;
print " - ".$langs->trans("VAT").": ".$vat.'%';
print " &nbsp; -> &nbsp; ".$langs->trans("TotalPriceAfterRounding").": ".$total_ht.' / '.$total_tva.' / '.$total_ttc."<br>\n";
}
}
print '<br><b>'.$langs->trans("VATRoundedOnTotal").'</b><br>';
foreach($vat_rates as $vat)
{
for ($qty=1; $qty<=2; $qty++)
{
$s1=10/3;
$s2=2/7;
// Global round
$subtotal_ht = (($qty*price2num($s1,'MU')) + ($qty*price2num($s2,'MU')));
$tmparray3=calcul_price_total(1,$subtotal_ht,0,$vat,0,0,0,'HT',0);
$total_ht = $tmparray3[0];
$total_tva = $tmparray3[1];
$total_ttc = $tmparray3[2];
print $langs->trans("UnitPriceOfProduct").": ".price2num($s1+$s2,'MU');
print " x ".$langs->trans("Quantity").": ".$qty;
print " - ".$langs->trans("VAT").": ".$vat.'%';
print " &nbsp; -> &nbsp; ".$langs->trans("TotalPriceAfterRounding").": ".$total_ht.' / '.$total_tva.' / '.$total_ttc."<br>\n";
}
}
*/
llxFooter(); llxFooter();

View File

@ -1,5 +1,5 @@
<?php <?php
/* Copyright (C) 2011 Regis Houssin <regis@dolibarr.fr> /* Copyright (C) 2011-2012 Regis Houssin <regis@dolibarr.fr>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -51,11 +51,11 @@ if((isset($_GET['action']) && ! empty($_GET['action'])) && (isset($_GET['name'])
{ {
if ($_GET['action'] == 'set') if ($_GET['action'] == 'set')
{ {
dolibarr_set_const($db, $_GET['name'], 1, 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, GETPOST('name','alpha'), 1, 'chaine', 0, '', GETPOST('entity','int'));
} }
else if ($_GET['action'] == 'del') else if ($_GET['action'] == 'del')
{ {
dolibarr_del_const($db, $_GET['name'], $conf->entity); dolibarr_del_const($db, GETPOST('name','alpha'), GETPOST('entity','int'));
} }
} }
} }

View File

@ -191,28 +191,19 @@ class Conf
$this->modules[]=$module; $this->modules[]=$module;
} }
} }
// Sharings between entities
else if ($value && preg_match('/^MULTICOMPANY_([A-Z_]+)_SHARING$/',$key,$reg))
{
$module=strtolower($reg[1]);
$multicompany_sharing[$module]=$value;
}
} }
$i++; $i++;
} }
// Sharings between entities // Load shared elements between entities
if (! empty($this->multicompany->enabled) && ! empty($multicompany_sharing)) if (! empty($this->multicompany->enabled))
{ {
$ret = @dol_include_once('/multicompany/class/actions_multicompany.class.php'); $ret = @dol_include_once('/multicompany/class/actions_multicompany.class.php');
if ($ret) if ($ret)
{ {
$mc = new ActionsMulticompany($db); $mc = new ActionsMulticompany($db);
$this->multicompany->entity = $mc->loadEntity();
foreach($multicompany_sharing as $key => $value) $this->entities = $mc->loadSharedElements();
{
$this->entities[$key]=$mc->check_entity($value);
}
} }
} }
} }

View File

@ -463,7 +463,7 @@ function dolibarr_set_const($db, $name, $value, $type='chaine', $visible=0, $not
$sql = "DELETE FROM ".MAIN_DB_PREFIX."const"; $sql = "DELETE FROM ".MAIN_DB_PREFIX."const";
$sql.= " WHERE name = ".$db->encrypt($name,1); $sql.= " WHERE name = ".$db->encrypt($name,1);
if ($entity > 0) $sql.= " AND entity = ".$entity; if ($entity >= 0) $sql.= " AND entity = ".$entity;
dol_syslog("admin.lib::dolibarr_set_const sql=".$sql, LOG_DEBUG); dol_syslog("admin.lib::dolibarr_set_const sql=".$sql, LOG_DEBUG);
$resql=$db->query($sql); $resql=$db->query($sql);

View File

@ -218,13 +218,16 @@ function ajax_combobox($htmlname)
/** /**
* On/off button for constant * On/off button for constant
* *
* @param code Name of constant * @param string $code Name of constant
* @param input Input element * @param array $input Input element
* @param int $entity Entity to set
* TODO add different method for other input (show/hide, disable, ..) * TODO add different method for other input (show/hide, disable, ..)
*/ */
function ajax_constantonoff($code,$input=array()) function ajax_constantonoff($code,$input=array(),$entity=false)
{ {
global $conf, $langs; global $conf, $langs;
$entity = ((! empty($entity) && is_numeric($entity) && $entity > 0) || $entity == 0 ? $entity : $conf->entity);
$out= '<script type="text/javascript"> $out= '<script type="text/javascript">
$(function() { $(function() {
@ -234,7 +237,8 @@ function ajax_constantonoff($code,$input=array())
$( "#set_'.$code.'" ).click(function() { $( "#set_'.$code.'" ).click(function() {
$.get( "'.DOL_URL_ROOT.'/core/ajax/constantonoff.php", { $.get( "'.DOL_URL_ROOT.'/core/ajax/constantonoff.php", {
action: \'set\', action: \'set\',
name: \''.$code.'\' name: \''.$code.'\',
entity: \''.$entity.'\'
}, },
function() { function() {
$("#set_'.$code.'" ).hide(); $("#set_'.$code.'" ).hide();
@ -256,7 +260,8 @@ function ajax_constantonoff($code,$input=array())
$( "#del_'.$code.'" ).click(function() { $( "#del_'.$code.'" ).click(function() {
$.get( "'.DOL_URL_ROOT.'/core/ajax/constantonoff.php", { $.get( "'.DOL_URL_ROOT.'/core/ajax/constantonoff.php", {
action: \'del\', action: \'del\',
name: \''.$code.'\' name: \''.$code.'\',
entity: \''.$entity.'\'
}, },
function() { function() {
$("#del_'.$code.'" ).hide(); $("#del_'.$code.'" ).hide();

View File

@ -1,7 +1,7 @@
<?php <?php
/* Copyright (C) 2005 Patrick Rouillon <patrick@rouillon.net> /* Copyright (C) 2005 Patrick Rouillon <patrick@rouillon.net>
* Copyright (C) 2005-2009 Destailleur Laurent <eldy@users.sourceforge.net> * Copyright (C) 2005-2009 Destailleur Laurent <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 * 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 * it under the terms of the GNU General Public License as published by
@ -34,54 +34,55 @@ $langs->load("orders");
$langs->load("sendings"); $langs->load("sendings");
$langs->load("companies"); $langs->load("companies");
$id = GETPOST('id', 'int');
$ref = GETPOST('ref', 'alpha');
$action = GETPOST('action', 'alpha');
// Security check // Security check
$id = isset($_GET["id"])?$_GET["id"]:'';
if ($user->societe_id) $socid=$user->societe_id; if ($user->societe_id) $socid=$user->societe_id;
$result = restrictedArea($user, 'commande_fournisseur', $id,''); $result = restrictedArea($user, 'commande_fournisseur', $id,'');
$object = new CommandeFournisseur($db);
/* /*
* Ajout d'un nouveau contact * Ajout d'un nouveau contact
*/ */
if ($_POST["action"] == 'addcontact' && $user->rights->commande->creer) if ($action == 'addcontact' && $user->rights->fournisseur->commande->creer)
{ {
$result = $object->fetch($id);
$result = 0; if ($result > 0 && $id > 0)
$commande = new CommandeFournisseur($db);
$result = $commande->fetch($_GET["id"]);
if ($result > 0 && $_GET["id"] > 0)
{ {
$result = $commande->add_contact($_POST["contactid"], $_POST["type"], $_POST["source"]); $result = $object->add_contact($_POST["contactid"], $_POST["type"], $_POST["source"]);
} }
if ($result >= 0) if ($result >= 0)
{ {
Header("Location: contact.php?id=".$commande->id); Header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
exit; exit;
} }
else else
{ {
if ($commande->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS')
{ {
$langs->load("errors"); $langs->load("errors");
$mesg = '<div class="error">'.$langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType").'</div>'; $mesg = '<div class="error">'.$langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType").'</div>';
} }
else else
{ {
$mesg = '<div class="error">'.$commande->error.'</div>'; $mesg = '<div class="error">'.$object->error.'</div>';
} }
} }
} }
// bascule du statut d'un contact // bascule du statut d'un contact
if ($_GET["action"] == 'swapstatut' && $user->rights->commande->creer) if ($action == 'swapstatut' && $user->rights->fournisseur->commande->creer)
{ {
$commande = new CommandeFournisseur($db); if ($object->fetch($id))
if ($commande->fetch(GETPOST("id")))
{ {
$result=$commande->swapContactStatus(GETPOST('ligne')); $result=$object->swapContactStatus(GETPOST('ligne'));
} }
else else
{ {
@ -90,15 +91,14 @@ if ($_GET["action"] == 'swapstatut' && $user->rights->commande->creer)
} }
// Efface un contact // Efface un contact
if ($_GET["action"] == 'deleteline' && $user->rights->commande->creer) if ($action == 'deleteline' && $user->rights->fournisseur->commande->creer)
{ {
$commande = new CommandeFournisseur($db); $object->fetch($id);
$commande->fetch($_GET["id"]); $result = $object->delete_contact($_GET["lineid"]);
$result = $commande->delete_contact($_GET["lineid"]);
if ($result >= 0) if ($result >= 0)
{ {
Header("Location: contact.php?id=".$commande->id); Header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
exit; exit;
} }
else { else {
@ -127,19 +127,17 @@ $userstatic=new User($db);
/* *************************************************************************** */ /* *************************************************************************** */
dol_htmloutput_mesg($mesg); dol_htmloutput_mesg($mesg);
$id = $_GET['id'];
$ref= $_GET['ref'];
if ($id > 0 || ! empty($ref)) if ($id > 0 || ! empty($ref))
{ {
$langs->trans("OrderCard"); $langs->trans("OrderCard");
$commande = new CommandeFournisseur($db);
if ( $commande->fetch($_GET['id'],$_GET['ref']) > 0) if ($object->fetch($id, $ref) > 0)
{ {
$soc = new Societe($db); $soc = new Societe($db);
$soc->fetch($commande->socid); $soc->fetch($object->socid);
$head = ordersupplier_prepare_head($commande); $head = ordersupplier_prepare_head($object);
dol_fiche_head($head, 'contact', $langs->trans("SupplierOrder"), 0, 'order'); dol_fiche_head($head, 'contact', $langs->trans("SupplierOrder"), 0, 'order');
@ -151,7 +149,7 @@ if ($id > 0 || ! empty($ref))
// Ref // Ref
print '<tr><td width="20%">'.$langs->trans("Ref").'</td>'; print '<tr><td width="20%">'.$langs->trans("Ref").'</td>';
print '<td colspan="2">'; print '<td colspan="2">';
print $form->showrefnav($commande,'ref','',1,'ref','ref'); print $form->showrefnav($object,'ref','',1,'ref','ref');
print '</td>'; print '</td>';
print '</tr>'; print '</tr>';
@ -175,7 +173,7 @@ if ($id > 0 || ! empty($ref))
* Ajouter une ligne de contact * Ajouter une ligne de contact
* Non affiche en mode modification de ligne * Non affiche en mode modification de ligne
*/ */
if ($_GET["action"] != 'editline' && $user->rights->fournisseur->facture->creer) if ($action != 'editline' && $user->rights->fournisseur->facture->creer)
{ {
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print '<td>'.$langs->trans("Source").'</td>'; print '<td>'.$langs->trans("Source").'</td>';
@ -187,11 +185,11 @@ if ($id > 0 || ! empty($ref))
$var = false; $var = false;
print '<form action="contact.php?id='.$id.'" method="post">'; print '<form action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'" method="POST">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="addcontact">'; print '<input type="hidden" name="action" value="addcontact">';
print '<input type="hidden" name="source" value="internal">'; print '<input type="hidden" name="source" value="internal">';
print '<input type="hidden" name="id" value="'.$id.'">'; print '<input type="hidden" name="id" value="'.$object->id.'">';
// Ligne ajout pour contact interne // Ligne ajout pour contact interne
print "<tr $bc[$var]>"; print "<tr $bc[$var]>";
@ -205,22 +203,22 @@ if ($id > 0 || ! empty($ref))
print '</td>'; print '</td>';
print '<td colspan="1">'; print '<td colspan="1">';
//$userAlreadySelected = $commande->getListContactId('internal'); // On ne doit pas desactiver un contact deja selectionner car on doit pouvoir le seclectionner une deuxieme fois pour un autre type //$userAlreadySelected = $object->getListContactId('internal'); // On ne doit pas desactiver un contact deja selectionner car on doit pouvoir le seclectionner une deuxieme fois pour un autre type
$form->select_users($user->id,'contactid',0,$userAlreadySelected); $form->select_users($user->id,'contactid',0,$userAlreadySelected);
print '</td>'; print '</td>';
print '<td>'; print '<td>';
$formcompany->selectTypeContact($commande, '', 'type','internal'); $formcompany->selectTypeContact($object, '', 'type','internal');
print '</td>'; print '</td>';
print '<td align="right" colspan="3" ><input type="submit" class="button" value="'.$langs->trans("Add").'"></td>'; print '<td align="right" colspan="3" ><input type="submit" class="button" value="'.$langs->trans("Add").'"></td>';
print '</tr>'; print '</tr>';
print '</form>'; print '</form>';
print '<form action="contact.php?id='.$id.'" method="post">'; print '<form action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'" method="POST">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="addcontact">'; print '<input type="hidden" name="action" value="addcontact">';
print '<input type="hidden" name="source" value="external">'; print '<input type="hidden" name="source" value="external">';
print '<input type="hidden" name="id" value="'.$id.'">'; print '<input type="hidden" name="id" value="'.$object->id.'">';
// Ligne ajout pour contact externe // Ligne ajout pour contact externe
$var=!$var; $var=!$var;
@ -231,8 +229,8 @@ if ($id > 0 || ! empty($ref))
print '</td>'; print '</td>';
print '<td colspan="1">'; print '<td colspan="1">';
$selectedCompany = isset($_GET["newcompany"])?$_GET["newcompany"]:$commande->client->id; $selectedCompany = isset($_GET["newcompany"])?$_GET["newcompany"]:$soc->id;
$selectedCompany = $formcompany->selectCompaniesForNewContact($commande, 'id', $selectedCompany, 'newcompany'); $selectedCompany = $formcompany->selectCompaniesForNewContact($object, 'id', $selectedCompany, 'newcompany');
print '</td>'; print '</td>';
print '<td colspan="1">'; print '<td colspan="1">';
@ -240,7 +238,7 @@ if ($id > 0 || ! empty($ref))
if ($nbofcontacts == 0) print $langs->trans("NoContactDefined"); if ($nbofcontacts == 0) print $langs->trans("NoContactDefined");
print '</td>'; print '</td>';
print '<td>'; print '<td>';
$formcompany->selectTypeContact($commande, '', 'type','external'); $formcompany->selectTypeContact($object, '', 'type','external');
print '</td>'; print '</td>';
print '<td align="right" colspan="3" ><input type="submit" class="button" value="'.$langs->trans("Add").'"'; print '<td align="right" colspan="3" ><input type="submit" class="button" value="'.$langs->trans("Add").'"';
if (! $nbofcontacts) print ' disabled="disabled"'; if (! $nbofcontacts) print ' disabled="disabled"';
@ -267,7 +265,7 @@ if ($id > 0 || ! empty($ref))
foreach(array('internal','external') as $source) foreach(array('internal','external') as $source)
{ {
$tab = $commande->liste_contact(-1,$source); $tab = $object->liste_contact(-1,$source);
$num=count($tab); $num=count($tab);
$i = 0; $i = 0;
@ -290,11 +288,11 @@ if ($id > 0 || ! empty($ref))
$companystatic->fetch($tab[$i]['socid']); $companystatic->fetch($tab[$i]['socid']);
print $companystatic->getNomUrl(1); print $companystatic->getNomUrl(1);
} }
if ($tab[$i]['socid'] < 0) else if ($tab[$i]['socid'] < 0)
{ {
print $conf->global->MAIN_INFO_SOCIETE_NOM; print $conf->global->MAIN_INFO_SOCIETE_NOM;
} }
if (! $tab[$i]['socid']) else if (! $tab[$i]['socid'])
{ {
print '&nbsp;'; print '&nbsp;';
} }
@ -324,17 +322,17 @@ if ($id > 0 || ! empty($ref))
// Statut // Statut
print '<td align="center">'; print '<td align="center">';
// Activation desativation du contact // Activation desativation du contact
if ($commande->statut >= 0) print '<a href="contact.php?id='.$commande->id.'&amp;action=swapstatut&amp;ligne='.$tab[$i]['rowid'].'">'; if ($object->statut >= 0) print '<a href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&amp;action=swapstatut&amp;ligne='.$tab[$i]['rowid'].'">';
print $contactstatic->LibStatut($tab[$i]['status'],3); print $contactstatic->LibStatut($tab[$i]['status'],3);
if ($commande->statut >= 0) print '</a>'; if ($object->statut >= 0) print '</a>';
print '</td>'; print '</td>';
// Icon update et delete // Icon update et delete
print '<td align="center" nowrap="nowrap">'; print '<td align="center" nowrap="nowrap">';
if ($commande->statut < 5 && $user->rights->commande->creer) if ($object->statut < 5 && $user->rights->fournisseur->commande->creer)
{ {
print '&nbsp;'; print '&nbsp;';
print '<a href="contact.php?id='.$commande->id.'&amp;action=deleteline&amp;lineid='.$tab[$i]['rowid'].'">'; print '<a href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&amp;action=deleteline&amp;lineid='.$tab[$i]['rowid'].'">';
print img_delete(); print img_delete();
print '</a>'; print '</a>';
} }
@ -354,7 +352,8 @@ if ($id > 0 || ! empty($ref))
} }
} }
llxFooter();
$db->close(); $db->close();
llxFooter();
?> ?>