Merge remote-tracking branch 'origin/3.4' into develop

Conflicts:
	ChangeLog
	htdocs/commande/fiche.php
	htdocs/core/class/extrafields.class.php
	htdocs/core/modules/livraison/pdf/pdf_typhon.modules.php
This commit is contained in:
Laurent Destailleur 2013-07-27 14:21:47 +02:00
commit 67820774bb
23 changed files with 302 additions and 240 deletions

View File

@ -2,7 +2,7 @@
English Dolibarr ChangeLog English Dolibarr ChangeLog
-------------------------------------------------------------- --------------------------------------------------------------
***** ChangeLog for 3.5 compared to 3.4 ***** ***** ChangeLog for 3.5 compared to 3.4.* *****
For users: For users:
- New: [ task #862 ] Add ODT on shipments - New: [ task #862 ] Add ODT on shipments
- New: [ task #149 ] Add # of notes and attachments in tabs - New: [ task #149 ] Add # of notes and attachments in tabs
@ -78,7 +78,7 @@ this was not a good pratice, since object->id is already known so no need to pro
parameter. All methods addline in this case were modified to remove this information. parameter. All methods addline in this case were modified to remove this information.
***** ChangeLog for 3.4 compared to 3.3.2 ***** ***** ChangeLog for 3.4 compared to 3.3.* *****
For users: For users:
- New: Can use ODS templates as document templates. - New: Can use ODS templates as document templates.
- New: Add link to autofill/reset with quantity to ship when creating a - New: Add link to autofill/reset with quantity to ship when creating a
@ -168,6 +168,8 @@ WARNING: If you used external modules, some of them may need to be upgraded due
function to keep same behaviour. function to keep same behaviour.
***** ChangeLog for 3.3.4 compared to 3.3.3 *****
- Fix: [ bug #1001 ] Social Contribution : State not correct
***** ChangeLog for 3.3.3 compared to 3.3.2 ***** ***** ChangeLog for 3.3.3 compared to 3.3.2 *****
- Fix: [ bug #903 ] Fatal error: Call to undefined function dol_get_first_day() in htdocs/commande/liste.php - Fix: [ bug #903 ] Fatal error: Call to undefined function dol_get_first_day() in htdocs/commande/liste.php
@ -212,7 +214,7 @@ WARNING: If you used external modules, some of them may need to be upgraded due
- Fix: [ bug #762 ] Bad profit calculation in Reporting - Fix: [ bug #762 ] Bad profit calculation in Reporting
- Fix: bug dictionnary with wrong prefix table - Fix: bug dictionnary with wrong prefix table
***** ChangeLog for 3.3 compared to 3.2.3 ***** ***** ChangeLog for 3.3 compared to 3.2.* *****
For users: For users:
- New: Add holiday module, to declare and follow holidays of your employees. - New: Add holiday module, to declare and follow holidays of your employees.
- New: Add margin management module. - New: Add margin management module.
@ -390,7 +392,7 @@ Dolibarr license has also been updated from GPLv2+ to GPLv3+.
***** ChangeLog for 3.2.0 compared to 3.1.3 ***** ***** ChangeLog for 3.2.0 compared to 3.1.* *****
WARNING: PHP lower than 5.x are no more supported. WARNING: PHP lower than 5.x are no more supported.
WARNING: Because of a major datastructure change onto supplier prices tables, be aware WARNING: Because of a major datastructure change onto supplier prices tables, be aware
to make a backup of your database before making upgrade. to make a backup of your database before making upgrade.
@ -631,7 +633,7 @@ For translators:
***** ChangeLog for 3.0 compared to 2.9 ***** ***** ChangeLog for 3.0 compared to 2.9.* *****
For users: For users:
- New: Can edit date of cheque receipts. - New: Can edit date of cheque receipts.
@ -727,7 +729,7 @@ For developers:
- Qual: Removed deprecated code. - Qual: Removed deprecated code.
***** ChangeLog for 2.9 compared to 2.8 ***** ***** ChangeLog for 2.9 compared to 2.8.* *****
For users: For users:
- New: POS module allow to choose which warehouse to use. - New: POS module allow to choose which warehouse to use.
@ -845,7 +847,7 @@ For users:
- Fix: bug #29526 : Numérotation Proposition Incorrecte après duplication - Fix: bug #29526 : Numérotation Proposition Incorrecte après duplication
***** ChangeLog for 2.8 compared to 2.7 ***** ***** ChangeLog for 2.8 compared to 2.7.* *****
For users: For users:
- New: Support note on trips module - New: Support note on trips module
@ -909,7 +911,7 @@ For users:
- Fix: Update member photo. - Fix: Update member photo.
***** ChangeLog for 2.7 compared to 2.6 ***** ***** ChangeLog for 2.7 compared to 2.6.* *****
For users: For users:
- New: Add a print icon to show a page to print without menus. - New: Add a print icon to show a page to print without menus.
@ -1008,7 +1010,7 @@ For developers:
- All install files are now in same directory /install. - All install files are now in same directory /install.
***** ChangeLog for 2.6 compared to 2.5 ***** ***** ChangeLog for 2.6 compared to 2.5.* *****
For users: For users:
- New: Add filter on status in emailing selector for Dolibarr users. - New: Add filter on status in emailing selector for Dolibarr users.
@ -1091,7 +1093,7 @@ For developers:
- First change for future geoip module. - First change for future geoip module.
***** ChangeLog for 2.5 compared to 2.4 ***** ***** ChangeLog for 2.5 compared to 2.4.* *****
For users: For users:
- Sessions timeout can be configured to overwrite PHP setup. - Sessions timeout can be configured to overwrite PHP setup.
@ -1155,7 +1157,7 @@ For developers:
***** ChangeLog for 2.4 compared to 2.2 ***** ***** ChangeLog for 2.4 compared to 2.2.* *****
For users: For users:
- Add a calendar module (module agenda) with ical/vcal/rss export. - Add a calendar module (module agenda) with ical/vcal/rss export.
@ -1210,7 +1212,7 @@ For developers:
Windows with Apache and Mysql included. Windows with Apache and Mysql included.
***** ChangeLog for 2.2 compared to 2.1 ***** ***** ChangeLog for 2.2 compared to 2.1.* *****
- Add more statistics on main page. - Add more statistics on main page.
- Add option to add message on login page. - Add option to add message on login page.
@ -1244,7 +1246,7 @@ For developers:
- Can drag and drop boxes on main page. - Can drag and drop boxes on main page.
***** ChangeLog for 2.1 compared to 2.0.1 ***** ***** ChangeLog for 2.1 compared to 2.0.* *****
- Added a better installer. - Added a better installer.
- Support user and groups permissions. - Support user and groups permissions.
@ -1315,7 +1317,7 @@ Minor bug fixes
***** ChangeLog for 2.0 compared to 1.0 ***** ***** ChangeLog for 2.0 compared to 1.0.* *****
ChangeLog file size is so important, that it is not included inside Dolibarr ChangeLog file size is so important, that it is not included inside Dolibarr
package. You can find it at www.dolibarr.org package. You can find it at www.dolibarr.org

View File

@ -914,7 +914,7 @@ else
// Login Dolibarr // Login Dolibarr
print '<tr><td>'.$langs->trans("LinkedToDolibarrUser").'</td><td class="valeur">'; print '<tr><td>'.$langs->trans("LinkedToDolibarrUser").'</td><td class="valeur">';
print $form->select_users($object->user_id,'userid',1); print $form->select_dolusers($object->user_id,'userid',1);
print '</td></tr>'; print '</td></tr>';
*/ */

View File

@ -155,7 +155,7 @@ $filter='s.client in (1,2,3)';
print $form->select_company($id,'memberid',$filter,1); print $form->select_company($id,'memberid',$filter,1);
print '</td></tr>'; print '</td></tr>';
print '<tr><td>'.$langs->trans("User").'</td><td>'; print '<tr><td>'.$langs->trans("User").'</td><td>';
print $form->select_users($userid,'userid',1); print $form->select_dolusers($userid,'userid',1);
print '</td></tr>'; print '</td></tr>';
print '<tr><td align="center" colspan="2"><input type="submit" name="submit" class="button" value="'.$langs->trans("Refresh").'"></td></tr>'; print '<tr><td align="center" colspan="2"><input type="submit" name="submit" class="button" value="'.$langs->trans("Refresh").'"></td></tr>';
print '</table>'; print '</table>';

View File

@ -142,7 +142,7 @@ print "</tr>";
print '<tr class="impair"><td>'.$langs->trans("ResponsibleUser").'</td>'; print '<tr class="impair"><td>'.$langs->trans("ResponsibleUser").'</td>';
print '<td align="left">'; print '<td align="left">';
print '<input type="hidden" name="nom0" value="PRELEVEMENT_USER">'; print '<input type="hidden" name="nom0" value="PRELEVEMENT_USER">';
print $form->select_users($conf->global->PRELEVEMENT_USER,'value0',1); print $form->select_dolusers($conf->global->PRELEVEMENT_USER,'value0',1);
print '</td>'; print '</td>';
print '</tr>'; print '</tr>';

View File

@ -331,7 +331,7 @@ else if ($action == 'add' && $user->rights->propal->creer)
$object->origin = GETPOST('origin'); $object->origin = GETPOST('origin');
$object->origin_id = GETPOST('originid'); $object->origin_id = GETPOST('originid');
for ($i = 1 ; $i <= $conf->global->PRODUCT_SHOW_WHEN_CREATE; $i++) for ($i = 1; $i <= $conf->global->PRODUCT_SHOW_WHEN_CREATE; $i++)
{ {
if ($_POST['idprod'.$i]) if ($_POST['idprod'.$i])
{ {
@ -344,55 +344,61 @@ else if ($action == 'add' && $user->rights->propal->creer)
// Fill array 'array_options' with data from add form // Fill array 'array_options' with data from add form
$ret = $extrafields->setOptionalsFromPost($extralabels,$object); $ret = $extrafields->setOptionalsFromPost($extralabels,$object);
if($ret < 0) {
$id = $object->create($user); $error++;
$action = 'create';
}
} }
if ($id > 0) if(!$error) {
{ $id = $object->create($user);
// Insertion contact par defaut si defini
if (GETPOST('contactidp') > 0)
{
$result=$object->add_contact(GETPOST('contactidp'),'CUSTOMER','external');
if ($result < 0)
{
$error++;
setEventMessage($langs->trans("ErrorFailedToAddContact"), 'errors');
}
}
if (! $error) if ($id > 0)
{ {
$db->commit(); // Insertion contact par defaut si defini
if (GETPOST('contactidp') > 0)
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
{ {
// Define output language $result=$object->add_contact(GETPOST('contactidp'),'CUSTOMER','external');
$outputlangs = $langs; if ($result < 0)
if (! empty($conf->global->MAIN_MULTILANGS))
{ {
$outputlangs = new Translate("",$conf); $error++;
$newlang=(GETPOST('lang_id') ? GETPOST('lang_id') : $object->client->default_lang); setEventMessage($langs->trans("ErrorFailedToAddContact"), 'errors');
$outputlangs->setDefaultLang($newlang);
} }
$ret=$object->fetch($id); // Reload to get new records
propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
} }
header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id); if (! $error)
exit; {
$db->commit();
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);
}
header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id);
exit;
}
else
{
$db->rollback();
}
} }
else else
{ {
dol_print_error($db,$object->error);
$db->rollback(); $db->rollback();
exit;
} }
} }
else
{
dol_print_error($db,$object->error);
$db->rollback();
exit;
}
} }
} }
@ -1150,24 +1156,30 @@ else if ($action == 'update_extras')
$extralabels=$extrafields->fetch_name_optionals_label($object->table_element); $extralabels=$extrafields->fetch_name_optionals_label($object->table_element);
$ret = $extrafields->setOptionalsFromPost($extralabels,$object); $ret = $extrafields->setOptionalsFromPost($extralabels,$object);
// Actions on extra fields (by external module or standard code) if($ret < 0) {
// FIXME le hook fait double emploi avec le trigger !! $error++;
$hookmanager->initHooks(array('propaldao')); $action = 'edit_extras';
$parameters=array('id'=>$object->id); }
$reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
if (empty($reshook)) if(!$error) {
{ // Actions on extra fields (by external module or standard code)
if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used // FIXME le hook fait double emploi avec le trigger !!
$hookmanager->initHooks(array('propaldao'));
$parameters=array('id'=>$object->id);
$reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
if (empty($reshook))
{ {
$result=$object->insertExtraFields(); if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used
if ($result < 0)
{ {
$error++; $result=$object->insertExtraFields();
if ($result < 0)
{
$error++;
}
} }
} }
else if ($reshook < 0) $error++;
} }
else if ($reshook < 0) $error++;
} }
if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && $user->rights->propal->creer) if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && $user->rights->propal->creer)

View File

@ -235,7 +235,7 @@ print '<div class="fichecenter"><div class="fichethirdleft">';
print '</td></tr>'; print '</td></tr>';
// User // User
print '<tr><td align="left">'.$langs->trans("CreatedBy").'</td><td align="left">'; print '<tr><td align="left">'.$langs->trans("CreatedBy").'</td><td align="left">';
print $form->select_users($userid,'userid',1); print $form->select_dolusers($userid,'userid',1);
print '</td></tr>'; print '</td></tr>';
// Year // Year
print '<tr><td align="left">'.$langs->trans("Year").'</td><td align="left">'; print '<tr><td align="left">'.$langs->trans("Year").'</td><td align="left">';

View File

@ -274,124 +274,137 @@ else if ($action == 'add' && $user->rights->commande->creer)
// Fill array 'array_options' with data from add form // Fill array 'array_options' with data from add form
$ret = $extrafields->setOptionalsFromPost($extralabels,$object); $ret = $extrafields->setOptionalsFromPost($extralabels,$object);
if($ret < 0)
$error++;
$object_id = $object->create($user); if(!$error) {
$object_id = $object->create($user);
if ($object_id > 0) if ($object_id > 0)
{
dol_include_once('/'.$element.'/class/'.$subelement.'.class.php');
$classname = ucfirst($subelement);
$srcobject = new $classname($db);
dol_syslog("Try to find source object origin=".$object->origin." originid=".$object->origin_id." to add lines");
$result=$srcobject->fetch($object->origin_id);
if ($result > 0)
{ {
$lines = $srcobject->lines; dol_include_once('/'.$element.'/class/'.$subelement.'.class.php');
if (empty($lines) && method_exists($srcobject,'fetch_lines')) $lines = $srcobject->fetch_lines();
$fk_parent_line=0; $classname = ucfirst($subelement);
$num=count($lines); $srcobject = new $classname($db);
for ($i=0;$i<$num;$i++) dol_syslog("Try to find source object origin=".$object->origin." originid=".$object->origin_id." to add lines");
$result=$srcobject->fetch($object->origin_id);
if ($result > 0)
{ {
$label=(! empty($lines[$i]->label)?$lines[$i]->label:''); $lines = $srcobject->lines;
$desc=(! empty($lines[$i]->desc)?$lines[$i]->desc:$lines[$i]->libelle); if (empty($lines) && method_exists($srcobject,'fetch_lines')) $lines = $srcobject->fetch_lines();
$product_type=(! empty($lines[$i]->product_type)?$lines[$i]->product_type:0);
// Dates $fk_parent_line=0;
// TODO mutualiser $num=count($lines);
$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=$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 for ($i=0;$i<$num;$i++)
if (($lines[$i]->product_type != 9 && empty($lines[$i]->fk_parent_line)) || $lines[$i]->product_type == 9) {
$fk_parent_line = 0;
}
//Extrafields
if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && method_exists($lines[$i],'fetch_optionals') ) // For avoid conflicts if trigger used
{ {
$lines[$i]->fetch_optionals($lines[$i]->rowid); $label=(! empty($lines[$i]->label)?$lines[$i]->label:'');
$array_option=$lines[$i]->array_options; $desc=(! empty($lines[$i]->desc)?$lines[$i]->desc:$lines[$i]->libelle);
$product_type=(! empty($lines[$i]->product_type)?$lines[$i]->product_type:0);
// Dates
// TODO mutualiser
$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=$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;
}
//Extrafields
if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && method_exists($lines[$i],'fetch_optionals') ) // For avoid conflicts if trigger used
{
$lines[$i]->fetch_optionals($lines[$i]->rowid);
$array_option=$lines[$i]->array_options;
}
$result = $object->addline(
$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,
$lines[$i]->info_bits,
$lines[$i]->fk_remise_except,
'HT',
0,
$date_start,
$date_end,
$product_type,
$lines[$i]->rang,
$lines[$i]->special_code,
$fk_parent_line,
$lines[$i]->fk_fournprice,
$lines[$i]->pa_ht,
$label,
$array_option
);
if ($result < 0)
{
$error++;
break;
}
// Defined the new fk_parent_line
if ($result > 0 && $lines[$i]->product_type == 9) {
$fk_parent_line = $result;
}
} }
$result = $object->addline( // Hooks
$desc, $parameters=array('objFrom'=>$srcobject);
$lines[$i]->subprice, $reshook=$hookmanager->executeHooks('createFrom',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
$lines[$i]->qty, if ($reshook < 0) $error++;
$lines[$i]->tva_tx, }
$lines[$i]->localtax1_tx, else
$lines[$i]->localtax2_tx, {
$lines[$i]->fk_product, $mesg=$srcobject->error;
$lines[$i]->remise_percent, $error++;
$lines[$i]->info_bits,
$lines[$i]->fk_remise_except,
'HT',
0,
$date_start,
$date_end,
$product_type,
$lines[$i]->rang,
$lines[$i]->special_code,
$fk_parent_line,
$lines[$i]->fk_fournprice,
$lines[$i]->pa_ht,
$label,
$array_option
);
if ($result < 0)
{
$error++;
break;
}
// Defined the new fk_parent_line
if ($result > 0 && $lines[$i]->product_type == 9) {
$fk_parent_line = $result;
}
} }
// Hooks
$parameters=array('objFrom'=>$srcobject);
$reshook=$hookmanager->executeHooks('createFrom',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
if ($reshook < 0) $error++;
} }
else else
{ {
$mesg=$srcobject->error; $mesg=$object->error;
$error++; $error++;
} }
} }
else else
{ {
$mesg=$object->error; // Required extrafield left blank, error message already defined by setOptionalsFromPost()
$error++; $action='create';
} }
} }
else else
{ {
// Fill array 'array_options' with data from add form // Fill array 'array_options' with data from add form
$ret = $extrafields->setOptionalsFromPost($extralabels,$object); $ret = $extrafields->setOptionalsFromPost($extralabels,$object);
if($ret < 0)
$error++;
$object_id = $object->create($user); if(!$error) {
$object_id = $object->create($user);
// If some invoice's lines already known // If some invoice's lines already known
$NBLINES=8; $NBLINES=8;
for ($i = 1 ; $i <= $NBLINES ; $i++) for ($i = 1 ; $i <= $NBLINES ; $i++)
{
if ($_POST['idprod'.$i])
{ {
$xid = 'idprod'.$i; if ($_POST['idprod'.$i])
$xqty = 'qty'.$i; {
$xremise = 'remise_percent'.$i; $xid = 'idprod'.$i;
$object->add_product($_POST[$xid],$_POST[$xqty],$_POST[$xremise]); $xqty = 'qty'.$i;
$xremise = 'remise_percent'.$i;
$object->add_product($_POST[$xid],$_POST[$xqty],$_POST[$xremise]);
}
} }
} }
} }
@ -1167,23 +1180,32 @@ else if ($action == 'update_extras')
$extralabels=$extrafields->fetch_name_optionals_label($object->table_element); $extralabels=$extrafields->fetch_name_optionals_label($object->table_element);
$ret = $extrafields->setOptionalsFromPost($extralabels,$object); $ret = $extrafields->setOptionalsFromPost($extralabels,$object);
// Actions on extra fields (by external module or standard code) if($ret < 0)
// FIXME le hook fait double emploi avec le trigger !! $error++;
$hookmanager->initHooks(array('orderdao'));
$parameters=array('id'=>$object->id); if(!$error) {
$reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks // Actions on extra fields (by external module or standard code)
if (empty($reshook)) // FIXME le hook fait double emploi avec le trigger !!
{ $hookmanager->initHooks(array('orderdao'));
if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used $parameters=array('id'=>$object->id);
$reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
if (empty($reshook))
{ {
$result=$object->insertExtraFields(); if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used
if ($result < 0)
{ {
$error++; $result=$object->insertExtraFields();
if ($result < 0)
{
$error++;
}
} }
} }
else if ($reshook < 0) $error++;
}
else
{
$action = 'edit_extras';
} }
else if ($reshook < 0) $error++;
} }
@ -1372,7 +1394,7 @@ if ($action == 'send' && ! GETPOST('addfile') && ! GETPOST('removedfile') && ! G
} }
} }
if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && $user->rights->commande->creer) if (! $error && ! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && $user->rights->commande->creer)
{ {
if ($action == 'addcontact') if ($action == 'addcontact')
{ {

View File

@ -257,7 +257,7 @@ print '<div class="fichecenter"><div class="fichethirdleft">';
print '</td></tr>'; print '</td></tr>';
// User // User
print '<tr><td align="left">'.$langs->trans("CreatedBy").'</td><td align="left">'; print '<tr><td align="left">'.$langs->trans("CreatedBy").'</td><td align="left">';
print $form->select_users($userid,'userid',1); print $form->select_dolusers($userid,'userid',1);
print '</td></tr>'; print '</td></tr>';
// Year // Year
print '<tr><td align="left">'.$langs->trans("Year").'</td><td align="left">'; print '<tr><td align="left">'.$langs->trans("Year").'</td><td align="left">';

View File

@ -280,7 +280,7 @@ if ($action == 'create')
print "<tr>"; print "<tr>";
print '<td class="fieldrequired">'.$langs->trans("Person").'</td><td>'; print '<td class="fieldrequired">'.$langs->trans("Person").'</td><td>';
print $form->select_users(GETPOST('fk_user','int'),'fk_user',1); print $form->select_dolusers(GETPOST('fk_user','int'),'fk_user',1);
print '</td></tr>'; print '</td></tr>';
print "<tr>"; print "<tr>";
@ -375,7 +375,7 @@ else if ($id)
// Who // Who
print "<tr>"; print "<tr>";
print '<td class="fieldrequired">'.$langs->trans("Person").'</td><td>'; print '<td class="fieldrequired">'.$langs->trans("Person").'</td><td>';
print $form->select_users(GETPOST('fk_user','int')?GETPOST('fk_user','int'):$object->fk_user,'fk_user',0); print $form->select_dolusers(GETPOST('fk_user','int')?GETPOST('fk_user','int'):$object->fk_user,'fk_user',0);
print '</td></tr>'; print '</td></tr>';
// Date // Date

View File

@ -220,7 +220,7 @@ print $form->select_company($socid,'socid',$filter,1,1);
print '</td></tr>'; print '</td></tr>';
// User // User
print '<tr><td>'.$langs->trans("User").'/'.$langs->trans("SalesRepresentative").'</td><td>'; print '<tr><td>'.$langs->trans("User").'/'.$langs->trans("SalesRepresentative").'</td><td>';
print $form->select_users($userid,'userid',1); print $form->select_dolusers($userid,'userid',1);
print '</td></tr>'; print '</td></tr>';
// Year // Year
print '<tr><td>'.$langs->trans("Year").'</td><td>'; print '<tr><td>'.$langs->trans("Year").'</td><td>';

View File

@ -661,7 +661,8 @@ else if ($action == 'add' && $user->rights->facture->creer)
// Fill array 'array_options' with data from add form // Fill array 'array_options' with data from add form
$extralabels=$extrafields->fetch_name_optionals_label($object->table_element); $extralabels=$extrafields->fetch_name_optionals_label($object->table_element);
$ret = $extrafields->setOptionalsFromPost($extralabels,$object); $ret = $extrafields->setOptionalsFromPost($extralabels,$object);
if($ret < 0)
$error++;
// Replacement invoice // Replacement invoice
if ($_POST['type'] == 1) if ($_POST['type'] == 1)
@ -1906,24 +1907,32 @@ if ($action == 'update_extras')
// Fill array 'array_options' with data from add form // Fill array 'array_options' with data from add form
$extralabels=$extrafields->fetch_name_optionals_label($object->table_element); $extralabels=$extrafields->fetch_name_optionals_label($object->table_element);
$ret = $extrafields->setOptionalsFromPost($extralabels,$object); $ret = $extrafields->setOptionalsFromPost($extralabels,$object);
if($ret < 0)
$error++;
// Actions on extra fields (by external module or standard code) if(!$error) {
// FIXME le hook fait double emploi avec le trigger !! // Actions on extra fields (by external module or standard code)
$hookmanager->initHooks(array('invoicedao')); // FIXME le hook fait double emploi avec le trigger !!
$parameters=array('id'=>$object->id); $hookmanager->initHooks(array('invoicedao'));
$reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks $parameters=array('id'=>$object->id);
if (empty($reshook)) $reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
{ if (empty($reshook))
if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used
{ {
$result=$object->insertExtraFields(); if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used
if ($result < 0)
{ {
$error++; $result=$object->insertExtraFields();
if ($result < 0)
{
$error++;
}
} }
} }
else if ($reshook < 0) $error++;
}
else
{
$action = 'edit_extras';
} }
else if ($reshook < 0) $error++;
} }

View File

@ -235,7 +235,7 @@ print '<div class="fichecenter"><div class="fichethirdleft">';
print '</td></tr>'; print '</td></tr>';
// User // User
print '<tr><td>'.$langs->trans("CreatedBy").'</td><td>'; print '<tr><td>'.$langs->trans("CreatedBy").'</td><td>';
print $form->select_users($userid,'userid',1); print $form->select_dolusers($userid,'userid',1);
print '</td></tr>'; print '</td></tr>';
// Year // Year
print '<tr><td>'.$langs->trans("Year").'</td><td>'; print '<tr><td>'.$langs->trans("Year").'</td><td>';

View File

@ -262,7 +262,7 @@ if ($resql)
// Expected to pay // Expected to pay
print '<td align="right">'.price($objp->sc_amount).'</td>'; print '<td align="right">'.price($objp->sc_amount).'</td>';
// Status // Status
print '<td align="center">'.$socialcontrib->LibStatut($objp->fk_statut,2).'</td>'; print '<td align="center">'.$socialcontrib->getLibStatut(4).'</td>';
// Amount payed // Amount payed
print '<td align="right">'.price($objp->amount).'</td>'; print '<td align="right">'.price($objp->amount).'</td>';
print "</tr>\n"; print "</tr>\n";

View File

@ -850,12 +850,12 @@ if ($action == 'create')
// Commercial suivi // Commercial suivi
print '<tr><td width="20%" nowrap><span class="fieldrequired">'.$langs->trans("TypeContact_contrat_internal_SALESREPFOLL").'</span></td><td>'; print '<tr><td width="20%" nowrap><span class="fieldrequired">'.$langs->trans("TypeContact_contrat_internal_SALESREPFOLL").'</span></td><td>';
print $form->select_users(GETPOST("commercial_suivi_id")?GETPOST("commercial_suivi_id"):$user->id,'commercial_suivi_id',1,''); print $form->select_dolusers(GETPOST("commercial_suivi_id")?GETPOST("commercial_suivi_id"):$user->id,'commercial_suivi_id',1,'');
print '</td></tr>'; print '</td></tr>';
// Commercial signature // Commercial signature
print '<tr><td width="20%" nowrap><span class="fieldrequired">'.$langs->trans("TypeContact_contrat_internal_SALESREPSIGN").'</span></td><td>'; print '<tr><td width="20%" nowrap><span class="fieldrequired">'.$langs->trans("TypeContact_contrat_internal_SALESREPSIGN").'</span></td><td>';
print $form->select_users(GETPOST("commercial_signature_id")?GETPOST("commercial_signature_id"):$user->id,'commercial_signature_id',1,''); print $form->select_dolusers(GETPOST("commercial_signature_id")?GETPOST("commercial_signature_id"):$user->id,'commercial_signature_id',1,'');
print '</td></tr>'; print '</td></tr>';
print '<tr><td><span class="fieldrequired">'.$langs->trans("Date").'</span></td><td>'; print '<tr><td><span class="fieldrequired">'.$langs->trans("Date").'</span></td><td>';

View File

@ -2254,6 +2254,10 @@ abstract class CommonObject
{ {
$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"]):$this->db->jdate($this->array_options['options_'.$key]); $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"]):$this->db->jdate($this->array_options['options_'.$key]);
} }
if($extrafields->attribute_required[$key])
$label = '<span class="fieldrequired">'.$label.'</span>';
$out .= '<td>'.$label.'</td>'; $out .= '<td>'.$label.'</td>';
$out .='<td colspan="'.$colspan.'">'; $out .='<td colspan="'.$colspan.'">';

View File

@ -23,13 +23,13 @@
/** /**
* \file htdocs/core/class/extrafields.class.php * \file htdocs/core/class/extrafields.class.php
* \ingroup core * \ingroup core
* \brief File of class to manage extra fields * \brief File of class to manage extra fields
*/ */
/** /**
* Class to manage standard extra fields * Class to manage standard extra fields
*/ */
class ExtraFields class ExtraFields
{ {
var $db; var $db;
@ -683,16 +683,18 @@ class ExtraFields
} }
elseif ($type == 'sellist') elseif ($type == 'sellist')
{ {
$out='<select class="flat" name="options_'.$key.'">'; $out='<select class="flat" name="options_'.$key.'">';
$param_list=array_keys($param['options']); if (is_array($param['options'])) {
$InfoFieldList = explode(":", $param_list[0]); $param_list=array_keys($param['options']);
$InfoFieldList = explode(":", $param_list[0]);
// 0 1 : tableName // 0 1 : tableName
// 1 2 : label field name Nom du champ contenant le libelle // 1 2 : label field name Nom du champ contenant le libelle
// 2 3 : key fields name (if differ of rowid) // 2 3 : key fields name (if differ of rowid)
// 3 4 : key field parent (for dependent lists) // 3 4 : key field parent (for dependent lists)
$keyList='rowid'; $keyList='rowid';
if (count($InfoFieldList)>=3) if (count($InfoFieldList)>=3)
$keyList=$InfoFieldList[2].' as rowid'; $keyList=$InfoFieldList[2].' as rowid';
@ -717,17 +719,15 @@ class ExtraFields
$sql.= ' FROM '.MAIN_DB_PREFIX .$InfoFieldList[0]; $sql.= ' FROM '.MAIN_DB_PREFIX .$InfoFieldList[0];
//$sql.= ' WHERE entity = '.$conf->entity; //$sql.= ' WHERE entity = '.$conf->entity;
dol_syslog(get_class($this).'::showInputField type=sellist sql='.$sql); dol_syslog(get_class($this).'::showInputField type=sellist sql='.$sql);
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if ($resql) if ($resql)
{
$out.='<option value="0">&nbsp;</option>';
$num = $this->db->num_rows($resql);
$i = 0;
if ($num)
{ {
while ($i < $num) $out.='<option value="0">&nbsp;</option>';
$num = $this->db->num_rows($resql);
$i = 0;
if ($num)
{ {
$labeltoshow=''; $labeltoshow='';
$obj = $this->db->fetch_object($resql); $obj = $this->db->fetch_object($resql);
@ -785,8 +785,8 @@ class ExtraFields
$i++; $i++;
} }
} }
$this->db->free();
} }
$this->db->free();
} }
$out.='</select>'; $out.='</select>';
} }
@ -993,7 +993,9 @@ class ExtraFields
*/ */
function setOptionalsFromPost($extralabels,&$object) function setOptionalsFromPost($extralabels,&$object)
{ {
global $_POST; global $_POST, $langs;
$nofillrequired='';// For error when required field left blank
$error_field_required = array();
if (is_array($extralabels)) if (is_array($extralabels))
{ {
@ -1001,6 +1003,11 @@ class ExtraFields
foreach ($extralabels as $key => $value) foreach ($extralabels as $key => $value)
{ {
$key_type = $this->attribute_type[$key]; $key_type = $this->attribute_type[$key];
if($this->attribute_required[$key] && !GETPOST("options_$key",2))
{
$nofillrequired++;
$error_field_required[] = $value;
}
if (in_array($key_type,array('date','datetime'))) if (in_array($key_type,array('date','datetime')))
{ {
@ -1028,7 +1035,14 @@ class ExtraFields
$object->array_options["options_".$key]=$value_key; $object->array_options["options_".$key]=$value_key;
} }
return 1; if($nofillrequired) {
$langs->load('errors');
setEventMessage($langs->trans('ErrorFieldsRequired').' : '.implode(', ',$error_field_required),'errors');
return -1;
}
else {
return 1;
}
} }
else { else {
return 0; return 0;
@ -1080,4 +1094,4 @@ class ExtraFields
return 0; return 0;
} }
} }
} }

View File

@ -1061,6 +1061,7 @@ class Form
* @param int $enableonly Array list of users id to be enabled. All other must be disabled * @param int $enableonly Array list of users id to be enabled. All other must be disabled
* @param int $force_entity 0 or Id of environment to force * @param int $force_entity 0 or Id of environment to force
* @return void * @return void
* @deprecated
*/ */
function select_users($selected='',$htmlname='userid',$show_empty=0,$exclude='',$disabled=0,$include='',$enableonly='',$force_entity=0) function select_users($selected='',$htmlname='userid',$show_empty=0,$exclude='',$disabled=0,$include='',$enableonly='',$force_entity=0)
{ {
@ -1079,9 +1080,10 @@ class Form
* @param array $enableonly Array list of users id to be enabled. All other must be disabled * @param array $enableonly Array list of users id to be enabled. All other must be disabled
* @param int $force_entity 0 or Id of environment to force * @param int $force_entity 0 or Id of environment to force
* @param int $maxlength Maximum length of string into list (0=no limit) * @param int $maxlength Maximum length of string into list (0=no limit)
* @param int $showstatus Show user status into label
* @return string HTML select string * @return string HTML select string
*/ */
function select_dolusers($selected='', $htmlname='userid', $show_empty=0, $exclude='', $disabled=0, $include='', $enableonly='', $force_entity=0, $maxlength=0) function select_dolusers($selected='', $htmlname='userid', $show_empty=0, $exclude='', $disabled=0, $include='', $enableonly='', $force_entity=0, $maxlength=0, $showstatus=0)
{ {
global $conf,$user,$langs; global $conf,$user,$langs;
@ -1142,7 +1144,7 @@ class Form
while ($i < $num) while ($i < $num)
{ {
$obj = $this->db->fetch_object($resql); $obj = $this->db->fetch_object($resql);
$userstatic->id=$obj->rowid; $userstatic->id=$obj->rowid;
$userstatic->lastname=$obj->lastname; $userstatic->lastname=$obj->lastname;
$userstatic->firstname=$obj->firstname; $userstatic->firstname=$obj->firstname;
@ -1164,13 +1166,10 @@ class Form
} }
$out.= $userstatic->getFullName($langs, 0, 0, $maxlength); $out.= $userstatic->getFullName($langs, 0, 0, $maxlength);
if ($obj->statut == 1) if ($showstatus)
{ {
$out.=" (".$langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'),'statut4').")"; if ($obj->statut == 1) $out.=" (".$langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'),'statut4').")";
} else $out.=" (".$langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'),'statut5').")";
else
{
$out.=" (".$langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'),'statut5').")";
} }
if (! empty($conf->multicompany->enabled) && empty($conf->multicompany->transverse_mode) && $conf->entity == 1 && $user->admin && ! $user->entity) if (! empty($conf->multicompany->enabled) && empty($conf->multicompany->transverse_mode) && $conf->entity == 1 && $user->admin && ! $user->entity)
@ -1182,7 +1181,7 @@ class Form
//if ($obj->admin) $out.= ' *'; //if ($obj->admin) $out.= ' *';
if (! empty($conf->global->MAIN_SHOW_LOGIN)) $out.= ' ('.$obj->login.')'; if (! empty($conf->global->MAIN_SHOW_LOGIN)) $out.= ' ('.$obj->login.')';
$out.= '</option>'; $out.= '</option>';
$i++; $i++;
} }
} }

View File

@ -347,9 +347,10 @@ class FormOther
* @param string $selected Preselected value * @param string $selected Preselected value
* @param string $htmlname Name of combo list (example: 'search_sale') * @param string $htmlname Name of combo list (example: 'search_sale')
* @param User $user Object user * @param User $user Object user
* @param int $showstatus Show user status into label
* @return string Html combo list code * @return string Html combo list code
*/ */
function select_salesrepresentatives($selected,$htmlname,$user) function select_salesrepresentatives($selected,$htmlname,$user,$showstatus=0)
{ {
global $conf,$langs; global $conf,$langs;
$langs->load('users'); $langs->load('users');
@ -385,13 +386,11 @@ class FormOther
if ($obj_usr->rowid == $selected) $moreforfilter.=' selected="selected"'; if ($obj_usr->rowid == $selected) $moreforfilter.=' selected="selected"';
$moreforfilter.='>'; $moreforfilter.='>';
if ($obj_usr->statut == 1) $moreforfilter.=dolGetFirstLastname($obj_usr->firstname,$obj_usr->name)." (".$obj_usr->login.')';
{ if ($showstatus)
$moreforfilter.=$obj_usr->firstname." ".$obj_usr->name." (".$obj_usr->login.')'." ". img_picto($langs->trans('Enabled'),'statut4').' '.$langs->trans('Enabled'); {
} if ($obj_usr->statut == 1) $moreforfilter.=" ". img_picto($langs->trans('Enabled'),'statut4').' '.$langs->trans('Enabled');
else else $moreforfilter.=" ". img_picto($langs->trans('Disabled'),'statut5').' '.$langs->trans('Disabled');
{
$moreforfilter.=$obj_usr->firstname." ".$obj_usr->name." (".$obj_usr->login.')'." ". img_picto($langs->trans('Disabled'),'statut5').' '.$langs->trans('Disabled');
} }
$moreforfilter.='</option>'; $moreforfilter.='</option>';
} }

View File

@ -787,6 +787,7 @@ class pdf_typhon extends ModelePDFDeliveryOrder
$pdf->MultiCell($widthrecbox, 4, $carac_client, 0, 'L'); $pdf->MultiCell($widthrecbox, 4, $carac_client, 0, 'L');
} }
$pdf->SetTextColor(0,0,60);
} }
/** /**

View File

@ -132,12 +132,12 @@ if ($resql)
print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">'; print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
print '<table class="noborder" width="100%">'; print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print_liste_field_titre($langs->trans("Ref"),$_SERVER["PHP_SELF"],"cf.ref","","",'',$sortfield,$sortorder); print_liste_field_titre($langs->trans("Ref"),$_SERVER["PHP_SELF"],"cf.ref","",$param,'',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Company"),$_SERVER["PHP_SELF"],"s.nom","","",'',$sortfield,$sortorder); print_liste_field_titre($langs->trans("Company"),$_SERVER["PHP_SELF"],"s.nom","",$param,'',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Author"),$_SERVER["PHP_SELF"],"u.login","","",'',$sortfield,$sortorder); print_liste_field_titre($langs->trans("Author"),$_SERVER["PHP_SELF"],"u.login","",$param,'',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("AmountTTC"),$_SERVER["PHP_SELF"],"total_ttc","","",'',$sortfield,$sortorder); print_liste_field_titre($langs->trans("AmountTTC"),$_SERVER["PHP_SELF"],"total_ttc","",$param,$sortfield,$sortorder);
print_liste_field_titre($langs->trans("OrderDate"),$_SERVER["PHP_SELF"],"dc","","",'align="center"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("OrderDate"),$_SERVER["PHP_SELF"],"dc","",$param,'align="center"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"cf.fk_statut","","",'align="right"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"cf.fk_statut","",$param,'align="right"',$sortfield,$sortorder);
print "</tr>\n"; print "</tr>\n";
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';

View File

@ -137,7 +137,7 @@ if($cp_events == 1)
print $langs->trans('MotifCP').' : '; print $langs->trans('MotifCP').' : ';
print $holiday->selectEventCP(); print $holiday->selectEventCP();
print ' &nbsp; '.$langs->trans('UserCP').' : '; print ' &nbsp; '.$langs->trans('UserCP').' : ';
print $form->select_users('',"userCP",1,"",0,''); print $form->select_dolusers('',"userCP",1,"",0,'');
print ' <input type="submit" value="'.$langs->trans("addEventToUserCP").'" name="bouton" class="button"/>'; print ' <input type="submit" value="'.$langs->trans("addEventToUserCP").'" name="bouton" class="button"/>';
print '</form><br>'; print '</form><br>';

View File

@ -299,7 +299,7 @@ if ($action == 'create' && $user->rights->projet->creer && (empty($object->socie
print '</td></tr>'; print '</td></tr>';
print '<tr><td>'.$langs->trans("AffectedTo").'</td><td>'; print '<tr><td>'.$langs->trans("AffectedTo").'</td><td>';
print $form->select_users($user->id,'userid',1); print $form->select_dolusers($user->id,'userid',1);
print '</td></tr>'; print '</td></tr>';
// Date start // Date start

View File

@ -323,7 +323,7 @@ if ($id > 0 || ! empty($ref))
print '<td class="nowrap">'; print '<td class="nowrap">';
$contactoftask=$object->getListContactId('internal'); $contactoftask=$object->getListContactId('internal');
print img_object('','user'); print img_object('','user');
print $form->select_users($_POST["userid"]?$_POST["userid"]:$user->id,'userid',0,'',0,'',$contactoftask); print $form->select_dolusers($_POST["userid"]?$_POST["userid"]:$user->id,'userid',0,'',0,'',$contactoftask);
print '</td>'; print '</td>';
// Note // Note
@ -412,7 +412,7 @@ if ($id > 0 || ! empty($ref))
print '<td>'; print '<td>';
if ($_GET['action'] == 'editline' && $_GET['lineid'] == $task_time->rowid) if ($_GET['action'] == 'editline' && $_GET['lineid'] == $task_time->rowid)
{ {
print $form->select_users($task_time->fk_user,'userid_line'); print $form->select_dolusers($task_time->fk_user,'userid_line');
} }
else else
{ {