Debug v16
This commit is contained in:
parent
c3673bfc3c
commit
84fccb0988
@ -1948,14 +1948,15 @@ class ExtraFields
|
||||
/**
|
||||
* Fill array_options property of object by extrafields value (using for data sent by forms)
|
||||
*
|
||||
* @param array $extralabels Deprecated (old $array of extrafields, now set this to null)
|
||||
* @param object $object Object
|
||||
* @param string $onlykey Only some keys are filled:
|
||||
* 'string' => When we make update of only one extrafield ($action = 'update_extras'), calling page can set this to avoid to have other extrafields being reset.
|
||||
* '@GETPOSTISSET' => When we make update of several extrafields ($action = 'update'), calling page can set this to avoid to have fields not into POST being reset.
|
||||
* @return int 1 if array_options set, 0 if no value, -1 if error (field required missing for example)
|
||||
* @param array $extralabels Deprecated (old $array of extrafields, now set this to null)
|
||||
* @param object $object Object
|
||||
* @param string $onlykey Only some keys are filled:
|
||||
* 'string' => When we make update of only one extrafield ($action = 'update_extras'), calling page can set this to avoid to have other extrafields being reset.
|
||||
* '@GETPOSTISSET' => When we make update of several extrafields ($action = 'update'), calling page can set this to avoid to have fields not into POST being reset.
|
||||
* @param int $todefaultifmissing 1=Set value to the default value in database if value is mandatory and missing
|
||||
* @return int 1 if array_options set, 0 if no value, -1 if error (field required missing for example)
|
||||
*/
|
||||
public function setOptionalsFromPost($extralabels, &$object, $onlykey = '')
|
||||
public function setOptionalsFromPost($extralabels, &$object, $onlykey = '', $todefaultifmissing = 0)
|
||||
{
|
||||
global $_POST, $langs;
|
||||
|
||||
@ -2015,8 +2016,10 @@ class ExtraFields
|
||||
|| (!is_array($_POST["options_".$key]) && isset($_POST["options_".$key]) && $this->attributes[$object->table_element]['type'][$key] == 'sellist' && $_POST['options_'.$key] == '0')
|
||||
|| (is_array($_POST["options_".$key]) && empty($_POST["options_".$key]))) {
|
||||
//print 'ccc'.$value.'-'.$this->attributes[$object->table_element]['required'][$key];
|
||||
|
||||
// Field is not defined. We mark this as a problem. We may fix it later if there is a default value and $todefaultifmissing is set.
|
||||
$nofillrequired++;
|
||||
$error_field_required[] = $langs->transnoentitiesnoconv($value);
|
||||
$error_field_required[$key] = $langs->transnoentitiesnoconv($value);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2047,12 +2050,22 @@ class ExtraFields
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($error_field_required[$key]) && $todefaultifmissing) {
|
||||
// Value is required but we have a default value and we asked to set empty value to the default value
|
||||
if (!empty($this->attributes[$object->table_element]['default']) && !is_null($this->attributes[$object->table_element]['default'][$key])) {
|
||||
$value_key = $this->attributes[$object->table_element]['default'][$key];
|
||||
unset($error_field_required[$key]);
|
||||
$nofillrequired--;
|
||||
}
|
||||
}
|
||||
|
||||
$object->array_options["options_".$key] = $value_key;
|
||||
}
|
||||
|
||||
if ($nofillrequired) {
|
||||
$langs->load('errors');
|
||||
setEventMessages($langs->trans('ErrorFieldsRequired').' : '.implode(', ', $error_field_required), null, 'errors');
|
||||
$this->error = $langs->trans('ErrorFieldsRequired').' : '.implode(', ', $error_field_required);
|
||||
setEventMessages($this->error, null, 'errors');
|
||||
return -1;
|
||||
} else {
|
||||
return 1;
|
||||
|
||||
@ -509,12 +509,14 @@ function project_admin_prepare_head()
|
||||
$head[$h][2] = 'attributes_task';
|
||||
$h++;
|
||||
|
||||
$langs->load("members");
|
||||
if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) {
|
||||
$langs->load("members");
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT.'/projet/admin/website.php';
|
||||
$head[$h][1] = $langs->trans("BlankSubscriptionForm");
|
||||
$head[$h][2] = 'website';
|
||||
$h++;
|
||||
$head[$h][0] = DOL_URL_ROOT.'/projet/admin/website.php';
|
||||
$head[$h][1] = $langs->trans("BlankSubscriptionForm");
|
||||
$head[$h][2] = 'website';
|
||||
$h++;
|
||||
}
|
||||
|
||||
complete_head_from_modules($conf, $langs, null, $head, $h, 'project_admin', 'remove');
|
||||
|
||||
|
||||
@ -265,7 +265,7 @@ print '<td width="80"> </td></tr>'."\n";
|
||||
print '<tr class="oddeven">';
|
||||
print '<td width="80%">'.$langs->trans("ManageOpportunitiesStatus").'</td>';
|
||||
print '<td width="60" class="right">';
|
||||
print ajax_constantonoff("PROJECT_USE_OPPORTUNITIES");
|
||||
print ajax_constantonoff("PROJECT_USE_OPPORTUNITIES", null, null, 0, 0, 1);
|
||||
print '</td><td class="right">';
|
||||
print "</td>";
|
||||
print '</tr>';
|
||||
|
||||
@ -206,16 +206,53 @@ if (empty($reshook) && $action == 'add') {
|
||||
$errmsg .= $langs->trans("ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv("Project"))."<br>\n";
|
||||
}
|
||||
|
||||
if (!$error) {
|
||||
$proj = new Project($db);
|
||||
$thirdparty = new Societe($db);
|
||||
$proj = new Project($db);
|
||||
$thirdparty = new Societe($db);
|
||||
|
||||
if (!$error) {
|
||||
// Search thirdparty and set it if found to the new created project
|
||||
$result = $thirdparty->fetch(0, '', '', '', '', '', '', '', '', '', $object->email);
|
||||
if ($result > 0) {
|
||||
$proj->socid = $thirdparty->id;
|
||||
}
|
||||
} else {
|
||||
// Create the prospect
|
||||
if (GETPOST('societe')) {
|
||||
$thirdparty->name = GETPOST('societe');
|
||||
$thirdparty->name_alias = dolGetFirstLastname(GETPOST('firstname'), GETPOST('lastname'));
|
||||
} else {
|
||||
$thirdparty->name = dolGetFirstLastname(GETPOST('firstname'), GETPOST('lastname'));
|
||||
}
|
||||
$thirdparty->address = GETPOST('address');
|
||||
$thirdparty->zip = GETPOST('zip');
|
||||
$thirdparty->town = GETPOST('town');
|
||||
$thirdparty->country_id = GETPOST('country_id', 'int');
|
||||
$thirdparty->state_id = GETPOST('state_id');
|
||||
$thirdparty->client = $thirdparty::PROSPECT;
|
||||
$thirdparty->code_client = 'auto';
|
||||
$thirdparty->code_fournisseur = 'auto';
|
||||
|
||||
// Fill array 'array_options' with data from the form
|
||||
$extrafields->fetch_name_optionals_label($thirdparty->table_element);
|
||||
$ret = $extrafields->setOptionalsFromPost(null, $thirdparty, '', 1);
|
||||
//var_dump($thirdparty->array_options);exit;
|
||||
if ($ret < 0) {
|
||||
$error++;
|
||||
$errmsg = ($extrafields->error ? $extrafields->error.'<br>' : '').join('<br>', $extrafields->errors);
|
||||
}
|
||||
|
||||
if (!$error) {
|
||||
$result = $thirdparty->create($user);
|
||||
if ($result <= 0) {
|
||||
$error++;
|
||||
$errmsg = ($thirdparty->error ? $thirdparty->error.'<br>' : '').join('<br>', $thirdparty->errors);
|
||||
} else {
|
||||
$proj->socid = $thirdparty->id;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!$error) {
|
||||
// Defined the ref into $defaultref
|
||||
$defaultref = '';
|
||||
$modele = empty($conf->global->PROJECT_ADDON) ? 'mod_project_simple' : $conf->global->PROJECT_ADDON;
|
||||
|
||||
@ -956,7 +956,7 @@ class Societe extends CommonObject
|
||||
$sql .= ", accountancy_code_sell";
|
||||
$sql .= ") VALUES (";
|
||||
$sql .= $this->id;
|
||||
$sql .= ", ".$conf->entity;
|
||||
$sql .= ", ".((int) $conf->entity);
|
||||
$sql .= ", '".$this->db->escape($this->accountancy_code_customer)."'";
|
||||
$sql .= ", '".$this->db->escape($this->accountancy_code_supplier)."'";
|
||||
$sql .= ", '".$this->db->escape($this->accountancy_code_buy)."'";
|
||||
|
||||
Loading…
Reference in New Issue
Block a user