28require
'../main.inc.php';
29require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formcompany.class.php';
30require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
31require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formprojet.class.php';
32require_once DOL_DOCUMENT_ROOT.
'/partnership/class/partnership.class.php';
33require_once DOL_DOCUMENT_ROOT.
'/partnership/lib/partnership.lib.php';
45$langs->loadLangs(array(
"partnership",
"other"));
50$action =
GETPOST(
'action',
'aZ09');
51$confirm =
GETPOST(
'confirm',
'alpha');
52$cancel =
GETPOST(
'cancel',
'aZ09');
53$contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') : str_replace(
'_',
'', basename(dirname(__FILE__)).basename(__FILE__,
'.php'));
54$backtopage =
GETPOST(
'backtopage',
'alpha');
55$backtopageforcancel =
GETPOST(
'backtopageforcancel',
'alpha');
57$dol_openinpopup =
GETPOST(
'dol_openinpopup',
'aZ09');
62$diroutputmassaction =
$conf->partnership->dir_output.
'/temp/massgeneration/'.$user->id;
63$hookmanager->initHooks(array(
'partnershipcard',
'globalcard'));
66$extrafields->fetch_name_optionals_label(
$object->table_element);
68$search_array_options = $extrafields->getOptionalsFromPost(
$object->table_element,
'',
'search_');
71$search_all =
GETPOST(
"search_all",
'alpha');
74foreach (
$object->fields as $key => $val) {
75 if (
GETPOST(
'search_'.$key,
'alpha')) {
76 $search[$key] =
GETPOST(
'search_'.$key,
'alpha');
80if (empty($action) && empty($id) && empty($ref)) {
85include DOL_DOCUMENT_ROOT.
'/core/actions_fetchobject.inc.php';
88$permissiontoread = $user->hasRight(
'partnership',
'read');
89$permissiontoadd = $user->hasRight(
'partnership',
'write');
90$permissiontodelete = $user->hasRight(
'partnership',
'delete') || ($permissiontoadd && isset(
$object->status) &&
$object->status == $object::STATUS_DRAFT);
91$permissionnote = $user->hasRight(
'partnership',
'write');
92$permissiondellink = $user->hasRight(
'partnership',
'write');
93$upload_dir =
$conf->partnership->multidir_output[isset(
$object->entity) ?
$object->entity : 1];
101if (!isModEnabled(
'partnership')) {
104if (!$permissiontoread) {
107if (
$object->id > 0 && !(
$object->fk_member > 0) && $managedfor ==
'member') {
110if (
$object->id > 0 && !(
$object->fk_soc > 0) && $managedfor ==
'thirdparty') {
119$parameters = array();
120$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
125if (empty($reshook)) {
128 $backurlforlist =
dol_buildpath(
'/partnership/partnership_list.php', 1);
130 if (empty($backtopage) || ($cancel && empty($id))) {
131 if (empty($backtopage) || ($cancel && strpos($backtopage,
'__ID__'))) {
132 if (empty($id) && (($action !=
'add' && $action !=
'create') || $cancel)) {
133 $backtopage = $backurlforlist;
135 $backtopage =
dol_buildpath(
'/partnership/partnership_card.php', 1).
'?id='.(
$id > 0 ?
$id :
'__ID__');
141 $obj_partner = ($managedfor ==
'member') ?
$object->fk_member :
$object->fk_soc;
143 $triggermodname =
'PARTNERSHIP_MODIFY';
146 include DOL_DOCUMENT_ROOT.
'/core/actions_addupdatedelete.inc.php';
149 if ($action ==
'confirm_validate' && $confirm ==
'yes' && $permissiontoadd) {
150 $result =
$object->validate($user);
154 if (method_exists($object,
'generateDocument')) {
155 $outputlangs = $langs;
158 $newlang =
GETPOST(
'lang_id',
'aZ09');
161 $newlang =
$object->thirdparty->default_lang;
163 if (!empty($newlang)) {
165 $outputlangs->setDefaultLang($newlang);
172 $retgen =
$object->generateDocument($model, $outputlangs, 0, 0, 0);
181 } elseif ($action ==
'confirm_accept' && $confirm ==
'yes' && $permissiontoadd) {
182 $result =
$object->approve($user);
186 if (method_exists($object,
'generateDocument')) {
187 $outputlangs = $langs;
190 $newlang =
GETPOST(
'lang_id',
'aZ09');
193 $newlang =
$object->thirdparty->default_lang;
195 if (!empty($newlang)) {
197 $outputlangs->setDefaultLang($newlang);
204 $retgen =
$object->generateDocument($model, $outputlangs, 0, 0, 0);
213 } elseif ($action ==
'confirm_refuse' && $permissiontoadd && !
GETPOST(
'cancel',
'alpha')) {
215 if (!(
GETPOST(
'reason_decline_or_cancel',
'alpha'))) {
216 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Refuse")),
null,
'errors');
220 if (
$object->statut != $object::STATUS_REFUSED) {
223 $result =
$object->refused($user,
GETPOST(
'reason_decline_or_cancel',
'restricthtml'));
228 $object->reason_decline_or_cancel =
GETPOST(
'reason_decline_or_cancel',
'restricthtml');
240 include DOL_DOCUMENT_ROOT.
'/core/actions_dellink.inc.php';
243 include DOL_DOCUMENT_ROOT.
'/core/actions_printing.inc.php';
249 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
251 if ($action ==
'set_thirdparty' && $permissiontoadd) {
252 $object->setValueFrom(
'fk_soc',
GETPOSTINT(
'fk_soc'),
'',
null,
'date',
'', $user, $triggermodname);
254 if ($action ==
'classin' && $permissiontoadd) {
259 $triggersendname =
'PARTNERSHIP_SENTBYMAIL';
260 $autocopy =
'MAIN_MAIL_AUTOCOPY_PARTNERSHIP_TO';
261 $trackid =
'pship'.$object->id;
262 include DOL_DOCUMENT_ROOT.
'/core/actions_sendmails.inc.php';
264 if (!empty($id) && !empty(
GETPOST(
'confirm'))) {
265 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".$id);
270if (
$object->id > 0 &&
$object->status == $object::STATUS_REFUSED) {
271 $object->fields[
'reason_decline_or_cancel'][
'visible'] = 3;
280$form =
new Form($db);
284$title = $langs->trans(
"Partnership");
286llxHeader(
'', $title, $help_url,
'', 0, 0,
'',
'',
'',
'mod-partnership page-card');
289if ($action ==
'create') {
290 if (empty($permissiontoadd)) {
294 print
load_fiche_titre($langs->trans(
"NewPartnership"),
'',
'object_'.$object->picto);
296 print
'<form method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
297 print
'<input type="hidden" name="token" value="'.newToken().
'">';
298 print
'<input type="hidden" name="action" value="add">';
300 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
302 if ($backtopageforcancel) {
303 print
'<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.
'">';
308 print
'<table class="border centpercent tableforfieldcreate">'.
"\n";
311 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_add.tpl.php';
314 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_add.tpl.php';
316 print
'</table>'.
"\n";
320 print $form->buttonsSaveCancel(
"Create");
328if (($id || $ref) && $action ==
'edit') {
329 print
load_fiche_titre($langs->trans(
"Partnership"),
'',
'object_'.$object->picto);
331 print
'<form method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
332 print
'<input type="hidden" name="token" value="'.newToken().
'">';
333 print
'<input type="hidden" name="action" value="update">';
334 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
336 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
338 if ($backtopageforcancel) {
339 print
'<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.
'">';
344 print
'<table class="border centpercent tableforfieldedit">'.
"\n";
347 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_edit.tpl.php';
350 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_edit.tpl.php';
356 print $form->buttonsSaveCancel();
362if (
$object->id > 0 && (empty($action) || ($action !=
'edit' && $action !=
'create'))) {
370 if ($action ==
'delete') {
371 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'DeletePartnership'), $langs->trans(
'ConfirmDeleteObject'),
'confirm_delete',
'', 0, 1);
374 if ($action ==
'deleteline') {
375 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&lineid='.$lineid, $langs->trans(
'DeleteLine'), $langs->trans(
'ConfirmDeleteLine'),
'confirm_deleteline',
'', 0, 1);
378 if ($action ==
'clone') {
380 $formquestion = array();
381 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'ToClone'), $langs->trans(
'ConfirmCloneAsk',
$object->ref),
'confirm_clone', $formquestion,
'yes', 1);
384 if ($action ==
'close') {
386 $formquestion = array();
387 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'ToClose'), $langs->trans(
'ConfirmClosePartnershipAsk',
$object->ref),
'confirm_close', $formquestion,
'yes', 1);
390 if ($action ==
'reopen') {
392 $formquestion = array();
393 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'ToReopon'), $langs->trans(
'ConfirmReoponAsk',
$object->ref),
'confirm_reopen', $formquestion,
'yes', 1);
397 if ($action ==
'refuse') {
399 $formquestion = array(
400 array(
'type' =>
'text',
'name' =>
'reason_decline_or_cancel',
'label' => $langs->trans(
"Note"),
'morecss' =>
'reason_decline_or_cancel minwidth400',
'value' =>
'')
411 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'ToRefuse'),
'',
'confirm_refuse', $formquestion,
'', 1, 250);
415 $parameters = array(
'formConfirm' => $formconfirm,
'lineid' => $lineid);
416 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters, $object, $action);
417 if (empty($reshook)) {
418 $formconfirm .= $hookmanager->resPrint;
419 } elseif ($reshook > 0) {
420 $formconfirm = $hookmanager->resPrint;
429 $linkback =
'<a href="'.dol_buildpath(
'/partnership/partnership_list.php', 1).
'?restore_lastsearch_values=1'.(!empty($socid) ?
'&socid='.$socid :
'').
'">'.$langs->trans(
"BackToList").
'</a>';
431 $morehtmlref =
'<div class="refidno">';
463 $morehtmlref .=
'</div>';
465 if ($managedfor ==
'member') {
466 $object->next_prev_filter =
"te.fk_member:>:0";
468 $object->next_prev_filter =
"te.fk_soc:>:0";
471 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref);
474 print
'<div class="fichecenter">';
475 print
'<div class="fichehalfleft">';
476 print
'<div class="underbanner clearboth"></div>';
477 print
'<table class="border centpercent tableforfield">'.
"\n";
483 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_view.tpl.php';
486 if ($managedfor ==
'member') {
488 $fadherent->fetch(
$object->fk_member);
489 print
'<tr><td>'.$langs->trans(
"SubscriptionEndDate").
'</td><td class="valeur">';
490 if ($fadherent->datefin) {
492 if ($fadherent->hasDelay()) {
493 print
" ".img_warning($langs->trans(
"Late"));
496 if (!$adht->subscription) {
497 print $langs->trans(
"SubscriptionNotRecorded");
498 if ($fadherent->statut > 0) {
499 print
" ".img_warning($langs->trans(
"Late"));
502 print $langs->trans(
"SubscriptionNotReceived");
503 if ($fadherent->statut > 0) {
504 print
" ".img_warning($langs->trans(
"Late"));
512 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
518 print
'<div class="clearboth"></div>';
527 if (!empty(
$object->table_element_line)) {
529 $result =
$object->getLinesArray();
531 print
' <form name="addproduct" id="addproduct" action="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.(($action !=
'editline') ?
'' :
'#line_'.
GETPOSTINT(
'lineid')).
'" method="POST">
532 <input type="hidden" name="token" value="' .
newToken().
'">
533 <input type="hidden" name="action" value="' . (($action !=
'editline') ?
'addline' :
'updateline').
'">
534 <input type="hidden" name="mode" value="">
535 <input type="hidden" name="page_y" value="">
536 <input type="hidden" name="id" value="' .
$object->id.
'">
539 if (!empty(
$conf->use_javascript_ajax) &&
$object->status == 0) {
540 include DOL_DOCUMENT_ROOT.
'/core/tpl/ajaxrow.tpl.php';
543 print
'<div class="div-table-responsive-no-min">';
544 if (!empty(
$object->lines) || (
$object->status == $object::STATUS_DRAFT && $permissiontoadd && $action !=
'selectlines' && $action !=
'editline')) {
545 print
'<table id="tablelines" class="noborder noshadow" width="100%">';
553 if (
$object->status == 0 && $permissiontoadd && $action !=
'selectlines') {
554 if ($action !=
'editline') {
557 $parameters = array();
558 $reshook = $hookmanager->executeHooks(
'formAddObjectLine', $parameters, $object, $action);
562 if (empty($reshook)) {
563 $object->formAddObjectLine(1, $mysoc, $soc);
568 if (!empty(
$object->lines) || (
$object->status == $object::STATUS_DRAFT && $permissiontoadd && $action !=
'selectlines' && $action !=
'editline')) {
579 if ($action !=
'presend' && $action !=
'editline') {
580 print
'<div class="tabsAction">'.
"\n";
581 $parameters = array();
582 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters, $object, $action);
587 if (empty($reshook)) {
589 if (empty($user->socid)) {
590 print
dolGetButtonAction(
'', $langs->trans(
'SendMail'),
'default', $_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=presend&token='.
newToken().
'&mode=init#formmailbeforetitle');
593 print
dolGetButtonAction(
'', $langs->trans(
'Modify'),
'default', $_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=edit&token='.
newToken(),
'', $permissiontoadd);
596 if (
$object->status != $object::STATUS_DRAFT) {
597 print
dolGetButtonAction(
'', $langs->trans(
'SetToDraft'),
'default', $_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=confirm_setdraft&confirm=yes&token='.
newToken(),
'', $permissiontoadd);
601 if (
$object->status == $object::STATUS_DRAFT) {
603 print
dolGetButtonAction(
'', $langs->trans(
'Validate'),
'default', $_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&action=confirm_validate&confirm=yes&token='.
newToken(),
'', $permissiontoadd);
605 $langs->load(
"errors");
606 print
dolGetButtonAction($langs->trans(
"ErrorAddAtLeastOneLineFirst"), $langs->trans(
"Validate"),
'default',
'#',
'', 0);
611 if (
$object->status == $object::STATUS_VALIDATED) {
613 print
dolGetButtonAction($langs->trans(
'Approve'),
'',
'default', $_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&action=confirm_accept&confirm=yes&token='.
newToken(),
'', $permissiontoadd);
615 $langs->load(
"errors");
616 print
dolGetButtonAction($langs->trans(
"ErrorAddAtLeastOneLineFirst"), $langs->trans(
"Approved"),
'default',
'#',
'', 0);
621 if ($permissiontoadd) {
622 if (
$object->status == $object::STATUS_APPROVED) {
623 print
dolGetButtonAction($langs->trans(
'Resiliate'),
'',
'default', $_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=close&token='.
newToken(),
'', $permissiontoadd);
624 } elseif (
$object->status > $object::STATUS_APPROVED) {
626 print
dolGetButtonAction($langs->trans(
'Re-Open'),
'',
'default', $_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=confirm_reopen&confirm=yes&token='.
newToken(),
'', $permissiontoadd);
631 if ($permissiontoadd) {
632 if (
$object->status != $object::STATUS_DRAFT &&
$object->status != $object::STATUS_APPROVED &&
$object->status != $object::STATUS_CANCELED &&
$object->status != $object::STATUS_REFUSED) {
633 print
dolGetButtonAction($langs->trans(
'Refuse'),
'',
'default', $_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&action=refuse&token='.
newToken(),
'', $permissiontoadd);
638 print
dolGetButtonAction($langs->trans(
'Delete'),
'',
'delete', $_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&action=delete&token='.
newToken(),
'', $permissiontodelete || (
$object->status == $object::STATUS_DRAFT && $permissiontoadd));
645 if (
GETPOST(
'modelselected')) {
649 if ($action !=
'presend') {
650 print
'<div class="fichecenter"><div class="fichehalfleft">';
651 print
'<a name="builddoc"></a>';
653 $includedocgeneration = 0;
656 if ($includedocgeneration) {
658 $relativepath = $objref.
'/'.$objref.
'.pdf';
659 $filedir =
$conf->partnership->dir_output.
'/'.
$object->element.
'/'.$objref;
660 $urlsource = $_SERVER[
"PHP_SELF"].
"?id=".
$object->id;
661 $genallowed = $permissiontoread;
662 $delallowed = $permissiontoadd;
663 print $formfile->showdocuments(
'partnership:Partnership',
$object->element.
'/'.$objref, $filedir, $urlsource, $genallowed, $delallowed,
$object->model_pdf, 1, 0, 0, 28, 0,
'',
'',
'', $langs->defaultlang);
667 $tmparray = $form->showLinkToObjectBlock($object, array(), array(
'partnership'), 1);
668 $linktoelem = $tmparray[
'linktoelem'];
669 $htmltoenteralink = $tmparray[
'htmltoenteralink'];
670 print $htmltoenteralink;
672 $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem);
675 print
'</div><div class="fichehalfright">';
679 $morehtmlcenter =
dolGetButtonTitle($langs->trans(
'SeeAll'),
'',
'fa fa-bars imgforviewmode', DOL_URL_ROOT.
'/partnership/partnership_agenda.php?id='.
$object->id);
682 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
684 $somethingshown = $formactions->showactions($object,
$object->element.
'@'.
$object->module, (is_object(
$object->thirdparty) ?
$object->thirdparty->id : 0), 1,
'', $MAXEVENT,
'', $morehtmlcenter);
686 print
'</div></div>';
690 if (
GETPOST(
'modelselected')) {
695 $modelmail =
'partnership_send';
696 $defaulttopic =
'InformationMessage';
697 $diroutput =
$conf->partnership->dir_output;
698 $trackid =
'pship'.$object->id;
700 include DOL_DOCUMENT_ROOT.
'/core/tpl/card_presend.tpl.php';
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Class to manage members of a foundation.
Class to manage translations.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0)
Show tabs of a record.
dolGetButtonTitle($label, $helpText='', $iconClass='fa fa-file', $url='', $id='', $status=1, $params=array())
Function dolGetButtonTitle : this kind of buttons are used in title in list.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
newToken()
Return the value of token currently saved into session with name 'newtoken'.
dolGetButtonAction($label, $text='', $actionType='default', $url='', $id='', $userRight=1, $params=array())
Function dolGetButtonAction.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
partnershipPrepareHead($object)
Prepare array of tabs for Partnership.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.