diff --git a/COPYRIGHT b/COPYRIGHT index cb1dc3e0d29..510bf5d3b4f 100644 --- a/COPYRIGHT +++ b/COPYRIGHT @@ -14,7 +14,7 @@ Component Version License GPL Compatible PHP libraries: AdoDb-Date 0.36 Modified BSD License Yes Date convertion (not into rpm package) ChromePHP 4.1.0 Apache Software License 2.0 Yes Return server log to chrome browser console -CKEditor 4.6.2 LGPL-2.1+ Yes Editor WYSIWYG +CKEditor 4.11.4 LGPL-2.1+ Yes Editor WYSIWYG PHPDebugBar 1.15.0 MIT License Yes Used only by the module "debugbar" for developers EvalMath 1.0 BSD Yes Safe math expressions evaluation Escpos-php ? MIT License Yes Thermal receipt printer library, for use with ESC/POS compatible printers diff --git a/htdocs/accountancy/class/accountancyexport.class.php b/htdocs/accountancy/class/accountancyexport.class.php index a641ccb4db5..344a45f19fc 100644 --- a/htdocs/accountancy/class/accountancyexport.class.php +++ b/htdocs/accountancy/class/accountancyexport.class.php @@ -538,7 +538,7 @@ class AccountancyExport //print substr(length_accountg($line->numero_compte), 0, 2) . $separator; print '"'.dol_trunc($line->label_operation, 40, 'right', 'UTF-8', 1).'"' . $separator; print '"'.dol_trunc($line->piece_num, 15, 'right', 'UTF-8', 1).'"'.$separator; - print price2num($line->montant).$separator; + print price2num(abs($line->montant)).$separator; print $line->sens.$separator; print $date . $separator; //print 'EUR'; diff --git a/htdocs/admin/emailcollector_card.php b/htdocs/admin/emailcollector_card.php index b098f090fa5..f05bf937169 100644 --- a/htdocs/admin/emailcollector_card.php +++ b/htdocs/admin/emailcollector_card.php @@ -67,7 +67,7 @@ foreach ($object->fields as $key => $val) { if (empty($action) && empty($id) && empty($ref)) $action='view'; // Load object -include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals +include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once. // Security check - Protection if external user //if ($user->societe_id > 0) access_forbidden(); @@ -75,6 +75,11 @@ include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be inclu //$isdraft = (($object->statut == MyObject::STATUS_DRAFT) ? 1 : 0); //$result = restrictedArea($user, 'mymodule', $object->id, '', '', 'fk_soc', 'rowid', $isdraft); +$permissionnote=$user->rights->emailcollector->write; // Used by the include of actions_setnotes.inc.php +$permissiondellink=$user->rights->emailcollector->write; // Used by the include of actions_dellink.inc.php +$permissionedit=$user->rights->emailcollector->write; // Used by the include of actions_lineupdown.inc.php +$permissiontoadd=$user->rights->emailcollector->write; // Used by the include of actions_addupdatedelete.inc.php + $debuginfo=''; @@ -99,7 +104,7 @@ if (empty($reshook)) include DOL_DOCUMENT_ROOT.'/core/actions_addupdatedelete.inc.php'; // Actions when linking object each other - include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php'; // Must be include, not include_once + include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php'; // Actions when printing a doc from card include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php'; diff --git a/htdocs/admin/fckeditor.php b/htdocs/admin/fckeditor.php index b6e8fcf0fd2..6c7cc5a7f66 100644 --- a/htdocs/admin/fckeditor.php +++ b/htdocs/admin/fckeditor.php @@ -109,7 +109,7 @@ if (GETPOST('save', 'alpha')) } else { $error ++; } - + $fckeditor_test = GETPOST('formtestfield'); if (! empty($fckeditor_test)) { if (! dolibarr_set_const($db, 'FCKEDITOR_TEST', $fckeditor_test, 'chaine', 0, '', $conf->entity)) { @@ -156,7 +156,7 @@ else { // Si condition non remplie, on ne propose pas l'option if (! $conditions[$const]) continue; - + print ''; print ''.img_object("", $picto[$const]).''; print ''.$langs->trans($desc).''; @@ -181,12 +181,12 @@ else print '
'."\n"; print '
'."\n"; - + // Skins show_skin(null, 1); print '
'."\n"; - - $listofmodes=array('dolibarr_mailings','dolibarr_notes','dolibarr_details','dolibarr_readonly','Full'); + + $listofmodes=array('dolibarr_mailings', 'dolibarr_notes', 'dolibarr_details', 'dolibarr_readonly', 'Full', 'Full_inline'); $linkstomode=''; foreach($listofmodes as $newmode) { @@ -200,10 +200,19 @@ else $linkstomode.=''; print load_fiche_titre($langs->trans("TestSubmitForm"), $linkstomode, ''); print ''; - $uselocalbrowser=true; - $readonly=($mode=='dolibarr_readonly'?1:0); - $editor=new DolEditor('formtestfield', isset($conf->global->FCKEDITOR_TEST)?$conf->global->FCKEDITOR_TEST:'Test', '', 200, $mode, 'In', true, $uselocalbrowser, 1, 120, 8, $readonly); - $editor->Create(); + if ($mode != 'Full_inline') + { + $uselocalbrowser=true; + $readonly=($mode=='dolibarr_readonly'?1:0); + $editor=new DolEditor('formtestfield', isset($conf->global->FCKEDITOR_TEST)?$conf->global->FCKEDITOR_TEST:'Test', '', 200, $mode, 'In', true, $uselocalbrowser, 1, 120, 8, $readonly); + $editor->Create(); + } + else + { + print '
'; + print $conf->global->FCKEDITOR_TEST; + print '
'; + } print '
'."\n"; print '
'; print '
'."\n"; diff --git a/htdocs/asset/card.php b/htdocs/asset/card.php index a45eae7047d..5bf3767ece1 100644 --- a/htdocs/asset/card.php +++ b/htdocs/asset/card.php @@ -66,8 +66,12 @@ if (empty($action) && empty($id) && empty($ref)) $action='view'; $extralabels = $extrafields->fetch_name_optionals_label($object->table_element); // Load object -include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals +include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once. +$permissionnote=$user->rights->asset->write; // Used by the include of actions_setnotes.inc.php +$permissiondellink=$user->rights->asset->write; // Used by the include of actions_dellink.inc.php +$permissionedit=$user->rights->asset->write; // Used by the include of actions_lineupdown.inc.php +$permissiontoadd=$user->rights->asset->write; // Used by the include of actions_addupdatedelete.inc.php /* diff --git a/htdocs/bom/bom_card.php b/htdocs/bom/bom_card.php index 25bcb8a1b15..42dd3ba7d95 100644 --- a/htdocs/bom/bom_card.php +++ b/htdocs/bom/bom_card.php @@ -61,7 +61,7 @@ foreach($object->fields as $key => $val) if (empty($action) && empty($id) && empty($ref)) $action='view'; // Load object -include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals +include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once. // Security check - Protection if external user //if ($user->societe_id > 0) access_forbidden(); @@ -69,6 +69,11 @@ include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be inclu //$isdraft = (($object->statut == BillOfMaterials::STATUS_DRAFT) ? 1 : 0); //$result = restrictedArea($user, 'bom', $object->id, '', '', 'fk_soc', 'rowid', $isdraft); +$permissionnote=$user->rights->bom->write; // Used by the include of actions_setnotes.inc.php +$permissiondellink=$user->rights->bom->write; // Used by the include of actions_dellink.inc.php +$permissionedit=$user->rights->bom->write; // Used by the include of actions_lineupdown.inc.php +$permissiontoadd=$user->rights->bom->write; // Used by the include of actions_addupdatedelete.inc.php + /* * Actions @@ -109,7 +114,6 @@ if (empty($reshook)) - /* * View * diff --git a/htdocs/bom/bom_list.php b/htdocs/bom/bom_list.php index f3fa1c670c6..8c9d60f1fe7 100644 --- a/htdocs/bom/bom_list.php +++ b/htdocs/bom/bom_list.php @@ -452,11 +452,13 @@ while ($i < min($num, $limit)) foreach($object->fields as $key => $val) { $cssforfield=''; - if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $cssforfield.=($cssforfield?' ':'').'center'; + if (in_array($val['type'], array('date','datetime','timestamp'))) $cssforfield.=($cssforfield?' ':'').'center'; elseif ($key == 'status') $cssforfield.=($cssforfield?' ':'').'center'; - if (in_array($val['type'], array('timestamp'))) $cssforfield.=($cssforfield?' ':'').'nowrap'; - elseif ($key == 'ref') $cssforfield.=($cssforfield?' ':'').'nowrap'; - if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real'))) $cssforfield.=($cssforfield?' ':'').'right'; + + if (in_array($val['type'], array('timestamp'))) $cssforfield.=($cssforfield?' ':'').'nowrap'; + elseif ($key == 'ref') $cssforfield.=($cssforfield?' ':'').'nowrap'; + + if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real'))) $cssforfield.=($cssforfield?' ':'').'right'; if (! empty($arrayfields['t.'.$key]['checked'])) { diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index e8da06ee2ca..d7abfb36f42 100755 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -126,6 +126,7 @@ $usercancreatewithdrarequest = $user->rights->prelevement->bons->creer; $permissionnote = $usercancreate; // Used by the include of actions_setnotes.inc.php $permissiondellink = $usercancreate; // Used by the include of actions_dellink.inc.php $permissiontoedit = $usercancreate; // Used by the include of actions_lineupdonw.inc.php +$permissiontoadd = $usercancreate; // Used by the include of actions_addupdatedelete.inc.php // Security check $fieldid = (! empty($ref) ? 'ref' : 'rowid'); @@ -160,21 +161,21 @@ if (empty($reshook)) include DOL_DOCUMENT_ROOT.'/core/actions_lineupdown.inc.php'; // Must be include, not include_once // Action clone object - if ($action == 'confirm_clone' && $confirm == 'yes' && $usercancreate) { - // if (1 == 0 && empty($_REQUEST["clone_content"]) && empty($_REQUEST["clone_receivers"])) { - // $mesgs [] = '
' . $langs->trans("NoCloneOptionsSpecified") . '
'; - // } else { - if ($object->fetch($id) > 0) { - $result = $object->createFromClone($socid); - if ($result > 0) { - header("Location: " . $_SERVER['PHP_SELF'] . '?facid=' . $result); - exit(); - } else { - setEventMessages($object->error, $object->errors, 'errors'); - $action = ''; - } - } - // } + if ($action == 'confirm_clone' && $confirm == 'yes' && $permissiontoadd) + { + $objectutil = dol_clone($object, 1); // To avoid to denaturate loaded object when setting some properties for clone. We use native clone to keep this->db valid. + + $objectutil->date = dol_mktime(12, 0, 0, GETPOST('newdatemonth', 'int'), GETPOST('newdateday', 'int'), GETPOST('newdateyear', 'int')); + $objectutil->socid = $socid; + $result = $objectutil->createFromClone($user, $id); + if ($result > 0) { + header("Location: " . $_SERVER['PHP_SELF'] . '?facid=' . $result); + exit(); + } else { + $langs->load("errors"); + setEventMessages($object->error, $object->errors, 'errors'); + $action = ''; + } } // Change status of invoice @@ -1391,7 +1392,7 @@ if (empty($reshook)) $desc=(! empty($lines[$i]->desc)?$lines[$i]->desc:$lines[$i]->libelle); if ($object->situation_counter == 1) $lines[$i]->situation_percent = 0; - if ($lines[$i]->subprice < 0) + if ($lines[$i]->subprice < 0 && empty($conf->global->INVOICE_KEEP_DISCOUNT_LINES_AS_IN_ORIGIN)) { // Negative line, we create a discount line $discount = new DiscountAbsolute($db); @@ -2588,22 +2589,47 @@ if ($action == 'create') if (empty($socid)) $soc = $objectsrc->thirdparty; - $cond_reglement_id = (! empty($objectsrc->cond_reglement_id)?$objectsrc->cond_reglement_id:(! empty($soc->cond_reglement_id)?$soc->cond_reglement_id:0)); - $mode_reglement_id = (! empty($objectsrc->mode_reglement_id)?$objectsrc->mode_reglement_id:(! empty($soc->mode_reglement_id)?$soc->mode_reglement_id:0)); - $fk_account = (! empty($objectsrc->fk_account)?$objectsrc->fk_account:(! empty($soc->fk_account)?$soc->fk_account:0)); - $remise_percent = (! empty($objectsrc->remise_percent)?$objectsrc->remise_percent:(! empty($soc->remise_percent)?$soc->remise_percent:0)); - $remise_absolue = (! empty($objectsrc->remise_absolue)?$objectsrc->remise_absolue:(! empty($soc->remise_absolue)?$soc->remise_absolue:0)); - $dateinvoice = (empty($dateinvoice)?(empty($conf->global->MAIN_AUTOFILL_DATE)?-1:''):$dateinvoice); + $dateinvoice = (empty($dateinvoice)?(empty($conf->global->MAIN_AUTOFILL_DATE)?-1:''):$dateinvoice); - if (!empty($conf->multicurrency->enabled)) - { - if (!empty($objectsrc->multicurrency_code)) $currency_code = $objectsrc->multicurrency_code; - if (!empty($conf->global->MULTICURRENCY_USE_ORIGIN_TX) && !empty($objectsrc->multicurrency_tx)) $currency_tx = $objectsrc->multicurrency_tx; + if ($element == 'expedition') { + $ref_client = (! empty($objectsrc->ref_customer)?$objectsrc->ref_customer:''); + + $elem = $subelem = $objectsrc->origin; + $expeoriginid = $objectsrc->origin_id; + dol_include_once('/'.$elem.'/class/'.$subelem.'.class.php'); + $classname = ucfirst($subelem); + + $expesrc = new $classname($db); + $expesrc->fetch($expeoriginid); + + $cond_reglement_id = (! empty($expesrc->cond_reglement_id)?$expesrc->cond_reglement_id:(! empty($soc->cond_reglement_id)?$soc->cond_reglement_id:1)); + $mode_reglement_id = (! empty($expesrc->mode_reglement_id)?$expesrc->mode_reglement_id:(! empty($soc->mode_reglement_id)?$soc->mode_reglement_id:0)); + $fk_account = (! empty($expesrc->fk_account)?$expesrc->fk_account:(! empty($soc->fk_account)?$soc->fk_account:0)); + $remise_percent = (! empty($expesrc->remise_percent)?$expesrc->remise_percent:(! empty($soc->remise_percent)?$soc->remise_percent:0)); + $remise_absolue = (! empty($expesrc->remise_absolue)?$expesrc->remise_absolue:(! empty($soc->remise_absolue)?$soc->remise_absolue:0)); + + //Replicate extrafields + $expesrc->fetch_optionals($expeoriginid); + $object->array_options=$expesrc->array_options; } + else + { + $cond_reglement_id = (! empty($objectsrc->cond_reglement_id)?$objectsrc->cond_reglement_id:(! empty($soc->cond_reglement_id)?$soc->cond_reglement_id:0)); + $mode_reglement_id = (! empty($objectsrc->mode_reglement_id)?$objectsrc->mode_reglement_id:(! empty($soc->mode_reglement_id)?$soc->mode_reglement_id:0)); + $fk_account = (! empty($objectsrc->fk_account)?$objectsrc->fk_account:(! empty($soc->fk_account)?$soc->fk_account:0)); + $remise_percent = (! empty($objectsrc->remise_percent)?$objectsrc->remise_percent:(! empty($soc->remise_percent)?$soc->remise_percent:0)); + $remise_absolue = (! empty($objectsrc->remise_absolue)?$objectsrc->remise_absolue:(! empty($soc->remise_absolue)?$soc->remise_absolue:0)); - // Replicate extrafields - $objectsrc->fetch_optionals($originid); - $object->array_options = $objectsrc->array_options; + if (!empty($conf->multicurrency->enabled)) + { + if (!empty($objectsrc->multicurrency_code)) $currency_code = $objectsrc->multicurrency_code; + if (!empty($conf->global->MULTICURRENCY_USE_ORIGIN_TX) && !empty($objectsrc->multicurrency_tx)) $currency_tx = $objectsrc->multicurrency_tx; + } + + // Replicate extrafields + $objectsrc->fetch_optionals($originid); + $object->array_options = $objectsrc->array_options; + } } } else @@ -3606,11 +3632,11 @@ elseif ($id > 0 || ! empty($ref)) { // Create an array for form $formquestion = array( - // 'text' => $langs->trans("ConfirmClone"), - // array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1) - array('type' => 'other','name' => 'socid','label' => $langs->trans("SelectThirdParty"),'value' => $form->select_company($object->socid, 'socid', '(s.client=1 OR s.client=2 OR s.client=3)', 1))); - // Paiement incomplet. On demande si motif = escompte ou autre - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?facid=' . $object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneInvoice', $object->ref), 'confirm_clone', $formquestion, 'yes', 1); + array('type' => 'other','name' => 'socid','label' => $langs->trans("SelectThirdParty"),'value' => $form->select_company($object->socid, 'socid', '(s.client=1 OR s.client=2 OR s.client=3)', 1)), + array('type' => 'date', 'name' => 'newdate', 'label' => $langs->trans("Date"), 'value' => dol_now()) + ); + // Ask confirmatio to clone + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?facid=' . $object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneInvoice', $object->ref), 'confirm_clone', $formquestion, 'yes', 1, 250); } // Call Hook formConfirm diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 2e299740290..c2dc89c903e 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -965,82 +965,80 @@ class Facture extends CommonInvoice /** - * Load an object from its id and create a new one in database + * Load an object from its id and create a new one in database * - * @param int $socid Id of thirdparty - * @return int New id of clone + * @param User $user User that clone + * @param int $fromid Id of object to clone + * @return int New id of clone */ - public function createFromClone($socid = 0) + public function createFromClone(User $user, $fromid = 0) { - global $user,$hookmanager, $conf; + global $hookmanager; $error=0; + $object=new Facture($this->db); + $this->db->begin(); - // get extrafields so they will be clone - foreach($this->lines as $line) - $line->fetch_optionals($line->rowid); - - // Load source object - $objFrom = clone $this; + $object->fetch($fromid); // Change socid if needed - if (! empty($socid) && $socid != $this->socid) + if (! empty($this->socid) && $this->socid != $object->socid) { $objsoc = new Societe($this->db); - if ($objsoc->fetch($socid)>0) + if ($objsoc->fetch($this->socid)>0) { - $this->socid = $objsoc->id; - $this->cond_reglement_id = (! empty($objsoc->cond_reglement_id) ? $objsoc->cond_reglement_id : 0); - $this->mode_reglement_id = (! empty($objsoc->mode_reglement_id) ? $objsoc->mode_reglement_id : 0); - $this->fk_project = ''; - $this->fk_delivery_address = ''; + $object->socid = $objsoc->id; + $object->cond_reglement_id = (! empty($objsoc->cond_reglement_id) ? $objsoc->cond_reglement_id : 0); + $object->mode_reglement_id = (! empty($objsoc->mode_reglement_id) ? $objsoc->mode_reglement_id : 0); + $object->fk_project = ''; + $object->fk_delivery_address = ''; } // TODO Change product price if multi-prices } - $this->id=0; - $this->statut= self::STATUS_DRAFT; + $object->id=0; + $object->statut= self::STATUS_DRAFT; // Clear fields - $this->date = dol_now(); // Date of invoice is set to current date when cloning. // TODO Best is to ask date into confirm box - $this->user_author = $user->id; - $this->user_valid = ''; - $this->fk_facture_source = 0; - $this->date_creation = ''; - $this->date_modification = ''; - $this->date_validation = ''; - $this->ref_client = ''; - $this->close_code = ''; - $this->close_note = ''; - $this->products = $this->lines; // Tant que products encore utilise + $object->date = (empty($this->date) ? dol_now() : $this->date); + $object->user_author = $user->id; + $object->user_valid = ''; + $object->fk_facture_source = 0; + $object->date_creation = ''; + $object->date_modification = ''; + $object->date_validation = ''; + $object->ref_client = ''; + $object->close_code = ''; + $object->close_note = ''; + $object->products = $object->lines; // For backward compatibility // Loop on each line of new invoice - foreach($this->lines as $i => $line) + foreach($object->lines as $i => $line) { - if (($this->lines[$i]->info_bits & 0x02) == 0x02) // We do not clone line of discounts + if (($object->lines[$i]->info_bits & 0x02) == 0x02) // We do not clone line of discounts { - unset($this->lines[$i]); - unset($this->products[$i]); // Tant que products encore utilise + unset($object->lines[$i]); + unset($object->products[$i]); // Tant que products encore utilise } } // Create clone - $this->context['createfromclone'] = 'createfromclone'; - $result=$this->create($user); + $object->context['createfromclone'] = 'createfromclone'; + $result=$object->create($user); if ($result < 0) $error++; else { // copy internal contacts - if ($this->copy_linked_contact($objFrom, 'internal') < 0) + if ($object->copy_linked_contact($this, 'internal') < 0) $error++; // copy external contacts if same company - elseif ($objFrom->socid == $this->socid) + elseif ($this->socid == $object->socid) { - if ($this->copy_linked_contact($objFrom, 'external') < 0) + if ($object->copy_linked_contact($this, 'external') < 0) $error++; } } @@ -1050,20 +1048,20 @@ class Facture extends CommonInvoice // Hook of thirdparty module if (is_object($hookmanager)) { - $parameters=array('objFrom'=>$objFrom); + $parameters=array('objFrom'=>$this); $action=''; - $reshook=$hookmanager->executeHooks('createFrom', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + $reshook=$hookmanager->executeHooks('createFrom', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) $error++; } } - unset($this->context['createfromclone']); + unset($object->context['createfromclone']); // End if (! $error) { $this->db->commit(); - return $this->id; + return $object->id; } else { @@ -1556,7 +1554,7 @@ class Facture extends CommonInvoice $line->multicurrency_total_tva = $objp->multicurrency_total_tva; $line->multicurrency_total_ttc = $objp->multicurrency_total_ttc; - $line->fetch_optionals(); + $line->fetch_optionals(); $this->lines[$i] = $line; diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index 749a0b28cfb..d978ddb62e5 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -82,6 +82,7 @@ $search_montant_localtax2=GETPOST('search_montant_localtax2', 'alpha'); $search_montant_ttc=GETPOST('search_montant_ttc', 'alpha'); $search_status=GETPOST('search_status', 'intcomma'); $search_paymentmode=GETPOST('search_paymentmode', 'int'); +$search_paymentterms=GETPOST('search_paymentterms', 'int'); $search_town=GETPOST('search_town', 'alpha'); $search_zip=GETPOST('search_zip', 'alpha'); $search_state=trim(GETPOST("search_state")); @@ -162,6 +163,7 @@ $arrayfields=array( 'country.code_iso'=>array('label'=>"Country", 'checked'=>0), 'typent.code'=>array('label'=>"ThirdPartyType", 'checked'=>$checkedtypetiers), 'f.fk_mode_reglement'=>array('label'=>"PaymentMode", 'checked'=>1), + 'f.fk_cond_reglement'=>array('label'=>"PaymentConditionsShort", 'checked'=>1), 'f.total_ht'=>array('label'=>"AmountHT", 'checked'=>1), 'f.total_vat'=>array('label'=>"AmountVAT", 'checked'=>0), 'f.total_localtax1'=>array('label'=>$langs->transcountry("AmountLT1", $mysoc->country_code), 'checked'=>0, 'enabled'=>($mysoc->localtax1_assuj=="1")), @@ -214,6 +216,7 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter', $search_montant_ttc=''; $search_status=''; $search_paymentmode=''; + $search_paymentterms=''; $search_town=''; $search_zip=""; $search_state=""; @@ -359,7 +362,7 @@ $thirdpartystatic=new Societe($db); $sql = 'SELECT'; if ($sall || $search_product_category > 0) $sql = 'SELECT DISTINCT'; -$sql.= ' f.rowid as id, f.ref, f.ref_client, f.type, f.note_private, f.note_public, f.increment, f.fk_mode_reglement, f.total as total_ht, f.tva as total_vat, f.total_ttc,'; +$sql.= ' f.rowid as id, f.ref, f.ref_client, f.type, f.note_private, f.note_public, f.increment, f.fk_mode_reglement, f.fk_cond_reglement, f.total as total_ht, f.tva as total_vat, f.total_ttc,'; $sql.= ' f.localtax1 as total_localtax1, f.localtax2 as total_localtax2,'; $sql.= ' f.datef as df, f.date_lim_reglement as datelimite,'; $sql.= ' f.paye as paye, f.fk_statut,'; @@ -451,6 +454,7 @@ if ($search_status != '-1' && $search_status != '') } } if ($search_paymentmode > 0) $sql .= " AND f.fk_mode_reglement = ".$db->escape($search_paymentmode); +if ($search_paymentterms > 0) $sql .= " AND f.fk_cond_reglement = ".$db->escape($search_paymentterms); $sql.= dolSqlDateFilter("f.datef", $search_day, $search_month, $search_year); $sql.= dolSqlDateFilter("f.date_lim_reglement", $search_day_lim, $search_month_lim, $search_year_lim); if ($option == 'late') $sql.=" AND f.date_lim_reglement < '".$db->idate(dol_now() - $conf->facture->client->warning_delay)."'"; @@ -468,7 +472,7 @@ $sql.=$hookmanager->resPrint; if (! $sall) { - $sql.= ' GROUP BY f.rowid, f.ref, ref_client, f.type, f.note_private, f.note_public, f.increment, f.fk_mode_reglement, f.total, f.tva, f.total_ttc,'; + $sql.= ' GROUP BY f.rowid, f.ref, ref_client, f.type, f.note_private, f.note_public, f.increment, f.fk_mode_reglement, f.fk_cond_reglement, f.total, f.tva, f.total_ttc,'; $sql.= ' f.localtax1, f.localtax2,'; $sql.= ' f.datef, f.date_lim_reglement,'; $sql.= ' f.paye, f.fk_statut,'; @@ -562,6 +566,7 @@ if ($resql) if ($search_montant_ttc != '') $param.='&search_montant_ttc='.urlencode($search_montant_ttc); if ($search_status != '') $param.='&search_status='.urlencode($search_status); if ($search_paymentmode > 0) $param.='&search_paymentmode='.urlencode($search_paymentmode); + if ($search_paymentterms > 0) $param.='&search_paymentterms='.urlencode($search_paymentterms); if ($show_files) $param.='&show_files='.urlencode($show_files); if ($option) $param.="&search_option=".urlencode($option); if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss); @@ -776,6 +781,13 @@ if ($resql) $form->select_types_paiements($search_paymentmode, 'search_paymentmode', '', 0, 1, 1, 10); print ''; } + // Payment terms + if (! empty($arrayfields['f.fk_cond_reglement']['checked'])) + { + print ''; + $form->select_conditions_paiements($search_paymentterms, 'search_paymentterms', -1, 1, 1); + print ''; + } if (! empty($arrayfields['f.total_ht']['checked'])) { // Amount @@ -869,6 +881,7 @@ if ($resql) if (! empty($arrayfields['country.code_iso']['checked'])) print_liste_field_titre($arrayfields['country.code_iso']['label'], $_SERVER["PHP_SELF"], "country.code_iso", "", $param, 'align="center"', $sortfield, $sortorder); if (! empty($arrayfields['typent.code']['checked'])) print_liste_field_titre($arrayfields['typent.code']['label'], $_SERVER["PHP_SELF"], "typent.code", "", $param, 'align="center"', $sortfield, $sortorder); if (! empty($arrayfields['f.fk_mode_reglement']['checked'])) print_liste_field_titre($arrayfields['f.fk_mode_reglement']['label'], $_SERVER["PHP_SELF"], "f.fk_mode_reglement", "", $param, "", $sortfield, $sortorder); + if (! empty($arrayfields['f.fk_cond_reglement']['checked'])) print_liste_field_titre($arrayfields['f.fk_cond_reglement']['label'], $_SERVER["PHP_SELF"], "f.fk_cond_reglement", "", $param, "", $sortfield, $sortorder); if (! empty($arrayfields['f.total_ht']['checked'])) print_liste_field_titre($arrayfields['f.total_ht']['label'], $_SERVER['PHP_SELF'], 'f.total', '', $param, 'class="right"', $sortfield, $sortorder); if (! empty($arrayfields['f.total_vat']['checked'])) print_liste_field_titre($arrayfields['f.total_vat']['label'], $_SERVER['PHP_SELF'], 'f.tva', '', $param, 'class="right"', $sortfield, $sortorder); if (! empty($arrayfields['f.total_localtax1']['checked'])) print_liste_field_titre($arrayfields['f.total_localtax1']['label'], $_SERVER['PHP_SELF'], 'f.localtax1', '', $param, 'class="right"', $sortfield, $sortorder); @@ -1081,6 +1094,15 @@ if ($resql) if (! $i) $totalarray['nbfield']++; } + // Payment terms + if (! empty($arrayfields['f.fk_cond_reglement']['checked'])) + { + print ''; + $form->form_conditions_reglement($_SERVER['PHP_SELF'], $obj->fk_cond_reglement, 'none'); + print ''; + if (! $i) $totalarray['nbfield']++; + } + // Amount HT if (! empty($arrayfields['f.total_ht']['checked'])) { diff --git a/htdocs/compta/sociales/list.php b/htdocs/compta/sociales/list.php index f5e88c7fb29..8893447ebf3 100644 --- a/htdocs/compta/sociales/list.php +++ b/htdocs/compta/sociales/list.php @@ -27,10 +27,18 @@ require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/chargesociales.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formsocialcontrib.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; // Load translation files required by the page $langs->loadLangs(array('compta', 'banks', 'bills')); +$action=GETPOST('action', 'alpha'); +$massaction=GETPOST('massaction', 'alpha'); +$show_files=GETPOST('show_files', 'int'); +$confirm=GETPOST('confirm', 'alpha'); +$toselect = GETPOST('toselect', 'array'); +$contextpage=GETPOST('contextpage', 'aZ')?GETPOST('contextpage', 'aZ'):'sclist'; + // Security check $socid = isset($_GET["socid"])?$_GET["socid"]:''; if ($user->societe_id) $socid=$user->societe_id; @@ -40,6 +48,9 @@ $search_ref = GETPOST('search_ref', 'int'); $search_label = GETPOST('search_label', 'alpha'); $search_amount = GETPOST('search_amount', 'alpha'); $search_status = GETPOST('search_status', 'int'); +$search_day_lim = GETPOST('search_day_lim', 'int'); +$search_month_lim = GETPOST('search_month_lim', 'int'); +$search_year_lim = GETPOST('search_year_lim', 'int'); $limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; $sortfield = GETPOST("sortfield", 'alpha'); @@ -78,7 +89,11 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x' $search_status=''; $search_typeid=""; $year=""; - $month=""; + $search_day_lim=''; + $search_year_lim=''; + $search_month_lim=''; + $toselect=''; + $search_array_options=array(); } @@ -87,6 +102,7 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x' */ $form = new Form($db); +$formother = new FormOther($db); $formsocialcontrib = new FormSocialContrib($db); $chargesociale_static=new ChargeSociales($db); @@ -106,6 +122,8 @@ if ($search_ref) $sql.=" AND cs.rowid=".$db->escape($search_ref); if ($search_label) $sql.=natural_search("cs.libelle", $search_label); if ($search_amount) $sql.=natural_search("cs.amount", price2num(trim($search_amount)), 1); if ($search_status != '' && $search_status >= 0) $sql.=" AND cs.paye = ".$db->escape($search_status); +$sql.= dolSqlDateFilter("cs.periode", $search_day_lim, $search_month_lim, $search_year_lim); +//$sql.= dolSqlDateFilter("cs.periode", 0, 0, $year); if ($year > 0) { $sql .= " AND ("; @@ -192,19 +210,23 @@ if ($resql) print ''; // Ref print ''; - print ''; + print ''; print ''; // Label - print ''; + print ''; // Type print ''; $formsocialcontrib->select_type_socialcontrib($search_typeid, 'search_typeid', 1, 0, 0, 'maxwidth100onsmartphone'); print ''; // Period end date - print ' '; + print ''; + if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ''; + print ''; + $formother->select_year($search_year_lim?$search_year_lim:-1, 'search_year_lim', 1, 20, 5, 0, 0, '', 'widthauto valignmiddle'); + print ''; // Amount print ''; - print ''; + print ''; print ''; print ' '; // Status diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php index 398640ffb64..d350c8b3ff3 100644 --- a/htdocs/contact/class/contact.class.php +++ b/htdocs/contact/class/contact.class.php @@ -5,7 +5,7 @@ * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2007 Franky Van Liedekerke * Copyright (C) 2008 Raphael Bertrand (Resultic) - * Copyright (C) 2013 Florian Henry + * Copyright (C) 2013 Florian Henry * Copyright (C) 2013 Alexandre Spangaro * Copyright (C) 2013 Juanjo Menent * Copyright (C) 2015 Marcos García @@ -81,6 +81,7 @@ class Contact extends CommonObject public $civility_id; // In fact we store civility_code public $civility_code; + public $civility; public $address; public $zip; public $town; @@ -695,6 +696,8 @@ class Contact extends CommonObject { global $langs; + $langs->load("dict"); + dol_syslog(get_class($this)."::fetch id=".$id, LOG_DEBUG); if (empty($id) && empty($ref_ext)) @@ -705,7 +708,7 @@ class Contact extends CommonObject $langs->load("companies"); - $sql = "SELECT c.rowid, c.entity, c.fk_soc, c.ref_ext, c.civility as civility_id, c.lastname, c.firstname,"; + $sql = "SELECT c.rowid, c.entity, c.fk_soc, c.ref_ext, c.civility as civility_code, c.lastname, c.firstname,"; $sql.= " c.address, c.statut, c.zip, c.town,"; $sql.= " c.fk_pays as country_id,"; $sql.= " c.fk_departement as state_id,"; @@ -747,10 +750,12 @@ class Contact extends CommonObject $this->entity = $obj->entity; $this->ref = $obj->rowid; $this->ref_ext = $obj->ref_ext; - $this->civility_id = $obj->civility_id; - $this->civility_code = $obj->civility_id; - $this->lastname = $obj->lastname; - $this->firstname = $obj->firstname; + + $this->civility_code = $obj->civility_code; + $this->civility = $obj->civility_code?($langs->trans("Civility".$obj->civility_code) != ("Civility".$obj->civility_code) ? $langs->trans("Civility".$obj->civility_code) : $obj->civility_code):''; + + $this->lastname = $obj->lastname; + $this->firstname = $obj->firstname; $this->address = $obj->address; $this->zip = $obj->zip; $this->town = $obj->town; @@ -766,23 +771,23 @@ class Contact extends CommonObject $this->country_code = $obj->country_id?$obj->country_code:''; $this->country = $obj->country_id?($langs->trans('Country'.$obj->country_code)!='Country'.$obj->country_code?$langs->transnoentities('Country'.$obj->country_code):$obj->country):''; - $this->socid = $obj->fk_soc; + $this->socid = $obj->fk_soc; $this->socname = $obj->socname; - $this->poste = $obj->poste; + $this->poste = $obj->poste; $this->statut = $obj->statut; - $this->phone_pro = trim($obj->phone); + $this->phone_pro = trim($obj->phone); $this->fax = trim($obj->fax); $this->phone_perso = trim($obj->phone_perso); $this->phone_mobile = trim($obj->phone_mobile); - $this->email = $obj->email; + $this->email = $obj->email; $this->jabberid = $obj->jabberid; - $this->skype = $obj->skype; - $this->twitter = $obj->twitter; - $this->facebook = $obj->facebook; - $this->linkedin = $obj->linkedin; - $this->photo = $obj->photo; + $this->skype = $obj->skype; + $this->twitter = $obj->twitter; + $this->facebook = $obj->facebook; + $this->linkedin = $obj->linkedin; + $this->photo = $obj->photo; $this->priv = $obj->priv; $this->mail = $obj->email; diff --git a/htdocs/core/actions_addupdatedelete.inc.php b/htdocs/core/actions_addupdatedelete.inc.php index 85d89c08e4b..5c5e7752b49 100644 --- a/htdocs/core/actions_addupdatedelete.inc.php +++ b/htdocs/core/actions_addupdatedelete.inc.php @@ -196,7 +196,24 @@ if ($action == 'confirm_delete' && ! empty($permissiontodelete)) } // Action clone object -if ($action == 'confirm_clone' && $confirm == 'yes' && ! empty($permissiontoadd)) +if ($action == 'confirm_clone' && $confirm == 'yes' && $permissiontoadd) +{ + $objectutil = dol_clone($object); // To avoid to denaturate loaded object when setting some properties for clone + //$objectutil->date = dol_mktime(12, 0, 0, GETPOST('newdatemonth', 'int'), GETPOST('newdateday', 'int'), GETPOST('newdateyear', 'int')); + + $result = $objectutil->createFromClone($id); + if ($result > 0) { + header("Location: " . $_SERVER['PHP_SELF'] . '?facid=' . $result); + exit(); + } else { + $langs->load("errors"); + setEventMessages($objectutil->error, $objectutil->errors, 'errors'); + $action = ''; + } +} + +// Action clone object +if ($action == 'confirm_clone' && $confirm == 'yes' && $permissiontoadd) { if (1==0 && ! GETPOST('clone_content') && ! GETPOST('clone_receivers')) { @@ -204,26 +221,23 @@ if ($action == 'confirm_clone' && $confirm == 'yes' && ! empty($permissiontoadd) } else { - if ($object->id > 0) - { - // Because createFromClone modifies the object, we must clone it so that we can restore it later if error - $orig = clone $object; + $objectutil = dol_clone($object, 1); // To avoid to denaturate loaded object when setting some properties for clone or if createFromClone modifies the object. We use native clone to keep this->db valid. + //$objectutil->date = dol_mktime(12, 0, 0, GETPOST('newdatemonth', 'int'), GETPOST('newdateday', 'int'), GETPOST('newdateyear', 'int')); + // ... - $result=$object->createFromClone($user, $object->id); - if ($result > 0) - { - $newid = 0; - if (is_object($result)) $newid = $result->id; - else $newid = $result; - header("Location: ".$_SERVER['PHP_SELF'].'?id='.$newid); // Open record of new object - exit; - } - else - { - setEventMessages($object->error, $object->errors, 'errors'); - $object = $orig; - $action=''; - } + $result=$objectutil->createFromClone($user, (($object->id > 0) ? $object->id : $id)); + if (is_object($result) || $result > 0) + { + $newid = 0; + if (is_object($result)) $newid = $result->id; + else $newid = $result; + header("Location: ".$_SERVER['PHP_SELF'].'?id='.$newid); // Open record of new object + exit; + } + else + { + setEventMessages($objectutil->error, $objectutil->errors, 'errors'); + $action=''; } } } diff --git a/htdocs/core/ajax/ajaxdirpreview.php b/htdocs/core/ajax/ajaxdirpreview.php index 7848257073a..4490d7bff3c 100644 --- a/htdocs/core/ajax/ajaxdirpreview.php +++ b/htdocs/core/ajax/ajaxdirpreview.php @@ -164,9 +164,9 @@ if (! dol_is_dir($upload_dir)) print ''."\n"; //print ''."\n"; -$param=($sortfield?'&sortfield='.$sortfield:'').($sortorder?'&sortorder='.$sortorder:''); -if (! empty($websitekey)) $param.='&website='.$websitekey; -if (! empty($pageid)) $param.='&pageid='.$pageid; +$param=($sortfield?'&sortfield='.urlencode($sortfield):'').($sortorder?'&sortorder='.urlencode($sortorder):''); +if (! empty($websitekey)) $param.='&website='.urlencode($websitekey); +if (! empty($pageid)) $param.='&pageid='.urlencode($pageid); // Dir scan diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 503a3995b93..60bfd1e5305 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -6130,6 +6130,12 @@ abstract class CommonObject $value=price($value); } } + elseif ($type == 'real') + { + if (!empty($value)) { + $value=price($value); + } + } elseif ($type == 'boolean') { $checked=''; diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index c84c501ad21..ea8663cab31 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -602,7 +602,9 @@ class Form $ret.=$hookmanager->resPrint; $ret.=''; - $ret.=ajax_combobox('.massactionselect'); + + if (empty($conf->dol_optimize_smallscreen)) $ret.=ajax_combobox('.massactionselect'); + // Warning: if you set submit button to disabled, post using 'Enter' will no more work if there is no another input submit. So we add a hidden button $ret.=''; // Hidden button BEFORE so it is the one used when we submit with ENTER. $ret.=''; @@ -6346,7 +6348,7 @@ class Form