public function create($data)
 {
     $projectid = $this->getRequest()->getQuery('projectid');
     $iterm = new Itermtm();
     if (array_key_exists('file', $data)) {
         if ($data['file']['id']) {
             $file = $this->find('\\User\\Entity\\File', $data['file']['id']);
         }
     }
     $project = $this->find('User\\Entity\\Project', $projectid);
     $iterm->setProject($project);
     $language = $this->find('User\\Entity\\Language', $data['languageid']);
     if ($data['rate_client']) {
         $DataArr = array('name' => $data['name'], 'rate' => $data['rate_client'], 'sourcebawu' => $data['sourcebawu'], 'sourcejiuwu' => $data['sourcejiuwu'], 'sourcenomatch' => $data['sourcenomatch'], 'sourceqiwu' => $data['sourceqiwu'], 'sourcerepetitions' => $data['sourcerepetitions'], 'sourcewushi' => $data['sourcewushi'], 'sourceyibai' => $data['sourceyibai'], 'total' => $data['total'], 'language' => $language);
     } else {
         $DataArr = array('name' => $data['name'], 'rate_freelancer' => $data['rate'], 'sourcebawu' => $data['sourcebawu'], 'sourcejiuwu' => $data['sourcejiuwu'], 'sourcenomatch' => $data['sourcenomatch'], 'sourceqiwu' => $data['sourceqiwu'], 'sourcerepetitions' => $data['sourcerepetitions'], 'sourcewushi' => $data['sourcewushi'], 'sourceyibai' => $data['sourceyibai'], 'total_freelancer' => $data['total'], 'language' => $language);
     }
     $DataArr['raterepetitions'] = $data['raterepetitions'] != null ? $data['raterepetitions'] : 0;
     $DataArr['rateyibai'] = $data['rateyibai'] != null ? $data['rateyibai'] : 0;
     $DataArr['ratejiuwu'] = $data['ratejiuwu'] != null ? $data['ratejiuwu'] : 0;
     $DataArr['ratebawu'] = $data['ratebawu'] != null ? $data['ratebawu'] : 0;
     $DataArr['rateqiwu'] = $data['rateqiwu'] != null ? $data['rateqiwu'] : 0;
     $DataArr['ratewushi'] = $data['ratewushi'] != null ? $data['ratewushi'] : 0;
     $DataArr['ratenomatch'] = $data['ratenomatch'] != null ? $data['ratenomatch'] : 0;
     $iterm->setData($DataArr);
     $iterm->save($this->getEntityManager());
     //add task if have not
     $entityManager = $this->getEntityManager();
     $repository = $entityManager->getRepository('User\\Entity\\Task');
     $task = $repository->findBy(array('project' => $project, 'language' => $language, 'type' => 2));
     //var_dump($data['total']);exit;
     if (!$task) {
         $task = new Task();
         $task->setData(['project' => $project, 'language' => $language, 'type' => 2, 'status' => 3, 'startDate' => new \DateTime('now'), 'dueDate' => $project->getDueDate(), 'total' => $data['total'], 'task_number' => $project->getProjectNo() . '-1']);
         $task->save($this->getEntityManager());
     }
     return new JsonModel(['iterm' => $iterm->getData()]);
 }
Exemplo n.º 2
0
 public function create($data)
 {
     //error_reporting(E_ALL);
     //ini_set('display_errors', 1);
     $this->cleanData($data);
     $targetLanguages = [];
     foreach ($data['targetLanguages'] as $targetLanguage) {
         $targetLanguages[$targetLanguage['id']] = $this->getReference('\\User\\Entity\\Language', $targetLanguage['id']);
     }
     $data['targetLanguages'] = $targetLanguages;
     if ($data['status'] == 1) {
         $data['quote_no'] = "QUO-" . date("Ymd") . mt_rand(0, 9) . mt_rand(0, 9) . mt_rand(0, 9) . mt_rand(0, 9);
     }
     $project = new Project();
     //var_dump($data);exit;
     $project->setData($data);
     $project->save($this->getEntityManager());
     $files = [];
     if (isset($data['files'])) {
         foreach ($data['files'] as $file) {
             $id = $file['id'];
             $file = $this->find('\\User\\Entity\\File', $id);
             if ($file->getProject() == null) {
                 $file->setProject($project);
                 $file->save($this->getEntityManager());
                 $files[$file->getId()] = $file;
             }
         }
     }
     //invoice
     $invoice = new Invoice();
     $invoice_no = "INV-" . date("Ymd") . mt_rand(0, 9) . mt_rand(0, 9) . mt_rand(0, 9) . mt_rand(0, 9);
     $invoice->setData(['invoice_no' => $invoice_no, 'dueDate' => $data['dueDate']]);
     $invoice->setProject($project);
     $invoice->save($this->getEntityManager());
     //
     if (isset($data['data'])) {
         foreach ($data['data'] as $iterms) {
             $identifier = $iterms['identifier'];
             $type = $identifier[0];
             $languageId = $identifier[1]['id'];
             if ($type == 'translationNoTM') {
                 foreach ($iterms['items'] as $item) {
                     $iterm = new Itermnotm();
                     $iterm->setProject($project);
                     $iterm->setData(['name' => $item['name'], 'file' => $files[$item['file']['id']], 'unit' => $item['unit']['id'], 'rate' => $item['rate'], 'quantity' => $item['quantity'], 'total' => $item['total'], 'language' => $targetLanguages[$languageId]]);
                 }
                 $iterm->save($this->getEntityManager());
             } else {
                 if ($type == 'translationTM') {
                     //foreach($iterms['itemtm'] as $item){
                     $iterm = new Itermtm();
                     $iterm->setProject($project);
                     $iterm->setData(['name' => $iterms['itemtm']['name'], 'file' => $files[$item['file']['id']], 'sourcebawu' => $iterms['itemtm']['sourcebawu'], 'sourcejiuwu' => $iterms['itemtm']['sourcejiuwu'], 'sourcenomatch' => $iterms['itemtm']['sourcenomatch'], 'sourceqiwu' => $iterms['itemtm']['sourceqiwu'], 'sourcerepetitions' => $iterms['itemtm']['sourcerepetitions'], 'sourcewushi' => $iterms['itemtm']['sourcewushi'], 'sourceyibai' => $iterms['itemtm']['sourceyibai'], 'raterepetitions' => $iterms['itemtm']['raterepetitions'], 'ratewushi' => $iterms['itemtm']['ratewushi'], 'rateyibai' => $iterms['itemtm']['rateyibai'], 'ratebawu' => $iterms['itemtm']['ratebawu'], 'ratejiuwu' => $iterms['itemtm']['ratejiuwu'], 'ratenomatch' => $iterms['itemtm']['ratenomatch'], 'rateqiwu' => $iterms['itemtm']['rateqiwu'], 'total' => $iterms['itemtm']['total'], 'rate' => $iterms['itemtm']['rate'], 'language' => $targetLanguages[$languageId]]);
                     //}
                     $iterm->save($this->getEntityManager());
                 } else {
                     if ($type == 'dtpMac') {
                         foreach ($iterms['items'] as $item) {
                             $iterm = new Itermdtpmac();
                             $iterm->setProject($project);
                             $iterm->setData(['name' => $item['name'], 'file' => $files[$item['file']['id']], 'unit' => $item['unit']['id'], 'rate' => $item['rate'], 'quantity' => $item['quantity'], 'total' => $item['total'], 'software' => $this->getReference('\\User\\Entity\\DesktopSoftware', $item['software']['id']), 'language' => $targetLanguages[$languageId]]);
                         }
                         $iterm->save($this->getEntityManager());
                     } else {
                         if ($type == 'dtpPc') {
                             foreach ($iterms['items'] as $item) {
                                 $iterm = new Itermdtppc();
                                 $iterm->setProject($project);
                                 $iterm->setData(['name' => $item['name'], 'file' => $files[$item['file']['id']], 'unit' => $item['unit']['id'], 'rate' => $item['rate'], 'quantity' => $item['quantity'], 'total' => $item['total'], 'software' => $this->getReference('\\User\\Entity\\DesktopSoftware', $item['software']['id']), 'language' => $targetLanguages[$languageId]]);
                             }
                             $iterm->save($this->getEntityManager());
                         } else {
                             if ($type == 'engineering') {
                                 foreach ($iterms['items'] as $item) {
                                     $iterm = new Itermengineering();
                                     $iterm->setProject($project);
                                     $iterm->setData(['name' => $item['name'], 'file' => $files[$item['file']['id']], 'unit' => $item['unit']['id'], 'rate' => $item['rate'], 'quantity' => $item['quantity'], 'total' => $item['total'], 'engineeringcategory' => $this->getReference('\\Common\\Entity\\EngineeringCategory', $item['category']['id']), 'language' => $targetLanguages[$languageId]]);
                                 }
                                 $iterm->save($this->getEntityManager());
                             } else {
                                 foreach ($iterms['items'] as $item) {
                                     $iterm = new Iterminterpreting();
                                     $iterm->setProject($project);
                                     $iterm->setData(['name' => $item['name'], 'file' => $files[$item['file']['id']], 'unit' => $item['unit']['id'], 'rate' => $item['rate'], 'quantity' => $item['quantity'], 'total' => $item['total'], 'language' => $targetLanguages[$languageId]]);
                                 }
                                 $iterm->save($this->getEntityManager());
                             }
                         }
                     }
                 }
             }
         }
         $project->save($this->getEntityManager());
         foreach ($data['data'] as $iterms) {
             $identifier = $iterms['identifier'];
             $type = $identifier[0];
             if ($type == 'translationNoTM') {
                 $type = 1;
             } else {
                 if ($type == 'translationTM') {
                     $type = 2;
                 } else {
                     if ($type == 'dtpMac') {
                         $type = 4;
                     } else {
                         if ($type == 'dtpPc') {
                             $type = 5;
                         } else {
                             if ($type == 'engineering') {
                                 $type = 6;
                             } else {
                                 $type = $data['types'][0]['id'];
                             }
                         }
                     }
                 }
             }
             $languageId = $identifier[1]['id'];
             $task = new Task();
             $task->setData(['project' => $project, 'language' => $targetLanguages[$languageId], 'type' => $type, 'status' => 3, 'name' => $data['reference'] . '-' . $identifier[0], 'startDate' => $data['startDate'], 'dueDate' => $data['dueDate']]);
             $task->save($this->getEntityManager());
         }
     }
     $activity = new Activity();
     $activity->setData(['activityDate' => new \DateTime('NOW'), 'project' => $project, 'type' => "create_quote", 'sender' => $data['pm'], 'message' => $data['description']]);
     //$activity->save($this->getEntityManager());
     return new JsonModel(['project' => $project->getData(), 'success' => true]);
 }
Exemplo n.º 3
0
 public function create($data)
 {
     //error_reporting(E_ALL);
     //ini_set('display_errors', 1);
     $projectTotal = 0;
     $this->cleanData($data);
     $targetLanguages = [];
     foreach ($data['targetLanguages'] as $targetLanguage) {
         $targetLanguages[$targetLanguage['id']] = $this->getReference('\\User\\Entity\\Language', $targetLanguage['id']);
     }
     $data['targetLanguages'] = $targetLanguages;
     //if($data['status'] == 2){//set odered
     $data['quote_no'] = "QUO-" . date("Ymd") . mt_rand(0, 9) . mt_rand(0, 9) . mt_rand(0, 9) . mt_rand(0, 9);
     //}
     $data['project_no'] = date("Ymd") . $this->generateRandomNumber();
     $project = new Project();
     if (($data['client'] == null || $data['client'] == '') && $data['newClient'] != null) {
         // Create User
         $Udata = array();
         $Udata['isActive'] = 1;
         $Udata['profileUpdated'] = null;
         $Udata['city'] = null;
         $Udata['currency'] = $data['currency'];
         $Udata['createdTime'] = new \DateTime('now');
         $Udata['email'] = $data['newClient']['Email'];
         $Udata['firstName'] = $data['newClient']['FirstName'];
         $Udata['lastName'] = $data['newClient']['LastName'];
         $Udata['password'] = $data['newClient']['Pass'];
         $Udata['phone'] = $data['newClient']['CellPhone'];
         $Udata['cellphone'] = $data['newClient']['CellPhone'];
         $Udata['gender'] = null;
         $Udata['comments'] = null;
         $Udata['position'] = null;
         $Udata['contracted'] = 0;
         $Udata['name'] = $data['newClient']['Email'];
         $UserEntityManager = $this->getEntityManager();
         $Udata['company_id'] = $UserEntityManager->getRepository('User\\Entity\\Company')->findOneBy(array('name' => $data['newClient']['CompanyName']));
         if (!$Udata['company_id']) {
             $Udata['company_id'] = null;
         }
         $Udata['country'] = $UserEntityManager->getRepository('User\\Entity\\Country')->findOneBy(array('id' => $data['newClient']['Country']['id']));
         $Udata['pm'] = null;
         $Udata['sales'] = null;
         $userExist = $UserEntityManager->getRepository('User\\Entity\\User')->findOneBy(array('email' => $data['newClient']['Email']));
         if ($userExist) {
             $data['client'] = $userExist;
             $userExist->createEmployer($this, $Udata, $UserEntityManager, null);
             $employer = $userExist->getEmployer();
             $employer->updateData(array('position' => null, 'defaultServiceLevel' => null, 'comments' => null, 'contracted' => '0', 'pm' => null, 'name' => $data['newClient']['Email'], 'sales' => null));
             $employer->save($UserEntityManager);
         } else {
             $user = new User();
             $user->setData($Udata);
             $user->save($UserEntityManager);
             $user->createEmployer($this, $Udata, $UserEntityManager, null);
             $employer = $user->getEmployer();
             $employer->updateData(array('position' => null, 'defaultServiceLevel' => null, 'comments' => null, 'contracted' => '0', 'pm' => null, 'name' => $data['newClient']['Email'], 'sales' => null));
             $employer->save($UserEntityManager);
             $data['client'] = $user;
         }
         // End Create User
     } else {
         //$employer = $this->find('User\Entity\Employer', $data['client']->getId());
         //$client = $this->getEntityManager()->getRepository('User\Entity\User')->findOneBy(array('employer' => $employer));
         //$data['client'] = $client;
     }
     $project->setData($data);
     $project->save($this->getEntityManager());
     $files = [];
     if (isset($data['files'])) {
         foreach ($data['files'] as $file) {
             $id = $file['id'];
             $file = $this->find('\\User\\Entity\\File', $id);
             if ($file->getProject() == null) {
                 $file->setProject($project);
                 $file->save($this->getEntityManager());
                 $files[$file->getId()] = $file;
             }
         }
     }
     // Create new Tasks for OrderTranslation & OrderTranslation Non Contract
     if (isset($data['createType'])) {
         if ($data['createType'] == 'orderTranslation' || $data['createType'] == 'orderTranslationNonContract' || $data['createType'] == 'landingOrder') {
             $i = 0;
             $langLength = count($targetLanguages);
             $task_array = array();
             foreach ($targetLanguages as $key => $targetLang) {
                 $i++;
                 $task = new Task();
                 $taskArrData = array('language' => $targetLang, 'status' => 3, 'project' => $project, 'startDate' => $data['startDate'], 'dueDate' => $data['dueDate'], 'total' => round($data['invoiceinfo']['total'] / $langLength, 2), 'task_number' => $data['project_no'] . '-' . $i);
                 $projectTotal = $projectTotal + floatval(round($data['invoiceinfo']['total'] / $langLength, 2));
                 $taskArrData['type'] = is_array($data['types']) && count($data['types']) > 0 ? $data['types'][0] : 1;
                 $name_ref = $data['files'][0]['name'];
                 $taskArrData['name'] = array_key_exists('reference', $data) ? $data['reference'] : $name_ref;
                 $task->setData($taskArrData);
                 $task->save($this->getEntityManager());
                 $task_array[$key] = $task;
                 if ($data['createType'] == 'orderTranslationNonContract' || $data['createType'] == 'landingOrder') {
                     foreach ($files as $key_id => $file) {
                         $iterm = new Itermnotm();
                         $iterm->setProject($project);
                         $entityManager = $this->getEntityManager();
                         //$task = $entityManager->getRepository('User\Entity\Task')->findBy(array('project'=>$project,'language'=>$targetLanguages[$languageId]));
                         //var_dump($targetLanguages[$languageId]);
                         //var_dump($project);
                         //var_dump($task);
                         $name_ref_tmp = $file->getName();
                         //$name_ref_tmp = (array_key_exists('reference',$data))?$data['reference']:$name_ref_tmp;
                         $iterm->setTask($task);
                         $iterm->setData(['name' => $name_ref_tmp, 'file' => $file, 'rate' => $data['price'][$targetLang->getId()], 'quantity' => $data['totalwords'], 'total' => $data['price'][$targetLang->getId()] * $data['totalwords'], 'language' => $targetLang]);
                         //$projectTotal = $projectTotal + floatval($item['total']);
                         $iterm->save($this->getEntityManager());
                     }
                 }
             }
             $invoice = new Invoice();
             $invoice_no = "INV-" . date("Ymd") . mt_rand(0, 9) . mt_rand(0, 9) . mt_rand(0, 9) . mt_rand(0, 9);
             $invoiceDataArr = array('invoice_no' => $invoice_no, 'dueDate' => $data['dueDate']);
             if (array_key_exists('invoiceinfo', $data)) {
                 //var_dump($data['invoiceinfo']);
                 $invoiceDataArr['subtotal'] = $data['invoiceinfo']['subtotal'];
                 $invoiceDataArr['tax'] = $data['invoiceinfo']['tax'];
                 $invoiceDataArr['discount'] = $data['invoiceinfo']['discount'];
                 $invoiceDataArr['total'] = $data['invoiceinfo']['total'];
             }
             $invoice->setData($invoiceDataArr);
             $invoice->setProject($project);
             $invoice->save($this->getEntityManager());
             //set session
             if ($data['createType'] == 'landingOrder') {
                 $ns = new Container('order');
                 $ns->project = $project->getId();
                 $ns->project_no = $project->getProjectNo();
                 $ns->total = $data['invoiceinfo']['total'];
                 $ns->currency = $data['currency'];
                 $ns->client = $data['client']->getId();
             }
         }
     }
     //
     $tmp_type = array();
     if (isset($data['data'])) {
         $i = 0;
         foreach ($data['data'] as $iterms) {
             $i++;
             $identifier = $iterms['identifier'];
             $type = $identifier[0];
             if ($type == 'translationNoTM') {
                 $type = 1;
                 if (!$tmp_type[$type]) {
                     $tmp_type[1] = $iterms;
                 }
             } else {
                 if ($type == 'translationTM') {
                     $type = 2;
                     if (!$tmp_type[$type]) {
                         $tmp_type[2] = $iterms;
                     }
                 } else {
                     if ($type == 'dtpMac') {
                         $type = 4;
                         if (!$tmp_type[$type]) {
                             $tmp_type[4] = $iterms;
                         }
                     } else {
                         if ($type == 'dtpPc') {
                             $type = 5;
                             if (!$tmp_type[$type]) {
                                 $tmp_type[5] = $iterms;
                             }
                         } else {
                             if ($type == 'engineering') {
                                 $type = 6;
                                 if (!$tmp_type[$type]) {
                                     $tmp_type[6] = $iterms;
                                 }
                             } else {
                                 $type = $data['types'][0]['id'];
                                 if (!$tmp_type[$type]) {
                                     $tmp_type[$type] = $iterms;
                                 }
                             }
                         }
                     }
                 }
             }
         }
         if (isset($data['data'])) {
             $i = 0;
             $tmp_task = array();
             foreach ($tmp_type as $key => $iterm) {
                 $i++;
                 $task = new Task();
                 $identifier = $iterm['identifier'];
                 $languageId = $identifier[1]['id'];
                 $task->setData(['project' => $project, 'language' => $targetLanguages[$languageId], 'type' => $key, 'status' => 3, 'name' => $data['reference'], 'startDate' => $data['startDate'], 'dueDate' => $data['dueDate'], 'task_number' => $data['project_no'] . '-' . $i]);
                 $task->save($this->getEntityManager());
                 $tmp_task[$key] = $task;
             }
         }
         /*if(isset($data['data'])){
         		      $i = 0;
         		      foreach($data['data'] as $iterms){
         			    $i++;
                   $identifier = $iterms['identifier'];
                     $type = $identifier[0];
         			      if ($type == 'translationNoTM'){
         				$type = 1;
         			}
         			else if ($type == 'translationTM'){
         				$type = 2;
         			}
         			else if ($type == 'dtpMac'){
         				$type = 4;
         			}
         			else if ($type == 'dtpPc'){
         				$type = 5;
         			}
         			else if ($type == 'engineering'){
         				$type = 6;
         			}
         			else{
         				$type = $data['types'][0]['id'];
         			}
         			//if(!$type)
         			//	$type = 1;
                     $languageId = $identifier[1]['id'];
         
         			$task = new Task();
         
         			$task->setData([
                             'project' => $project,
                             'language' => $targetLanguages[$languageId],
                             'type' => $type,
                             'status' => 3,
         					'name' => $data['reference'],// . '-' . $identifier[0],
         					'startDate' => $data['startDate'],
         					'dueDate' => $data['dueDate'],
         					'task_number' => $data['project_no'].'-'.$i,
         
                         ]);
         			$task->save($this->getEntityManager());
         
         		}*/
         //if(isset($data['data'])){
         foreach ($data['data'] as $iterms) {
             $identifier = $iterms['identifier'];
             $type = $identifier[0];
             $languageId = $identifier[1]['id'];
             if ($type == 'translationNoTM') {
                 foreach ($iterms['items'] as $item) {
                     //var_dump($item); exit;
                     $iterm = new Itermnotm();
                     $iterm->setProject($project);
                     $entityManager = $this->getEntityManager();
                     //$task = $entityManager->getRepository('User\Entity\Task')->findBy(array('project'=>$project,'language'=>$targetLanguages[$languageId]));
                     //var_dump($targetLanguages[$languageId]);
                     //var_dump($project);
                     //var_dump($task);
                     $iterm->setTask($tmp_task[1]);
                     $iterm->setData(['name' => $item['name'], 'file' => $files[$item['file']['id']], 'unit' => $item['unit']['id'], 'rate' => $item['rate'], 'quantity' => $item['quantity'], 'total' => $item['total'], 'language' => $targetLanguages[$languageId]]);
                     $projectTotal = $projectTotal + floatval($item['total']);
                     $iterm->save($this->getEntityManager());
                 }
                 //exit;
             } else {
                 if ($type == 'translationTM') {
                     //foreach($iterms['itemtm'] as $item){
                     $iterm = new Itermtm();
                     $iterm->setProject($project);
                     $iterm->setData(['name' => $iterms['itemtm']['name'], 'sourcebawu' => $iterms['itemtm']['sourcebawu'], 'sourcejiuwu' => $iterms['itemtm']['sourcejiuwu'], 'sourcenomatch' => $iterms['itemtm']['sourcenomatch'], 'sourceqiwu' => $iterms['itemtm']['sourceqiwu'], 'sourcerepetitions' => $iterms['itemtm']['sourcerepetitions'], 'sourcewushi' => $iterms['itemtm']['sourcewushi'], 'sourceyibai' => $iterms['itemtm']['sourceyibai'], 'raterepetitions' => $iterms['itemtm']['raterepetitions'], 'ratewushi' => $iterms['itemtm']['ratewushi'], 'rateyibai' => $iterms['itemtm']['rateyibai'], 'ratebawu' => $iterms['itemtm']['ratebawu'], 'ratejiuwu' => $iterms['itemtm']['ratejiuwu'], 'ratenomatch' => $iterms['itemtm']['ratenomatch'], 'rateqiwu' => $iterms['itemtm']['rateqiwu'], 'total' => $iterms['itemtm']['total'], 'rate' => $iterms['itemtm']['rate'], 'language' => $targetLanguages[$languageId]]);
                     $projectTotal = $projectTotal + floatval($iterms['itemtm']['total']);
                     //}
                     $iterm->save($this->getEntityManager());
                 } else {
                     if ($type == 'dtpMac') {
                         foreach ($iterms['items'] as $item) {
                             $iterm = new Itermdtpmac();
                             $iterm->setProject($project);
                             $iterm->setTask($tmp_task[4]);
                             $iterm->setData(['name' => $item['name'], 'file' => $files[$item['file']['id']], 'unit' => $item['unit']['id'], 'rate' => $item['rate'], 'quantity' => $item['quantity'], 'total' => $item['total'], 'software' => $this->getReference('\\User\\Entity\\DesktopSoftware', $item['software']['id']), 'language' => $targetLanguages[$languageId]]);
                             $projectTotal = $projectTotal + floatval($item['total']);
                             $iterm->save($this->getEntityManager());
                         }
                     } else {
                         if ($type == 'dtpPc') {
                             foreach ($iterms['items'] as $item) {
                                 $iterm = new Itermdtppc();
                                 $iterm->setProject($project);
                                 $iterm->setTask($tmp_task[5]);
                                 $iterm->setData(['name' => $item['name'], 'file' => $files[$item['file']['id']], 'unit' => $item['unit']['id'], 'rate' => $item['rate'], 'quantity' => $item['quantity'], 'total' => $item['total'], 'software' => $this->getReference('\\User\\Entity\\DesktopSoftware', $item['software']['id']), 'language' => $targetLanguages[$languageId]]);
                                 $projectTotal = $projectTotal + floatval($item['total']);
                                 $iterm->save($this->getEntityManager());
                             }
                         } else {
                             if ($type == 'engineering') {
                                 foreach ($iterms['items'] as $item) {
                                     $iterm = new Itermengineering();
                                     $iterm->setProject($project);
                                     $iterm->setTask($tmp_task[6]);
                                     $iterm->setData(['name' => $item['name'], 'file' => $files[$item['file']['id']], 'unit' => $item['unit']['id'], 'rate' => $item['rate'], 'quantity' => $item['quantity'], 'total' => $item['total'], 'engineeringcategory' => $this->getReference('\\Common\\Entity\\EngineeringCategory', $item['category']['id']), 'language' => $targetLanguages[$languageId]]);
                                     $projectTotal = $projectTotal + floatval($item['total']);
                                     $iterm->save($this->getEntityManager());
                                 }
                             } else {
                                 foreach ($iterms['items'] as $item) {
                                     $iterm = new Iterminterpreting();
                                     $iterm->setProject($project);
                                     $iterm->setTask($tmp_task[7]);
                                     $iterm->setData(['name' => $item['name'], 'file' => $files[$item['file']['id']], 'unit' => $item['unit']['id'], 'rate' => $item['rate'], 'quantity' => $item['quantity'], 'total' => $item['total'], 'language' => $targetLanguages[$languageId]]);
                                     $projectTotal = $projectTotal + floatval($item['total']);
                                     $iterm->save($this->getEntityManager());
                                 }
                             }
                         }
                     }
                 }
             }
         }
         // Create Invoice forData
         $invoice = new Invoice();
         $invoice_no = "INV-" . date("Ymd") . mt_rand(0, 9) . mt_rand(0, 9) . mt_rand(0, 9) . mt_rand(0, 9);
         $invoiceDataArr = array('invoice_no' => $invoice_no, 'dueDate' => $data['dueDate'], 'subtotal' => $projectTotal, 'tax' => 0, 'discount' => 0, 'total' => $projectTotal);
         $invoice->setData($invoiceDataArr);
         $invoice->setProject($project);
         $invoice->save($this->getEntityManager());
         $project->save($this->getEntityManager());
     }
     $ActiDataArr = ['activityDate' => new \DateTime('NOW'), 'project' => $project, 'type' => "create_quote"];
     if (array_key_exists('pm', $data)) {
         $ActiDataArr['sender'] = $data['pm'];
     }
     if (array_key_exists('description', $data)) {
         $ActiDataArr['message'] = $data['description'];
     }
     $activity = new Activity();
     $activity->setData($ActiDataArr);
     $project->setData(['total_tmp' => $projectTotal]);
     $project->save($this->getEntityManager());
     $activity->save($this->getEntityManager());
     //var_dump($project); exit;
     return new JsonModel(['project' => $project->getData(), 'success' => true]);
 }