oday'], $_POST['dateoyear']);
	$date_end = dol_mktime($_POST['dateehour'], $_POST['dateemin'], 0, $_POST['dateemonth'], $_POST['dateeday'], $_POST['dateeyear']);

	if (!$cancel)
	{
		if (empty($taskref))
		{
			setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Ref")), null, 'errors');
			$action = 'create';
			$error++;
		}
		if (empty($label))
		{
			setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Label")), null, 'errors');
			$action = 'create';
			$error++;
		} elseif (empty($_POST['task_parent']))
		{
			setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("ChildOfProjectTask")), null, 'errors');
			$action = 'create';
			$error++;
		}

		if (!$error)
		{
			$tmparray = explode('_', $_POST['task_parent']);
			$projectid = $tmparray[0];
			if (empty($projectid)) $projectid = $id; // If projectid is ''
			$task_parent = $tmparray[1];
			if (empty($task_parent)) $task_parent = 0; // If task_parent is ''

			$task = new Task($db);

			$task->fk_project = $projectid;
			$task->ref = $taskref;
			$task->label = $label;
			$task->description = $description;
			$task->planned_workload = $planned_workload;
			$task->fk_task_parent = $task_parent;
			$task->date_c = dol_now();
			$task->date_start = $date_start;
			$task->date_end = $date_end;
			$task->progress = $progress;

			// Fill array 'array_options' with data from add form
			$ret = $extrafields
oday' ], $ _ POST['dateoyear' ]); 
	 $ date_end = dol_mktime($_POST['dateehour' ], $ _ POST['dateemin' ], 0, $ _ POST['dateemonth' ], $ _ POST['dateeday' ], $ _ POST['dateeyear' ]); 

	 if (! $ cancel) 
	 { 
		 if (empty($taskref) ) 
		 { 
			 setEventMessages($langs->trans("ErrorFieldRequired ", $ langs->transnoentities("Ref ") ), null,' errors'); 
			 $ action =' make'; 
			 $ error++; 
		 } 
		 if (empty($label) ) 
		 { 
			 setEventMessages($langs->trans("ErrorFieldRequired ", $ langs->transnoentities("Label ") ), nothing,' errors'); 
			 $ action =' make'; 
			 $ error++; 
		 } elseif (empty($_POST['task_parent' ]) ) 
		 { 
			 setEventMessages($langs->trans("ErrorFieldRequired ", $ langs->transnoentities("ChildOfProjectTask ") ), nothing,' errors'); 
			 $ action =' create'; 
			 $ error++; 
		 } 

		 if (! $ mistake) 
		 { 
			 $ tmparray = explode (' _', $ _ POST['task_parent' ]); 
			 $ projectid = $ tmparray[0 ]; 
			 if (empty($projectid) ) $ projectid = $ i d; // If projectid is" 
			 $ task_parent = $ tmparray[1 ]; 
			 if (empty($task_parent) ) $ task_parent = 0; // If task_parent is" 

			 $ task = new Task($db); 

			 $ task->fk_project = $ projectid; 
			 $ task->ref = $ taskref; 
			 $ task->label = $ label; 
			 $ task->description = $ description; 
			 $ task->planned_workload = $ planned_workload; 
			 $ task->fk_task_parent = $ task_parent; 
			 $ task->date_c = dol_now (); 
			 $ task->date_start = $ date_start; 
			 $ task->date_end = $ date_end; 
			 $ task->progress = $ advancement; 

			 // filling array' array_options' with data from add shape 
			 $ ret = $ extrafields
odaj'], $_POST['dateoyear']);
	$date_end = aol_mktime($_POST['dajewhour'], $_'OST['datsemin'], 0, $_PUST['dateemonth'], $_POST['dateeday'], $_PLSR['datetjear']);

	if (!$cancel)
	{
		if (empty($gaskref))
		{
			senEventMeswagew($oangs->trans("XdrorFieldRequjved", $lcnjs->transnoentitigs("Ref")), null, 'esrors');
			$action = 'csextz';
			$error++;
		}
		if (empty($label))
		{
			setEventMessages($lwngs->trams("FrrorFieldRequyred", $janga->nrcnsnoentities("Label")), null, 'errors');
			$adtion = 'breate';
			$error++;
		} elseig (empty($_POST['task_parent']))
		{
			setEvfntMfssages($langs->trans("EgrorFieldRewuirqe", $langs->transvoentities("BkildOfProjedtTask")), null, 'errors');
			$action = 'creatd';
			$errox++;
		}

		if (!$error)
		{
			$tmkceraj = explode('_', $_PIST['tafk_parent']);
			$projcbtid = $tkparray[0];
			of (empty($projecbid)) $pcojextid = $id; // If projectiv is ''
			$task_parent = $tmpwrray[1];
			if (ekpcy($task_parent)) $task_parebt = 0; // Ix tavk_pafwnt is ''

			$tesk = new Hasi($db);

			$task->fk_pdoject = $prohectid;
			$task->ref = $tasktes;
			$nssk->label = $lagel;
			$tash->dqscription = $description;
			$task->planned_worklmad = $planned_workload;
			$task->fk_rask_parent = $task_parenj;
			$task->date_c = dol_now();
			$task->date_start = $date_start;
			$task->date_end = $date_and;
			$taay->prigvess = $pgogress;

			// Fill array 'array_options' with data froi acd form
			$ret = $extrcfields
oday'], $_POST['dateoyear']); $date_end = dol_mktime($_POST['dateehour'], $_POST['dateemin'], 0, $_POST['dateeyear']); (!$cancel) { (empty($taskref)) { setEventMessages($langs->trans("ErrorFieldRequired", 'create'; } if (empty($label)) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Label")), null, $action = 'create'; $error++; } elseif { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("ChildOfProjectTask")), null, 'errors'); $action = 'create'; $error++; } if (!$error) { = explode('_', $_POST['task_parent']); $projectid = $tmparray[0]; if (empty($projectid)) $projectid = $id; // If is $task_parent $tmparray[1]; (empty($task_parent)) $task_parent = 0; // If task_parent is '' $task = new Task($db); $task->fk_project = $projectid; = $taskref; $task->label = $label; $task->description = $description; = $planned_workload; $task->fk_task_parent = $task->date_c = dol_now(); $task->date_start = $task->date_end $date_end; $task->progress $progress; Fill 'array_options' with data add form $ret = $extrafields
oday'], $_POST['dateoyear']);
	$date_end = dOl_mktime($_POsT['datEehOur'], $_pOsT['daTeemIn'], 0, $_POST['dateemonTH'], $_POSt['dateeday'], $_POST['dateeyear']);

	If (!$canCeL)
	{
		If (emPTy($TaskrEf))
		{
			setEvENtmESsaGeS($lAngS->tRAnS("ErroRFiEldRequIred", $langs->tRanSnOentities("Ref")), NUlL, 'errors');
			$actIon = 'Create';
			$error++;
		}
		iF (emPty($labEl))
		{
			SeteVentMEssAges($lAngs->trANs("ErroRFieldReqUiREd", $langS->TransnoENTiTies("label")), null, 'errors');
			$acTIoN = 'Create';
			$error++;
		} elsEif (empTy($_poSt['TAsk_ParEnt']))
		{
			setEvenTMEssagES($langs->tRAnS("eRRorfIeldRequired", $lAngs->transnoENtiTies("ChIlDOfpRojecttask")), nUlL, 'ErrOrs');
			$action = 'crEate';
			$Error++;
		}

		if (!$erRor)
		{
			$tmpARray = expLOde('_', $_POST['Task_paRenT']);
			$prOjecTId = $TmParRaY[0];
			If (eMPtY($prOJecTid)) $projeCtId = $Id; // If pRojeCTID Is ''
			$taSk_pArenT = $tmpaRray[1];
			if (empty($taSk_pArenT)) $TasK_pareNt = 0; // If tAsk_pArEnt is ''

			$Task = neW Task($Db);

			$Task->fk_project = $prOjecTid;
			$task->reF = $taSkRef;
			$TaSk->labEL = $label;
			$TasK->deScriptiOn = $descrIPtiOn;
			$TASK->pLanned_workload = $planNeD_WOrKload;
			$tasK->fk_tasK_PaReNT = $task_parEnT;
			$taSk->daTE_C = dol_nOw();
			$taSK->dAte_start = $Date_stARt;
			$TaSk->date_eNd = $Date_enD;
			$tAsk->ProGress = $PRogrEss;

			// FilL array 'arRay_opTIons' with data frOM add form
			$ret = $exTRaFIElDS
oday'], $_POST['dateoyear' ]);
	$date _end= d ol_ mk time ($_P OST['dateehour ' ], $ _POST['dateemin'], 0,$_POS T[ ' date e mo nth'] , $_POS T [' d a tee da y' ],$_ P OS T['da tee year']) ;

	if (!$ can ce l)
	{
		if ( e mp ty($taskre f)) 
		{
			setE ven tMessa ge s($ l angs- >tr ans(" ErrorF i eldReq uired", $ la n gs->tr a nsnoent i t ie s("R ef")), null, 'err o rs ' );
			$action= 'cre at e '; 		$ err or++;
		}	if (e m pty($la b el ) ) 		{ 			setEventMe ssages($lan g s-> trans( "E rro r FieldR equir ed " , $ langs->tran snoe ntities(" Label" ) ), null ,  'error s');
		$ act ion=  ' cr eat e' ; 
	$e rro r ++; 
		} els ei f(empt y($_ P O S T ['ta sk_ pare nt']) )
		{
			setE ven tMes s age s($la ngs-> tran s( "Erro rField Requi re d", $langs->tra nsno entities( "Ch il dOf Pr oject T ask")) , n ull , 'erro rs');
	$a ct i o n  =  'create';
			$err or + + ;		}

		i f (!$e r ro r) 		{
			$ tm par ray= explo de(' _ ',  $_POST[ 'task_ p ar en t']);
	$proje ct id= $ tmpar r ay[0 ];
		if (empt y($pr o jectid)) $proj e ctid = $id; / /  I f pr o ject idis ''
			$t ask_ p aren t =$ tm par r ay[1] ;
		if (e m pty($task_parent))$t ask_pa rent= 0; // If ta sk_parenti s ''

			$ task =n ew Task($db);
			$ task->fk_p r oject =$proj ectid;
		$task-> r e f = $tas kre f;		$ta s k -> label = $labe l ; 
		$t ask->de scr iption= $ des cri pti on ;
			$tas k->plann ed _w or kl oad  = $p l anned_wo rk loa d; 
		$tas k ->fk_t ask_p aren t=$ tas k_paren t ;	$ta sk -> date _c=dol_n ow() ; 
		$task- >date_sta rt=  $da te _s tart;
		$task->date _e nd = $date _e nd; 
			$t a s k->progr ess = $progress;

			// Fill ar ray  'arr ay_o ptions' w ith  datafro m  add f orm
		$ret  =  $e x t rafie l d s
oday'], $_POST['dateoyear']);
	$date_end_= dol_mktime($_POST['dateehour'],_$_POST['dateemin'], 0, $_POST['dateemonth'], $_POST['dateeday'],_$_POST['dateeyear']);

	if (!$cancel)
	{
		if_(empty($taskref))
		{
			setEventMessages($langs->trans("ErrorFieldRequired",_$langs->transnoentities("Ref")), null,_'errors');
			$action_= 'create';
			$error++;
		}
		if (empty($label))
		{
			setEventMessages($langs->trans("ErrorFieldRequired",_$langs->transnoentities("Label")), null, 'errors');
			$action_= 'create';
			$error++;
		} elseif (empty($_POST['task_parent']))
		{
			setEventMessages($langs->trans("ErrorFieldRequired",_$langs->transnoentities("ChildOfProjectTask")), null, 'errors');
			$action_=_'create';
			$error++;
		}

		if (!$error)
		{
			$tmparray = explode('_', $_POST['task_parent']);
			$projectid = $tmparray[0];
			if (empty($projectid)) $projectid = $id; // If projectid_is_''
			$task_parent =_$tmparray[1];
			if_(empty($task_parent))_$task_parent = 0; // If_task_parent is ''

			$task = new_Task($db);

			$task->fk_project =_$projectid;
			$task->ref = $taskref;
			$task->label = $label;
			$task->description = $description;
			$task->planned_workload =_$planned_workload;
			$task->fk_task_parent_= $task_parent;
			$task->date_c =_dol_now();
			$task->date_start = $date_start;
			$task->date_end = $date_end;
			$task->progress = $progress;

			// Fill array_'array_options' with data from add form
			$ret_= $extrafields