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

This commit is contained in:
Laurent Destailleur 2014-10-30 18:04:51 +01:00
commit 058a7a9743
19 changed files with 960 additions and 755 deletions

File diff suppressed because it is too large Load Diff

View File

@ -222,6 +222,18 @@ else if ($action == 'set_COMMANDE_FREE_TEXT')
}
}
//Activate Set Shippable Icon In List
else if ($action=="setshippableiconinlist") {
$setshippableiconinlist = GETPOST('value','int');
$res = dolibarr_set_const($db, "SHIPPABLE_ORDER_ICON_IN_LIST", $setshippableiconinlist,'yesno',0,'',$conf->entity);
if (! $res > 0) $error++;
if (! $error) {
setEventMessage($langs->trans("SetupSaved"));
} else {
setEventMessage($langs->trans("Error"), 'errors');
}
}
/*
* View
@ -548,6 +560,22 @@ print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">'
print "</td></tr>\n";
print '</form>';
// Shippable Icon in List
$var=!$var;
print "<tr ".$bc[$var].">";
print '<td>'.$langs->trans("ShippableOrderIconInList").'</td>';
print '<td>&nbsp</td>';
print '<td align="center">';
if (!empty($conf->global->SHIPPABLE_ORDER_ICON_IN_LIST)) {
print '<a href="'.$_SERVER['PHP_SELF'].'?action=setshippableiconinlist&value=0">';
print img_picto($langs->trans("Activated"),'switch_on');
} else {
print '<a href="'.$_SERVER['PHP_SELF'].'?action=setshippableiconinlist&value=1">';
print img_picto($langs->trans("Disabled"),'switch_off');
}
print '</a></td>';
print '</tr>';
print '</table>';
print '<br>';

View File

@ -33,6 +33,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
require_once DOL_DOCUMENT_ROOT .'/product/class/product.class.php';
$langs->load('orders');
$langs->load('deliveries');
@ -325,22 +326,77 @@ if ($resql)
$total=0;
$subtotal=0;
$generic_commande = new Commande($db);
while ($i < min($num,$limit))
{
$objp = $db->fetch_object($resql);
$var=!$var;
print '<tr '.$bc[$var].'>';
print '<td class="nowrap">';
$generic_commande = new Commande($db);
$generic_product = new Product($db);
while ($i < min($num,$limit)) {
$objp = $db->fetch_object($resql);
$var=!$var;
print '<tr '.$bc[$var].'>';
print '<td class="nowrap">';
$generic_commande->id=$objp->rowid;
$generic_commande->ref=$objp->ref;
$generic_commande->id=$objp->rowid;
$generic_commande->ref=$objp->ref;
$generic_commande->lines=array();
$generic_commande->getLinesArray();
print '<table class="nobordernopadding"><tr class="nocellnopadd">';
print '<td class="nobordernopadding nowrap">';
print $generic_commande->getNomUrl(1,($viewstatut != 2?0:$objp->fk_statut));
print '</td>';
print '<table class="nobordernopadding"><tr class="nocellnopadd">';
print '<td class="nobordernopadding nowrap">';
print $generic_commande->getNomUrl(1,($viewstatut != 2?0:$objp->fk_statut));
print '</td>';
// Shippable Icon
if (($objp->fk_statut > 0) && ($objp->fk_statut < 3) && ! empty($conf->global->SHIPPABLE_ORDER_ICON_IN_LIST)) {
$notshippable=0;
$text_info='';
$nbprod=0;
for ($lig=0; $lig<(count($generic_commande->lines)); $lig++) {
if ($generic_commande->lines[$lig]->product_type==0) {
$nbprod++; // order contains real products
$generic_product->id = $generic_commande->lines[$lig]->fk_product;
$generic_product->load_stock();
// stock order and stock order_supplier
$stock_order=0;
$stock_order_supplier=0;
if (! empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT)) {
if (! empty($conf->commande->enabled)) {
$generic_product->load_stats_commande(0,'1,2');
$stock_order=$generic_product->stats_commande['qty'];
}
if (! empty($conf->fournisseur->enabled)) {
$generic_product->load_stats_commande_fournisseur(0,'3');
$stock_order_supplier=$generic_product->stats_commande_fournisseur['qty'];
}
}
$text_info .= $generic_commande->lines[$lig]->qty.' X '.$generic_commande->lines[$lig]->ref.'&nbsp;'.dol_trunc($generic_commande->lines[$lig]->product_label, 25);
$text_stock_reel = $generic_product->stock_reel.'/'.$stock_order;
if ($generic_product->stock_reel<$generic_commande->lines[$lig]->qty) {
$notshippable++;
$text_info.='<span class="warning">'.$langs->trans('Available').'&nbsp;:&nbsp;'.$text_stock_reel.'</span>';
} else {
$text_info.='<span class="ok">'.$langs->trans('Available').'&nbsp;:&nbsp;'.$text_stock_reel.'</span>';
}
if ($stock_order_supplier>0) {
$text_info.= '&nbsp;'.$langs->trans('SupplierOrder').'&nbsp;:&nbsp;'.$stock_order_supplier.'<br>';
} else {
$text_info.= '<br>';
}
}
}
if ($notshippable==0) {
$text_icon = img_picto('', 'object_sending');
$text_info = $langs->trans('Shippable').'<br>'.$text_info;
} else {
$text_icon = img_picto('', 'error');
$text_info = $langs->trans('NonShippable').'<br>'.$text_info;
}
if ($nbprod>0) {
print '<td>';
print $form->textwithtooltip('',$text_info,2,1,$text_icon,'',2);
print '</td>';
}
}
// warning late icon
print '<td style="min-width: 20px" class="nobordernopadding nowrap">';
if (($objp->fk_statut > 0) && ($objp->fk_statut < 3) && max($db->jdate($objp->date_commande),$db->jdate($objp->date_livraison)) < ($now - $conf->commande->client->warning_delay))
print img_picto($langs->trans("Late"),"warning");

View File

@ -937,7 +937,7 @@ if ($action == 'create')
// Ref Int
print '<tr><td>'.$langs->trans('RefCustomer').'</td>';
print '<td colspan="2"><input type="text" siez="5" name="ref_supplier" id="ref_supplier" value="'.GETPOST('ref_supplier','alpha').'"></td></tr>';
print '<td colspan="2"><input type="text" size="5" name="ref_supplier" id="ref_supplier" value="'.GETPOST('ref_supplier','alpha').'"></td></tr>';
// Customer
print '<tr>';

View File

@ -74,7 +74,7 @@ $sql.= ' SUM('.$db->ifsql("cd.statut=4 AND (cd.date_fin_validite IS NOT NULL AND
$sql.= ' SUM('.$db->ifsql("cd.statut=4 AND (cd.date_fin_validite IS NOT NULL AND cd.date_fin_validite < '".$db->idate($now - $conf->contrat->services->expires->warning_delay)."')",1,0).') as nb_late,';
$sql.= ' SUM('.$db->ifsql("cd.statut=5",1,0).') as nb_closed,';
$sql.= " c.rowid as cid, c.ref, c.datec, c.date_contrat, c.statut,";
$sql.= " s.nom, s.rowid as socid";
$sql.= " s.nom as name, s.rowid as socid";
$sql.= " ,c.ref_supplier";
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s";
if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";

View File

@ -3012,13 +3012,13 @@ abstract class CommonObject
print '<table class="nobordernopadding margintable" width="100%">';
print '<tr class="liste_titre">';
print '<td width="30%">'.$langs->trans('Margins').'</td>';
print '<td width="20%" align="right">'.$langs->trans('SellingPrice').'</td>';
print '<td width="15%">'.$langs->trans('Margins').'</td>';
print '<td width="15%" align="right">'.$langs->trans('SellingPrice').'</td>';
if ($conf->global->MARGIN_TYPE == "1")
print '<td width="20%" align="right">'.$langs->trans('BuyingPrice').'</td>';
print '<td width="15%" align="right">'.$langs->trans('BuyingPrice').'</td>';
else
print '<td width="20%" align="right">'.$langs->trans('CostPrice').'</td>';
print '<td width="20%" align="right">'.$langs->trans('Margin').'</td>';
print '<td width="15%" align="right">'.$langs->trans('CostPrice').'</td>';
print '<td width="15%" align="right">'.$langs->trans('Margin').'</td>';
if (! empty($conf->global->DISPLAY_MARGIN_RATES))
print '<td align="right">'.$langs->trans('MarginRate').'</td>';
if (! empty($conf->global->DISPLAY_MARK_RATES))

View File

@ -48,7 +48,7 @@ if (empty($reshook) && ! empty($extrafields->attribute_label))
print '<table width="100%" class="nobordernopadding"><tr><td';
if (! empty($extrafields->attribute_required [$key])) print ' class="fieldrequired"';
print '>' . $label . '</td>';
if (($object->statut == 0 || $extrafields->attribute_alwayseditable[$key]) && $user->rights->propal->creer && ($action != 'edit_extras' || GETPOST('attribute') != $key))
if (($object->statut == 0 || $extrafields->attribute_alwayseditable[$key]) && $user->rights->{$object->element}->creer && ($action != 'edit_extras' || GETPOST('attribute') != $key))
print '<td align="right"><a href="' . $_SERVER['PHP_SELF'] . '?id=' . $object->id . '&action=edit_extras&attribute=' . $key . '">' . img_edit().'</a></td>';
print '</tr></table>';
@ -59,9 +59,9 @@ if (empty($reshook) && ! empty($extrafields->attribute_label))
$value = isset($_POST ["options_" . $key]) ? dol_mktime($_POST ["options_" . $key . "hour"], $_POST ["options_" . $key . "min"], 0, $_POST ["options_" . $key . "month"], $_POST ["options_" . $key . "day"], $_POST ["options_" . $key . "year"]) : $db->jdate($object->array_options ['options_' . $key]);
}
if ($action == 'edit_extras' && $user->rights->propal->creer && GETPOST('attribute') == $key)
if ($action == 'edit_extras' && $user->rights->{$object->element}->creer && GETPOST('attribute') == $key)
{
print '<form enctype="multipart/form-data" action="' . $_SERVER["PHP_SELF"] . '" method="post" name="formsoc">';
print '<form enctype="multipart/form-data" action="' . $_SERVER["PHP_SELF"] . '" method="post" name="formextra">';
print '<input type="hidden" name="action" value="update_extras">';
print '<input type="hidden" name="attribute" value="' . $key . '">';
print '<input type="hidden" name="token" value="' . $_SESSION ['newtoken'] . '">';

View File

@ -160,7 +160,7 @@ else {
'option_disabled' => 'addPredefinedProductButton', // html id to disable once select is done
'warning' => $langs->trans("NoPriceDefinedForThisSupplier") // translation of an error saved into var 'error'
);
$form->select_produits_fournisseurs($object->fourn_id, GETPOST('idprodfournprice'), 'idprodfournprice', '', '', $ajaxoptions, 1);
$form->select_produits_fournisseurs($object->socid, GETPOST('idprodfournprice'), 'idprodfournprice', '', '', $ajaxoptions, 1);
}
echo '</span>';
}

View File

@ -1928,6 +1928,47 @@ class CommandeFournisseur extends CommonOrder
}
}
/**
* Charge indicateurs this->nb de tableau de bord
*
* @return int <0 si ko, >0 si ok
*/
function load_state_board()
{
global $conf, $user;
$this->nb=array();
$clause = "WHERE";
$sql = "SELECT count(co.rowid) as nb";
$sql.= " FROM ".MAIN_DB_PREFIX."commande_fournisseur as co";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON co.fk_soc = s.rowid";
if (!$user->rights->societe->client->voir && !$user->societe_id)
{
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON s.rowid = sc.fk_soc";
$sql.= " WHERE sc.fk_user = " .$user->id;
$clause = "AND";
}
$sql.= " ".$clause." co.entity = ".$conf->entity;
$resql=$this->db->query($sql);
if ($resql)
{
while ($obj=$this->db->fetch_object($resql))
{
$this->nb["supplier_orders"]=$obj->nb;
}
$this->db->free($resql);
return 1;
}
else
{
dol_print_error($this->db);
$this->error=$this->db->error();
return -1;
}
}
/**
* Load indicators for dashboard (this->nbtodo and this->nbtodolate)
*

View File

@ -1614,6 +1614,48 @@ class FactureFournisseur extends CommonInvoice
$this->total_ttc = $xnbp*119.6;
}
/**
* Load indicators for dashboard (this->nbtodo and this->nbtodolate)
*
* @return int <0 if KO, >0 if OK
*/
function load_state_board()
{
global $conf, $user;
$this->nb=array();
$clause = "WHERE";
$sql = "SELECT count(f.rowid) as nb";
$sql.= " FROM ".MAIN_DB_PREFIX."facture_fourn as f";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON f.fk_soc = s.rowid";
if (!$user->rights->societe->client->voir && !$user->societe_id)
{
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON s.rowid = sc.fk_soc";
$sql.= " WHERE sc.fk_user = " .$user->id;
$clause = "AND";
}
$sql.= " ".$clause." f.entity = ".$conf->entity;
$resql=$this->db->query($sql);
if ($resql)
{
while ($obj=$this->db->fetch_object($resql))
{
$this->nb["supplier_invoices"]=$obj->nb;
}
$this->db->free($resql);
return 1;
}
else
{
dol_print_error($this->db);
$this->error=$this->db->error();
return -1;
}
}
/**
* Load an object from its id and create a new one in database
*

View File

@ -467,7 +467,7 @@ class ProductFournisseur extends Product
$sql = "SELECT s.nom as supplier_name, s.rowid as fourn_id,";
$sql.= " pfp.rowid as product_fourn_price_id, pfp.ref_fourn,";
$sql.= " pfp.price, pfp.quantity, pfp.unitprice, pfp.tva_tx, pfp.charges, pfp.unitcharges";
$sql.= " pfp.price, pfp.quantity, pfp.unitprice, pfp.tva_tx, pfp.charges, pfp.unitcharges, ";
$sql.= " pfp.remise, pfp.remise_percent";
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."product_fournisseur_price as pfp";
$sql.= " WHERE s.entity IN (".getEntity('societe', 1).")";

View File

@ -154,7 +154,9 @@ if (empty($user->societe_id))
! empty($conf->propal->enabled) && $user->rights->propale->lire,
! empty($conf->commande->enabled) && $user->rights->commande->lire,
! empty($conf->facture->enabled) && $user->rights->facture->lire,
! empty($conf->contrat->enabled) && $user->rights->contrat->activer);
! empty($conf->contrat->enabled) && $user->rights->contrat->activer,
! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->commande->lire,
! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->facture->lire);
// Class file containing the method load_state_board for each line
$includes=array(DOL_DOCUMENT_ROOT."/societe/class/client.class.php",
DOL_DOCUMENT_ROOT."/comm/prospect/class/prospect.class.php",
@ -165,7 +167,9 @@ if (empty($user->societe_id))
DOL_DOCUMENT_ROOT."/comm/propal/class/propal.class.php",
DOL_DOCUMENT_ROOT."/commande/class/commande.class.php",
DOL_DOCUMENT_ROOT."/compta/facture/class/facture.class.php",
DOL_DOCUMENT_ROOT."/contrat/class/contrat.class.php");
DOL_DOCUMENT_ROOT."/contrat/class/contrat.class.php",
DOL_DOCUMENT_ROOT."/fourn/class/fournisseur.commande.class.php",
DOL_DOCUMENT_ROOT."/fourn/class/fournisseur.facture.class.php");
// Name class containing the method load_state_board for each line
$classes=array('Client',
'Prospect',
@ -173,10 +177,12 @@ if (empty($user->societe_id))
'Adherent',
'Product',
'Service',
'Propal',
'Commande',
'Facture',
'Contrat');
'Propal',
'Commande',
'Facture',
'Contrat',
'CommandeFournisseur',
'FactureFournisseur');
// Cle array returned by the method load_state_board for each line
$keys=array('customers',
'prospects',
@ -184,10 +190,12 @@ if (empty($user->societe_id))
'members',
'products',
'services',
'proposals',
'orders',
'invoices',
'Contracts');
'proposals',
'orders',
'invoices',
'Contracts',
'supplier_orders',
'supplier_invoices');
// Dashboard Icon lines
$icons=array('company',
'company',
@ -195,10 +203,12 @@ if (empty($user->societe_id))
'user',
'product',
'service',
'propal',
'order',
'bill',
'order');
'propal',
'order',
'bill',
'order',
'order',
'bill');
// Translation keyword
$titres=array("ThirdPartyCustomersStats",
"ThirdPartyProspectsStats",
@ -209,7 +219,9 @@ if (empty($user->societe_id))
"CommercialProposalsShort",
"CustomersOrders",
"BillsCustomers",
"Contracts");
"Contracts",
"SuppliersOrders",
"SuppliersInvoices");
// Dashboard Link lines
$links=array(DOL_URL_ROOT.'/comm/list.php',
DOL_URL_ROOT.'/comm/prospect/list.php',
@ -220,7 +232,9 @@ if (empty($user->societe_id))
DOL_URL_ROOT.'/comm/propal/list.php?mainmenu=commercial',
DOL_URL_ROOT.'/commande/list.php?mainmenu=commercial',
DOL_URL_ROOT.'/compta/facture/list.php?mainmenu=accountancy',
DOL_URL_ROOT.'/contrat/list.php');
DOL_URL_ROOT.'/contrat/list.php',
DOL_URL_ROOT.'/fourn/commande/list.php',
DOL_URL_ROOT.'/fourn/facture/list.php');
// Translation lang files
$langfile=array("companies",
"prospects",

View File

@ -37,7 +37,7 @@ create table llx_adherent
pass varchar(50), -- password
fk_adherent_type integer NOT NULL,
morphy varchar(3) NOT NULL, -- personne morale / personne physique
societe varchar(60), -- company name (should be same lenght than societe.name)
societe varchar(128), -- company name (should be same lenght than societe.name)
fk_soc integer NULL, -- Link to third party linked to member
address text,
zip varchar(30),

View File

@ -22,7 +22,7 @@
create table llx_societe
(
rowid integer AUTO_INCREMENT PRIMARY KEY,
nom varchar(60), -- company reference name (should be smae length than adherent.societe)
nom varchar(128), -- company reference name (should be same length than adherent.societe)
entity integer DEFAULT 1 NOT NULL, -- multi company id
ref_ext varchar(128), -- reference into an external system (not used by dolibarr)

View File

@ -1147,6 +1147,7 @@ HideTreadedOrders=Hide the treated or cancelled orders in the list
ValidOrderAfterPropalClosed=To validate the order after proposal closer, makes it possible not to step by the provisional order
FreeLegalTextOnOrders=Free text on orders
WatermarkOnDraftOrders=Watermark on draft orders (none if empty)
ShippableOrderIconInList=Add an icon in Orders list which indicate if order is shippable
##### Clicktodial #####
ClickToDialSetup=Click To Dial module setup
ClickToDialUrlDesc=Url called when a click on phone picto is done. In URL, you can use tags<br><b>__PHONETO__</b> that will be replaced with the phone number of person to call<br><b>__PHONEFROM__</b> that will be replaced with phone number of calling person (yours)<br><b>__LOGIN__</b> that will be replaced with your clicktodial login (defined on your user card)<br><b>__PASS__</b> that will be replaced with your clicktodial password (defined on your user card).

View File

@ -24,3 +24,5 @@ Deliverer=Deliverer :
Sender=Sender
Recipient=Recipient
ErrorStockIsNotEnough=There's not enough stock
Shippable=Shippable
NonShippable=Not Shippable

View File

@ -1316,6 +1316,19 @@ class Societe extends CommonObject
}
}
// Remove associated users
if (! $error)
{
$sql = "DELETE FROM ".MAIN_DB_PREFIX."societe_commerciaux";
$sql.= " WHERE fk_soc = " . $id;
dol_syslog(get_class($this)."::Delete", LOG_DEBUG);
if (! $this->db->query($sql))
{
$error++;
$this->error = $this->db->lasterror();
}
}
// Removed extrafields
if ((! $error) && (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED))) // For avoid conflicts if trigger used
{

View File

@ -805,7 +805,7 @@ else
print '<span span id="TypeName" class="fieldrequired"><label for="name">'.$langs->trans('ThirdPartyName').'</label></span>';
}
print '</td><td'.(empty($conf->global->SOCIETE_USEPREFIX)?' colspan="3"':'').'>';
print '<input type="text" size="30" maxlength="60" name="nom" id="name" value="'.$object->name.'" autofocus="autofocus"></td>';
print '<input type="text" size="60" maxlength="128" name="nom" id="name" value="'.$object->name.'" autofocus="autofocus"></td>';
if (! empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field
{
print '<td>'.$langs->trans('Prefix').'</td><td><input type="text" size="5" maxlength="5" name="prefix_comm" value="'.$object->prefix_comm.'"></td>';
@ -816,7 +816,7 @@ else
if ($conf->use_javascript_ajax)
{
print '<tr class="individualline"><td><label for="firstname">'.$langs->trans('FirstName').'</label></td>';
print '<td><input type="text" size="30" name="firstname" id="firstname" value="'.$object->firstname.'"></td>';
print '<td><input type="text" size="60" name="firstname" id="firstname" value="'.$object->firstname.'"></td>';
print '<td colspan=2>&nbsp;</td></tr>';
print '<tr class="individualline"><td><label for="civility_id">'.$langs->trans("UserTitle").'</label></td><td>';
print $formcompany->select_civility($object->civility_id).'</td>';
@ -1266,7 +1266,7 @@ else
// Name
print '<tr><td><label for="name"><span class="fieldrequired">'.$langs->trans('ThirdPartyName').'</span></label></td>';
print '<td colspan="3"><input type="text" size="40" maxlength="60" name="nom" id="name" value="'.dol_escape_htmltag($object->name).'" autofocus="autofocus"></td></tr>';
print '<td colspan="3"><input type="text" size="60" maxlength="128" name="nom" id="name" value="'.dol_escape_htmltag($object->name).'" autofocus="autofocus"></td></tr>';
// Prefix
if (! empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field

View File

@ -525,7 +525,15 @@ function createInvoice($authentication,$invoice)
$newobject->statut=0; // We start with status draft
$newobject->fk_project=$invoice['project_id'];
$newobject->date_creation=$now;
$newobject->mode_reglement_id = $invoice['payment_mode_id'];
//take mode_reglement and cond_reglement from thirdparty
$soc = new Societe($db);
$res=$soc->fetch($newobject->socid);
if ($res > 0) {
$newobject->mode_reglement_id = ! empty($invoice['payment_mode_id'])?$invoice['payment_mode_id']:$soc->mode_reglement_id;
$newobject->cond_reglement_id = $soc->cond_reglement_id;
}
else $newobject->mode_reglement_id = $invoice['payment_mode_id'];
// Trick because nusoap does not store data with same structure if there is one or several lines
$arrayoflines=array();