Guest User

Untitled

a guest
Feb 22nd, 2018
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 64.63 KB | None | 0 0
  1. <?php
  2.  
  3. defined('BASEPATH') OR exit('No direct script access allowed');
  4.  
  5. class Projects extends CI_Controller {
  6.  
  7. public function __construct() {
  8. parent::__construct();
  9. error_reporting(E_ALL);
  10. $this->load->model('Managers');
  11. $this->Managers->auth();
  12. $this->load->library('pagination');
  13. $this->load->helper('common');
  14. //$this->load->library('session');
  15. }
  16.  
  17. public function index() {
  18.  
  19. $projects = $this->Managers->get_table_data('tbl_projects')->result();
  20. //echo "<pre/>"; print_r($projects); die;
  21. $content = $this->load->view('admin/projects/index.php', array('data' => $projects), TRUE);
  22. $this->load->view('admin/templete', array('content' => $content));
  23. }
  24.  
  25.  
  26. public function add($id = false) {
  27. //echo '<pre>'; print_r($_POST); die;
  28. $project_data = array(
  29. 'id' => $id,
  30. 'name' => '',
  31. 'slug' => '',
  32. 'time' => '',
  33. 'start_date' => '',
  34. 'end_date' => '',
  35. 'client_id' => '',
  36. 'services' => '',
  37. 'currency_id' => '',
  38. 'ammount' => '',
  39. 'description' => '',
  40. 'status' => '',
  41. 'client_project_id' => ''
  42. );
  43. if($id){
  44. $this->form_validation->set_rules('name', 'Project Name', 'trim|required');
  45. $this->form_validation->set_rules('ammount', 'Project Amount', 'trim|required');
  46. $this->form_validation->set_rules('client_id', 'Client Name', 'trim|required');
  47. $this->form_validation->set_rules('client_project_id', 'Client Project Id', 'trim|required');
  48. }else{
  49. $this->form_validation->set_rules('name', 'Project Name', 'trim|required|is_unique[tbl_projects.name]');
  50. $this->form_validation->set_rules('ammount', 'Project Amount', 'trim|required');
  51. $this->form_validation->set_rules('client_id', 'Client Name', 'trim|required');
  52. $this->form_validation->set_rules('client_project_id', 'Client Project Id', 'trim|required');
  53. }
  54.  
  55. $first_data = $this->Managers->get_table_data('tbl_projects')->last_row();
  56.  
  57. if($id){
  58.  
  59. $project_id = trim($this->input->post('project_id'));
  60. $invoice = trim($this->input->post('invoice'));
  61.  
  62. $date1 = new DateTime($this->input->post('start_date'));
  63. $date2 = new DateTime($this->input->post('end_date'));
  64.  
  65. $diff = $date2->diff($date1)->format("%a");
  66.  
  67. }else{
  68.  
  69. $project_unique_string = strtotime(date("h:i:sa"));
  70. $project_unique_word = substr($project_unique_string, -8);
  71. $project_unique_number = substr($project_unique_word, -4);
  72.  
  73. if(!empty($first_data)){
  74.  
  75. $val_time = $first_data->project_id;
  76. $latest_value = substr($val_time, -1);
  77. $current_value = $latest_value+1;
  78. $project_id = 'EPM-'.date('y').''.$project_unique_number.''.$current_value;
  79.  
  80. }else{
  81.  
  82. $project_id = 'EPM-'.date('y').''.$project_unique_number.'1';
  83. }
  84.  
  85. $unixTimestamp = strtotime(date("Y-m-d h:i:sa"));
  86. $invoice = 'ES-'.$unixTimestamp;
  87.  
  88. $date1 = new DateTime($this->input->post('start_date'));
  89. $date2 = new DateTime($this->input->post('end_date'));
  90.  
  91. $diff = $date2->diff($date1)->format("%a");
  92.  
  93. }
  94.  
  95. if ($this->form_validation->run() == TRUE) {
  96.  
  97. if($this->input->post('translation') == 'true'){
  98. $translation = array(
  99. 'translation' => array(
  100. 'name' => 'translation',
  101. 'value' => trim($this->input->post('translation_word'))
  102. )
  103. );
  104. }else{
  105. $translation = array(
  106. 'translation' => array(
  107. 'name' => '',
  108. 'value' => ''
  109. )
  110. );
  111. }
  112.  
  113. if($this->input->post('editing') == 'true'){
  114. $editing = array(
  115. 'editing' => array(
  116. 'name' => 'editing',
  117. 'value' => trim($this->input->post('editing_word'))
  118. )
  119. );
  120. }else{
  121. $editing = array(
  122. 'editing' => array(
  123. 'name' => '',
  124. 'value' => ''
  125. )
  126. );
  127. }
  128.  
  129. if($this->input->post('proofread') == 'true'){
  130. $proofread = array(
  131. 'proofread' => array(
  132. 'name' => 'proofread',
  133. 'value' => trim($this->input->post('proofread_word'))
  134. )
  135. );
  136. }else{
  137. $proofread = array(
  138. 'proofread' => array(
  139. 'name' => '',
  140. 'value' => ''
  141. )
  142. );
  143. }
  144.  
  145. if($this->input->post('transcription') == 'true'){
  146. $transcription = array(
  147. 'transcription' => array(
  148. '0' => array(
  149. 'name' => 'transcription_audio',
  150. 'value' => trim($this->input->post('transcription_audio'))
  151. ),
  152. '1' => array(
  153. 'name' => 'transcription_video',
  154. 'value' => trim($this->input->post('transcription_video'))
  155. )
  156. )
  157. );
  158. }else{
  159. $transcription = array(
  160. 'transcription' => array(
  161. '0' => array(
  162. 'name' => '',
  163. 'value' => ''
  164. ),
  165. '1' => array(
  166. 'name' => '',
  167. 'value' => ''
  168. )
  169. )
  170. );
  171. }
  172.  
  173. if($this->input->post('subtitling') == 'true'){
  174. $subtitling = array(
  175. 'subtitling' => array(
  176. 'name' => 'checked',
  177. 'value' => 'checked'
  178. )
  179. );
  180. }else{
  181. $subtitling = array(
  182. 'subtitling' => array(
  183. 'name' => '',
  184. 'value' => ''
  185. )
  186. );
  187. }
  188.  
  189. if($this->input->post('creation') == 'true'){
  190. $creation = array(
  191. 'creation' => array(
  192. 'name' => 'creation',
  193. 'value' => trim($this->input->post('creation_video'))
  194. )
  195. );
  196. }else{
  197. $creation = array(
  198. 'creation' => array(
  199. 'name' => '',
  200. 'value' => ''
  201. )
  202. );
  203. }
  204.  
  205. if($this->input->post('translator') == 'true'){
  206. $translator = array(
  207. 'translator' => array(
  208. 'name' => 'translator',
  209. 'value' => trim($this->input->post('translator_video'))
  210. )
  211. );
  212. }else{
  213. $translator = array(
  214. 'translator' => array(
  215. 'name' => '',
  216. 'value' => ''
  217. )
  218. );
  219. }
  220.  
  221. if($this->input->post('voiceover') == 'true'){
  222.  
  223. $first_voiceover = array(
  224. 'first_voiceover' => array(
  225. 'name' => ucwords(trim($this->input->post('voice_language_1'))),
  226. 'value' => trim($this->input->post('cost_language_1'))
  227. )
  228. );
  229.  
  230. $second_voiceover = array(
  231. 'second_voiceover' => array(
  232. 'name' => ucwords(trim($this->input->post('voice_language_2'))),
  233. 'value' => trim($this->input->post('cost_language_2'))
  234. )
  235. );
  236.  
  237. $third_voiceover = array(
  238. 'third_voiceover' => array(
  239. 'name' => ucwords(trim($this->input->post('voice_language_3'))),
  240. 'value' => trim($this->input->post('cost_language_3'))
  241. )
  242. );
  243.  
  244. $studio = array(
  245. 'studio' => array(
  246. 'name' => 'studio',
  247. 'value' => trim($this->input->post('studio'))
  248. )
  249. );
  250.  
  251. }else{
  252.  
  253. $first_voiceover = array(
  254. 'first_voiceover' => array(
  255. 'name' => '',
  256. 'value' => ''
  257. )
  258. );
  259.  
  260. $second_voiceover = array(
  261. 'second_voiceover' => array(
  262. 'name' => '',
  263. 'value' => ''
  264. )
  265. );
  266.  
  267. $third_voiceover = array(
  268. 'third_voiceover' => array(
  269. 'name' => '',
  270. 'value' => ''
  271. )
  272. );
  273.  
  274. $studio = array(
  275. 'studio' => array(
  276. 'name' => '',
  277. 'value' => ''
  278. )
  279. );
  280. }
  281.  
  282.  
  283. if(!empty($this->input->post('translation_word'))){
  284. $translation_1 = 1;
  285. }else{
  286. $translation_1 = 0;
  287. }
  288.  
  289. if(!empty($this->input->post('editing_word'))){
  290. $editing_1 = 1;
  291. }else{
  292. $editing_1 = 0;
  293. }
  294.  
  295. if(!empty($this->input->post('proofread_word'))){
  296. $proofread_1 = 1;
  297. }else{
  298. $proofread_1 = 0;
  299. }
  300.  
  301. if(!empty($this->input->post('transcription_audio'))){
  302. $transcription_audio_1 = 1;
  303. }else{
  304. $transcription_audio_1 = 0;
  305. }
  306.  
  307. if(!empty($this->input->post('transcription_video'))){
  308. $transcription_video_1 = 1;
  309. }else{
  310. $transcription_video_1 = 0;
  311. }
  312.  
  313. if(!empty($this->input->post('creation_video'))){
  314. $creation_video_1 = 1;
  315. }else{
  316. $creation_video_1 = 0;
  317. }
  318.  
  319. if(!empty($this->input->post('translator_video'))){
  320. $translator_video_1 = 1;
  321. }else{
  322. $translator_video_1 = 0;
  323. }
  324.  
  325. if(!empty($this->input->post('voice_language_1'))){
  326. $voice_over_1 = 1;
  327. }else{
  328. $voice_over_1 = 0;
  329. }
  330.  
  331. if(!empty($this->input->post('voice_language_2'))){
  332. $voice_over_2 = 1;
  333. }else{
  334. $voice_over_2 = 0;
  335. }
  336.  
  337. if(!empty($this->input->post('voice_language_3'))){
  338. $voice_over_3 = 1;
  339. }else{
  340. $voice_over_3 = 0;
  341. }
  342.  
  343. $total_service = $translation_1 + $editing_1 + $proofread_1 + $transcription_audio_1 + $transcription_video_1 + $creation_video_1 + $translator_video_1 + $voice_over_1 + $voice_over_2 + $voice_over_3;
  344. //echo $total_service; die;
  345.  
  346. $services = array_merge($translation,$editing,$proofread,$transcription,$subtitling,$creation,$translator,$first_voiceover,$second_voiceover,$third_voiceover,$studio);
  347.  
  348. //echo '<pre>'; print_r($_POST).'<br>';
  349. //echo '<pre>'; print_r($services).'<br>';
  350. $test = json_encode($services);
  351. //echo '<pre>'; print_r($test); die;
  352.  
  353.  
  354. $project_data['name'] = trim($this->input->post('name'));
  355. $project_data['slug'] = str_replace(' ', '-', strtolower ($project_data['name']));
  356. $project_data['time'] = $diff;
  357. $project_data['start_date'] = trim($this->input->post('start_date'));
  358. $project_data['end_date'] = trim($this->input->post('end_date'));
  359. $project_data['client_id'] = trim($this->input->post('client_id'));
  360.  
  361. if(!empty($this->input->post('member_id'))){
  362. $project_data['member_id'] = trim($this->input->post('member_id'));
  363. }else{
  364. $project_data['member_id'] = '0';
  365. }
  366.  
  367. $project_data['currency_id'] = trim($this->input->post('currency_id'));
  368. $project_data['client_project_id'] = trim($this->input->post('client_project_id'));
  369. $project_data['ammount'] = trim($this->input->post('ammount'));
  370. $project_data['services'] = $test;
  371. $project_data['project_id'] = $project_id;
  372. $project_data['invoice'] = $invoice;
  373. $project_data['total_service'] = $total_service;
  374. $project_data['description'] = trim($this->input->post('content'));
  375. $project_data['status'] = trim($this->input->post('status'));
  376.  
  377. //echo '<pre>'; print_r($_POST).'<br>';
  378. //echo '<pre>'; print_r($project_data); die;
  379.  
  380. if(!empty($_POST['mobileCompany'])){
  381. $company_data['name'] = trim($this->input->post('clinetCompany'));
  382. $company_data['phone'] = trim($this->input->post('mobileCompany'));
  383. $company_data['address'] = trim($this->input->post('addresCompany'));
  384. $company_data[' country'] = trim($this->input->post('countryCompany'));
  385. $date = strtotime(date("Y-m-d h:i:sa"));
  386. $arr = explode(' ',trim(strtolower($company_data['name'])));
  387. $company_data['client_id'] = $arr['0'].''.$date;
  388. $company_data['type'] = '1';
  389. $project_data['client_id'] = $this->Managers->insert_data('tbl_clients', $company_data);
  390. }else{
  391.  
  392. }
  393.  
  394. $result = $this->Managers->insert_data_and_update($id, 'tbl_projects', $project_data);
  395. ($result) ? $this->session->set_flashdata('inserted', TRUE) : $this->session->set_flashdata('error', TRUE);
  396. redirect('admin/projects');
  397. }
  398.  
  399. if ($id) {
  400. $client_data = $this->Managers->get_clients_tiered();
  401. $currency_data = $this->Managers->get_currency_tiered();
  402. $data = $this->Managers->get_data_where('tbl_projects', array('id' => $id));
  403. $project_data = $this->Managers->get_data_where('tbl_projects', array('id' => $id))->row();
  404. $company_data = $this->Managers->get_data_where('tbl_clients', array('id' => $project_data->client_id))->row();
  405. if(!empty($company_data->client_id)){
  406. $company_client_data = $this->Managers->get_company_clients_tiered($company_data->client_id);
  407. }else{
  408. $company_client_data = '';
  409. }
  410. $content = $this->load->view('admin/projects/add', array('data' => $data, 'id' => $id, 'clients' => $client_data, 'currency' => $currency_data, 'company_clients' => $company_client_data), TRUE);
  411. $this->load->view('admin/templete', array('content' => $content));
  412. } else {
  413. $client_data['clients'] = $this->Managers->get_clients_tiered();
  414. $client_data['currency'] = $this->Managers->get_currency_tiered();
  415. $content = $this->load->view('admin/projects/add', $client_data, TRUE);
  416. $this->load->view('admin/templete', array('content' => $content));
  417. }
  418. }
  419.  
  420. public function updatestaus() {
  421. $id = $this->input->post('id');
  422. $type = $this->input->post('status');
  423. if($type == 0){
  424. $status = 1;
  425. }else{
  426. $status = 0;
  427. }
  428.  
  429. $project_status = $this->Managers->updateDataWhere('tbl_projects', array('status' => $status), array('id' => $id));
  430. }
  431.  
  432. public function currencyDetails(){
  433.  
  434. $currency = $this->Managers->get_table_data('tbl_currnecy')->result();
  435. //echo "<pre/>"; print_r($currency); die;
  436. $content = $this->load->view('admin/projects/currency_details.php', array('data' => $currency), TRUE);
  437. $this->load->view('admin/templete', array('content' => $content));
  438.  
  439. }
  440.  
  441. public function currency_add($id = false) {
  442. //echo '<pre>'; print_r($_POST); die;
  443. $curency_data = array(
  444. 'id' => $id,
  445. 'USD' => '',
  446. 'EURO' => '',
  447. 'AED' => '',
  448. 'GBP' => '',
  449. 'created' => ''
  450. );
  451. if($id){
  452. $this->form_validation->set_rules('currency_1', 'Currency Data', 'trim|required');
  453. }else{
  454. $this->form_validation->set_rules('date', 'Currency Date', 'trim|required|is_unique[tbl_currnecy.created]');
  455. }
  456.  
  457. if ($this->form_validation->run() == TRUE) {
  458. $curency_data['USD'] = trim($this->input->post('currency_1'));
  459. $curency_data['EURO'] = trim($this->input->post('currency_2'));
  460. $curency_data['AED'] = trim($this->input->post('currency_3'));
  461. $curency_data['GBP'] = trim($this->input->post('currency_4'));
  462. if($id){
  463. $curency_data['created'] = trim($this->input->post('date'));
  464. }else{
  465. $curency_data['created'] = strtotime($this->input->post('date'));
  466. }
  467.  
  468. $result = $this->Managers->insert_data_and_update($id, 'tbl_currnecy', $curency_data);
  469. ($result) ? $this->session->set_flashdata('inserted', TRUE) : $this->session->set_flashdata('error', TRUE);
  470. redirect('admin/projects/currencyDetails');
  471. }
  472.  
  473. if ($id) {
  474. $data = $this->Managers->get_data_where('tbl_currnecy', array('id' => $id));
  475. $content = $this->load->view('admin/projects/currency_add', array('data' => $data, 'id' => $id), TRUE);
  476. $this->load->view('admin/templete', array('content' => $content));
  477. } else {
  478. $content = $this->load->view('admin/projects/currency_add', $curency_data, TRUE);
  479. $this->load->view('admin/templete', array('content' => $content));
  480. }
  481. }
  482.  
  483. public function currencyPopupDetails($id) {
  484. $where = array( 'id' => $id );
  485. $data = $this->Managers->get_data_where('tbl_currnecy', $where);
  486. $content = $this->load->view('admin/projects/currency_popup_details', array('data' => $data));
  487. }
  488.  
  489. public function deleteProject(){
  490. $id = $this->input->post('id');
  491. if($id)
  492. $query = $this->db->delete('tbl_projects', array('id' => $id));
  493. ($query) ? $response = TRUE : $response = FALSE;
  494. return $response;
  495. return false;
  496. }
  497.  
  498. public function assignments(){
  499.  
  500. $projects = $this->Managers->get_data_where('tbl_projects', array('status' => '1'))->result();
  501. //echo "<pre/>"; print_r($projects); die;
  502. $content = $this->load->view('admin/projects/assignments.php', array('data' => $projects), TRUE);
  503. $this->load->view('admin/templete', array('content' => $content));
  504.  
  505. }
  506.  
  507. public function assign($id = false) {
  508. //echo $id; die;
  509.  
  510. // init params
  511. $params = array();
  512. $limit_per_page = 50;
  513. $start_index = ($this->uri->segment(5)) ? $this->uri->segment(5) : 0;
  514. $total_records = $this->Managers->get_total();
  515.  
  516. if ($total_records > 0)
  517. {
  518. // get current page records
  519. $params["results"] = $this->Managers->get_current_page_records($limit_per_page, $start_index);
  520.  
  521. $config['base_url'] = base_url() . 'admin/projects/assign/'.$id.'/';
  522. $config['total_rows'] = $total_records;
  523. $config['per_page'] = $limit_per_page;
  524. $config["uri_segment"] = 5;
  525.  
  526. // custom paging configuration
  527. $config['first_link'] = 'First';
  528. $config['first_tag_open'] = '<li>';
  529. $config['first_tag_close'] = '</li>';
  530. $config['last_link'] = 'Last';
  531. $config['last_tag_open'] = '<li>';
  532. $config['last_tag_close'] = '</li>';
  533.  
  534. $config['full_tag_open'] = '<nav><ul class="pagination">';
  535. $config['full_tag_close'] = '</ul></nav>';
  536. $config['cur_tag_open'] = '<li class="active"><a href="#">';
  537. $config['cur_tag_close'] = '</a></li>';
  538.  
  539. $config['num_tag_open'] = '<li>';
  540. $config['num_tag_close'] = '</li>';
  541.  
  542. $config['prev_link'] = '&laquo;';
  543. $config['prev_tag_open'] = '<li>';
  544. $config['prev_tag_close'] = '</li>';
  545.  
  546. $config['next_link'] = '&raquo;';
  547. $config['next_tag_open'] = '<li>';
  548. $config['next_tag_close'] = '</li>';
  549.  
  550. $this->pagination->initialize($config);
  551.  
  552. // build paging links
  553. $params["links"] = $this->pagination->create_links();
  554. }
  555.  
  556. //echo '<pre>'; print_r($params); die;
  557.  
  558. $data = $this->Managers->get_data_where('tbl_projects', array('id' => $id));
  559. $content = $this->load->view('admin/projects/assign', array('data' => $data, 'id' => $id, 'users' => $params), TRUE);
  560. $this->load->view('admin/templete', array('content' => $content));
  561.  
  562. }
  563.  
  564. public function getServiceValue(){
  565.  
  566. // echo '<pre>'; print_r($_POST).'<br>';die;
  567. $service_value = $_POST['val'];
  568. $projectUID = $_POST['project_id'];
  569.  
  570. $project_service_value = $this->Managers->get_data_where('tbl_projects', array('project_id' => $_POST['project_id']))->row();
  571.  
  572. $services_values = json_decode($project_service_value->services);
  573.  
  574. if($service_value == 'first_voiceover'){
  575. $latest_service_value = $services_values->first_voiceover->name .' (voice Over)';
  576. }elseif($service_value == 'second_voiceover'){
  577. $latest_service_value = $services_values->second_voiceover->name .' (voice Over)';
  578. }elseif($service_value == 'third_voiceover'){
  579. $latest_service_value = $services_values->third_voiceover->name .' (voice Over)';
  580. }else{
  581. $latest_service_value = $_POST['val'];
  582. }
  583.  
  584. //echo $latest_service_value.'<br>';
  585.  
  586. $worker_denied_users = $this->Managers->get_data_where('tbl_project_assignments', array('service' => $latest_service_value, 'denied' => '1', 'project_id' => $projectUID))->result();
  587. //echo '<pre>'; print_r($worker_denied_users).'<br>';die;
  588. if(!empty($worker_denied_users)){
  589. foreach ($worker_denied_users as $worker_denied_user) {
  590. $filter_data[] = $worker_denied_user->user_id;
  591. }
  592. $workers = $this->Managers->get_table_data_not('tbl_users', $filter_data, 70)->result();
  593. }else{
  594. $workers = $this->Managers->get_table_data('tbl_users', 70)->result();
  595. }
  596. $last_workers = $this->Managers->get_table_data('tbl_users', 70)->last_row();
  597.  
  598. //$count_all_workers = count($this->Managers->get_table_data('tbl_users')->result());
  599. //echo count($count_load_workers); die;
  600. //echo '<pre>'; print_r($last_workers); die;
  601.  
  602. if($_POST['val'] == 'first_voiceover'){
  603. $vals = $services_values->first_voiceover->value;
  604. $name = $services_values->first_voiceover->name;
  605.  
  606. }elseif($_POST['val'] == 'second_voiceover'){
  607. $vals = $services_values->second_voiceover->value;
  608. $name = $services_values->second_voiceover->name;
  609.  
  610. }elseif($_POST['val'] == 'third_voiceover'){
  611. $vals = $services_values->third_voiceover->value;
  612. $name = $services_values->third_voiceover->name;
  613.  
  614. }else{
  615. $vals = '';
  616. $name = '';
  617. }
  618.  
  619. //echo $vals.'====>'.$name.'<br>';
  620.  
  621. //$workers_data = $this->Managers->getVoiceServiceData('tbl_users', $name);
  622.  
  623. //echo '<pre>'; print_r($services_values).'<br>'; die;
  624.  
  625. $count_load_workers = $this->Managers->getLimitUserData('tbl_users', 69, $service_value, $name);
  626.  
  627. $project_service = $this->Managers->get_data_where('tbl_project_assignments', array('return_type' => 1, 'service' => $latest_service_value, 'project_id' => $_POST['project_id']))->row();
  628.  
  629. //echo '<pre>'; print_r($project_service); die;
  630.  
  631. if(!empty($project_service) && $project_service->service == $latest_service_value){
  632. $service_type = 'yes';
  633. }else{
  634. $service_type = 'no';
  635. }
  636.  
  637. if($service_value == 'transcription_audio' || $service_value == 'transcription_video'){
  638.  
  639. $users = [];
  640. $i = 0;
  641. foreach($workers as $worker):
  642. $services = json_decode($worker->services);
  643. $arr = explode('_',trim($service_value));
  644. foreach($services as $key => $service){
  645. if($key == $arr[0]){
  646.  
  647. if($service[0]->name == 'transcription_audio'){
  648. $users[$i]['id'] = $worker->id;
  649. $users[$i]['value'] = $service[0]->value;
  650. }elseif($service[1]->name == 'transcription_video'){
  651. $users[$i]['id'] = $worker->id;
  652. $users[$i]['value'] = $service[1]->value;
  653. }else{
  654.  
  655. }
  656.  
  657. }
  658. $i++;
  659. }
  660.  
  661. endforeach;
  662.  
  663. }elseif($service_value == 'translation' || $service_value == 'editing' || $service_value == 'proofread' || $service_value == 'creation' || $service_value == 'translator'){
  664.  
  665. $users = [];
  666. $j = 0;
  667. foreach($workers as $worker):
  668. $services = json_decode($worker->services);
  669. //echo '<pre> service '; print_r($services).'<br>';
  670. foreach($services as $key => $service){
  671. if($key == $service_value){
  672. if(!empty($service->value)){
  673. $users[$j]['id'] = $worker->id;
  674. $users[$j]['value'] = $service->value;
  675. }
  676. }
  677. $j++;
  678. }
  679.  
  680. endforeach;
  681.  
  682. }else{
  683.  
  684. $users = [];
  685. $k = 0;
  686. foreach($workers as $worker):
  687. $services = json_decode($worker->services);
  688. foreach($services as $key => $service){
  689.  
  690. if($key == 'first_voiceover'){
  691. if($service->name == $name){
  692. $users[$k]['id'] = $worker->id;
  693. $users[$k]['value'] = $service->value;
  694. }else{
  695.  
  696. }
  697. }elseif($key == 'second_voiceover'){
  698. if($service->name == $name){
  699. $users[$k]['id'] = $worker->id;
  700. $users[$k]['value'] = $service->value;
  701. }else{
  702.  
  703. }
  704. }elseif($key == 'third_voiceover'){
  705. if($service->name == $name){
  706. $users[$k]['id'] = $worker->id;
  707. $users[$k]['value'] = $service->value;
  708. }else{
  709.  
  710. }
  711. }else{
  712.  
  713. }
  714. $k++;
  715. }
  716.  
  717. endforeach;
  718.  
  719. }
  720.  
  721. //echo count($users).'<br>';
  722. //echo $count_load_workers.'<br>';
  723.  
  724. //echo '<pre>'; print_r($users); die;
  725.  
  726. $this->load->view('admin/projects/assignment_users.php', array('data' => $users, 'project_id' => $_POST['project_id'], 'service_type' => $service_type, 'id' => $service_value, 'cost' => $_POST['cost'], 'last_id' => $last_workers->id, 'translators' => count($count_load_workers), 'all_translators' => count($users), 'project_currency' => $_POST['project_currency'], 'project_ammount' => $_POST['project_ammount'], 'project_start_date' => $_POST['project_start_date']));
  727.  
  728. }
  729.  
  730.  
  731. public function getAnotherServiceValue(){
  732. //echo '<pre>'; print_r($_POST); die;
  733. $service_value = $_POST['val'];
  734. $currentId = $_POST['current_id'];
  735. $assignment = $this->Managers->get_data_where('tbl_project_assignments', array('service' => $service_value, 'id' => $currentId))->row();
  736. $workers = $this->Managers->get_data_where('tbl_users', array('id != ' => $assignment->user_id), 70)->result();
  737. $last_workers = $this->Managers->get_data_where('tbl_users' , array('id != ' => $assignment->user_id), 70)->last_row();
  738. $count_load_workers = $this->Managers->getAnotherServiceLimitUserData('tbl_users', 69, $assignment->user_id, $service_value);
  739.  
  740. if($service_value == 'transcription_audio' || $service_value == 'transcription_video'){
  741.  
  742. $users = [];
  743. $i = 0;
  744. foreach($workers as $worker):
  745. $services = json_decode($worker->services);
  746. $arr = explode('_',trim($service_value));
  747. foreach($services as $key => $service){
  748. if($key == $arr[0]){
  749. if($service[0]->name == 'transcription_audio'){
  750. $users[$i]['id'] = $worker->id;
  751. $users[$i]['value'] = $service[0]->value;
  752. }elseif($service[1]->name == 'transcription_video'){
  753. $users[$i]['id'] = $worker->id;
  754. $users[$i]['value'] = $service[1]->value;
  755. }else{
  756.  
  757. }
  758. }
  759.  
  760. $i++;
  761. }
  762.  
  763. endforeach;
  764.  
  765. }else{
  766.  
  767. $users = [];
  768. $j = 0;
  769. foreach($workers as $worker):
  770. $services = json_decode($worker->services);
  771.  
  772. foreach($services as $key => $service){
  773. if($key == $service_value){
  774. if(!empty($service->value)){
  775. $users[$j]['id'] = $worker->id;
  776. $users[$j]['value'] = $service->value;
  777. }
  778. }
  779. $j++;
  780. }
  781.  
  782. endforeach;
  783.  
  784. }
  785.  
  786. //echo '<pre>'; print_r($users); die;
  787.  
  788. $this->load->view('admin/projects/assignment_another_users.php', array('data' => $users, 'service_name' => $service_value, 'current_id' => $currentId, 'task_cost' => $assignment->task_cost, 'project_id' => $_POST['project_id'], 'project_cost' => $_POST['project_cost'], 'last_id' => $last_workers->id, 'translators' => count($count_load_workers), 'all_translators' => count($users), 'user_id' => $assignment->user_id));
  789.  
  790. }
  791.  
  792.  
  793. public function projectAssigns(){
  794. // echo '<pre>'; print_r($_POST).'<br>';
  795. $response = 0;
  796. if ($this->input->post()) {
  797. parse_str($this->input->post()['assignment'], $searcharray);
  798. // echo '<pre>'; print_r($searcharray).'<br>';
  799.  
  800. $project_id_service = $this->Managers->get_data_where('tbl_projects', array('project_id' => $_POST['project_id']))->row();
  801.  
  802. //echo '<pre>'; print_r($project_id_service).'<br>'; die;
  803.  
  804. $id_services = json_decode($project_id_service->services);
  805.  
  806. if($_POST['service'] == 'first_voiceover'){
  807. $vals = $id_services->first_voiceover->name.' (voice Over)';
  808.  
  809. }elseif($_POST['service'] == 'second_voiceover'){
  810. $vals = $id_services->second_voiceover->name.' (voice Over)';
  811.  
  812. }elseif($_POST['service'] == 'third_voiceover'){
  813. $vals = $id_services->third_voiceover->name.' (voice Over)';
  814.  
  815. }else{
  816. $vals = $_POST['service'];
  817. }
  818.  
  819. $user_id = $searcharray['users_id'];
  820. $task_cost = $searcharray['cost'];
  821. $currency_id = $searcharray['currency'];
  822. $start_date = $searcharray['start_date'];
  823. $end_date = $searcharray['end_date'];
  824.  
  825. $temp = $_POST['total'];
  826.  
  827. $first_data = $this->Managers->get_data_where('tbl_project_assignments', array('project_id' => $_POST['project_id']))->last_row();
  828.  
  829. for($i=0; $i < $temp; $i++){
  830.  
  831. if(!empty($first_data)){
  832.  
  833. $val_time = $first_data->purchase_order;
  834. $latest_value = substr($val_time, -1);
  835. $current_value = $i+($latest_value+1);
  836. $purchase_order = $_POST['project_id'].'-0'.$current_value;
  837.  
  838. }else{
  839. if($i == 0){
  840. $purchase_order = $_POST['project_id'].'-01';
  841. }
  842. $purchase_order = $_POST['project_id'].'-0'.($i+1);
  843. // echo '<pre>'; print_r($purchase_order); die;
  844. }
  845.  
  846. $data2 = array(
  847. 'project_id' => $_POST['project_id'],
  848. 'service' => $vals,
  849. 'service_cost' => $_POST['project_cost'],
  850. 'user_id' =>$user_id[$i],
  851. 'task_cost' => $task_cost[$i],
  852. 'currency_id' => $currency_id[$i],
  853. 'start_date' => $start_date[$i],
  854. 'end_date' => $end_date[$i],
  855. 'purchase_order' => $purchase_order
  856. );
  857. // $this->db->insert('tbl_project_assignments', $data2);
  858. ////////////// PDF ///////////////
  859. $user_data = $this->Managers->get_data_where('tbl_users', array('id' => $user_id[$i]))->row();
  860. $admin_data = $this->Managers->get_data_where('tbl_admin', array('id_admin' => '1'))->row();
  861. $project_data = $this->Managers->get_data_where('tbl_projects', array('id' => $user_id[$i]))->row();
  862. $currency_name = $this->Managers->get_data_where('tbl_change_currency', array('id' => $currency_id[$i]))->row();
  863. $total_cost = $_POST['user_value'] * $_POST['project_cost'];
  864. $user_data_currency = $this->Managers->get_data_where('tbl_change_currency', array('id' => $user_data->currency_id))->row();
  865. $startDates = $start_date[$i];
  866. $endDates = $end_date[$i];
  867. $interval = $endDates - $startDates;
  868. $days = floor($interval / (60 * 60 * 24));
  869. $html = $this->load->view('form.php', array('user_data' => $user_data, 'admin_data' => $admin_data, 'data' => $data2, 'project_data' => $project_data, 'days' => $days, 'currency_name' => $currency_name, 'total_cost' => $total_cost, 'user_value' => $_POST['user_value'], 'user_data_currency' => $user_data_currency, 'project_cost' => $_POST['project_cost']), true);
  870. // echo '<pre>'; print_r($html); die;
  871. require_once APPPATH . 'third_party/mpdf/mpdf.php';
  872. $pdf_name = $purchase_order. '.pdf';
  873. $pdfFilePath = ROOT_PATH . "ekitai_project_management/uploads/invoices/$pdf_name";
  874. $html2pdf = new \mPDF();
  875. $html2pdf->WriteHTML($html);
  876. $html2pdf->Output($pdfFilePath, 'F');
  877. chmod($pdfFilePath, 0777);
  878.  
  879.  
  880. ///////////// PDF //////////////
  881.  
  882. }
  883.  
  884. //echo $vals.'<br>';
  885. //echo '<pre>'; print_r($id_services).'<br>'; die;
  886.  
  887. $currency_ammont = $this->Managers->get_data_where('tbl_change_currency', array('id' => $_POST['project_currency']))->row();
  888.  
  889. // Project Start Date Currency Ammount
  890.  
  891. $project_date_currency = $this->Managers->get_data_where('tbl_currnecy', array('created' => $_POST['project_start_date']))->row();
  892.  
  893. $assign_date_currency = $this->Managers->get_data_where('tbl_currnecy', array('created' => strtotime($searcharray['start_date'])))->row();
  894.  
  895. $assign_currency_name = $this->Managers->get_data_where('tbl_change_currency', array('id' => $searcharray['currency']))->row();
  896.  
  897. $a_currency_name = $assign_currency_name->name;
  898.  
  899. //echo '<pre>'; print_r($assign_currency_name).'<br>';
  900. //echo '<pre>'; print_r($assign_date_currency).'<br>';
  901.  
  902. //if(empty($assign_date_currency)){
  903. //echo $response = 2; exit;
  904.  
  905. //}else{
  906.  
  907. if(!empty($assign_date_currency)){
  908.  
  909. $user_ammount = $_POST['user_value'] * $_POST['project_cost'] * $assign_date_currency->$a_currency_name;
  910.  
  911. if($currency_ammont->name == 'USD'){
  912. $project_ammount = $project_date_currency->USD * $_POST['project_ammount'];
  913. $assign_ammount = $assign_date_currency->USD * $searcharray['cost'];
  914.  
  915. }elseif($currency_ammont->name == 'EURO'){
  916. $project_ammount = $project_date_currency->EURO * $_POST['project_ammount'];
  917. $assign_ammount = $assign_date_currency->EURO * $searcharray['cost'];
  918.  
  919. }elseif($currency_ammont->name == 'AED'){
  920. $project_ammount = $project_date_currency->AED * $_POST['project_ammount'];
  921. $assign_ammount = $assign_date_currency->AED * $searcharray['cost'];
  922.  
  923. }else{
  924. $project_ammount = $project_date_currency->GBP * $_POST['project_ammount'];
  925. $assign_ammount = $assign_date_currency->GBP * $searcharray['cost'];
  926. }
  927.  
  928. }else{
  929.  
  930. $user_ammount = $_POST['user_value'] * $_POST['project_cost'] * 0;
  931. $project_ammount = 0;
  932. $assign_ammount = 0;
  933. }
  934.  
  935. //echo $user_ammount.'<br>';
  936.  
  937. //echo $project_ammount.'====>'.$assign_ammount; die;
  938.  
  939. $first_data = $this->Managers->get_data_where('tbl_project_assignments', array('project_id' => $_POST['project_id']))->last_row();
  940. if(!empty($first_data)){
  941.  
  942. $val_time = $first_data->purchase_order;
  943. $latest_value = substr($val_time, -1);
  944. $current_value = $latest_value+1;
  945. $purchase_order = $_POST['project_id'].'-0'.$current_value;
  946.  
  947. }else{
  948.  
  949. $purchase_order = $_POST['project_id'].'-01';
  950. }
  951.  
  952. $profit = $user_ammount;
  953.  
  954. $data = array(
  955. 'project_id' => $_POST['project_id'],
  956. 'user_id' => $_POST['user_id'],
  957. 'currency_id' => $searcharray['currency'],
  958. 'start_date' => strtotime($searcharray['start_date']),
  959. 'end_date' => strtotime($searcharray['end_date']),
  960. 'task_cost' => $searcharray['cost'],
  961. 'service' => $vals,
  962. 'service_cost' => $_POST['project_cost'],
  963. 'profit' => $profit,
  964. 'purchase_order' => $purchase_order,
  965. );
  966.  
  967. //echo '<pre>'; print_r($data); die;
  968.  
  969. $project_assign = $this->Managers->updateDataWhere('tbl_projects', array('assign' => '1'), array('project_id' => $_POST['project_id']));
  970.  
  971. $result = $this->Managers->insert_data('tbl_project_assignments',$data);
  972.  
  973. if($result){
  974. $user_data = $this->Managers->get_data_where('tbl_users', array('id' => $_POST['user_id']))->row();
  975. $admin_data = $this->Managers->get_data_where('tbl_admin', array('id_admin' => '1'))->row();
  976. $project_data = $this->Managers->get_data_where('tbl_projects', array('project_id' => $_POST['project_id']))->row();
  977. $currency_name = $this->Managers->get_data_where('tbl_change_currency', array('id' => $searcharray['currency']))->row();
  978. $total_cost = $_POST['user_value'] * $_POST['project_cost'];
  979. $user_data_currency = $this->Managers->get_data_where('tbl_change_currency', array('id' => $user_data->currency_id))->row();
  980.  
  981. $startDate = $data['start_date'];
  982. $endDate = $data['end_date'];
  983. $interval = $endDate - $startDate;
  984. $days = floor($interval / (60 * 60 * 24));
  985.  
  986. $html = $this->load->view('form.php', array('user_data' => $user_data, 'admin_data' => $admin_data, 'data' => $data, 'project_data' => $project_data, 'days' => $days, 'currency_name' => $currency_name, 'total_cost' => $total_cost, 'user_value' => $_POST['user_value'], 'user_data_currency' => $user_data_currency, 'project_cost' => $_POST['project_cost']), true);
  987. require_once APPPATH . 'third_party/mpdf/mpdf.php';
  988. $pdf_name = $purchase_order. '.pdf';
  989. $pdfFilePath = ROOT_PATH . "ekitai_project_management/uploads/invoices/$pdf_name";
  990. $html2pdf = new \mPDF();
  991. $html2pdf->WriteHTML($html);
  992. $html2pdf->Output($pdfFilePath, 'F');
  993. chmod($pdfFilePath, 0777);
  994.  
  995. //echo '<pre>'; print_r($html2pdf); die;
  996. // $from = $admin_data->email;
  997. // $url = "https://api.sendgrid.com/";
  998. // $user = 'devendra775123';
  999. // $pass = '9928387298q123';
  1000. // $to = $user_data->email;
  1001. // //$to = 'greatdeveloper002@gmail.com';
  1002. // $messege = 'Project Invoice';
  1003. // $params = array(
  1004. // 'api_user' => $user,
  1005. // 'api_key' => $pass,
  1006. // 'to' => $to,
  1007. // 'fromname' => 'Ekitai Solutions',
  1008. // 'from' => $from,
  1009. // 'subject' => 'Project Invoice',
  1010. // 'html' => $messege,
  1011. // 'files[' . $pdf_name . ']' => new \CurlFile($pdfFilePath)
  1012. // );
  1013. // $request = $url . 'api/mail.send.json';
  1014. // $session = curl_init($request);
  1015. // curl_setopt($session, CURLOPT_POST, true);
  1016. // curl_setopt($session, CURLOPT_POSTFIELDS, $params);
  1017. // curl_setopt($session, CURLOPT_HEADER, false);
  1018. // curl_setopt($session, CURLOPT_SSL_VERIFYPEER, false);
  1019. // curl_setopt($session, CURLOPT_RETURNTRANSFER, true);
  1020. // $responsed = curl_exec($session);
  1021. // curl_close($session);
  1022.  
  1023. echo $response = 1; exit;
  1024.  
  1025. }
  1026. }
  1027. }
  1028.  
  1029. public function projectAssignsAnotherUser(){
  1030. //echo '<pre>'; print_r($_POST).'<br>';
  1031. $response = 0;
  1032. if ($this->input->post()) {
  1033. parse_str($this->input->post()['assignment'], $searcharray);
  1034. //echo '<pre>'; print_r($searcharray).'<br>';
  1035. $project_currency = $this->Managers->get_data_where('tbl_projects', array('project_id' => $_POST['project_id']))->row();
  1036. $currency_ammont = $this->Managers->get_data_where('tbl_change_currency', array('id' => $project_currency->currency_id))->row();
  1037.  
  1038. $assign_date_currency = $this->Managers->get_data_where('tbl_currnecy', array('created' => strtotime($searcharray['start_date'])))->row();
  1039.  
  1040. //echo '<pre>'; print_r($currency_ammont).'<br>';
  1041. //echo '<pre>'; print_r($assign_date_currency).'<br>'; die;
  1042.  
  1043. if(empty($assign_date_currency)){
  1044. echo $response = 2; exit;
  1045.  
  1046. }else{
  1047.  
  1048. $user_ammount = $_POST['user_value'] * $_POST['project_cost'] * $assign_date_currency->USD;
  1049.  
  1050. $profit = $user_ammount;
  1051. //echo '<pre>'; print_r($assign_date_currency).'<br>';
  1052. //echo '<pre>'; print_r($searcharray).'<br>'; die;
  1053.  
  1054. $project_assign = $this->Managers->updateDataWhere('tbl_project_assignments', array('profit' => $profit,'user_id' => $_POST['user_id'], 'start_date' => strtotime($searcharray['start_date']), 'end_date' => strtotime($searcharray['end_date'])), array('id' => $_POST['current_id'], 'service' => $_POST['service'], 'project_id' => $_POST['project_id']));
  1055.  
  1056. echo $response = 1; exit;
  1057.  
  1058. }
  1059. }
  1060. }
  1061.  
  1062. public function assigned_users($projectid = false){
  1063. $projects_users = $this->Managers->get_data_where('tbl_project_assignments', array('project_id' => $projectid))->result();
  1064. //echo "<pre/>"; print_r($projects_users); die;
  1065. $content = $this->load->view('admin/projects/assigned_users.php', array('data' => $projects_users), TRUE);
  1066. $this->load->view('admin/templete', array('content' => $content));
  1067.  
  1068. }
  1069.  
  1070. public function editAssignedUser($id = false) {
  1071.  
  1072. $assignment = $this->Managers->get_data_where('tbl_project_assignments', array('id' => $id))->row();
  1073. $service_value = $assignment->service;
  1074. $workers = $this->Managers->get_data_where('tbl_users', array('id != ' => $assignment->user_id))->result();
  1075.  
  1076. if($service_value == 'transcription_audio' || $service_value == 'transcription_video'){
  1077.  
  1078. $users = [];
  1079. $i = 0;
  1080. foreach($workers as $worker):
  1081. $services = json_decode($worker->services);
  1082. $arr = explode('_',trim($service_value));
  1083. foreach($services as $key => $service){
  1084. if($key == $arr[0]){
  1085. if($service[0]->value == 'transcription_audio'){
  1086. $users[$i]['id'] = $worker->id;
  1087. $users[$i]['value'] = $service[0]->value;
  1088. }elseif($service[1]->value == 'transcription_video'){
  1089. $users[$i]['id'] = $worker->id;
  1090. $users[$i]['value'] = $service[1]->value;
  1091. }else{
  1092.  
  1093. }
  1094. }
  1095. $i++;
  1096. }
  1097.  
  1098. endforeach;
  1099.  
  1100. }else{
  1101.  
  1102. $users = [];
  1103. $j = 0;
  1104. foreach($workers as $worker):
  1105. $services = json_decode($worker->services);
  1106.  
  1107. foreach($services as $key => $service){
  1108. if($key == $service_value){
  1109. if(!empty($service->value)){
  1110. $users[$j]['id'] = $worker->id;
  1111. $users[$j]['value'] = $service->value;
  1112. }
  1113. }
  1114. $j++;
  1115. }
  1116.  
  1117. endforeach;
  1118. }
  1119.  
  1120. //echo '<pre>'; print_r($users); die;
  1121.  
  1122. if ($id) {
  1123. $data = $this->Managers->get_data_where('tbl_project_assignments', array('id' => $id));
  1124. $content = $this->load->view('admin/projects/edit_assigned_users', array('data' => $assignment, 'id' => $id, 'users' => $users), TRUE);
  1125. $this->load->view('admin/templete', array('content' => $content));
  1126. }
  1127. }
  1128.  
  1129. public function viewAssignedUser($id){
  1130. $where = array(
  1131. 'id' => $id
  1132. );
  1133.  
  1134. $data = $this->Managers->get_data_where('tbl_project_assignments', $where);
  1135. //echo '<pre>'; print_r($data->row()); die;
  1136. $content = $this->load->view('admin/projects/view_assigned_user_details', array('data' => $data));
  1137. }
  1138.  
  1139. public function returnProjectDate() {
  1140. $project_id = $this->input->post('project_id');
  1141. $id = $this->input->post('id');
  1142. $service = $this->input->post('service');
  1143. $where = array(
  1144. 'project_id' => $project_id
  1145. );
  1146. $date = $this->Managers->get_data_where('tbl_projects', $where)->row();
  1147. $this->load->view('admin/projects/popup_return_date', array('project_id' => $project_id, 'id' => $id, 'start_date' => $date->start_date, 'service' => $service));
  1148. }
  1149.  
  1150. public function userDenied(){
  1151. $project_id = $this->input->post('project_id');
  1152. $id = $this->input->post('id');
  1153.  
  1154. //echo $project_id.'====>'.$id; die;
  1155. $project_status = $this->Managers->updateDataWhere('tbl_projects', array('assign' => '0'), array('project_id' => $project_id));
  1156. $project_assignmnet_denied = $this->Managers->updateDataWhere('tbl_project_assignments', array('denied' => '1'), array('project_id' => $project_id, 'id' => $id));
  1157. }
  1158.  
  1159.  
  1160. public function returnProjects(){
  1161.  
  1162. $responsed = 0;
  1163. if ($this->input->post()) {
  1164. parse_str($this->input->post()['data'], $searcharray);
  1165. //echo '<pre>'; print_r($searcharray).'<br>'; die;
  1166.  
  1167. $curdate = strtotime($searcharray['project_start_date']);
  1168. $mydate = strtotime($searcharray['return_date']);
  1169.  
  1170. if($curdate > $mydate){
  1171. $response = 2;
  1172. }else{
  1173. $date = strtotime($searcharray['return_date']);
  1174. $project_assign = $this->Managers->updateDataWhere('tbl_projects', array('assign' => '0'), array('project_id' => $searcharray['project_id']));
  1175. $project_return_date = $this->Managers->updateDataWhere('tbl_project_assignments', array('return_type' => '1', 'return_date' => $date, 'denied' => '1'), array('project_id' => $searcharray['project_id'], 'service' => $searcharray['service_name']));
  1176. $response = 1;
  1177. }
  1178.  
  1179. }
  1180. echo $response; exit;
  1181. }
  1182.  
  1183. public function reports(){
  1184.  
  1185. $projects = $this->Managers->get_table_data('tbl_projects')->result();
  1186. //echo "<pre/>"; print_r($projects); die;
  1187. $content = $this->load->view('admin/projects/reports.php', array('data' => $projects), TRUE);
  1188. $this->load->view('admin/templete', array('content' => $content));
  1189.  
  1190. }
  1191.  
  1192. public function reports_edit($id = false) {
  1193. $projects = $this->Managers->get_data_where('tbl_projects', array('id' => $id))->row();
  1194. $data = $this->Managers->getReports($projects->project_id);
  1195. //echo '<pre>'; print_r($data); die;
  1196. $content = $this->load->view('admin/projects/reports_check', array('data' => $data, 'id' => $id, 'project_name' => $projects->name), TRUE);
  1197. $this->load->view('admin/templete', array('content' => $content));
  1198.  
  1199. }
  1200.  
  1201. public function loadUsers(){
  1202. //echo '<pre>'; print_r($_POST).'<br>';
  1203. $service_value = $_POST['service'];
  1204. $workers = $this->Managers->get_data_where('tbl_users', array('id >' => $_POST['id']), 70)->result();
  1205. $last_workers = $this->Managers->get_data_where('tbl_users', array('id >' => $_POST['id']), 70)->last_row();
  1206.  
  1207. $project_service_value = $this->Managers->get_data_where('tbl_projects', array('project_id' => $_POST['project_id']))->row();
  1208.  
  1209. $services_values = json_decode($project_service_value->services);
  1210.  
  1211. if($_POST['service'] == 'first_voiceover'){
  1212. $vals = $services_values->first_voiceover->value;
  1213. $name = $services_values->first_voiceover->name;
  1214.  
  1215. }elseif($_POST['service'] == 'second_voiceover'){
  1216. $vals = $services_values->second_voiceover->value;
  1217. $name = $services_values->second_voiceover->name;
  1218.  
  1219. }elseif($_POST['service'] == 'third_voiceover'){
  1220. $vals = $services_values->third_voiceover->value;
  1221. $name = $services_values->third_voiceover->name;
  1222.  
  1223. }else{
  1224. $vals = '';
  1225. $name = '';
  1226. }
  1227.  
  1228. //echo $vals.'====>'.$name.'<br>'; die;
  1229.  
  1230. $count_load_workers_another = $this->Managers->getLimitLoadUserData('tbl_users', $_POST['id'], 69, $service_value, $name);
  1231. //echo '<pre>'; print_r($count_load_workers_another); die;
  1232. if(!empty($workers)){
  1233.  
  1234. if($service_value == 'transcription_audio' || $service_value == 'transcription_video'){
  1235.  
  1236. $users = array();
  1237. $i = 0;
  1238. foreach($workers as $worker):
  1239. $services = json_decode($worker->services);
  1240. $arr = explode('_',trim($service_value));
  1241. foreach($services as $key => $service){
  1242. if($key == $arr[0]){
  1243. if($service[0]->name == 'transcription_audio'){
  1244. $users[$i]['id'] = $worker->id;
  1245. $users[$i]['value'] = $service[0]->value;
  1246. }elseif($service[1]->name == 'transcription_video'){
  1247. $users[$i]['id'] = $worker->id;
  1248. $users[$i]['value'] = $service[1]->value;
  1249. }else{
  1250.  
  1251. }
  1252. }
  1253. $i++;
  1254. }
  1255.  
  1256. endforeach;
  1257.  
  1258. }elseif($service_value == 'translation' || $service_value == 'editing' || $service_value == 'proofread' || $service_value == 'creation' || $service_value == 'translator'){
  1259.  
  1260. $users = [];
  1261. $j = 0;
  1262. foreach($workers as $worker):
  1263. $services = json_decode($worker->services);
  1264.  
  1265. foreach($services as $key => $service){
  1266. if($key == $service_value){
  1267. if(!empty($service->value)){
  1268. $users[$j]['id'] = $worker->id;
  1269. $users[$j]['value'] = $service->value;
  1270. }
  1271. }
  1272. $j++;
  1273. }
  1274.  
  1275. endforeach;
  1276.  
  1277. }else{
  1278.  
  1279. $users = [];
  1280. $k = 0;
  1281. foreach($workers as $worker):
  1282. $services = json_decode($worker->services);
  1283. foreach($services as $key => $service){
  1284.  
  1285. if($key == 'first_voiceover'){
  1286. if($service->name == $name){
  1287. $users[$k]['id'] = $worker->id;
  1288. $users[$k]['value'] = $service->value;
  1289. }else{
  1290.  
  1291. }
  1292. }elseif($key == 'second_voiceover'){
  1293. if($service->name == $name){
  1294. $users[$k]['id'] = $worker->id;
  1295. $users[$k]['value'] = $service->value;
  1296. }else{
  1297.  
  1298. }
  1299. }elseif($key == 'third_voiceover'){
  1300. if($service->name == $name){
  1301. $users[$k]['id'] = $worker->id;
  1302. $users[$k]['value'] = $service->value;
  1303. }else{
  1304.  
  1305. }
  1306. }else{
  1307.  
  1308. }
  1309. $k++;
  1310. }
  1311.  
  1312. endforeach;
  1313.  
  1314. }
  1315.  
  1316. //echo '<pre>'; print_r($users);
  1317.  
  1318. $this->load->view('admin/projects/view_more_assignment_users.php', array('data' => $users, 'j' => $_POST['val'], 'id' => $service_value, 'project_id' => $_POST['project_id'], 'cost' => $_POST['cost'], 'last_id' => $last_workers->id, 'translators' => count($count_load_workers_another), 'all_translators' => count($users), 'project_currency' => $_POST['project_currency'], 'project_ammount' => $_POST['project_ammount'], 'project_start_date' => $_POST['project_start_date']));
  1319.  
  1320. }else{
  1321. echo '<p style="color:red;">No Data Found</p>'; die;
  1322. }
  1323.  
  1324. }
  1325.  
  1326. public function loadRelatedServiceUsers(){
  1327. //echo '<pre>'; print_r($_POST).'<br>'; die;
  1328. $service_value = $_POST['service'];
  1329. $workers = $this->Managers->get_data_where('tbl_users', array('id >' => $_POST['id'], 'id !=' => $_POST['user_id']), 70)->result();
  1330. $last_workers = $this->Managers->get_data_where('tbl_users', array('id >' => $_POST['id'], 'id !=' => $_POST['user_id']), 70)->last_row();
  1331. $count_load_workers_another = $this->Managers->getLimitLoadUserData('tbl_users', $_POST['id'], 69, $service_value, $_POST['user_id']);
  1332. //echo '<pre>'; print_r($workers).'<br>';
  1333. //echo '<pre>'; print_r($count_load_workers_another).'<br>';
  1334. //echo count($workers).'<br>';
  1335. //echo count($count_load_workers_another).'<br>';
  1336. if(!empty($workers)){
  1337. if($service_value == 'transcription_audio' || $service_value == 'transcription_video'){
  1338.  
  1339. $users = array();
  1340. $i = 0;
  1341. foreach($workers as $worker):
  1342. $services = json_decode($worker->services);
  1343. $arr = explode('_',trim($service_value));
  1344. foreach($services as $key => $service){
  1345. if($key == $arr[0]){
  1346. if($service[0]->name == 'transcription_audio'){
  1347. $users[$i]['id'] = $worker->id;
  1348. $users[$i]['value'] = $service[0]->value;
  1349. }elseif($service[1]->name == 'transcription_video'){
  1350. $users[$i]['id'] = $worker->id;
  1351. $users[$i]['value'] = $service[1]->value;
  1352. }else{
  1353.  
  1354. }
  1355. }
  1356. $i++;
  1357. }
  1358.  
  1359. endforeach;
  1360.  
  1361. }else{
  1362.  
  1363. $users = [];
  1364. $j = 0;
  1365. foreach($workers as $worker):
  1366. $services = json_decode($worker->services);
  1367.  
  1368. foreach($services as $key => $service){
  1369. if($key == $service_value){
  1370. if(!empty($service->value)){
  1371. $users[$j]['id'] = $worker->id;
  1372. $users[$j]['value'] = $service->value;
  1373. }
  1374. }
  1375. $j++;
  1376. }
  1377.  
  1378. endforeach;
  1379.  
  1380. }
  1381.  
  1382. //echo '<pre>'; print_r($users);
  1383.  
  1384. $this->load->view('admin/projects/view_more_assignment_another_users.php', array('data' => $users, 'j' => $_POST['val'], 'id' => $service_value, 'project_id' => $_POST['project_id'], 'last_id' => $last_workers->id, 'translators' => count($count_load_workers_another), 'all_translators' => count($users), 'task_cost' => $_POST['task_cost'], 'current_id' => $_POST['current_id'], 'project_cost' => $_POST['project_cost'], 'user_id' => $_POST['user_id']));
  1385.  
  1386. }else{
  1387. echo '<p style="color:red;">No Data Found</p>'; die;
  1388. }
  1389.  
  1390. }
  1391.  
  1392. public function checkDatewiseCurrency(){
  1393.  
  1394. $response = 0;
  1395. $result = $this->Managers->get_data_where('tbl_currnecy', array('created' => strtotime($_POST['selected'])))->row();
  1396. if(!empty($result)){
  1397. $response = 1;
  1398. }else{
  1399. $response = 2;
  1400. }
  1401.  
  1402. echo $response; exit;
  1403. }
  1404.  
  1405. public function filterByDate(){
  1406. $response = 0;
  1407. if ($this->input->post()) {
  1408. parse_str($this->input->post()['postform'], $searcharray);
  1409.  
  1410. $filter_data = $this->Managers->get_data_where('tbl_projects', array('start_date <=' => $searcharray['start_date'], 'end_date >=' => $searcharray['end_date']))->result();
  1411.  
  1412. $this->load->view('admin/projects/filter_datewise_reports.php', array('data' => $filter_data));
  1413. }
  1414. }
  1415.  
  1416. public function searchCompany(){
  1417. $value = $_POST['value'];
  1418. $data= $this->Managers->get_company_clinet('tbl_clients',$value, 1);
  1419. $this->load->view('admin/projects/search_company.php', array('data' => $data, 'name' => $value));
  1420. }
  1421.  
  1422.  
  1423. public function searchIndividusal(){
  1424. $value = $_POST['value'];
  1425. $data= $this->Managers->get_company_clinet('tbl_clients',$value, 2);
  1426. $this->load->view('admin/projects/search_company_client.php', array('data' => $data, 'name' => $value));
  1427. }
  1428.  
  1429. // public function searchCompany(){
  1430. // $actual_link = "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
  1431. // $pos = strpos($actual_link, "?");
  1432. // $filter = explode("?term=", $actual_link);
  1433. // $filters = explode('&types=',$actual_link);
  1434. // $filter_term = substr($filters[0],77,120);
  1435. // $data= $this->Managers->get_company_clinet('tbl_clients',$filter_term,$filters[1]);
  1436. // $types = $filters[1];
  1437. // echo'<pre>'; print_r($filter).'<br>';
  1438. // echo $types.'<br>';
  1439. // echo '<pre>'; print_r($filter_term).'<br>';
  1440. // echo '<pre>'; print_r($data); die;
  1441. // $this->load->view('admin/projects/search_company.php', array('data' => $data,'type'=>$types));
  1442. // }
  1443.  
  1444. public function companyClinet(){
  1445.  
  1446. $dataCompanyDb = $this->Managers->get_data_where('tbl_clients',array('id'=>$_POST['id']))->row();
  1447.  
  1448. if($_POST['type'] == 'edit'){
  1449. $dataCompany = $this->Managers->get_company_clients_tiered($dataCompanyDb->client_id);
  1450. $this->load->view('admin/projects/company_edit_client.php', array('data' => $dataCompany, 'companyname' => $dataCompanyDb));
  1451. }else{
  1452. $dataCompany = $this->Managers->get_data_where('tbl_company_clients',array('company_id'=>$dataCompanyDb->client_id))->result();
  1453. $this->load->view('admin/projects/company_client.php', array('data' => $dataCompany, 'companyname' => $dataCompanyDb));
  1454. }
  1455.  
  1456. }
  1457.  
  1458. }
Add Comment
Please, Sign In to add comment