diff --git a/ChangeLog b/ChangeLog index 63a3740a7c8..a1de53b75a0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -50,7 +50,9 @@ For users: - New: Allow to search thirds and products from barcodes directly from the permanent mini search left box. - New: Allow to search product from barcodes directly from invoices, proposals... through AJAX. - New: Can make one invoice for several orders. -- New: POS module can works with only one payment method (cach, chq, credit card). +- New: POS module can works with only one payment method (cach, chq, credit card). +- New: Add possibility to defined position/job of a user + New experimental modules: - New: Add margin and commissions management module. diff --git a/htdocs/comm/fiche.php b/htdocs/comm/fiche.php index bd3b96977c1..e760ff7c393 100644 --- a/htdocs/comm/fiche.php +++ b/htdocs/comm/fiche.php @@ -5,7 +5,7 @@ * Copyright (C) 2006 Andre Cianfarani * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2008 Raphael Bertrand (Resultic) - * Copyright (C) 2010-2011 Juanjo Menent + * Copyright (C) 2010-2012 Juanjo Menent * * 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 @@ -504,7 +504,7 @@ if ($id > 0) $sql2.= " AND ((c.fk_statut IN (1,2)) OR (c.fk_statut = 3 AND c.facture = 0))"; $resql2=$db->query($sql2); - $num2 = $db->num_rows($resql2); + $orders2invoice = $db->num_rows($resql2); $db->free($resql2); print ''; @@ -512,8 +512,8 @@ if ($id > 0) print ''; print ''; print ''; } @@ -777,12 +777,17 @@ if ($id > 0) if ($user->rights->facture->creer) { $langs->load("bills"); + + if($orders2invoice > 0) print ''.$langs->trans("CreateInvoiceForThisCustomer").''; + else print ''.$langs->trans("CreateInvoiceForThisCustomer").''; + if ($object->client != 0) print ''.$langs->trans("AddBill").''; else print ''.$langs->trans("AddBill").''; + } else { - print ''.$langs->trans("AddBill").''; + print ''.$langs->trans("AddBill").''; } } } diff --git a/htdocs/comm/propal.php b/htdocs/comm/propal.php index ff28de54e80..56a4e4cc754 100644 --- a/htdocs/comm/propal.php +++ b/htdocs/comm/propal.php @@ -161,18 +161,16 @@ else if ($action == 'confirm_deleteline' && $confirm == 'yes' && $user->rights-> // reorder lines if ($result) $object->line_order(true); - // Define output language - $outputlangs = $langs; - $newlang=''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id')) $newlang=GETPOST('lang_id'); - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang; - if (! empty($newlang)) - { - $outputlangs = new Translate("",$conf); - $outputlangs->setDefaultLang($newlang); - } if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { + // Define output language + $outputlangs = $langs; + if (! empty($conf->global->MAIN_MULTILANGS)) + { + $outputlangs = new Translate("",$conf); + $newlang=(GETPOST('lang_id') ? GETPOST('lang_id') : $object->client->default_lang); + $outputlangs->setDefaultLang($newlang); + } $ret=$object->fetch($id); // Reload to get new records propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $hookmanager); } @@ -187,20 +185,18 @@ else if ($action == 'confirm_validate' && $confirm == 'yes' && $user->rights->pr $result=$object->valid($user); if ($result >= 0) { - // Define output language - $outputlangs = $langs; - $newlang=''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id')) $newlang=GETPOST('lang_id'); - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang; - if (! empty($newlang)) - { - $outputlangs = new Translate("",$conf); - $outputlangs->setDefaultLang($newlang); - } if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { - $ret=$object->fetch($object->id); // Reload to get new records - propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $hookmanager); + // Define output language + $outputlangs = $langs; + if (! empty($conf->global->MAIN_MULTILANGS)) + { + $outputlangs = new Translate("",$conf); + $newlang=(GETPOST('lang_id') ? GETPOST('lang_id') : $object->client->default_lang); + $outputlangs->setDefaultLang($newlang); + } + $ret=$object->fetch($id); // Reload to get new records + propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $hookmanager); } } else @@ -366,17 +362,19 @@ else if ($action == 'add' && $user->rights->propal->creer) { $db->commit(); - // Define output language - $outputlangs = $langs; - $newlang=''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) $newlang=$_REQUEST['lang_id']; - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang; - if (! empty($newlang)) + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { - $outputlangs = new Translate("",$conf); - $outputlangs->setDefaultLang($newlang); + // Define output language + $outputlangs = $langs; + if (! empty($conf->global->MAIN_MULTILANGS)) + { + $outputlangs = new Translate("",$conf); + $newlang=(GETPOST('lang_id') ? GETPOST('lang_id') : $object->client->default_lang); + $outputlangs->setDefaultLang($newlang); + } + $ret=$object->fetch($id); // Reload to get new records + propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $hookmanager); } - if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $hookmanager); header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id); exit; @@ -600,18 +598,19 @@ if ($action == 'modif' && $user->rights->propal->creer) { $object->set_draft($user); - // Define output language - $outputlangs = $langs; - $newlang=''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) $newlang=$_REQUEST['lang_id']; - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang; - if (! empty($newlang)) + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { - $outputlangs = new Translate("",$conf); - $outputlangs->setDefaultLang($newlang); + // Define output language + $outputlangs = $langs; + if (! empty($conf->global->MAIN_MULTILANGS)) + { + $outputlangs = new Translate("",$conf); + $newlang=(GETPOST('lang_id') ? GETPOST('lang_id') : $object->client->default_lang); + $outputlangs->setDefaultLang($newlang); + } + $ret=$object->fetch($id); // Reload to get new records + propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $hookmanager); } - - if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $hookmanager); } else if ($action == "setabsolutediscount" && $user->rights->propal->creer) @@ -795,20 +794,18 @@ else if ($action == "addline" && $user->rights->propal->creer) if ($result > 0) { - // Define output language - $outputlangs = $langs; - $newlang=''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) $newlang=$_REQUEST['lang_id']; - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang; - if (! empty($newlang)) - { - $outputlangs = new Translate("",$conf); - $outputlangs->setDefaultLang($newlang); - } if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { - $ret=$object->fetch($id); // Reload to get new records - propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $hookmanager); + // Define output language + $outputlangs = $langs; + if (! empty($conf->global->MAIN_MULTILANGS)) + { + $outputlangs = new Translate("",$conf); + $newlang=(GETPOST('lang_id') ? GETPOST('lang_id') : $object->client->default_lang); + $outputlangs->setDefaultLang($newlang); + } + $ret=$object->fetch($id); // Reload to get new records + propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $hookmanager); } unset($_POST['qty']); @@ -922,15 +919,12 @@ else if ($action == 'updateligne' && $user->rights->propal->creer && GETPOST('sa { // Define output language $outputlangs = $langs; - $newlang=''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) $newlang=$_REQUEST['lang_id']; - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang; - if (! empty($newlang)) + if (! empty($conf->global->MAIN_MULTILANGS)) { $outputlangs = new Translate("",$conf); + $newlang=(GETPOST('lang_id') ? GETPOST('lang_id') : $object->client->default_lang); $outputlangs->setDefaultLang($newlang); } - $ret=$object->fetch($id); // Reload to get new records propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $hookmanager); } @@ -971,15 +965,15 @@ else if ($action == 'builddoc' && $user->rights->propal->creer) // Define output language $outputlangs = $langs; - $newlang=''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) $newlang=$_REQUEST['lang_id']; - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang; - if (! empty($newlang)) + if (! empty($conf->global->MAIN_MULTILANGS)) { $outputlangs = new Translate("",$conf); + $newlang=(GETPOST('lang_id') ? GETPOST('lang_id') : $object->client->default_lang); $outputlangs->setDefaultLang($newlang); } + $ret=$object->fetch($id); // Reload to get new records $result=propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $hookmanager); + if ($result <= 0) { dol_print_error($db,$result); @@ -1056,17 +1050,19 @@ else if ($action == 'up' && $user->rights->propal->creer) { $object->line_up(GETPOST('rowid')); - // Define output language - $outputlangs = $langs; - $newlang=''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id')) $newlang=GETPOST('lang_id'); - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang; - if (! empty($newlang)) + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { - $outputlangs = new Translate("",$conf); - $outputlangs->setDefaultLang($newlang); + // Define output language + $outputlangs = $langs; + if (! empty($conf->global->MAIN_MULTILANGS)) + { + $outputlangs = new Translate("",$conf); + $newlang=(GETPOST('lang_id') ? GETPOST('lang_id') : $object->client->default_lang); + $outputlangs->setDefaultLang($newlang); + } + $ret=$object->fetch($id); // Reload to get new records + propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $hookmanager); } - if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $hookmanager); header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id.'#'.GETPOST('rowid')); exit; @@ -1076,17 +1072,19 @@ else if ($action == 'down' && $user->rights->propal->creer) { $object->line_down(GETPOST('rowid')); - // Define output language - $outputlangs = $langs; - $newlang=''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id')) $newlang=GETPOST('lang_id'); - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang; - if (! empty($newlang)) + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { - $outputlangs = new Translate("",$conf); - $outputlangs->setDefaultLang($newlang); + // Define output language + $outputlangs = $langs; + if (! empty($conf->global->MAIN_MULTILANGS)) + { + $outputlangs = new Translate("",$conf); + $newlang=(GETPOST('lang_id') ? GETPOST('lang_id') : $object->client->default_lang); + $outputlangs->setDefaultLang($newlang); + } + $ret=$object->fetch($id); // Reload to get new records + propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $hookmanager); } - if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $hookmanager); header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id.'#'.GETPOST('rowid')); exit; diff --git a/htdocs/comm/propal/propalstoorder.php b/htdocs/comm/propal/propalstoorder.php deleted file mode 100755 index 77905ed3170..00000000000 --- a/htdocs/comm/propal/propalstoorder.php +++ /dev/null @@ -1,688 +0,0 @@ - - * Copyright (C) 2004-2011 Laurent Destailleur - * Copyright (C) 2005 Marc Barilley / Ocebo - * Copyright (C) 2005-2012 Regis Houssin - * Copyright (C) 2012 Andreu Bisquerra Gaya - * Copyright (C) 2012 David Rodriguez Martinez - * Copyright (C) 2012 Juanjo Menent - * Copyright (C) 2012 Maxime Kohlhaas - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/** - * \file htdocs/comm/propal/propalstoorder.php - * \ingroup propal - * \brief Page to order multiple propals - */ - -require '../../main.inc.php'; -require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; -require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; -require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; -require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/report.lib.php'; -if (! empty($conf->projet->enabled)) require_once DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php'; - -$langs->load('orders'); -$langs->load('deliveries'); -$langs->load('companies'); - -if (! $user->rights->commande->creer) - accessforbidden(); - -$id = (GETPOST('id')?GETPOST("id"):GETPOST("facid")); // For backward compatibility -$ref = GETPOST('ref','alpha'); -$action = GETPOST('action','alpha'); -$confirm = GETPOST('confirm','alpha'); -$sref = GETPOST('sref'); -$sref_client = GETPOST('sref_client'); -$sall = GETPOST('sall'); -$socid = GETPOST('socid','int'); - - -$sortfield = GETPOST("sortfield",'alpha'); -$sortorder = GETPOST("sortorder",'alpha'); -if (! $sortfield) $sortfield='p.rowid'; -if (! $sortorder) $sortorder='DESC'; - -$date_start=dol_mktime(0,0,0,$_REQUEST["date_startmonth"],$_REQUEST["date_startday"],$_REQUEST["date_startyear"]); // Date for local PHP server -$date_end=dol_mktime(23,59,59,$_REQUEST["date_endmonth"],$_REQUEST["date_endday"],$_REQUEST["date_endyear"]); -$date_starty=dol_mktime(0,0,0,$_REQUEST["date_start_delymonth"],$_REQUEST["date_start_delyday"],$_REQUEST["date_start_delyyear"]); // Date for local PHP server -$date_endy=dol_mktime(23,59,59,$_REQUEST["date_end_delymonth"],$_REQUEST["date_end_delyday"],$_REQUEST["date_end_delyyear"]); -$selected=GETPOST('propals_to_order'); -$action=GETPOST('action','alpha'); -if ($action == 'create') -{ - if (! is_array($selected)) - { - $mesgs[]='
'.$langs->trans('Error_OrderNotChecked').'
'; - } - else - { - $socid=GETPOST('socid'); - $action=GETPOST('action'); - $origin=GETPOST('origin'); - $originid=GETPOST('originid'); - } -} -$now=dol_now(); - -$viewstatut=GETPOST('viewstatut'); - - -/* - * Actions - */ - -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'; - require_once DOL_DOCUMENT_ROOT.'/core/modules/facture/modules_facture.php'; - require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; - require_once DOL_DOCUMENT_ROOT.'/core/class/discount.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 (! 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'); - if (isset($_GET['propals_to_order'])) - { - $orders_id = $_GET['propals_to_order']; - $n = count($orders_id); - $i = 0; - - $originid=$orders_id[0]; - $_GET['originid']=$orders_id[0]; - - } - if (isset($_POST['propals_to_order'])) - { - $orders_id = $_POST['propals_to_order']; - $nn = count($orders_id); - $ii = 0; - - $originid=$orders_id[0]; - $_POST['originid']=$orders_id[0]; - - } - - $projectid = GETPOST('projectid','int')?GETPOST('projectid','int'):0; - $lineid = GETPOST('lineid','int'); - $userid = GETPOST('userid','int'); - $search_ref = GETPOST('sf_ref')?GETPOST('sf_ref'):GETPOST('search_ref'); - $closeOrders = GETPOST('autocloseorders') != '' ? true : false; - - // Security check - $fieldid = GETPOST('ref','alpha')?'facnumber':'rowid'; - if ($user->societe_id) $socid=$user->societe_id; - $result = restrictedArea($user, 'facture', $id,'','','fk_soc',$fieldid); - - $usehm=$conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE; - $object=new Facture($db); - - // Insert new invoice in database - if ($action == 'add' && $user->rights->facture->creer) - { - $object->socid=GETPOST('socid'); - $db->begin(); - $error=0; - - // Standard or deposit or proforma invoice - if ($_POST['type'] == 0 ) - { - $datefacture = dol_mktime(12, 0, 0, $_POST['remonth'], $_POST['reday'], $_POST['reyear']); - if (empty($datefacture)) - { - $datefacture = dol_mktime(12, 0, 0, date("m"), date("d"), date("Y")); - } - if (! $error) - { - // Si facture standard - $object->socid = $_POST['socid']; - $object->type = $_POST['type']; - $object->number = $_POST['facnumber']; - $object->date = $datefacture; - $object->note_public = trim($_POST['note_public']); - $object->note = trim($_POST['note']); - $object->ref_client = $_POST['ref_client']; - $object->ref_int = $_POST['ref_int']; - $object->modelpdf = $_POST['model']; - $object->fk_project = $_POST['projectid']; - $object->cond_reglement_id = ($_POST['type'] == 3?1:$_POST['cond_reglement_id']); - $object->mode_reglement_id = $_POST['mode_reglement_id']; - $object->amount = $_POST['amount']; - $object->remise_absolue = $_POST['remise_absolue']; - $object->remise_percent = $_POST['remise_percent']; - - if ($_POST['origin'] && $_POST['originid']) - { - $object->origin = $_POST['origin']; - $object->origin_id = $orders_id[$ii]; - $object->linked_objects = $orders_id; - $id = $object->create($user); - - if ($id>0) - { - foreach($orders_id as $origin => $origin_id) - { - $origin_id = (! empty($origin_id) ? $origin_id : $object->origin_id); - $db->begin(); - $sql = "INSERT INTO ".MAIN_DB_PREFIX."element_element ("; - $sql.= "fk_source"; - $sql.= ", sourcetype"; - $sql.= ", fk_target"; - $sql.= ", targettype"; - $sql.= ") VALUES ("; - $sql.= $origin_id; - $sql.= ", '".$object->origin."'"; - $sql.= ", ".$id; - $sql.= ", '".$object->element."'"; - $sql.= ")"; - - if ($db->query($sql)) - { - $db->commit(); - } - else - { - $db->rollback(); - } - } - - while ($ii < $nn) - { - dol_include_once('/commande/class/commande.class.php'); - $srcobject = new Commande($db); - dol_syslog("Try to find source object origin=".$object->origin." originid=".$object->origin_id." to add lines"); - $result=$srcobject->fetch($orders_id[$ii]); - if ($result > 0) - { - if($closeOrders) { - $srcobject->classer_facturee(); - $srcobject->setStatut(3); - } - $lines = $srcobject->lines; - if (empty($lines) && method_exists($srcobject,'fetch_lines')) $lines = $srcobject->fetch_lines(); - $fk_parent_line=0; - $num=count($lines); - for ($i=0;$i<$num;$i++) - { - $desc=($lines[$i]->desc?$lines[$i]->desc:$lines[$i]->libelle); - if ($lines[$i]->subprice < 0) - { - // Negative line, we create a discount line - $discount = new DiscountAbsolute($db); - $discount->fk_soc=$object->socid; - $discount->amount_ht=abs($lines[$i]->total_ht); - $discount->amount_tva=abs($lines[$i]->total_tva); - $discount->amount_ttc=abs($lines[$i]->total_ttc); - $discount->tva_tx=$lines[$i]->tva_tx; - $discount->fk_user=$user->id; - $discount->description=$desc; - $discountid=$discount->create($user); - if ($discountid > 0) - { - $result=$object->insert_discount($discountid); - //$result=$discount->link_to_invoice($lineid,$id); - } - else - { - $mesgs[]=$discount->error; - $error++; - break; - } - } - else - { - // Positive line - $product_type=($lines[$i]->product_type?$lines[$i]->product_type:0); - // Date start - $date_start=false; - if ($lines[$i]->date_debut_prevue) $date_start=$lines[$i]->date_debut_prevue; - if ($lines[$i]->date_debut_reel) $date_start=$lines[$i]->date_debut_reel; - if ($lines[$i]->date_start) $date_start=$lines[$i]->date_start; - //Date end - $date_end=false; - if ($lines[$i]->date_fin_prevue) $date_end=$lines[$i]->date_fin_prevue; - if ($lines[$i]->date_fin_reel) $date_end=$lines[$i]->date_fin_reel; - if ($lines[$i]->date_end) $date_end=$lines[$i]->date_end; - // Reset fk_parent_line for no child products and special product - if (($lines[$i]->product_type != 9 && empty($lines[$i]->fk_parent_line)) || $lines[$i]->product_type == 9) - { - $fk_parent_line = 0; - } - $result = $object->addline( - $id, - $desc, - $lines[$i]->subprice, - $lines[$i]->qty, - $lines[$i]->tva_tx, - $lines[$i]->localtax1_tx, - $lines[$i]->localtax2_tx, - $lines[$i]->fk_product, - $lines[$i]->remise_percent, - $date_start, - $date_end, - 0, - $lines[$i]->info_bits, - $lines[$i]->fk_remise_except, - 'HT', - 0, - $product_type, - $lines[$i]->rang, - $lines[$i]->special_code, - $object->origin, - $lines[$i]->rowid, - $fk_parent_line - ); - if ($result > 0) - { - $lineid=$result; - } - else - { - $lineid=0; - $error++; - break; - } - // Defined the new fk_parent_line - if ($result > 0 && $lines[$i]->product_type == 9) - { - $fk_parent_line = $result; - } - } - } - } - else - { - $mesgs[]=$srcobject->error; - $error++; - } - $ii++; - } - } - else - { - $mesgs[]=$object->error; - $error++; - } - } - } - } - - // End of object creation, we show it - if ($id > 0 && ! $error) - { - $db->commit(); - header('Location: '.DOL_URL_ROOT.'/compta/facture.php?facid='.$id); - exit; - } - else - { - $db->rollback(); - $action='create'; - $_GET["origin"]=$_POST["origin"]; - $_GET["originid"]=$_POST["originid"]; - $mesgs[]='
'.$object->error.'
'; - } - } -} - - -/* - * View - */ - -$html = new Form($db); -$htmlother = new FormOther($db); -$formfile = new FormFile($db); -$companystatic = new Societe($db); - -// Mode creation -if ($action == 'create') -{ - $facturestatic=new Facture($db); - - llxHeader(); - print_fiche_titre($langs->trans('NewBill')); - - $soc = new Societe($db); - if ($socid) $res=$soc->fetch($socid); - if ($res) - { - $cond_reglement_id = $soc->cond_reglement_id; - $mode_reglement_id = $soc->mode_reglement_id; - $remise_percent = $soc->remise_percent; - } - $remise_absolue = 0; - $dateinvoice = empty($conf->global->MAIN_AUTOFILL_DATE)?-1:0; - - $absolute_discount=$soc->getAvailableDiscounts(); - print '
'; - print ''; - print ''; - print '' ."\n"; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print '
'; print ''; - if($num2 > 0) print ''; - else print ''; + //if($num2 > 0) print ''; + //else print ''; print '
'.$langs->trans("LastOrders",($num<=$MAXLIST?"":$MAXLIST)).''.$langs->trans("AllOrders").' ('.$num.')'.img_picto($langs->trans("Statistics"),'stats').''.img_picto($langs->trans("CreateInvoiceForThisCustomer"),'object_bill').''.img_picto($langs->trans("NoOrdersToInvoice"),'object_bill').''.img_picto($langs->trans("CreateInvoiceForThisCustomer"),'object_bill').''.img_picto($langs->trans("NoOrdersToInvoice"),'object_bill').'
'; - // Ref - print ''; - // Tiers - print ''; - print ''."\n"; - print ''; - // Payment term - print ''; - // Payment mode - print ''; - // Project - if (! empty($conf->projet->enabled)) - { - $langs->load('projects'); - print ''; - } - // Modele PDF - print ''; - print '"; - - // Public note - print ''; - print ''; - print ''; - // Private note - if (! $user->societe_id) - { - print ''; - print ''; - print ''; - } - - print '
'.$langs->trans('Ref').''.$langs->trans('Draft').'
'.$langs->trans('Customer').''; - print $soc->getNomUrl(1); - print ''; - print '
'.$langs->trans('Type').''; - print ''."\n"; - // Standard invoice - print ''."\n"; - print '
'; - print ''; - print ''; - $desc=$html->textwithpicto($langs->trans("InvoiceStandardAsk"),$langs->transnoentities("InvoiceStandardDesc"),1); - print $desc; - print '
'; - - // Date invoice - print '
'.$langs->trans('Date').''; - $html->select_date(0,'','','','',"add",1,1); - print '
'.$langs->trans('PaymentConditionsShort').''; - $html->select_conditions_paiements(isset($_POST['cond_reglement_id'])?$_POST['cond_reglement_id']:$cond_reglement_id,'cond_reglement_id'); - print '
'.$langs->trans('PaymentMode').''; - $html->select_types_paiements(isset($_POST['mode_reglement_id'])?$_POST['mode_reglement_id']:$mode_reglement_id,'mode_reglement_id'); - print '
'.$langs->trans('Project').''; - select_projects($soc->id, $projectid, 'projectid'); - print '
'.$langs->trans('Model').''; - include_once DOL_DOCUMENT_ROOT.'/core/modules/facture/modules_facture.php'; - $liste=ModelePDFFactures::liste_modeles($db); - print $html->selectarray('model',$liste,$conf->global->FACTURE_ADDON_PDF); - print "
'.$langs->trans('NotePublic').''; - print '
'.$langs->trans('NotePrivate').''; - print '
'; - - while ($i < $n) - { - print ''; - - $i++; - } - - // Button "Create Draft" - print '
'; - print "\n"; - - print ''; - print "\n"; -} - - -//Mode liste -if (($action != 'create' && $action != 'add') || ! empty($mesgs)) -{ - llxHeader(); - ?> - - rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= ' WHERE p.entity = '.$conf->entity; - $sql.= ' AND p.fk_soc = s.rowid'; - - // Show orders with status validated, shipping started and delivered (well any order we can bill) - $sql.= " AND p.fk_statut IN (1,2)"; - - if ($socid) $sql.= ' AND s.rowid = '.$socid; - if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; - if ($sref) - { - $sql.= " AND p.ref LIKE '%".$db->escape($sref)."%'"; - } - if ($sall) - { - $sql.= " AND (p.ref LIKE '%".$db->escape($sall)."%' OR p.note LIKE '%".$db->escape($sall)."%')"; - } - - //Date filter - if ($date_start && $date_end) $sql.= " AND p.date_valid >= '".$db->idate($date_start)."' AND p.date_valid <= '".$db->idate($date_end)."'"; - if ($date_starty && $date_endy) $sql.= " AND p.fin_validite >= '".$db->idate($date_starty)."' AND p.fin_validite <= '".$db->idate($date_endy)."'"; - - if (!empty($sref_client)) - { - $sql.= ' AND p.ref_client LIKE \'%'.$db->escape($sref_client).'%\''; - } - $sql.= ' ORDER BY '.$sortfield.' '.$sortorder; - $resql = $db->query($sql); - - if ($resql) - { - if ($socid) - { - $soc = new Societe($db); - $soc->fetch($socid); - } - $title.= $langs->trans('ListOfProposals').' - '.$langs->trans('PropalStatusOpened').', '.$langs->trans("PropalStatusSigned"); - $num = $db->num_rows($resql); - print_fiche_titre($title); - $i = 0; - $period=$html->select_date($date_start,'date_start',0,0,1,'',1,0,1).' - '.$html->select_date($date_end,'date_end',0,0,1,'',1,0,1); - $periodely=$html->select_date($date_starty,'date_start_dely',0,0,1,'',1,0,1).' - '.$html->select_date($date_endy,'date_end_dely',0,0,1,'',1,0,1); - - if (! empty($socid)) - { - // Company - $companystatic->id=$socid; - $companystatic->nom=$soc->nom; - print '

'.$companystatic->getNomUrl(1,'customer').'

'; - } - - print ''; - print ''; - print_liste_field_titre($langs->trans('Ref'),'propalstoorder.php','p.ref','','&socid='.$socid,'',$sortfield,$sortorder); - print_liste_field_titre($langs->trans('RefCustomerOrder'),'propalstoorder.php','p.ref_client','','&socid='.$socid,'',$sortfield,$sortorder); - print_liste_field_titre($langs->trans('Date'),'propalstoorder.php','p.date_valid','','&socid='.$socid, 'align="center"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans('DateEndPropal'),'propalstoorder.php','p.fin_validite','','&socid='.$socid, 'align="center"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans('Status'),'','','','','align="right"'); - print_liste_field_titre($langs->trans('GenerateBill'),'','','','','align="center"'); - print ''; - - // Lignes des champs de filtre - print ''; - print ''; - print ''; - print ''; - //print ''; - - //DATE DELIVERY - print ''; - - //SEARCH BUTTON - print ''; - - print ''; - print ''; - - print ''; - $var=True; - $generic_propal = new Propal($db); - - while ($i < $num) - { - $objp = $db->fetch_object($resql); - $var=!$var; - print ''; - print ''; - - print ''; - - // Validation date - print ''; - - // Limit valid date - print ''; - - // Statut - print ''; - - // Checkbox - print '' ; - - print ''; - - $total = $total + $objp->price; - $subtotal = $subtotal + $objp->price; - $i++; - } - print '
'; - //REF - print ''; - print ''; - print ''; - print ''; - - //DATE ORDER - print ''; - print $period; - print ''; - print $periodely; - print ''; - print ''; - - //ALL/NONE - print ''; - if ($conf->use_javascript_ajax) print ''.$langs->trans("All").' / '.$langs->trans("None").''; - print '
'; - - $generic_propal->id=$objp->rowid; - $generic_propal->ref=$objp->ref; - - print ''; - print ''; - - print ''; - - print '
'; - print $generic_propal->getNomUrl(1); - print ''; - if (($objp->fk_statut > 0) && ($objp->fk_statut < 3) && $db->jdate($objp->fin_validite) < ($now - $conf->propal->client->warning_delay)) print img_picto($langs->trans("Late"),"warning"); - print ''; - $filename=dol_sanitizeFileName($objp->ref); - $filedir=$conf->propal->dir_output . '/' . dol_sanitizeFileName($objp->ref); - $urlsource=$_SERVER['PHP_SELF'].'?id='.$objp->rowid; - print $formfile->getDocumentsLink($generic_propal->element, $filename, $filedir); - print '
'; - print '
'.$objp->ref_client.''; - print dol_print_date($db->jdate($objp->date_valid),'day'); - print ''; - print dol_print_date($db->jdate($objp->fin_validite),'day'); - print ''.$generic_propal->LibStatut($objp->fk_statut,5).''; - print ''; - print '
'; - - /* - * Boutons actions - */ - print '
'; - print ''; - print ''; - print '
'; - print ''.$langs->trans("GoBack").''; - print ''; - print '

'.$langs->trans("ClosePropalsAutomatically"); - print '
'; - print ''; - $db->free($resql); - } - else - { - print dol_print_error($db); - } - -} - -dol_htmloutput_mesg($mesg,$mesgs); - -llxFooter(); -$db->close(); -?> \ No newline at end of file diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 4415fb05229..1ab079e0fc8 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -2754,7 +2754,7 @@ class Commande extends CommonOrder $sql.= ' l.total_ht, l.total_tva, l.total_ttc, l.fk_product_fournisseur_price as fk_fournprice, l.buy_price_ht as pa_ht, l.localtax1_tx, l.localtax2_tx,'; $sql.= ' l.date_start, l.date_end,'; $sql.= ' p.label as product_label, p.ref, p.fk_product_type, p.rowid as prodid, '; - $sql.= ' p.description as product_desc'; + $sql.= ' p.description as product_desc, p.stock as stock_reel'; $sql.= ' FROM '.MAIN_DB_PREFIX.'commandedet as l'; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON l.fk_product=p.rowid'; $sql.= ' WHERE l.fk_commande = '.$this->id; @@ -2790,6 +2790,7 @@ class Commande extends CommonOrder $this->lines[$i]->total_ttc = $obj->total_ttc; $this->lines[$i]->fk_parent_line = $obj->fk_parent_line; $this->lines[$i]->special_code = $obj->special_code; + $this->lines[$i]->stock = $obj->stock_reel; $this->lines[$i]->rang = $obj->rang; $this->lines[$i]->date_start = $this->db->jdate($obj->date_start); $this->lines[$i]->date_end = $this->db->jdate($obj->date_end); diff --git a/htdocs/commande/liste.php b/htdocs/commande/liste.php index 1a8afa7fef5..c8c6198e154 100644 --- a/htdocs/commande/liste.php +++ b/htdocs/commande/liste.php @@ -3,6 +3,7 @@ * Copyright (C) 2004-2012 Laurent Destailleur * Copyright (C) 2005 Marc Barilley / Ocebo * Copyright (C) 2005-2012 Regis Houssin + * Copyright (C) 2012 Juanjo Menent * * 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 @@ -328,7 +329,20 @@ if ($resql) print ''; print $companystatic->getNomUrl(1,'customer'); print ' '; - print img_picto($langs->trans("CreateInvoiceForThisCustomer").' : '.$companystatic->nom,'object_bill').''; + + // If module invoices enabled and user with invoice creation permissions + if (! empty($conf->facture->enabled)) + { + if ($user->rights->facture->creer) + { + + if (($objp->fk_statut > 0 && $objp->fk_statut < 3) || ($objp->fk_statut == 3 && $objp->facturee == 0)) + { + + print img_picto($langs->trans("CreateInvoiceForThisCustomer").' : '.$companystatic->nom,'object_bill').''; + } + } + } print ''; print ''.$objp->ref_client.''; diff --git a/htdocs/compta/facture_multi_origin.php b/htdocs/compta/facture_multi_origin.php deleted file mode 100644 index 0d6424f3ecd..00000000000 --- a/htdocs/compta/facture_multi_origin.php +++ /dev/null @@ -1,213 +0,0 @@ -global->FACTURE_MULTI_ORIGIN) include_once(DOL_DOCUMENT_ROOT.'/compta/facture_multi_origin.php'); - -if(empty($origin)) return 0; -else if ($origin == 'commande') { - - // Show other origin objects mergeable into same invoice - print_titre($langs->trans('OtherOrders')); - - // Display list of elements - // 1 - Filters - $sref = GETPOST('sref'); - $sref_client = GETPOST('sref_client'); - $sall = GETPOST('sall'); - $date_start=dol_mktime(0,0,0,$_REQUEST["date_startmonth"],$_REQUEST["date_startday"],$_REQUEST["date_startyear"]); // Date for local PHP server - $date_end=dol_mktime(23,59,59,$_REQUEST["date_endmonth"],$_REQUEST["date_endday"],$_REQUEST["date_endyear"]); - $date_starty=dol_mktime(0,0,0,$_REQUEST["date_start_delymonth"],$_REQUEST["date_start_delyday"],$_REQUEST["date_start_delyyear"]); // Date for local PHP server - $date_endy=dol_mktime(23,59,59,$_REQUEST["date_end_delymonth"],$_REQUEST["date_end_delyday"],$_REQUEST["date_end_delyyear"]); - - $sortfield = GETPOST("sortfield",'alpha'); - $sortorder = GETPOST("sortorder",'alpha'); - if (! $sortfield) $sortfield='c.rowid'; - if (! $sortorder) $sortorder='DESC'; - - $html = new Form($db); - $htmlother = new FormOther($db); - $formfile = new FormFile($db); - $companystatic = new Societe($db); - - // 2 - Query for orders - $sql = 'SELECT s.nom, s.rowid as socid, s.client, c.rowid, c.ref, c.total_ht, c.ref_client,'; - $sql.= ' c.date_valid, c.date_commande, c.date_livraison, c.fk_statut, c.facture as facturee'; - $sql.= ' FROM '.MAIN_DB_PREFIX.'societe as s'; - $sql.= ', '.MAIN_DB_PREFIX.'commande as c'; - if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= ' WHERE c.entity = '.$conf->entity; - $sql.= ' AND c.fk_soc = s.rowid'; - - // Show orders with status validated, shipping started and delivered (well any order we can bill) - $sql.= " AND ((c.fk_statut IN (1,2)) OR (c.fk_statut = 3 AND c.facture = 0))"; - - if ($socid) $sql.= ' AND s.rowid = '.$socid; - if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; - if ($sref) - { - $sql.= " AND c.ref LIKE '%".$db->escape($sref)."%'"; - } - if ($sall) - { - $sql.= " AND (c.ref LIKE '%".$db->escape($sall)."%' OR c.note LIKE '%".$db->escape($sall)."%')"; - } - if (!empty($sref_client)) - { - $sql.= ' AND c.ref_client LIKE \'%'.$db->escape($sref_client).'%\''; - } - - // Date filter - if ($date_start && $date_end) $sql.= " AND c.date_commande >= '".$db->idate($date_start)."' AND c.date_commande <= '".$db->idate($date_end)."'"; - if ($date_starty && $date_endy) $sql.= " AND c.date_livraison >= '".$db->idate($date_starty)."' AND c.date_livraison <= '".$db->idate($date_endy)."'"; - - $sql.= ' ORDER BY '.$sortfield.' '.$sortorder; - $resql = $db->query($sql); - - if ($resql) - { - if ($socid) - { - $soc = new Societe($db); - $soc->fetch($socid); - } - $num = $db->num_rows($resql); - - $i = 0; - $period=$html->select_date($date_start,'date_start',0,0,1,'',1,0,1).' - '.$html->select_date($date_end,'date_end',0,0,1,'',1,0,1); - $periodely=$html->select_date($date_starty,'date_start_dely',0,0,1,'',1,0,1).' - '.$html->select_date($date_endy,'date_end_dely',0,0,1,'',1,0,1); - - print ''; - print ''; - print_liste_field_titre($langs->trans('Ref'),'orderstoinvoice.php','c.ref','','&socid='.$socid,'',$sortfield,$sortorder); - print_liste_field_titre($langs->trans('RefCustomerOrder'),'orderstoinvoice.php','c.ref_client','','&socid='.$socid,'',$sortfield,$sortorder); - print_liste_field_titre($langs->trans('OrderDate'),'orderstoinvoice.php','c.date_commande','','&socid='.$socid, 'align="center"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans('DeliveryDate'),'orderstoinvoice.php','c.date_livraison','','&socid='.$socid, 'align="center"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans('Status'),'','','','','align="right"'); - print_liste_field_titre($langs->trans('GenerateBill'),'','','','','align="center"'); - print ''; - - // Lignes des champs de filtre - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - //print ''; - - //DATE DELIVERY - print ''; - - //SEARCH BUTTON - print ''; - - print ''; - print ''; - - print ''; - print ''; - print ''; - print ''; - print ''; - $var=True; - $generic_commande = new Commande($db); - - while ($i < $num) - { - $objp = $db->fetch_object($resql); - $var=!$var; - print ''; - print ''; - - print ''; - - // Order date - print ''; - - //Delivery date - print ''; - - // Statut - print ''; - - // Checkbox - print '' ; - - print ''; - - $total = $total + $objp->price; - $subtotal = $subtotal + $objp->price; - $i++; - } - print '
'; - //REF - print ''; - print ''; - print ''; - print ''; - - //DATE ORDER - print ''; - print $period; - print ''; - print $periodely; - print ''; - print ''; - - //ALL/NONE - print ''; - if ($conf->use_javascript_ajax) print ''.$langs->trans("All").' / '.$langs->trans("None").''; - print '
'; - - $generic_commande->id=$objp->rowid; - $generic_commande->ref=$objp->ref; - - print ''; - print ''; - - print ''; - - print '
'; - print $generic_commande->getNomUrl(1,$objp->fk_statut); - print ''; - if (($objp->fk_statut > 0) && ($objp->fk_statut < 3) && $db->jdate($objp->date_valid) < ($now - $conf->commande->client->warning_delay)) print img_picto($langs->trans("Late"),"warning"); - print ''; - $filename=dol_sanitizeFileName($objp->ref); - $filedir=$conf->commande->dir_output . '/' . dol_sanitizeFileName($objp->ref); - $urlsource=$_SERVER['PHP_SELF'].'?id='.$objp->rowid; - print $formfile->getDocumentsLink($generic_commande->element, $filename, $filedir); - print '
'; - print '
'.$objp->ref_client.''; - print dol_print_date($db->jdate($objp->date_commande),'day'); - print ''; - print dol_print_date($db->jdate($objp->date_livraison),'day'); - print ''.$generic_commande->LibStatut($objp->fk_statut,$objp->facturee,5).''; - print ''; - print '
'; - print '

'.$langs->trans("CloseProcessedOrdersAutomatically"); - // Button "Create Draft" - print '
'; - print ''; - $db->free($resql); - ?> - - \ No newline at end of file diff --git a/htdocs/core/boxes/box_produits_alerte_stock.php b/htdocs/core/boxes/box_produits_alerte_stock.php new file mode 100644 index 00000000000..0156a96b9cb --- /dev/null +++ b/htdocs/core/boxes/box_produits_alerte_stock.php @@ -0,0 +1,181 @@ + + * Copyright (C) 2004-2011 Laurent Destailleur + * Copyright (C) 2005-2012 Regis Houssin + * Copyright (C) 2005-2012 Maxime Kohlhaas + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file htdocs/core/boxes/box_produits_alerte_stock.php + * \ingroup produits + * \brief Module to generate box of products with too low stock + */ + +include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; +include_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; + + +/** + * Class to manage the box to show too low stocks products + */ +class box_produits_alerte_stock extends ModeleBoxes +{ + var $boxcode="productsalertstock"; + var $boximg="object_product"; + var $boxlabel; + var $depends = array("produit"); + + var $db; + var $param; + + var $info_box_head = array(); + var $info_box_contents = array(); + + + /** + * Constructor + */ + function __construct() + { + global $langs; + $langs->load("boxes"); + + $this->boxlabel=$langs->transnoentitiesnoconv("BoxProductsAlertStock"); + } + + /** + * Load data into info_box_contents array to show array later. + * + * @param int $max Maximum number of records to load + * @return void + */ + function loadBox($max=5) + { + global $user, $langs, $db, $conf; + + $this->max=$max; + + include_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; + $productstatic=new Product($db); + + $this->info_box_head = array('text' => $langs->trans("BoxTitleProductsAlertStock",$max)); + + if ($user->rights->produit->lire || $user->rights->service->lire) + { + $sql = "SELECT p.rowid, p.label, p.price, p.price_base_type, p.price_ttc, p.fk_product_type, p.tms, p.tosell, p.tobuy, p.seuil_stock_alerte, s.reel"; + $sql.= " FROM ".MAIN_DB_PREFIX."product as p"; + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_stock as s on p.rowid = s.fk_product"; + $sql.= ' WHERE p.entity IN ('.getEntity($productstatic->element, 1).')'; + $sql.= " AND p.tosell = 1"; + if (empty($user->rights->produit->lire)) $sql.=' AND p.fk_product_type != 0'; + if (empty($user->rights->service->lire)) $sql.=' AND p.fk_product_type != 1'; + $sql.= " HAVING s.reel < p.seuil_stock_alerte"; + $sql.= $db->order('s.reel', 'DESC'); + $sql.= $db->plimit($max, 0); + + $result = $db->query($sql); + if ($result) + { + $num = $db->num_rows($result); + $i = 0; + while ($i < $num) + { + $objp = $db->fetch_object($result); + $datem=$db->jdate($objp->tms); + + // Multilangs + if (! empty($conf->global->MAIN_MULTILANGS)) // si l'option est active + { + $sqld = "SELECT label"; + $sqld.= " FROM ".MAIN_DB_PREFIX."product_lang"; + $sqld.= " WHERE fk_product=".$objp->rowid; + $sqld.= " AND lang='". $langs->getDefaultLang() ."'"; + $sqld.= " LIMIT 1"; + + $resultd = $db->query($sqld); + if ($resultd) + { + $objtp = $db->fetch_object($resultd); + if (isset($objtp->label) && $objtp->label != '') + $objp->label = $objtp->label; + } + } + + $this->info_box_contents[$i][0] = array('td' => 'align="left" width="16"', + 'logo' => ($objp->fk_product_type==1?'object_service':'object_product'), + 'url' => DOL_URL_ROOT."/product/fiche.php?id=".$objp->rowid); + + $this->info_box_contents[$i][1] = array('td' => 'align="left"', + 'text' => $objp->label, + 'url' => DOL_URL_ROOT."/product/fiche.php?id=".$objp->rowid); + + if ($objp->price_base_type == 'HT') + { + $price=price($objp->price); + $price_base_type=$langs->trans("HT"); + } + else + { + $price=price($objp->price_ttc); + $price_base_type=$langs->trans("TTC"); + } + $this->info_box_contents[$i][2] = array('td' => 'align="right"', + 'text' => $price); + + $this->info_box_contents[$i][3] = array('td' => 'align="left" nowrap="nowrap"', + 'text' => $price_base_type); + + $this->info_box_contents[$i][4] = array('td' => 'align="center"', + 'text' => $objp->reel . ' / '.$objp->seuil_stock_alerte); + + $this->info_box_contents[$i][5] = array('td' => 'align="right" width="18"', + 'text' => $productstatic->LibStatut($objp->tosell,3,0)); + + $this->info_box_contents[$i][6] = array('td' => 'align="right" width="18"', + 'text' => $productstatic->LibStatut($objp->tobuy,3,1)); + + $i++; + } + if ($num==0) $this->info_box_contents[$i][0] = array('td' => 'align="center"','text'=>$langs->trans("NoRecordedProducts")); + } + else + { + $this->info_box_contents[0][0] = array( 'td' => 'align="left"', + 'maxlength'=>500, + 'text' => ($db->error().' sql='.$sql)); + } + } + else { + $this->info_box_contents[0][0] = array('td' => 'align="left"', + 'text' => $langs->trans("ReadPermissionNotAllowed")); + } + } + + /** + * Method to show box + * + * @param array $head Array with properties of box title + * @param array $contents Array with properties of box lines + * @return void + */ + function showBox($head = null, $contents = null) + { + parent::showBox($this->info_box_head, $this->info_box_contents); + } + +} + +?> diff --git a/htdocs/core/lib/member.lib.php b/htdocs/core/lib/member.lib.php index c3314bb3087..07985bda263 100644 --- a/htdocs/core/lib/member.lib.php +++ b/htdocs/core/lib/member.lib.php @@ -96,6 +96,9 @@ function member_prepare_head($object) $head[$h][2] = 'info'; $h++; + + complete_head_from_modules($conf,$langs,$object,$head,$h,'member','remove'); + return $head; } @@ -180,4 +183,4 @@ function member_stats_prepare_head($object) return $head; } -?> \ No newline at end of file +?> diff --git a/htdocs/core/lib/product.lib.php b/htdocs/core/lib/product.lib.php index dd14889dfb5..cb345399733 100644 --- a/htdocs/core/lib/product.lib.php +++ b/htdocs/core/lib/product.lib.php @@ -123,6 +123,7 @@ function product_prepare_head($object, $user) // More tabs from canvas + // TODO Is this still used ? if (isset($object->onglets) && is_array($object->onglets)) { foreach ($object->onglets as $onglet) diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index c23ca4caaed..4ae5dad0731 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -1,6 +1,7 @@ * Copyright (C) 2010 Regis Houssin + * Copyright (C) 2012 Juanjo Menent * * 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 @@ -953,8 +954,6 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after) $langs->load("orders"); if (! empty($conf->facture->enabled)) $newmenu->add("/commande/liste.php?leftmenu=orders&viewstatut=-3", $langs->trans("MenuOrdersToBill2"), 0, $user->rights->commande->lire, '', $mainmenu, 'orders'); // if ($leftmenu=="orders") $newmenu->add("/commande/", $langs->trans("StatusOrderToBill"), 1, $user->rights->commande->lire); - // Does this link is required now we have link into "Orders to bill" list ? - //if ($leftmenu=="orders") $newmenu->add("/commande/customer.php", $langs->trans("GenerateBill"), 1, $user->rights->commande->lire); } // Donations diff --git a/htdocs/core/tpl/objectline_edit.tpl.php b/htdocs/core/tpl/objectline_edit.tpl.php index 4b079ef78d2..4c64d2dce0e 100644 --- a/htdocs/core/tpl/objectline_edit.tpl.php +++ b/htdocs/core/tpl/objectline_edit.tpl.php @@ -106,6 +106,7 @@ info_bits & 2) != 2) { ?> + qty > $line->stock) print img_picto($langs->trans("StockTooLow"),"warning", 'style="vertical-align: bottom;"')." "; ?>   diff --git a/htdocs/core/tpl/objectline_view.tpl.php b/htdocs/core/tpl/objectline_view.tpl.php index cc90227dcba..836c01c6499 100644 --- a/htdocs/core/tpl/objectline_view.tpl.php +++ b/htdocs/core/tpl/objectline_view.tpl.php @@ -102,8 +102,10 @@ - info_bits & 2) != 2) && $line->special_code != 3) echo $line->qty; - else echo ' '; ?> + info_bits & 2) != 2) && $line->special_code != 3) { + if($line->qty > $line->stock) print img_picto($langs->trans("StockTooLow"),"warning", 'style="vertical-align: bottom;"')." "; + echo $line->qty; + } else echo ' '; ?> remise_percent) && $line->special_code != 3) { ?> diff --git a/htdocs/install/mysql/migration/3.2.0-3.3.0.sql b/htdocs/install/mysql/migration/3.2.0-3.3.0.sql index a24f214bfcb..81922a2b4b9 100755 --- a/htdocs/install/mysql/migration/3.2.0-3.3.0.sql +++ b/htdocs/install/mysql/migration/3.2.0-3.3.0.sql @@ -753,3 +753,9 @@ insert into llx_accountingaccount (rowid, fk_pcg_version, pcg_type, pcg_subtype, -- Add discount in product supplier price ALTER TABLE llx_product_fournisseur_price ADD COLUMN remise_percent DOUBLE NOT NULL DEFAULT 0 AFTER quantity; ALTER TABLE llx_product_fournisseur_price ADD COLUMN remise DOUBLE NOT NULL DEFAULT 0 AFTER remise_percent; + +-- Stock calculation on product +UPDATE llx_product p SET p.stock= (SELECT SUM(ps.reel) FROM llx_product_stock ps WHERE ps.fk_product = p.rowid); + +-- Add possibility to defined position/job of a user +ALTER TABLE llx_user ADD COLUMN job varchar(128) AFTER firstname; diff --git a/htdocs/install/mysql/tables/llx_user.sql b/htdocs/install/mysql/tables/llx_user.sql index 006b0cc993e..dd42a2062c7 100644 --- a/htdocs/install/mysql/tables/llx_user.sql +++ b/htdocs/install/mysql/tables/llx_user.sql @@ -1,7 +1,7 @@ -- ============================================================================ -- Copyright (C) 2001-2003 Rodolphe Quiedeville -- Copyright (C) 2006-2011 Laurent Destailleur --- Copyright (C) 2007-2011 Regis Houssin +-- Copyright (C) 2007-2012 Regis Houssin -- -- This program is free software; you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by @@ -35,6 +35,7 @@ create table llx_user civilite varchar(6), name varchar(50), firstname varchar(50), + job varchar(128), office_phone varchar(20), office_fax varchar(20), user_mobile varchar(20), @@ -58,4 +59,5 @@ create table llx_user statut tinyint DEFAULT 1, photo varchar(255), -- filename or url of photo lang varchar(6) + )ENGINE=innodb; diff --git a/htdocs/langs/ca_ES/orders.lang b/htdocs/langs/ca_ES/orders.lang index ef2f9e43efa..15fd9b6c9a1 100644 --- a/htdocs/langs/ca_ES/orders.lang +++ b/htdocs/langs/ca_ES/orders.lang @@ -141,8 +141,10 @@ OrderSource6=Revistes QtyOrdered=Qt. demanda AddDeliveryCostLine=Afegir una línia de despeses de ports indicant el pes de la comanda SetDemandReason=Indicar origen de la comanda -CreateInvoiceForThisCustomer=Crear una factura a partir de diverses comandes d'aquest client +CreateInvoiceForThisCustomer=Facturar comandes +NoOrdersToInvoice=Sense comandes facturables CloseProcessedOrdersAutomatically=Classificar automàticament com "Processades" les comandes seleccionades. +MenuOrdersToBill2=Comandes facturables # Document models PDFEinsteinDescription=Model de comanda complet (logo...) diff --git a/htdocs/langs/en_GB/bills.lang b/htdocs/langs/en_GB/bills.lang index 7bfffa69165..60c38ade196 100644 --- a/htdocs/langs/en_GB/bills.lang +++ b/htdocs/langs/en_GB/bills.lang @@ -1,8 +1,6 @@ # Dolibarr language file - en_GB - main CHARSET=UTF-8 PrettyLittleSentence=Accept the amount of payments due by cheques issued in my name as a Member of an accounting association approved by the Fiscal Administration. -PaymentTypeCHQ=Cheque -PaymentTypeShortCHQ=Cheque ChequeNumber=Cheque N° ChequeOrTransferNumber=Cheque/Transfer N° ChequeMaker=Cheque transmitter @@ -19,4 +17,22 @@ Cheques=Cheques # PaymentConditions PaymentConditionShortRECEP=Due on Receipt -PaymentConditionRECEP=Due on Receipt \ No newline at end of file +PaymentConditionRECEP=Due on Receipt + +# PaymentType +PaymentTypeVIR=Bank transfer +PaymentTypeShortVIR=Bank transfer +PaymentTypePRE=Direct debit +PaymentTypeShortPRE=Direct debit +PaymentTypeLIQ=Cash +PaymentTypeShortLIQ=Cash +PaymentTypeCB=Credit card +PaymentTypeShortCB=Credit card +PaymentTypeCHQ=Cheque +PaymentTypeShortCHQ=Cheque +PaymentTypeTIP=TIP +PaymentTypeShortTIP=TIP +PaymentTypeVAD=On line payment +PaymentTypeShortVAD=On line payment +PaymentTypeTRA=Bill payment +PaymentTypeShortTRA=Bill \ No newline at end of file diff --git a/htdocs/langs/en_US/boxes.lang b/htdocs/langs/en_US/boxes.lang index 403e1e077ca..e7a56618f88 100644 --- a/htdocs/langs/en_US/boxes.lang +++ b/htdocs/langs/en_US/boxes.lang @@ -2,6 +2,7 @@ CHARSET=UTF-8 BoxLastRssInfos=Rss information BoxLastProducts=Last %s products/services +BoxProductsAlertStock=Products in stock alert BoxLastProductsInContract=Last %s contracted products/services BoxLastSupplierBills=Last supplier's invoices BoxLastCustomerBills=Last customer's invoices @@ -25,6 +26,7 @@ BoxTitleLastBooks=Last %s recorded books BoxTitleNbOfCustomers=Number of clients BoxTitleLastRssInfos=Last %s news from %s BoxTitleLastProducts=Last %s modified products/services +BoxTitleProductsAlertStock=Products in stock alert BoxTitleLastCustomerOrders=Last %s modified customer orders BoxTitleLastSuppliers=Last %s recorded suppliers BoxTitleLastCustomers=Last %s recorded customers diff --git a/htdocs/langs/en_US/orders.lang b/htdocs/langs/en_US/orders.lang index 9a626731e8c..2796759a8f0 100644 --- a/htdocs/langs/en_US/orders.lang +++ b/htdocs/langs/en_US/orders.lang @@ -155,5 +155,7 @@ OrderByEMail=EMail OrderByWWW=Online OrderByPhone=Phone -CreateInvoiceForThisCustomer=Create an invoice for several orders of this customer -CloseProcessedOrdersAutomatically=Classify "Processed" all selected orders. \ No newline at end of file +CreateInvoiceForThisCustomer=Bill orders +NoOrdersToInvoice=No orders billable +CloseProcessedOrdersAutomatically=Classify "Processed" all selected orders. +MenuOrdersToBill2=Billables orders \ No newline at end of file diff --git a/htdocs/langs/es_ES/orders.lang b/htdocs/langs/es_ES/orders.lang index 06a662847c6..13710c240b7 100644 --- a/htdocs/langs/es_ES/orders.lang +++ b/htdocs/langs/es_ES/orders.lang @@ -141,8 +141,10 @@ OrderSource6=Revistas QtyOrdered=Cant. pedida AddDeliveryCostLine=Añadir una línea de gastos de portes indicando el peso del pedido SetDemandReason=Indicar origen del pedido -CreateInvoiceForThisCustomer=Crear una factura a partir de varios pedidos de este cliente +CreateInvoiceForThisCustomer=Facturar pedidos +NoOrdersToInvoice=Sin pedidos facturables CloseProcessedOrdersAutomatically=Clasificar automáticamente como "Procesados" los pedidos seleccionados. +MenuOrdersToBill2=Pedidos facturables # Document models PDFEinsteinDescription=Modelo de pedido completo (logo...) diff --git a/htdocs/langs/fr_FR/boxes.lang b/htdocs/langs/fr_FR/boxes.lang index 977f218c08d..61ef3d2ab52 100644 --- a/htdocs/langs/fr_FR/boxes.lang +++ b/htdocs/langs/fr_FR/boxes.lang @@ -2,6 +2,7 @@ CHARSET=UTF-8 BoxLastRssInfos=Fils d'informations RSS BoxLastProducts=Les %s derniers produits/services enregistrés +BoxProductsAlertStock=Produits en alerte stock BoxLastProductsInContract=Les %s derniers produits/services contractés BoxLastSupplierBills=Dernières factures fournisseurs BoxLastCustomerBills=Dernières factures clients @@ -25,6 +26,7 @@ BoxTitleLastBooks=Les %s derniers ouvrages enregistrés BoxTitleNbOfCustomers=Nombre de clients BoxTitleLastRssInfos=Les %s dernières infos de %s BoxTitleLastProducts=Les %s derniers produits/services enregistrés +BoxTitleProductsAlertStock=Produits en alerte stock BoxTitleLastCustomerOrders=Les %s dernières commandes clients modifiées BoxTitleLastSuppliers=Les %s derniers fournisseurs enregistrés BoxTitleLastCustomers=Les %s derniers clients enregistrés diff --git a/htdocs/langs/fr_FR/orders.lang b/htdocs/langs/fr_FR/orders.lang index 04dc0184800..1866ecbdcfb 100644 --- a/htdocs/langs/fr_FR/orders.lang +++ b/htdocs/langs/fr_FR/orders.lang @@ -156,5 +156,7 @@ OrderByEMail=EMail OrderByWWW=En ligne OrderByPhone=Téléphone -CreateInvoiceForThisCustomer=Créer une facture à partir de plusieurs commande de ce client -CloseProcessedOrdersAutomatically=Classer automatiquement à "Traitées" les commandes sélectionnées. \ No newline at end of file +CreateInvoiceForThisCustomer=Facturer commandes +NoOrdersToInvoice=Pas de commandes facturables +CloseProcessedOrdersAutomatically=Classer automatiquement à "Traitées" les commandes sélectionnées. +MenuOrdersToBill2=Commandes facturables diff --git a/htdocs/master.inc.php b/htdocs/master.inc.php index 34dd9ad8dca..9d6897c6de1 100644 --- a/htdocs/master.inc.php +++ b/htdocs/master.inc.php @@ -194,72 +194,9 @@ if (! empty($conf->global->MAIN_ONLY_LOGIN_ALLOWED)) if (! defined('NOREQUIREDB') && ! defined('NOREQUIRESOC')) { require_once DOL_DOCUMENT_ROOT .'/societe/class/societe.class.php'; + $mysoc=new Societe($db); - - $mysoc->id=0; - $mysoc->name=(! empty($conf->global->MAIN_INFO_SOCIETE_NOM))?$conf->global->MAIN_INFO_SOCIETE_NOM:''; - $mysoc->nom=$mysoc->name; // deprecated - $mysoc->address=(! empty($conf->global->MAIN_INFO_SOCIETE_ADRESSE))?$conf->global->MAIN_INFO_SOCIETE_ADRESSE:''; - $mysoc->adresse=$mysoc->address; // deprecated - $mysoc->zip=(! empty($conf->global->MAIN_INFO_SOCIETE_CP))?$conf->global->MAIN_INFO_SOCIETE_CP:''; - $mysoc->cp=$mysoc->zip; // deprecated - $mysoc->town=(! empty($conf->global->MAIN_INFO_SOCIETE_VILLE))?$conf->global->MAIN_INFO_SOCIETE_VILLE:''; - $mysoc->ville=$mysoc->town; // deprecated - $mysoc->state_id=$conf->global->MAIN_INFO_SOCIETE_DEPARTEMENT; - $mysoc->note=empty($conf->global->MAIN_INFO_SOCIETE_NOTE)?'':$conf->global->MAIN_INFO_SOCIETE_NOTE; - - // We define country_id, country_code and country - $country_id=$country_code=$country_label=''; - if (! empty($conf->global->MAIN_INFO_SOCIETE_PAYS)) - { - $tmp=explode(':',$conf->global->MAIN_INFO_SOCIETE_PAYS); - $country_id=$tmp[0]; - if (! empty($tmp[1])) // If $conf->global->MAIN_INFO_SOCIETE_PAYS is "id:code:label" - { - $country_code=$tmp[1]; - $country_label=$tmp[2]; - } - else // For backward compatibility - { - dol_syslog("Your country setup use an old syntax. Reedit it using setup area.", LOG_WARNING); - include_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; - $country_code=getCountry($country_id,2,$db); // This need a SQL request, but it's the old feature - $country_label=getCountry($country_id,0,$db); // This need a SQL request, but it's the old feature - } - } - $mysoc->pays_id=$country_id; // TODO deprecated - $mysoc->country_id=$country_id; - $mysoc->pays_code=$country_code; // TODO deprecated - $mysoc->country_code=$country_code; - $mysoc->country=$country_label; - if (is_object($langs)) $mysoc->country=($langs->trans('Country'.$country_code)!='Country'.$country_code)?$langs->trans('Country'.$country_code):$country_label; - $mysoc->pays=$mysoc->country; // TODO deprecated - - $mysoc->tel=empty($conf->global->MAIN_INFO_SOCIETE_TEL)?'':$conf->global->MAIN_INFO_SOCIETE_TEL; // TODO deprecated - $mysoc->phone=empty($conf->global->MAIN_INFO_SOCIETE_TEL)?'':$conf->global->MAIN_INFO_SOCIETE_TEL; - $mysoc->fax=empty($conf->global->MAIN_INFO_SOCIETE_FAX)?'':$conf->global->MAIN_INFO_SOCIETE_FAX; - $mysoc->url=empty($conf->global->MAIN_INFO_SOCIETE_WEB)?'':$conf->global->MAIN_INFO_SOCIETE_WEB; - // Id prof generiques - $mysoc->idprof1=empty($conf->global->MAIN_INFO_SIREN)?'':$conf->global->MAIN_INFO_SIREN; - $mysoc->idprof2=empty($conf->global->MAIN_INFO_SIRET)?'':$conf->global->MAIN_INFO_SIRET; - $mysoc->idprof3=empty($conf->global->MAIN_INFO_APE)?'':$conf->global->MAIN_INFO_APE; - $mysoc->idprof4=empty($conf->global->MAIN_INFO_RCS)?'':$conf->global->MAIN_INFO_RCS; - $mysoc->idprof5=empty($conf->global->MAIN_INFO_PROFID5)?'':$conf->global->MAIN_INFO_PROFID5; - $mysoc->idprof6=empty($conf->global->MAIN_INFO_PROFID6)?'':$conf->global->MAIN_INFO_PROFID6; - $mysoc->tva_intra=(! empty($conf->global->MAIN_INFO_TVAINTRA))?$conf->global->MAIN_INFO_TVAINTRA:''; // VAT number, not necessarly INTRA. - $mysoc->capital=(! empty($conf->global->MAIN_INFO_CAPITAL))?$conf->global->MAIN_INFO_CAPITAL:''; - $mysoc->forme_juridique_code=$conf->global->MAIN_INFO_SOCIETE_FORME_JURIDIQUE; - $mysoc->email=(! empty($conf->global->MAIN_INFO_SOCIETE_MAIL))?$conf->global->MAIN_INFO_SOCIETE_MAIL:''; - $mysoc->logo=(! empty($conf->global->MAIN_INFO_SOCIETE_LOGO))?$conf->global->MAIN_INFO_SOCIETE_LOGO:''; - $mysoc->logo_small=(! empty($conf->global->MAIN_INFO_SOCIETE_LOGO_SMALL))?$conf->global->MAIN_INFO_SOCIETE_LOGO_SMALL:''; - $mysoc->logo_mini=(! empty($conf->global->MAIN_INFO_SOCIETE_LOGO_MINI))?$conf->global->MAIN_INFO_SOCIETE_LOGO_MINI:''; - - // Define if company use vat or not (Do not use conf->global->FACTURE_TVAOPTION anymore) - $mysoc->tva_assuj=((isset($conf->global->FACTURE_TVAOPTION) && $conf->global->FACTURE_TVAOPTION=='franchise')?0:1); - - // Define if company use local taxes - $mysoc->localtax1_assuj=((isset($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on')?1:0); - $mysoc->localtax2_assuj=((isset($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on')?1:0); + $mysoc->getMysoc($conf); // For some countries, we need to invert our address with customer address if ($mysoc->country_code == 'DE' && ! isset($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $conf->global->MAIN_INVERT_SENDER_RECIPIENT=1; diff --git a/htdocs/product/stock/class/mouvementstock.class.php b/htdocs/product/stock/class/mouvementstock.class.php index ea0a4aee05b..c95f8b9b3a3 100644 --- a/htdocs/product/stock/class/mouvementstock.class.php +++ b/htdocs/product/stock/class/mouvementstock.class.php @@ -193,7 +193,7 @@ class MouvementStock if (! $error) { - $sql = "UPDATE ".MAIN_DB_PREFIX."product SET pmp = ".$newpmp.", stock = stock + ".$qty; + $sql = "UPDATE ".MAIN_DB_PREFIX."product SET pmp = ".$newpmp.", stock = IFNULL(stock, 0) + ".$qty; $sql.= " WHERE rowid = ".$fk_product; dol_syslog("MouvementStock::_create sql=".$sql); diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 047a61f4e02..3924838e7c7 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -2344,6 +2344,81 @@ class Societe extends CommonObject } } + /** + * Build and get $mysoc object + * + * @param Conf $conf Conf object (possibility to use another entity) + * @return void + */ + function getMysoc($conf) + { + global $langs; + + $this->id=0; + $this->name=(! empty($conf->global->MAIN_INFO_SOCIETE_NOM))?$conf->global->MAIN_INFO_SOCIETE_NOM:''; + $this->nom=$this->name; // deprecated + $this->address=(! empty($conf->global->MAIN_INFO_SOCIETE_ADRESSE))?$conf->global->MAIN_INFO_SOCIETE_ADRESSE:''; + $this->adresse=$this->address; // deprecated + $this->zip=(! empty($conf->global->MAIN_INFO_SOCIETE_CP))?$conf->global->MAIN_INFO_SOCIETE_CP:''; + $this->cp=$this->zip; // deprecated + $this->town=(! empty($conf->global->MAIN_INFO_SOCIETE_VILLE))?$conf->global->MAIN_INFO_SOCIETE_VILLE:''; + $this->ville=$this->town; // deprecated + $this->state_id=$conf->global->MAIN_INFO_SOCIETE_DEPARTEMENT; + $this->note=empty($conf->global->MAIN_INFO_SOCIETE_NOTE)?'':$conf->global->MAIN_INFO_SOCIETE_NOTE; + + // We define country_id, country_code and country + $country_id=$country_code=$country_label=''; + if (! empty($conf->global->MAIN_INFO_SOCIETE_PAYS)) + { + $tmp=explode(':',$conf->global->MAIN_INFO_SOCIETE_PAYS); + $country_id=$tmp[0]; + if (! empty($tmp[1])) // If $conf->global->MAIN_INFO_SOCIETE_PAYS is "id:code:label" + { + $country_code=$tmp[1]; + $country_label=$tmp[2]; + } + else // For backward compatibility + { + dol_syslog("Your country setup use an old syntax. Reedit it using setup area.", LOG_WARNING); + include_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; + $country_code=getCountry($country_id,2,$db); // This need a SQL request, but it's the old feature + $country_label=getCountry($country_id,0,$db); // This need a SQL request, but it's the old feature + } + } + $this->pays_id=$country_id; // TODO deprecated + $this->country_id=$country_id; + $this->pays_code=$country_code; // TODO deprecated + $this->country_code=$country_code; + $this->country=$country_label; + if (is_object($langs)) $this->country=($langs->trans('Country'.$country_code)!='Country'.$country_code)?$langs->trans('Country'.$country_code):$country_label; + $this->pays=$this->country; // TODO deprecated + + $this->tel=empty($conf->global->MAIN_INFO_SOCIETE_TEL)?'':$conf->global->MAIN_INFO_SOCIETE_TEL; // TODO deprecated + $this->phone=empty($conf->global->MAIN_INFO_SOCIETE_TEL)?'':$conf->global->MAIN_INFO_SOCIETE_TEL; + $this->fax=empty($conf->global->MAIN_INFO_SOCIETE_FAX)?'':$conf->global->MAIN_INFO_SOCIETE_FAX; + $this->url=empty($conf->global->MAIN_INFO_SOCIETE_WEB)?'':$conf->global->MAIN_INFO_SOCIETE_WEB; + // Id prof generiques + $this->idprof1=empty($conf->global->MAIN_INFO_SIREN)?'':$conf->global->MAIN_INFO_SIREN; + $this->idprof2=empty($conf->global->MAIN_INFO_SIRET)?'':$conf->global->MAIN_INFO_SIRET; + $this->idprof3=empty($conf->global->MAIN_INFO_APE)?'':$conf->global->MAIN_INFO_APE; + $this->idprof4=empty($conf->global->MAIN_INFO_RCS)?'':$conf->global->MAIN_INFO_RCS; + $this->idprof5=empty($conf->global->MAIN_INFO_PROFID5)?'':$conf->global->MAIN_INFO_PROFID5; + $this->idprof6=empty($conf->global->MAIN_INFO_PROFID6)?'':$conf->global->MAIN_INFO_PROFID6; + $this->tva_intra=(! empty($conf->global->MAIN_INFO_TVAINTRA))?$conf->global->MAIN_INFO_TVAINTRA:''; // VAT number, not necessarly INTRA. + $this->capital=(! empty($conf->global->MAIN_INFO_CAPITAL))?$conf->global->MAIN_INFO_CAPITAL:''; + $this->forme_juridique_code=$conf->global->MAIN_INFO_SOCIETE_FORME_JURIDIQUE; + $this->email=(! empty($conf->global->MAIN_INFO_SOCIETE_MAIL))?$conf->global->MAIN_INFO_SOCIETE_MAIL:''; + $this->logo=(! empty($conf->global->MAIN_INFO_SOCIETE_LOGO))?$conf->global->MAIN_INFO_SOCIETE_LOGO:''; + $this->logo_small=(! empty($conf->global->MAIN_INFO_SOCIETE_LOGO_SMALL))?$conf->global->MAIN_INFO_SOCIETE_LOGO_SMALL:''; + $this->logo_mini=(! empty($conf->global->MAIN_INFO_SOCIETE_LOGO_MINI))?$conf->global->MAIN_INFO_SOCIETE_LOGO_MINI:''; + + // Define if company use vat or not (Do not use conf->global->FACTURE_TVAOPTION anymore) + $this->tva_assuj=((isset($conf->global->FACTURE_TVAOPTION) && $conf->global->FACTURE_TVAOPTION=='franchise')?0:1); + + // Define if company use local taxes + $this->localtax1_assuj=((isset($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on')?1:0); + $this->localtax2_assuj=((isset($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on')?1:0); + } /** * Initialise an instance with random values. diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index 1542e51a5f1..ce7c2953e19 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -51,6 +51,7 @@ class User extends CommonObject var $firstname; var $note; var $email; + var $job; var $signature; var $office_phone; var $office_fax; @@ -138,7 +139,7 @@ class User extends CommonObject $login=trim($login); // Get user - $sql = "SELECT u.rowid, u.name, u.firstname, u.email, u.signature, u.office_phone, u.office_fax, u.user_mobile,"; + $sql = "SELECT u.rowid, u.name, u.firstname, u.email, u.job, u.signature, u.office_phone, u.office_fax, u.user_mobile,"; $sql.= " u.admin, u.login, u.webcal_login, u.phenix_login, u.phenix_pass, u.note,"; $sql.= " u.pass, u.pass_crypted, u.pass_temp,"; $sql.= " u.fk_societe, u.fk_socpeople, u.fk_member, u.ldap_sid,"; @@ -193,28 +194,29 @@ class User extends CommonObject $this->prenom = $obj->firstname; // TODO deprecated $this->firstname = $obj->firstname; - $this->login = $obj->login; + $this->login = $obj->login; $this->pass_indatabase = $obj->pass; $this->pass_indatabase_crypted = $obj->pass_crypted; - $this->pass = $obj->pass; - $this->pass_temp = $obj->pass_temp; - $this->office_phone = $obj->office_phone; + $this->pass = $obj->pass; + $this->pass_temp = $obj->pass_temp; + $this->office_phone = $obj->office_phone; $this->office_fax = $obj->office_fax; $this->user_mobile = $obj->user_mobile; - $this->email = $obj->email; - $this->signature = $obj->signature; - $this->admin = $obj->admin; - $this->note = $obj->note; - $this->statut = $obj->statut; - $this->photo = $obj->photo; - $this->openid = $obj->openid; - $this->lang = $obj->lang; - $this->entity = $obj->entity; + $this->email = $obj->email; + $this->job = $obj->job; + $this->signature = $obj->signature; + $this->admin = $obj->admin; + $this->note = $obj->note; + $this->statut = $obj->statut; + $this->photo = $obj->photo; + $this->openid = $obj->openid; + $this->lang = $obj->lang; + $this->entity = $obj->entity; - $this->datec = $this->db->jdate($obj->datec); - $this->datem = $this->db->jdate($obj->datem); - $this->datelastlogin = $this->db->jdate($obj->datel); - $this->datepreviouslogin = $this->db->jdate($obj->datep); + $this->datec = $this->db->jdate($obj->datec); + $this->datem = $this->db->jdate($obj->datem); + $this->datelastlogin = $this->db->jdate($obj->datel); + $this->datepreviouslogin = $this->db->jdate($obj->datep); $this->webcal_login = $obj->webcal_login; $this->phenix_login = $obj->phenix_login; @@ -1070,6 +1072,7 @@ class User extends CommonObject $this->office_fax = trim($this->office_fax); $this->user_mobile = trim($this->user_mobile); $this->email = trim($this->email); + $this->job = trim($this->job); $this->signature = trim($this->signature); $this->note = trim($this->note); $this->openid = trim(empty($this->openid)?'':$this->openid); // Avoid warning @@ -1101,7 +1104,8 @@ class User extends CommonObject $sql.= ", office_fax = '".$this->db->escape($this->office_fax)."'"; $sql.= ", user_mobile = '".$this->db->escape($this->user_mobile)."'"; $sql.= ", email = '".$this->db->escape($this->email)."'"; - $sql.= ", signature = '".addslashes($this->signature)."'"; + $sql.= ", job = '".$this->db->escape($this->job)."'"; + $sql.= ", signature = '".$this->db->escape($this->signature)."'"; $sql.= ", webcal_login = '".$this->db->escape($this->webcal_login)."'"; $sql.= ", phenix_login = '".$this->db->escape($this->phenix_login)."'"; $sql.= ", phenix_pass = '".$this->db->escape($this->phenix_pass)."'"; diff --git a/htdocs/user/fiche.php b/htdocs/user/fiche.php index 429be1f16e6..d3c1c40e877 100644 --- a/htdocs/user/fiche.php +++ b/htdocs/user/fiche.php @@ -183,12 +183,16 @@ if ($action == 'add' && $canadduser) $edituser->office_fax = $_POST["office_fax"]; $edituser->user_mobile = $_POST["user_mobile"]; $edituser->email = $_POST["email"]; - $edituser->webcal_login = $_POST["webcal_login"]; + $edituser->job = $_POST["job"]; $edituser->signature = $_POST["signature"]; - $edituser->phenix_login = $_POST["phenix_login"]; - $edituser->phenix_pass = $_POST["phenix_pass"]; $edituser->note = $_POST["note"]; $edituser->ldap_sid = $_POST["ldap_sid"]; + + // FIXME external module + $edituser->webcal_login = $_POST["webcal_login"]; + $edituser->phenix_login = $_POST["phenix_login"]; + $edituser->phenix_pass = $_POST["phenix_pass"]; + // If multicompany is off, admin users must all be on entity 0. if (! empty($conf->multicompany->enabled)) { @@ -301,11 +305,15 @@ if ($action == 'update' && ! $_POST["cancel"]) $edituser->office_fax = $_POST["office_fax"]; $edituser->user_mobile = $_POST["user_mobile"]; $edituser->email = $_POST["email"]; + $edituser->job = $_POST["job"]; $edituser->signature = $_POST["signature"]; $edituser->openid = $_POST["openid"]; + + // FIXME external module $edituser->webcal_login = $_POST["webcal_login"]; $edituser->phenix_login = $_POST["phenix_login"]; $edituser->phenix_pass = $_POST["phenix_pass"]; + if (! empty($conf->multicompany->enabled)) { if (! empty($_POST["superadmin"])) @@ -639,6 +647,12 @@ if (($action == 'create') || ($action == 'adduserldap')) } print ''; + // Position/Job + print ''.$langs->trans("PostOrFunction").''; + print ''; + print ''; + print ''; + // Login print ''.$langs->trans("Login").''; print ''; @@ -996,6 +1010,11 @@ else print ''.$fuser->prenom.''; print ''."\n"; + // Position/Job + print ''.$langs->trans("PostOrFunction").''; + print ''.$fuser->job.''; + print ''."\n"; + // Login print ''.$langs->trans("Login").''; if (! empty($fuser->ldap_sid) && $fuser->statut==0) @@ -1488,6 +1507,12 @@ else } print ''; + // Position/Job + print ''.$langs->trans("PostOrFunction").''; + print ''; + print ''; + print ''; + // Login print "".''.$langs->trans("Login").''; print ''; diff --git a/htdocs/user/perms.php b/htdocs/user/perms.php index e229db46c32..0a1ecd72b56 100644 --- a/htdocs/user/perms.php +++ b/htdocs/user/perms.php @@ -4,6 +4,7 @@ * Copyright (C) 2004-2012 Laurent Destailleur * Copyright (C) 2004 Eric Seigne * Copyright (C) 2005-2012 Regis Houssin + * Copyright (C) 2012 Juanjo Menent * * 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 @@ -365,17 +366,21 @@ if ($result) print img_picto($langs->trans("Active"),'tick'); print ''; } - else if (in_array($obj->id, $permsgroupbyentity[$entity])) // Permission own by group + + else if (is_array($permsgroupbyentity[$entity])) { - if ($caneditperms) - { - print ''; - print $form->textwithtooltip($langs->trans("Inherited"),$langs->trans("PermissionInheritedFromAGroup")); - print ''; - } - print ''; - print img_picto($langs->trans("Active"),'tick'); - print ''; + if (in_array($obj->id, $permsgroupbyentity[$entity])) // Permission own by group + { + if ($caneditperms) + { + print ''; + print $form->textwithtooltip($langs->trans("Inherited"),$langs->trans("PermissionInheritedFromAGroup")); + print ''; + } + print ''; + print img_picto($langs->trans("Active"),'tick'); + print ''; + } } else {