/** * Loads Buyer signUp page. * * @access public * @param nil * @return void */ function create() { //echo $this->loggedInUser->email; $result = '0'; $manage = '1'; $this->outputData['showPreview'] = false; //Load Language $this->lang->load('enduser/withdrawMoney', $this->config->item('language_code')); $this->lang->load('enduser/createBids', $this->config->item('language_code')); $this->outputData['created'] = get_est_time(); $this->outputData['enddate'] = get_est_time() + $this->input->post('openDays') * 86400; //Check For Buyer Session if (!isBuyer()) { $this->session->set_flashdata('flash_message', $this->common_model->flash_message('error', $this->lang->line('You must be logged in as a buyer to post projects'))); redirect('info'); } //load validation libraray $this->load->library('form_validation'); //Load Form Helper $this->load->helper('form'); //Intialize values for library and helpers $this->form_validation->set_error_delimiters($this->config->item('field_error_start_tag'), $this->config->item('field_error_end_tag')); if ($this->input->post('projectid')) { $project = $this->input->post('projectid'); } //Save the draft projects if ($this->input->post('save_draft')) { //echo $this->input->post('projectName'); if ($this->input->post('projectName')) { $draft_name = $this->input->post('projectName'); $condition = array('draftprojects.project_name' => $draft_name); $draft = $this->skills_model->getDraft($condition); //pr($draft->num_rows()); //pr($draft->result()); if ($draft->num_rows() <= 0) { $insertData = array(); $insertData['project_name'] = $this->input->post('projectName'); $insertData['description'] = $this->input->post('description'); if ($this->input->post('budget_min', TRUE)) { $insertData['budget_min'] = $this->input->post('budget_min'); } else { $insertData['budget_min'] = ''; } if ($this->input->post('budget_max', TRUE)) { $insertData['budget_max'] = $this->input->post('budget_max'); } else { $insertData['budget_max'] = ''; } $insertData['is_feature'] = $this->input->post('is_feature'); $insertData['is_urgent'] = $this->input->post('is_urgent'); $insertData['is_hide_bids'] = $this->input->post('is_hide_bids'); if ($this->input->post('is_private')) { $insertData['is_private'] = $this->input->post('is_private'); } $insertData['creator_id'] = $this->loggedInUser->id; $insertData['created'] = get_est_time(); $insertData['enddate'] = get_est_time() + $this->input->post('openDays') * 86400; //$insertData['open_days'] = $this->input->post('openDays'); //pr($insertData); if ($insertData) { $this->skills_model->draftProject($insertData); } } else { $draft = $draft->row(); $updateDraft = array(); $updateDraft['project_name'] = $this->input->post('projectName'); $updateDraft['description'] = $this->input->post('description'); if ($this->input->post('budget_min', TRUE)) { $updateDraft['budget_min'] = $this->input->post('budget_min'); } else { $updateDraft['budget_min'] = ''; } if ($this->input->post('budget_max', TRUE)) { $updateDraft['budget_max'] = $this->input->post('budget_max'); } else { $updateDraft['budget_max'] = ''; } $updateDraft['is_feature'] = $this->input->post('is_feature'); $updateDraft['is_urgent'] = $this->input->post('is_urgent'); $updateDraft['is_hide_bids'] = $this->input->post('is_hide_bids'); //$updateDraft['open_days'] = $this->input->post('openDays'); if ($this->input->post('is_private')) { $updateDraft['is_private'] = $this->input->post('is_private'); } $updateDraft['creator_id'] = $this->loggedInUser->id; $updateDraft['created'] = get_est_time(); $updateDraft['enddate'] = get_est_time() + $this->input->post('openDays') * 86400; $categories = $this->input->post('categories'); //pr($categories); //Work With Project Categories $project_categoriesNameArray = $this->skills_model->convertCategoryIdsToName($categories); $project_categoriesNameString = implode(',', $project_categoriesNameArray); $updateDraft['project_categories'] = $project_categoriesNameString; //pr($updateDraft); if ($updateDraft) { $condition = array('draftprojects.id' => $draft->id); $this->skills_model->updateDraftProject($updateDraft, $condition); } } } else { $this->session->set_flashdata('flash_message', $this->common_model->flash_message('error', $this->lang->line('You cannot save this project as Draft'))); redirect('info'); } //Notification message $this->session->set_flashdata('flash_message', $this->common_model->flash_message('success', $this->lang->line('Your project has been saved as Draft'))); redirect('info/index/success'); } //Get Form Data if ($this->input->post('createProject') or $this->input->post('preview_project')) { //Set rules $this->form_validation->set_rules('projectName', 'lang:project_name_validation', 'required|trim|min_length[5]|xss_clean'); $this->form_validation->set_rules('description', 'lang:description_validation', 'required|min_length[25]|trim|xss_clean'); $this->form_validation->set_rules('attachment', 'lang:attachment_validation', 'callback_attachment_check'); $this->form_validation->set_rules('categories[]', 'lang:categories_validation', 'required'); $this->form_validation->set_rules('is_feature', 'lang:is_feature_validation', 'trim'); $this->form_validation->set_rules('is_urgent', 'lang:is_urgent_validation', 'trim'); $this->form_validation->set_rules('is_hide_bids', 'lang:is_hide_bids_validation', 'trim'); if ($this->form_validation->run()) { //This is condition check for post similar project $conditions = array('projects.project_name' => $this->input->post('projectName')); $postSimilar = $this->skills_model->getUsersproject($conditions); $res = $postSimilar->num_rows(); if ($res > 0) { $sameProject = $postSimilar->row(); $project = $sameProject->id; } //echo $this->input->post('update'); //Check the post project is already exists or not //echo $this->input->post('update'); if ($this->input->post('update', true) === false) { $manage = '1'; } else { $manage = '0'; } if ($manage != '0') { if ($res > 0) { $this->session->set_flashdata('flash_message', $this->common_model->flash_message('error', $this->lang->line('Project already Exists'))); redirect('project/postProject/' . $project); } } $insertData = array(); $insertData['project_name'] = $this->input->post('projectName'); $insertData['description'] = $this->input->post('description'); if ($this->input->post('update') == '0') { $insertData['description'] = $this->input->post('description') . '<br/>'; $insertData['description'] .= $this->input->post('add_description'); } else { $insertData['description'] = $this->input->post('description'); } $insertData['budget_min'] = $this->input->post('budget_min'); $insertData['budget_max'] = $this->input->post('budget_max'); $insertData['is_feature'] = $this->input->post('is_feature'); $insertData['is_urgent'] = $this->input->post('is_urgent'); $insertData['is_hide_bids'] = $this->input->post('is_hide_bids'); //$insertData['open_days'] = $this->input->post('openDays'); if ($this->input->post('is_private')) { $insertData['is_private'] = $this->input->post('is_private'); } $insertData['creator_id'] = $this->loggedInUser->id; $insertData['created'] = get_est_time(); $insertData['enddate'] = get_est_time() + $this->input->post('openDays') * 86400; $result = '0'; if ($this->input->post('preview_project')) { $this->outputData['showPreview'] = true; $result = '1'; $this->outputData['project_status'] = 'Pending'; $this->outputData['project_name'] = $this->input->post('projectName'); //Update additional information for projects if ($this->input->post('update') == '0') { $this->outputData['description'] = $this->input->post('description') . '<br>'; $this->outputData['description'] .= $this->input->post('add_description'); } else { $this->outputData['description'] = $this->input->post('description'); } $this->outputData['budget_min'] = $this->input->post('budget_min'); $this->outputData['budget_max'] = $this->input->post('budget_max'); $this->outputData['is_feature'] = $this->input->post('is_feature'); $this->outputData['is_urgent'] = $this->input->post('is_urgent'); $this->outputData['is_hide_bids'] = $this->input->post('is_hide_bids'); // $this->outputData['open_days'] = $this->input->post('openDays'); if ($this->input->post('is_private')) { $insertData['is_private'] = $this->input->post('is_private'); } $this->outputData['creator_id'] = $this->loggedInUser->id; $this->outputData['created'] = get_est_time(); $this->outputData['enddate'] = get_est_time() + $this->input->post('openDays') * 86400; $categories = $this->input->post('categories'); //Work With Project Categories $project_categoriesNameArray = $this->skills_model->convertCategoryIdsToName($categories); $project_categoriesNameString = implode(',', $project_categoriesNameArray); $this->outputData['project_categories'] = $project_categoriesNameString; } //check the condition for view the preview about the project if ($result == '0') { //Get the values from settings table $paymentSettings = $this->settings_model->getSiteSettings(); $feature_project = $paymentSettings['FEATURED_PROJECT_AMOUNT']; $urgent_project = $paymentSettings['URGENT_PROJECT_AMOUNT']; $hide_project = $paymentSettings['HIDE_PROJECT_AMOUNT']; $this->outputData['feature_project'] = $feature_project; $this->outputData['urgent_project'] = $urgent_project; $this->outputData['hide_project'] = $hide_project; $this->outputData['created'] = get_est_time(); $this->outputData['enddate'] = get_est_time() + $this->input->post('openDays') * 86400; if ($manage != '0') { //initial value set for check the featured , urgent, hide projects $settingAmount = 0; //check the values for featured, urgent, hide projects if ($this->input->post('is_feature', TRUE)) { $settingAmount = $settingAmount + $feature_project; } if ($this->input->post('is_urgent', TRUE)) { $settingAmount = $settingAmount + $urgent_project; } if ($this->input->post('is_hide_bids', TRUE)) { $settingAmount = $settingAmount + $hide_project; } //Check User Balance $condition_balance = array('user_balance.user_id' => $this->loggedInUser->id); $results = $this->transaction_model->getBalance($condition_balance); //If Record already exists if ($results->num_rows() > 0) { //get balance detail $rowBalance = $results->row(); $this->outputData['userAvailableBalance'] = $rowBalance->amount; // $avail_balance = $rowBalance->amount; } if ($this->input->post('is_hide_bids', TRUE) or $this->input->post('is_urgent', TRUE) or $this->input->post('is_feature', TRUE)) { $withdrawvalue = $rowBalance->amount - ($settingAmount + $paymentSettings['PAYMENT_SETTINGS']); if ($withdrawvalue < 0) { $this->session->set_flashdata('flash_message', $this->common_model->flash_message('error', $this->lang->line('your not having sufficient balance'))); //redirect('project/create'); } else { //Check User Balance //Update Amount $updateKey = array('user_balance.user_id' => $this->loggedInUser->id); $updateData = array(); $updateData['amount'] = $rowBalance->amount - $settingAmount; $results = $this->transaction_model->updateBalance($updateKey, $updateData); //Insert transaction for post projects $insertTransaction = array(); $insertTransaction['creator_id'] = $this->loggedInUser->id; $insertTransaction['type'] = $this->lang->line('Project Fee'); $insertTransaction['amount'] = $settingAmount; $insertTransaction['transaction_time'] = get_est_time(); $insertTransaction['status'] = 'Completed'; //Can Be success,failed,pending $insertTransaction['description'] = $this->lang->line('Project Fee for Bid'); //$insertData['user_type'] = $role; if ($this->loggedInUser->role_id == '1') { $insertTransaction['buyer_id'] = $this->loggedInUser->id; $insertTransaction['user_type'] = $this->lang->line('Project Fee for Bid'); } if ($this->loggedInUser->role_id == '2') { $insertTransaction['provider_id'] = $this->loggedInUser->id; $insertTransaction['user_type'] = $this->lang->line('Project Fee for Bid'); } //pr($insertData); $this->load->model('transaction_model'); $this->transaction_model->addTransaction($insertTransaction); } } } //Get payment settings for check minimum balance from settings table $this->outputData['paymentSettings'] = $paymentSettings; $this->outputData['PAYMENT_SETTINGS'] = $paymentSettings['PAYMENT_SETTINGS']; $categories = $this->input->post('categories'); //Work With Project Categories $project_categoriesNameArray = $this->skills_model->convertCategoryIdsToName($categories); $project_categoriesNameString = implode(',', $project_categoriesNameArray); $insertData['project_categories'] = $project_categoriesNameString; //Create Projects before it for update the projects datas for manage option if ($this->input->post('update') == '0') { if ($this->input->post('projectid')) { //Notification message //Load Model For Mail $this->load->model('email_model'); //Send Mail $conditionUserMail = array('email_templates.type' => 'projectpost_notification'); $result = $this->email_model->getEmailSettings($conditionUserMail); $rowUserMailConent = $result->row(); $splVars = array("!site_name" => $this->config->item('site_title'), "!username" => $this->loggedInUser->user_name, "!profile" => $project_categoriesNameString, "!projectid" => $this->db->insert_id(), "!date" => get_datetime(time())); $mailSubject = strtr($rowUserMailConent->mail_subject, $splVars); $mailContent = strtr($rowUserMailConent->mail_body, $splVars); $toEmail = $this->loggedInUser->email; $fromEmail = $this->config->item('site_admin_mail', TRUE); //echo $mailContent; //$this->email_model->sendHtmlMail($toEmail,$fromEmail,$mailSubject,$mailContent); //Update the data $project = $this->input->post('projectid'); $condition = array('projects.id' => $project); $this->skills_model->manageProjects($insertData, $condition); $this->session->set_flashdata('flash_message', $this->common_model->flash_message('success', $this->lang->line('Your Project has been Updated Successfully'))); redirect('buyer/viewMyProjects'); } } if ($this->input->post('createProject')) { //Load Model For Mail $this->load->model('email_model'); //Send Mail $conditionUserMail = array('email_templates.type' => 'projectpost_notification'); $result = $this->email_model->getEmailSettings($conditionUserMail); $rowUserMailConent = $result->row(); $splVars = array("!site_name" => $this->config->item('site_title'), "!username" => $this->loggedInUser->user_name, "!profile" => $project_categoriesNameString, "!projectid" => $this->db->insert_id(), "!date" => get_datetime(time())); $mailSubject = strtr($rowUserMailConent->mail_subject, $splVars); $mailContent = strtr($rowUserMailConent->mail_body, $splVars); $toEmail = $this->loggedInUser->email; $fromEmail = $this->config->item('site_admin_mail', TRUE); // $this->email_model->sendHtmlMail($toEmail,$fromEmail,$mailSubject,$mailContent); // insert the projects details into project table $this->skills_model->createProject($insertData); $delete_condition = array('draftprojects.project_name' => $this->input->post('projectName')); $this->skills_model->deletedraftprojects($delete_condition); //Notification message $this->session->set_flashdata('flash_message', $this->common_model->flash_message('success', $this->lang->line('Your Project has been Posted Successfully'))); redirect('buyer/viewMyProjects'); } redirect('info/index/success'); } } //Form Validation End } //If - Form Submission End //Get Groups $this->outputData['groupsWithCategories'] = $this->skills_model->getGroupsWithCategory(); if ($result == '0') { $this->load->view('project/createProject', $this->outputData); } else { $this->load->view('project/previewProject', $this->outputData); } }
/** * Remove Profile image * * @access private * @param nil * @return void */ function removePhoto() { //language file $this->lang->load('enduser/editProfile', $this->config->item('language_code')); //Check For Buyer Session if ($this->uri->segment(4) == '2') { if (!isProgrammer()) { $this->session->set_flashdata('flash_message', $this->common_model->flash_message('error', $this->lang->line('You must be logged in as a Programmer'))); redirect('info'); } } elseif ($this->uri->segment(4) == '1') { if (!isBuyer()) { $this->session->set_flashdata('flash_message', $this->common_model->flash_message('error', 'You must be logged in as a Buyer')); redirect('info'); } } $userid = $this->uri->segment(3); $path = $this->config->item('basepath') . 'files/logos/'; $condition2 = array('users.id' => $userid); $port = $this->user_model->getUsers($condition2); $folio = $port->row(); //$arr = explode(".",$folio->logo); //$thumb = $arr[0]."_thumb.".$arr[1]; $files = array($folio->logo); delete_file($path, $files); $updateData['users.logo'] = ''; $updateKey = array('users.id' => $userid); //Edit Portfolio $this->user_model->updateUser($updateKey, $updateData); $this->session->set_flashdata('flash_message', $this->common_model->flash_message('error', 'Profile photo deleted successfully')); if ($this->uri->segment(4) == '2') { redirect('programmer/editProfile/'); } elseif ($this->uri->segment(4) == '1') { redirect('buyer/editProfile/'); } }
/** * Post new job list by buyer * * @access private * @param nil * @return void */ function create() { $this->outputData['current_page'] = 'post_project'; $result = '0'; $manage = '1'; $this->outputData['showPreview'] = false; //Load Language $this->lang->load('enduser/withdrawMoney', $this->config->item('language_code')); $this->lang->load('enduser/createBids', $this->config->item('language_code')); $this->outputData['created'] = get_est_time(); $this->outputData['enddate'] = get_est_time() + $this->input->post('openDays') * 86400; //Check For Buyer Session if (!isBuyer()) { $this->session->set_flashdata('flash_message', $this->common_model->flash_message('error', $this->lang->line('You must be logged in as a buyer to post projects'))); redirect('info'); } if ($this->loggedInUser->suspend_status == 1) { $this->session->set_flashdata('flash_message', $this->common_model->flash_message('error', $this->lang->line('Suspend Error'))); redirect('info'); } //load validation libraray $this->load->library('form_validation'); //Load Form Helper $this->load->helper('form'); //Intialize values for library and helpers $this->form_validation->set_error_delimiters($this->config->item('field_error_start_tag'), $this->config->item('field_error_end_tag')); if ($this->input->post('projectid')) { $project = $this->input->post('projectid'); } //Save the draft projects if ($this->input->post('save_draft')) { //Save the Project if ($this->input->post('postProject') == "Project") { if ($this->input->post('projectName')) { $draft_name = $this->input->post('projectName'); $condition = array('draftprojects.project_name' => $draft_name); $draft = $this->skills_model->getDraft($condition); if ($draft->num_rows() <= 0) { $insertData = array(); $insertData['project_name'] = $this->input->post('projectName'); $insertData['description'] = $this->input->post('description'); if ($this->input->post('budget_min', TRUE)) { $insertData['budget_min'] = $this->input->post('budget_min'); } else { $insertData['budget_min'] = ''; } if ($this->input->post('budget_max', TRUE)) { $insertData['budget_max'] = $this->input->post('budget_max'); } else { $insertData['budget_max'] = ''; } $insertData['is_feature'] = $this->input->post('is_feature'); $insertData['is_urgent'] = $this->input->post('is_urgent'); $insertData['is_hide_bids'] = $this->input->post('is_hide_bids'); if ($this->input->post('is_private')) { $insertData['is_private'] = $this->input->post('is_private'); $insertData['private_users'] = $this->input->post('private_list'); } $insertData['creator_id'] = $this->loggedInUser->id; $insertData['created'] = get_est_time(); $insertData['enddate'] = get_est_time() + $this->input->post('openDays') * 86400; $insertData['flag'] = 0; if ($this->input->post('categories')) { $categories = $this->input->post('categories'); //Work With Project Categories $project_categoriesNameArray = $this->skills_model->convertCategoryIdsToName($categories); $project_categoriesNameString = implode(',', $project_categoriesNameArray); $insertData['project_categories'] = $project_categoriesNameString; } if ($insertData) { $this->skills_model->draftProject($insertData); $this->session->set_flashdata('flash_message', $this->common_model->flash_message('success', $this->lang->line('Your project has been saved as Draft'))); redirect('info/index/success'); } else { $this->session->set_flashdata('flash_message', $this->common_model->flash_message('error', $this->lang->line('You cannot save this project as Draft'))); redirect('info'); } } else { $draft = $draft->row(); $updateDraft = array(); $updateDraft['project_name'] = $this->input->post('projectName'); $updateDraft['description'] = $this->input->post('description'); //Set budget min value if ($this->input->post('budget_min', TRUE)) { $updateDraft['budget_min'] = $this->input->post('budget_min'); } else { $updateDraft['budget_min'] = ''; } //Set budget max value if ($this->input->post('budget_max', TRUE)) { $updateDraft['budget_max'] = $this->input->post('budget_max'); } else { $updateDraft['budget_max'] = ''; } $updateDraft['is_feature'] = $this->input->post('is_feature'); $updateDraft['is_urgent'] = $this->input->post('is_urgent'); $updateDraft['is_hide_bids'] = $this->input->post('is_hide_bids'); if ($this->input->post('is_private')) { $updateDraft['is_private'] = $this->input->post('is_private'); $updateDraft['private_users'] = $this->input->post('private_list'); } $updateDraft['creator_id'] = $this->loggedInUser->id; $updateDraft['created'] = get_est_time(); $updateDraft['enddate'] = get_est_time() + $this->input->post('openDays') * 86400; if ($this->input->post('categories')) { $categories = $this->input->post('categories'); //Work With Project Categories $project_categoriesNameArray = $this->skills_model->convertCategoryIdsToName($categories); $project_categoriesNameString = implode(',', $project_categoriesNameArray); $updateDraft['project_categories'] = $project_categoriesNameString; } if ($updateDraft) { $condition = array('draftprojects.id' => $draft->id); $this->skills_model->updateDraftProject($updateDraft, $condition); $this->session->set_flashdata('flash_message', $this->common_model->flash_message('success', $this->lang->line('Your project has been updated as Draft'))); redirect('info/index/success'); } else { $this->session->set_flashdata('flash_message', $this->common_model->flash_message('error', $this->lang->line('You cannot update this project as Draft'))); redirect('info'); } } } } else { if ($this->input->post('projectName')) { $draft_name = $this->input->post('projectName'); $condition = array('draftprojects.project_name' => $draft_name); $draft = $this->skills_model->getDraft($condition); $paymentSettings = $this->settings_model->getSiteSettings(); $joblistvalidity = $paymentSettings['JOBLIST_VALIDITY_LIMIT']; if ($draft->num_rows() <= 0) { $insertJobData = array(); $insertJobData['project_name'] = $this->input->post('projectName'); $insertJobData['description'] = $this->input->post('description'); $insertJobData['creator_id'] = $this->loggedInUser->id; $insertJobData['created'] = get_est_time(); $insertJobData['enddate'] = get_est_time() + $joblistvalidity * 86400; $insertJobData['contact'] = $this->input->post('contactinfo'); $insertJobData['salary'] = $this->input->post('salary'); $insertJobData['salarytype'] = $this->input->post('salarytype'); $insertJobData['flag'] = 1; if ($this->input->post('categories')) { $categories = $this->input->post('categories'); //Work With Project Categories $project_categoriesNameArray = $this->skills_model->convertCategoryIdsToName($categories); $project_categoriesNameString = implode(',', $project_categoriesNameArray); $insertJobData['project_categories'] = $project_categoriesNameString; } if ($insertJobData) { $this->skills_model->draftProject($insertJobData); $this->session->set_flashdata('flash_message', $this->common_model->flash_message('success', $this->lang->line('Your Job has been saved as Draft'))); redirect('info/index/success'); } else { $this->session->set_flashdata('flash_message', $this->common_model->flash_message('error', $this->lang->line('You cannot save this Job as Draft'))); redirect('info'); } } else { $draft = $draft->row(); $updatejobDraft = array(); $updatejobDraft['project_name'] = $this->input->post('projectName'); $updatejobDraft['description'] = $this->input->post('description'); //Set budget min value $updatejobDraft['creator_id'] = $this->loggedInUser->id; $updatejobDraft['created'] = get_est_time(); //$updatejobDraft['enddate'] = get_est_time() + ($this->input->post('openDays') * 86400); $updatejobDraft['contact'] = $this->input->post('contactinfo'); $updatejobDraft['salary'] = $this->input->post('salary'); $updatejobDraft['salarytype'] = $this->input->post('salarytype'); if ($this->input->post('categories')) { $categories = $this->input->post('categories'); //Work With Project Categories $project_categoriesNameArray = $this->skills_model->convertCategoryIdsToName($categories); $project_categoriesNameString = implode(',', $project_categoriesNameArray); $updatejobDraft['project_categories'] = $project_categoriesNameString; } if ($updatejobDraft) { $condition = array('draftprojects.id' => $draft->id); $this->skills_model->updateDraftProject($updatejobDraft, $condition); $this->session->set_flashdata('flash_message', $this->common_model->flash_message('success', $this->lang->line('Your Job has been updated as Draft'))); redirect('info/index/success'); } else { $this->session->set_flashdata('flash_message', $this->common_model->flash_message('error', $this->lang->line('You cannot update this Job as Draft'))); redirect('info'); } } } } } if ($this->uri->segment(3, 0)) { $project_id = $this->uri->segment(3, 0); } else { $project_id = $this->input->post('projectid'); } //Get the project details for post similar projects $conditions = array('projects.id' => $project_id, 'projects.creator_id' => $this->loggedInUser->id); $postSimilar = $this->skills_model->getUsersproject($conditions); $this->outputData['postSimilar'] = $postSimilar; //Get Form Data if ($this->input->post('createProject') or $this->input->post('preview_project')) { $type = $this->input->post('postProject'); //Set rules // Puhal Changes Start Following validations are to verify the post of Email address and Phone number (Sep 17 Issue 1) ------------------------------------------- $this->form_validation->set_rules('projectName', 'lang:project_name_validation', 'required|trim|min_length[5]|xss_clean|alpha_space|callback__emailpresent_projectname_check|callback__phonenumber_projectname_check'); // Puhal Changes End Following validations are to verify the post of Email address and Phone number (Sep 17 Issue 1) ------------------------------------------- if ($type == "Project") { $this->form_validation->set_rules('description', 'lang:description_validation', 'required|min_length[25]|trim|xss_clean|callback__emailpresent_check|callback__phonenumber_check'); } else { $this->form_validation->set_rules('description', 'lang:description_validation', 'required|min_length[25]|trim|xss_clean'); $this->form_validation->set_rules('contactinfo', 'lang:contactinfo_validation', 'required'); } $this->form_validation->set_rules('attachment', 'lang:attachment_validation', 'callback_attachment_check'); $this->form_validation->set_rules('categories[]', 'lang:categories_validation', 'required'); $this->form_validation->set_rules('is_feature', 'lang:is_feature_validation', 'trim'); $this->form_validation->set_rules('is_private', 'lang:is_private_validation', 'trim'); $this->form_validation->set_rules('is_urgent', 'lang:is_urgent_validation', 'trim'); $this->form_validation->set_rules('is_hide_bids', 'lang:is_hide_bids_validation', 'trim'); $this->form_validation->set_rules('budget_min', 'lang:budget_min_validation', 'trim|integer|is_natural|abs|xss_clean'); $this->form_validation->set_rules('budget_max', 'lang:budget_max_validation', 'trim|integer|is_natural|abs|xss_clean'); $this->form_validation->set_rules('salary', 'lang:salary_validation', '|trim|integer|xss_clean'); $this->form_validation->set_rules('salarytype', 'lang:salarytype_validation', '|trim|xss_clean'); if ($this->input->post('is_private')) { $this->form_validation->set_rules('private_list', 'lang:private_list', 'required'); } if ($this->form_validation->run()) { //This is condition check for post similar project $conditions = array('projects.project_name' => $this->input->post('projectName')); $postSimilar = $this->skills_model->getUsersproject($conditions); $res = $postSimilar->num_rows(); if ($res > 0) { $sameProject = $postSimilar->row(); $project = $sameProject->id; } if ($this->input->post('update') != '0') { $manage = '1'; } else { $manage = '0'; } if ($manage != '0') { if ($res > 0) { $this->session->set_flashdata('flash_message', $this->common_model->flash_message('error', $this->lang->line('Project already Exists'))); redirect('joblist/postProject/' . $project); } } //insert project data $insertData = array(); $insertData['project_name'] = $this->input->post('projectName'); $insertData['description'] = $this->input->post('description'); //Puhal Changes Start for downloading the Project attachment file (Sep 20 Isssue 17) if (isset($this->data['file'])) { $insertData['attachment_url'] = $this->data['file']['file_name']; $insertData['attachment_name'] = $this->data['file']['orig_name']; } if ($this->input->post('update') == '0') { $insertData['description'] = $this->input->post('description') . '<br/>'; $insertData['description'] .= $this->input->post('add_description'); } else { $insertData['description'] = $this->input->post('description'); } $insertData['budget_min'] = $this->input->post('budget_min'); $insertData['budget_max'] = $this->input->post('budget_max'); $insertData['is_feature'] = $this->input->post('is_feature'); $insertData['is_urgent'] = $this->input->post('is_urgent'); $insertData['is_hide_bids'] = $this->input->post('is_hide_bids'); $insertData['flag'] = 0; if ($this->input->post('is_private')) { $insertData['is_private'] = $this->input->post('is_private'); } $insertData['creator_id'] = $this->loggedInUser->id; $insertData['created'] = get_est_time(); $insertData['enddate'] = get_est_time() + $this->input->post('openDays') * 86400; $result = '0'; //insert joblist data $insertJobData = array(); $insertJobData['project_name'] = $this->input->post('projectName'); $insertJobData['description'] = $this->input->post('description'); //Puhal Changes Start for downloading the Project attachment file (Sep 20 Isssue 17) if (isset($this->data['file'])) { $insertJobData['attachment_url'] = $this->data['file']['file_name']; $insertJobData['attachment_name'] = $this->data['file']['orig_name']; } if ($this->input->post('update') == '0') { $insertJobData['description'] = $this->input->post('description') . '<br/>'; $insertJobData['description'] .= $this->input->post('add_description'); } else { $insertJobData['description'] = $this->input->post('description'); } if ($this->input->post('categories')) { $categories = $this->input->post('categories'); //pr($categories); //Work With Project Categories $project_categoriesNameArray = $this->skills_model->convertCategoryIdsToName($categories); $project_categoriesNameString = implode(',', $project_categoriesNameArray); $insertJobData['project_categories'] = $project_categoriesNameString; } $paymentSettings = $this->settings_model->getSiteSettings(); $joblistvalidity = $paymentSettings['JOBLIST_VALIDITY_LIMIT']; $insertJobData['flag'] = 1; $insertJobData['creator_id'] = $this->loggedInUser->id; $insertJobData['created'] = get_est_time(); $insertJobData['enddate'] = get_est_time() + $joblistvalidity * 86400; $insertJobData['contact'] = $this->input->post('contactinfo'); $insertJobData['salary'] = $this->input->post('salary'); $insertJobData['salarytype'] = $this->input->post('salarytype'); $insertJobData['flag'] = 1; $result = '0'; //Project Preview if ($this->input->post('preview_project')) { $this->outputData['showPreview'] = true; $result = '1'; $outputData['project_status'] = 'Pending'; $outputData['project_name'] = $this->input->post('projectName'); //Update additional information for projects if ($this->input->post('update') == '0') { $outputData['description'] = $this->input->post('description') . '<br>'; $outputData['description'] .= $this->input->post('add_description'); } else { $outputData['description'] = $this->input->post('description'); } $outputData['budget_min'] = $this->input->post('budget_min'); $outputData['budget_max'] = $this->input->post('budget_max'); $outputData['is_feature'] = $this->input->post('is_feature'); $outputData['is_urgent'] = $this->input->post('is_urgent'); $outputData['is_hide_bids'] = $this->input->post('is_hide_bids'); $outputData['flag'] = '0'; if ($this->input->post('is_private')) { $insertData['is_private'] = $this->input->post('is_private'); } $outputData['creator_id'] = $this->loggedInUser->id; $outputData['created'] = get_est_time(); $outputData['enddate'] = get_est_time() + $this->input->post('openDays') * 86400; if ($this->input->post('categories')) { $categories = $this->input->post('categories'); //Work With Project Categories $project_categoriesNameArray = $this->skills_model->convertCategoryIdsToName($categories); $project_categoriesNameString = implode(',', $project_categoriesNameArray); $outputData['project_categories'] = $project_categoriesNameString; } //joblist data $this->outputjobData['showPreview'] = true; $result = '1'; $outputjobData['project_status'] = 'Pending'; $outputjobData['project_name'] = $this->input->post('projectName'); $paymentSettings = $this->settings_model->getSiteSettings(); $joblistvalidity = $paymentSettings['JOBLIST_VALIDITY_LIMIT']; //Update additional information for Joblist if ($this->input->post('update') == '0') { $outputjobData['description'] = $this->input->post('description') . '<br>'; $outputjobData['description'] .= $this->input->post('add_description'); } else { $outputjobData['description'] = $this->input->post('description'); } $outputjobData['creator_id'] = $this->loggedInUser->id; $outputjobData['created'] = get_est_time(); $outputjobData['enddate'] = get_est_time() + $joblistvalidity * 86400; $outputjobData['contact'] = $this->input->post('contactinfo'); $outputjobData['salary'] = $this->input->post('salary'); $outputjobData['salarytype'] = $this->input->post('salarytype'); $outputjobData['flag'] = '1'; if ($this->input->post('categories')) { $categories = $this->input->post('categories'); //Work With Project Categories $project_categoriesNameArray = $this->skills_model->convertCategoryIdsToName($categories); $project_categoriesNameString = implode(',', $project_categoriesNameArray); $outputjobData['project_categories'] = $project_categoriesNameString; } if ($this->input->post('postProject') == "Joblist") { // insert the jobs details into project table $this->skills_model->previewProject($outputjobData); } else { // insert the projects details into project table $this->skills_model->previewProject($outputData); } } //Project Submit //check the condition for view the preview about the project if ($result == '0') { $this->loggedInUser = $this->common_model->getLoggedInUser(); $this->outputData['loggedInUser'] = $this->loggedInUser; $login_user = $this->loggedInUser; $condition = array('subscriptionuser.username' => $this->loggedInUser->id); $userlists = $this->certificate_model->getCertificateUser($condition); if ($userlists->num_rows() > 0) { // get the validity $validdate = $userlists->row(); $end_date = $validdate->valid; $created_date = $validdate->created; $valid_date = date('d/m/Y', $created_date); $next = $created_date + $end_date * 24 * 60 * 60; $next_day = date('d/m/Y', $next) . "\n"; if (time() <= $next) { $paymentSettings = $this->settings_model->getSiteSettings(); $feature_project = $this->config->item('featured_project_amount_cm'); $urgent_project = $paymentSettings['URGENT_PROJECT_AMOUNT_CM']; $hide_project = $paymentSettings['HIDE_PROJECT_AMOUNT_CM']; $private_project = $paymentSettings['PRIVATE_PROJECT_AMOUNT_CM']; $this->outputData['feature_project'] = $feature_project; $this->outputData['urgent_project'] = $urgent_project; $this->outputData['hide_project'] = $hide_project; $this->outputData['private_project'] = $private_project; $this->outputData['created'] = get_est_time(); $this->outputData['enddate'] = get_est_time() + $this->input->post('openDays') * 86400; } else { //Get the values from settings table $paymentSettings = $this->settings_model->getSiteSettings(); $feature_project = $this->config->item('featured_project_amount'); $urgent_project = $paymentSettings['URGENT_PROJECT_AMOUNT']; $hide_project = $paymentSettings['HIDE_PROJECT_AMOUNT']; $private_project = $paymentSettings['PRIVATE_PROJECT_AMOUNT']; $this->outputData['feature_project'] = $feature_project; $this->outputData['urgent_project'] = $urgent_project; $this->outputData['hide_project'] = $hide_project; $this->outputData['private_project'] = $this->outputData['created'] = get_est_time(); $this->outputData['enddate'] = get_est_time() + $this->input->post('openDays') * 86400; } } else { $paymentSettings = $this->settings_model->getSiteSettings(); $feature_project = $paymentSettings['FEATURED_PROJECT_AMOUNT']; $urgent_project = $paymentSettings['URGENT_PROJECT_AMOUNT']; $hide_project = $paymentSettings['HIDE_PROJECT_AMOUNT']; $private_project = $paymentSettings['PRIVATE_PROJECT_AMOUNT']; } if ($this->input->post('createProject')) { //initial value set for check the featured , urgent, hide projects $settingAmount = 0; //check the values for featured, urgent, hide projects if ($this->input->post('is_feature')) { $settingAmount = $settingAmount + $feature_project; } if ($this->input->post('is_urgent')) { $settingAmount = $settingAmount + $urgent_project; } if ($this->input->post('is_hide_bids')) { $settingAmount = $settingAmount + $hide_project; } if ($this->input->post('is_private')) { $settingAmount = $settingAmount + $private_project; } //Check User Balance $condition_balance = array('user_balance.user_id' => $this->loggedInUser->id); $results = $this->transaction_model->getBalance($condition_balance); //If Record already exists if ($results->num_rows() > 0) { //get balance detail $rowBalance = $results->row(); $this->outputData['userAvailableBalance'] = $rowBalance->amount; } if ($this->input->post('is_hide_bids', TRUE) or $this->input->post('is_urgent', TRUE) or $this->input->post('is_feature', TRUE) or $this->input->post('is_private', TRUE)) { $withdrawvalue = $rowBalance->amount - ($settingAmount + $paymentSettings['PAYMENT_SETTINGS']); if ($rowBalance->amount == 0) { $this->session->set_flashdata('flash_message', $this->common_model->flash_message('error', $this->lang->line('your not having sufficient balance'))); redirect('info'); } else { if ($withdrawvalue < 0) { $this->session->set_flashdata('flash_message', $this->common_model->flash_message('error', $this->lang->line('your not having sufficient balance'))); redirect('info'); } else { //Check User Balance //Update Amount $updateKey = array('user_balance.user_id' => $this->loggedInUser->id); $updateData = array(); $updateData['amount'] = $rowBalance->amount - $settingAmount; $results = $this->transaction_model->updateBalance($updateKey, $updateData); //Insert transaction for post projects $insertTransaction = array(); $insertTransaction['creator_id'] = $this->loggedInUser->id; $insertTransaction['type'] = $this->lang->line('Project Fee'); $insertTransaction['amount'] = $settingAmount; $insertTransaction['transaction_time'] = get_est_time(); $insertTransaction['status'] = 'Completed'; //Can Be success,failed,pending if ($this->input->post('is_feature')) { $insertTransaction['description'] = $this->lang->line('Project Fee for Feature Project'); } elseif ($this->input->post('is_urgent')) { $insertTransaction['description'] = $this->lang->line('Project Fee for Urgent Project'); } elseif ($this->input->post('is_hide_bids')) { $insertTransaction['description'] = $this->lang->line('Project Fee for hide bids Project'); } elseif ($this->input->post('is_private')) { $insertTransaction['description'] = $this->lang->line('Project Fee for Private Project'); } if ($this->loggedInUser->role_id == '1') { $insertTransaction['buyer_id'] = $this->loggedInUser->id; $insertTransaction['user_type'] = $this->lang->line('Project Fee for Bid'); } if ($this->loggedInUser->role_id == '2') { $insertTransaction['provider_id'] = $this->loggedInUser->id; $insertTransaction['user_type'] = $this->lang->line('Project Fee for Bid'); } $this->load->model('transaction_model'); $this->transaction_model->addTransaction($insertTransaction); } } } } //Get payment settings for check minimum balance from settings table $this->outputData['paymentSettings'] = $paymentSettings; $this->outputData['PAYMENT_SETTINGS'] = $paymentSettings['PAYMENT_SETTINGS']; if ($this->input->post('categories')) { $categories = $this->input->post('categories'); //Work With Project Categories $project_categoriesNameArray = $this->skills_model->convertCategoryIdsToName($categories); $project_categoriesNameString = implode(',', $project_categoriesNameArray); $insertData['project_categories'] = $project_categoriesNameString; } if ($this->input->post('createProject')) { if ($this->input->post('postProject') == "Joblist") { //payment Checking $joblistsettings = 0; $paymentSettings = $this->settings_model->getSiteSettings(); $joblistamount = $paymentSettings['JOBLISTING_PROJECT_AMOUNT']; $joblistsettings = $joblistsettings + $joblistamount; $condition_balance = array('user_balance.user_id' => $this->loggedInUser->id); $results = $this->transaction_model->getBalance($condition_balance); $results->num_rows(); if ($results->num_rows() > 0) { //get balance detail $rowBalance = $results->row(); $this->outputData['userAvailableBalance'] = $rowBalance->amount; } if ($rowBalance->amount <= $joblistamount) { $this->skills_model->draftProject($insertJobData); $this->session->set_flashdata('flash_message', $this->common_model->flash_message('error', $this->lang->line('your not having sufficient balance'))); redirect('joblist/create'); } else { //Check User Balance //Update Amount $updateKey = array('user_balance.user_id' => $this->loggedInUser->id); $updateData = array(); $updateData['amount'] = $rowBalance->amount - $joblistsettings; $results = $this->transaction_model->updateBalance($updateKey, $updateData); //Insert transaction for post projects $insertTransaction = array(); $insertTransaction['creator_id'] = $this->loggedInUser->id; $insertTransaction['type'] = $this->lang->line('Project Fee'); $insertTransaction['amount'] = $joblistsettings; $insertTransaction['transaction_time'] = get_est_time(); $insertTransaction['status'] = 'Completed'; //Can Be success,failed,pending $insertTransaction['description'] = $this->lang->line('Job Fee'); if ($this->loggedInUser->role_id == '1') { $insertTransaction['buyer_id'] = $this->loggedInUser->id; $insertTransaction['user_type'] = $this->lang->line('Job Fee'); } if ($this->loggedInUser->role_id == '2') { $insertTransaction['provider_id'] = $this->loggedInUser->id; $insertTransaction['user_type'] = $this->lang->line('Job Fee'); } $this->load->model('transaction_model'); $this->transaction_model->addTransaction($insertTransaction); // insert the jobs details into project table $this->skills_model->createProject($insertJobData); $this->session->set_flashdata('flash_message', $this->common_model->flash_message('success', $this->lang->line('Your Job has been Posted Successfully'))); redirect('joblist/viewAlljoblists/flag'); } } else { // insert the projects details into project table $this->skills_model->createProject($insertData); $this->session->set_flashdata('flash_message', $this->common_model->flash_message('success', $this->lang->line('Your Project has been Posted Successfully'))); } $projectid = $this->db->insert_id(); if ($this->input->post('is_private')) { $private_users = $this->input->post('private_list', TRUE); if ($private_users != '') { $private_users_array = explode("\n", $private_users); $condition = '`role_id`=2'; foreach ($private_users_array as $val) { $private_users_array1[] = " `user_name`='" . $val . "'"; } $private_users_str1 = implode(' OR ', $private_users_array1); $private_users_cond = $condition . ' AND (' . $private_users_str1 . ')'; //$sel_users=$this->user_model->getUsersfromusername($condition=array(),$private_users_array,NULL); $sel_users = $this->user_model->getUsersfromusername($private_users_cond); //pr($sel_users->result()); if ($sel_users->num_rows() > 0) { foreach ($sel_users->result() as $users) { $pusers[] = $users->id; } $pusers = array_unique($pusers); $pusers1 = implode(',', $pusers); $data = array('private_users' => $pusers1); $condition = array('id' => $projectid); $table = 'projects'; $this->common_model->updateTableData($table, NULL, $data, $condition); //insert project_invitation table for private users $insertprivate = array('project_id' => $projectid, 'sender_id' => $this->loggedInUser->id, 'invite_date' => get_est_time(), 'notification_status' => '0'); $invitetable = 'project_invitation'; foreach ($pusers as $val) { $insertprivate['receiver_id'] = $val; $this->common_model->insertData($invitetable, $insertprivate); } } } } if ($this->input->post('is_private')) { //Send Mail $conditionProviderMail = array('email_templates.type' => 'private_project_provider'); $resultProvider = $this->email_model->getEmailSettings($conditionProviderMail); $resultProvider = $resultProvider->row(); $projectpage = site_url('project/view/' . $projectid); $splVars_provider = array("!site_name" => $this->config->item('site_title'), "!projectname" => $insertData['project_name'], "!creatorname" => $this->loggedInUser->user_name, "!profile" => $project_categoriesNameString, "!projectid" => $projectid, "!date" => get_datetime(time()), "!projecturl" => $projectpage); //pr($sel_users->result()); //sending emailto all the providers if ($private_users != '') { if ($sel_users->num_rows() > 0) { foreach ($sel_users->result() as $users) { $insertMessageData['project_id'] = $projectid; $insertMessageData['to_id'] = $users->id; $insertMessageData['from_id'] = $this->loggedInUser->id; $insertMessageData['message'] = "Private Project Notification --> You are Invited for the private project<br/>Follow the link given below to view the project<br/>" . site_url('project/view/' . $projectid); $insertMessageData['created'] = get_est_time(); //pr($insertMessageData); exit; $this->messages_model->postMessage($insertMessageData); if ($users->email != '') { $toEmail_provider = $users->email; $fromEmail_provider = $this->config->item('site_admin_mail'); $selusernames[] = $users->user_name; $splVars_provider['!username'] = $users->user_name; $mailSubject_provider = strtr($resultProvider->mail_subject, $splVars_provider); $mailContent_provider = strtr($resultProvider->mail_body, $splVars_provider); $this->email_model->sendHtmlMail($toEmail_provider, $fromEmail_provider, $mailSubject_provider, $mailContent_provider); } } } } } if ($this->input->post('is_private')) { $conditionUserMail = array('email_templates.type' => 'privateproject_post'); $result = $this->email_model->getEmailSettings($conditionUserMail); $rowUserMailConent = $result->row(); $splVars = array("!site_name" => $this->config->item('site_title'), "!projectname" => $insertData['project_name'], "!username" => $this->loggedInUser->user_name, "!profile" => $project_categoriesNameString, "!projectid" => $projectid, "!projectid" => $projectid, "!date" => get_datetime(time())); if ($private_users != '') { if ($sel_users->num_rows() > 0) { $selusernamesstr = implode(",", $selusernames); } else { $selusernamesstr = ''; } } else { $selusernamesstr = ''; } $splVars['!privateproviders'] = $selusernamesstr; $mailSubject = strtr($rowUserMailConent->mail_subject, $splVars); $mailContent = strtr($rowUserMailConent->mail_body, $splVars); $toEmail = $this->loggedInUser->email; $fromEmail = $this->config->item('site_admin_mail'); $this->email_model->sendHtmlMail($toEmail, $fromEmail, $mailSubject, $mailContent); } else { //Send Mail $conditionUserMail = array('email_templates.type' => 'projectpost_notification'); $result = $this->email_model->getEmailSettings($conditionUserMail); $rowUserMailConent = $result->row(); $splVars = array("!site_name" => $this->config->item('site_title'), "!projectname" => $insertData['project_name'], "!username" => $this->loggedInUser->user_name, "!profile" => $project_categoriesNameString, "!projectid" => $this->db->insert_id(), "!projectid" => $this->db->insert_id(), "!date" => get_datetime(time())); $mailSubject = strtr($rowUserMailConent->mail_subject, $splVars); $mailContent = strtr($rowUserMailConent->mail_body, $splVars); $toEmail = $this->loggedInUser->email; $fromEmail = $this->config->item('site_admin_mail'); $this->email_model->sendHtmlMail($toEmail, $fromEmail, $mailSubject, $mailContent); } /* New version as of June 09 2009 */ $tuser = $this->config->item('twitter_username'); $tpass = $this->config->item('twitter_password'); $twit_msg = "<" . $this->loggedInUser->user_name . "> " . $insertData['project_name'] . " : " . site_url('project/view/' . $this->db->insert_id()); $twit_content = $this->skills_model->tinyUrl(site_url('project/view/' . $this->db->insert_id())); $this->skills_model->sendTwitter($twit_content, $tuser, $tpass); //Send instant notification mail to providers $conditions = array('users.role_id' => '2', 'users.user_status' => '1', 'user_categories.user_categories !=' => '', 'users.project_notify' => 'Instantly'); $users = $this->user_model->getUsersWithCategories($conditions); foreach ($users->result() as $user) { $cate = explode(",", $user->user_categories); $inter = array_intersect($cate, $categories); //Check if categories are matched to send notification if (count($inter) > 0) { $mailSubject = $this->config->item('site_title') . " Project Notice"; $mailContent = "The following project was recently added to " . $this->config->item('site_title') . " and match your expertise:"; $condition3 = array('projects.id' => $this->db->insert_id()); $mpr = $this->skills_model->getProjects($condition3); $prj = $mpr->row(); $mailContent .= $prj->project_name . " (Posted by " . $prj->user_name . ", " . get_datetime($prj->created) . ", Job type:" . $prj->project_categories . ")" . " " . site_url('project/view/' . $prj->id); //Send mail $toEmail = $user->email; $fromEmail = $this->config->item('site_admin_mail'); $this->email_model->sendHtmlMail($toEmail, $fromEmail, $mailSubject, $mailContent); } } /* end of new vesrion */ $delete_condition = array('draftprojects.project_name' => $this->input->post('projectName')); $this->skills_model->deletedraftprojects($delete_condition); //Notification message // redirect('buyer/viewMyProjects'); } redirect('info/index/success'); } } //Form Validation End } //If - Form Submission End //Get Groups $this->outputData['groupsWithCategories'] = $this->skills_model->getGroupsWithCategory(); if ($result == '0') { $this->load->view('joblist/createjoblist', $this->outputData); } else { $condition = array('projects_preview.id' => $this->db->insert_id()); $preview = $this->skills_model->getpreviewProjects($condition); $this->outputData['preview'] = $preview; if ($this->input->post('postProject') == "Joblist") { $this->load->view('joblist/createjoblist', $this->outputData); } else { $this->load->view('joblist/createjoblist', $this->outputData); } //$this->load->view('joblist/createjoblist',$this->outputData); } }
/** * review Programmers * * @access private * @param nil * @return void */ function reviewProgrammer() { //Load Language $this->lang->load('enduser/review', $this->config->item('language_code')); //Check For Buyer Session if (!isBuyer()) { $this->session->set_flashdata('flash_message', $this->common_model->flash_message('error', $this->lang->line('You must be logged in as a buyer to review programmer'))); redirect('info'); } if ($this->input->post('reviewProgrammer')) { $insertData = array(); $insertData['comments'] = $this->input->post('comment', TRUE); $insertData['rating'] = $this->input->post('rate', TRUE); $insertData['review_type'] = '2'; $insertData['review_time'] = get_est_time(); $insertData['project_id'] = $this->input->post('projectid', TRUE); $insertData['buyer_id'] = $this->loggedInUser->id; $insertData['provider_id'] = $this->input->post('providerid', TRUE); //Create Review $reviewId = $this->skills_model->createReview($insertData); //Update projects $this->skills_model->updateProjects($insertData['project_id'], array('provider_rated' => '1')); $condition = array('reviews.project_id' => $insertData['project_id']); $rev = $this->skills_model->getReviews($condition); //Send Mail $conditionUserMail = array('email_templates.type' => 'buyer_review'); $result = $this->email_model->getEmailSettings($conditionUserMail); $rowUserMailConent = $result->row(); //Get Project details $condition = array('projects.id' => $insertData['project_id']); $projectDetails = $this->skills_model->getProjects($condition, 'projects.project_name'); $prjRow = $projectDetails->row(); //Get User details $getuser = $this->user_model->getUsers(array('users.id' => $insertData['provider_id'])); $user = $getuser->row(); $splVars = array("!buyer_name" => $this->loggedInUser->user_name, "!project_name" => $prjRow->project_name, "!site_name" => base_url(), '!site_title' => $this->config->item('site_title')); $mailSubject = strtr($rowUserMailConent->mail_subject, $splVars); $mailContent = strtr($rowUserMailConent->mail_body, $splVars); $toEmail = $user->email; $fromEmail = $this->config->item('site_admin_mail'); //Send mail $this->email_model->sendHtmlMail($toEmail, $fromEmail, $mailSubject, $mailContent); if ($rev->num_rows() == 2) { //Increase number of reviews $num_reviews = $user->num_reviews + 1; //Rating if ($user->user_rating == 0) { $rating = $insertData['rating']; } else { $rating = ($user->user_rating + $insertData['rating']) / 2; } $tot_rating2 = $rating * $num_reviews; //Update Provider $this->skills_model->updateUsers($insertData['provider_id'], array('user_rating' => $rating, 'num_reviews' => $num_reviews, 'tot_rating' => $tot_rating2)); //Get buyer details $getHold = $this->skills_model->getRatingHold(array('rating_hold.user_id' => $this->loggedInUser->id, 'rating_hold.project_id' => $insertData['project_id'])); $holdRow = $getHold->row(); if ($getHold->num_rows() > 0) { //Get Provider details $getuser = $this->user_model->getUsers(array('users.id' => $this->loggedInUser->id), 'users.user_rating,users.num_reviews'); $buyerRow = $getuser->row(); //Rating if ($buyerRow->user_rating == 0) { $rating = $holdRow->rating; } else { $rating = ($buyerRow->user_rating + $holdRow->rating) / 2; } //Increase number of reviews $num_reviews = $buyerRow->num_reviews + 1; $tot_rating = $rating * $num_reviews; //Update buyer $this->skills_model->updateUsers($this->loggedInUser->id, array('user_rating' => $rating, 'num_reviews' => $num_reviews, 'tot_rating' => $tot_rating)); $condition2 = array('reviews.project_id' => $insertData['project_id'], 'reviews.buyer_id' => $this->loggedInUser->id, 'reviews.review_type' => '1'); $getrev = $this->skills_model->getReviews($condition2, 'reviews.id'); $revRow = $getrev->row(); $this->skills_model->updateReviews($revRow->id, array('reviews.hold' => '0')); } } elseif ($rev->num_rows() == 1) { $insertData2 = array(); $insertData2['rating'] = $insertData['rating']; $insertData2['user_id'] = $insertData['provider_id']; $insertData2['project_id'] = $insertData['project_id']; $this->skills_model->insertRatingHold($insertData2); $this->skills_model->updateReviews($reviewId, array('reviews.hold' => '1')); } //Notification message $this->session->set_flashdata('flash_message', $this->common_model->flash_message('success', $this->lang->line('review_added'))); redirect('info/index/success'); } if (!is_numeric($this->uri->segment(3))) { $this->session->set_flashdata('flash_message', $this->common_model->flash_message('error', $this->lang->line('You can not access to this page'))); redirect('info'); } //Get project id $projectid = $this->uri->segment(3, '0'); //Get Project details $condition = array('projects.id' => $projectid); $projectDetails = $this->skills_model->getProjects($condition); $this->outputData['projectDetails'] = $projectDetails; $prjRow = $projectDetails->row(); //Get provider details $condition3 = array('users.id' => $prjRow->programmer_id); $providerDetails = $this->user_model->getUsers($condition3); $this->outputData['providerDetails'] = $providerDetails->row(); //Get review details $condition2 = array('reviews.project_id' => $projectid, 'reviews.provider_id' => $prjRow->programmer_id, 'reviews.review_type' => '2'); $this->outputData['reviewDetails'] = $this->skills_model->getReviews($condition2); $this->load->view('buyer/reviewProgrammer', $this->outputData); }
/** * View the cancellation/Dispute case * * @access private * @param case id * @return contents */ function viewCase() { //Load Language $this->lang->load('enduser/cancelProject', $this->config->item('language_code')); //Check Whether User Logged In Or Not if (isLoggedIn() === false) { $this->session->set_flashdata('flash_message', $this->common_model->flash_message('error', $this->lang->line('Please login to view case'))); redirect('info'); } //If Admin try to access this url...redirect him if (isAdmin() === true) { $this->session->set_flashdata('flash_message', $this->common_model->flash_message('error', $this->lang->line('Please login to view case'))); redirect('info'); } //Load model $this->load->helper('users'); $this->load->helper('projectcases'); //load validation libraray $this->load->library('form_validation'); //Load Form Helper $this->load->helper('form'); //Intialize values for library and helpers $this->form_validation->set_error_delimiters($this->config->item('field_error_start_tag'), $this->config->item('field_error_end_tag')); //Get Form Data if ($this->input->post('respondCase')) { //Set rules if ($this->input->post('updates') == '0') { $this->form_validation->set_rules('problem_description', 'lang:problem_description_validation', 'required|trim|xss_clean'); } else { $this->form_validation->set_rules('problem_description', 'lang:problem_description_validation', 'trim|xss_clean'); } $this->form_validation->set_rules('comments', '', 'trim|xss_clean'); if ($this->form_validation->run()) { if (check_form_token() === false) { $this->session->set_flashdata('flash_message', $this->common_model->flash_message('error', $this->lang->line('token_error'))); redirect('info'); } $insertData = array(); $insertData['parent'] = $this->input->post('case_id'); $insertData['problem_description'] = $this->input->post('problem_description'); $insertData['private_comments'] = $this->input->post('comments'); $insertData['user_id'] = $this->loggedInUser->id; $insertData['created'] = get_est_time(); if ($this->input->post('updates') != '0') { $insertData['updates'] = $this->input->post('updates'); } //Create Case $this->dispute_model->insertProjectCase($insertData); $project_id = $this->input->post('project_id'); $condition2 = array('projects.id' => $project_id); $res = $this->skills_model->getProjects($condition2); $prj = $res->row(); if (isProgrammer()) { $other_user = $prj->user_name; $user_type = 'Provider'; } if (isBuyer()) { $provider_id = $prj->programmer_id; $providerRow = getUserInfo($provider_id); $other_user = $providerRow->user_name; $user_type = 'Buyer'; } //Send Mail to other user about the case $conditionUserMail = array('email_templates.type' => 'respond_case'); $result = $this->email_model->getEmailSettings($conditionUserMail); $rowUserMailConent = $result->row(); //Update the details $splVars = array("!project_name" => '<a href="' . site_url('project/view/' . $prj->id) . '">' . $prj->project_name . '</a>', "!pr_name" => $prj->project_name, "!other_user" => $other_user, "!contact_url" => site_url('contact'), "!user" => $this->loggedInUser->user_name, '!site_title' => $this->config->item('site_title'), "!link" => site_url('dispute/viewCase/' . $insertData['parent'])); $mailSubject = strtr($rowUserMailConent->mail_subject, $splVars); $mailContent = strtr($rowUserMailConent->mail_body, $splVars); $toEmail = $prj->email; $fromEmail = $this->config->item('site_admin_mail'); $this->email_model->sendHtmlMail($toEmail, $fromEmail, $mailSubject, $mailContent); //Send acknowledgement Mail to siteadmin $conditionUserMail = array('email_templates.type' => 'response_case_admin'); $result = $this->email_model->getEmailSettings($conditionUserMail); $rowUserMailConent = $result->row(); //Update the details $splVars = array("!project_name" => '<a href="' . site_url('project/view/' . $prj->id) . '">' . $prj->project_name . '</a>', "!user" => $this->loggedInUser->user_name, '!user_type' => $user_type, '!case_id' => $insertData['parent']); $mailSubject = strtr($rowUserMailConent->mail_subject, $splVars); $mailContent = strtr($rowUserMailConent->mail_body, $splVars); $toEmail = $this->config->item('site_admin_mail'); $fromEmail = $prj->email; $this->email_model->sendHtmlMail($toEmail, $fromEmail, $mailSubject, $mailContent); //Notification message $this->session->set_flashdata('flash_message', $this->common_model->flash_message('success', $this->lang->line('response added successfully'))); redirect('dispute/viewCase/' . $insertData['parent']); } } if ($this->input->post('reopen')) { $insertData = array(); $insertData['parent'] = $this->input->post('case_id'); $insertData['user_id'] = $this->loggedInUser->id; $insertData['created'] = get_est_time(); $insertData['updates'] = $this->lang->line('case reopened'); //Create Case $this->dispute_model->insertProjectCase($insertData); //prepare update data $updateData = array(); $updateData['status'] = 'open'; //update case $this->skills_model->updateProjectCase($this->input->post('case_id'), $updateData); //Notification message $this->session->set_flashdata('flash_message', $this->common_model->flash_message('success', $this->lang->line('Case reopened successfully'))); redirect('dispute/viewCase/' . $insertData['parent']); } $caseid = $this->uri->segment('3', 0); $condition2 = array('project_cases.id' => $caseid); $res = $this->dispute_model->getProjectCases($condition2); if ($res->num_rows() == 0) { //Notification message $this->session->set_flashdata('flash_message', $this->common_model->flash_message('error', $this->lang->line('Invalid input given'))); redirect('info'); } $this->outputData['projectCase'] = $res->row(); $condition3 = array('project_cases.parent' => $caseid); $this->outputData['caseResolution'] = $this->dispute_model->getProjectCases($condition3); //pr($this->outputData['projectCase']);exit; //$this->outputData['provider'] = getUserInfo($this->outputData['project']->programmer_id); $this->load->view('dispute/viewCase', $this->outputData); }