diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index 4c6fbb2045c..3233dff3a4b 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -348,13 +348,13 @@ if (empty($reshook)) // If we select proposal to clone during creation (when option PROPAL_CLONE_ON_CREATE_PAGE is on) if (GETPOST('createmode') == 'copy' && GETPOST('copie_propal')) { - if ($object->fetch(GETPOST('copie_propal')) > 0) { + if ($object->fetch(GETPOST('copie_propal','int')) > 0) { $object->ref = GETPOST('ref'); $object->datep = $datep; $object->date_livraison = $date_delivery; $object->availability_id = GETPOST('availability_id'); $object->demand_reason_id = GETPOST('demand_reason_id'); - $object->fk_delivery_address = GETPOST('fk_address'); + $object->fk_delivery_address = GETPOST('fk_address','int'); $object->shipping_method_id = GETPOST('shipping_method_id', 'int'); $object->duree_validite = $duration; $object->cond_reglement_id = GETPOST('cond_reglement_id'); @@ -362,9 +362,9 @@ if (empty($reshook)) $object->fk_account = GETPOST('fk_account', 'int'); $object->remise_percent = GETPOST('remise_percent'); $object->remise_absolue = GETPOST('remise_absolue'); - $object->socid = GETPOST('socid'); - $object->contactid = GETPOST('contactid'); - $object->fk_project = GETPOST('projectid'); + $object->socid = GETPOST('socid','int'); + $object->contactid = GETPOST('contactid','int'); + $object->fk_project = GETPOST('projectid','int'); $object->modelpdf = GETPOST('model'); $object->author = $user->id; // deprecated $object->note_private = GETPOST('note_private','none'); @@ -391,8 +391,8 @@ if (empty($reshook)) $object->cond_reglement_id = GETPOST('cond_reglement_id'); $object->mode_reglement_id = GETPOST('mode_reglement_id'); $object->fk_account = GETPOST('fk_account', 'int'); - $object->contactid = GETPOST('contactid'); - $object->fk_project = GETPOST('projectid'); + $object->contactid = GETPOST('contactid','int'); + $object->fk_project = GETPOST('projectid','int'); $object->modelpdf = GETPOST('model'); $object->author = $user->id; // deprecated $object->note_private = GETPOST('note_private','none'); @@ -566,6 +566,16 @@ if (empty($reshook)) } } + if (! empty($conf->global->PROPOSAL_AUTO_ADD_AUTHOR_AS_CONTACT)) + { + $result = $object->add_contact($user->id, 'SALESREPFOLL', 'internal'); + if ($result < 0) + { + $error++; + setEventMessages($langs->trans("ErrorFailedToAddUserAsContact"), null, 'errors'); + } + } + if (! $error) { $db->commit();