Example #1
0
 public static function UpdateProjectInfo($project_id, $data)
 {
     $db = Zend_Db_Table::getDefaultAdapter();
     $current_user = ProNav_Auth::getUserID();
     $orig = $db->query("SELECT * FROM projects WHERE project_id = ?", array($project_id))->fetchObject();
     $project = array('title' => $data['title'], 'stage_id' => $data['stage_id'], 'point_of_contact' => $data['point_of_contact'], 'schedule_not_before' => $data['schedule_not_before'], 'schedule_required_by' => $data['schedule_required_by'], 'ref_no' => $data['ref_no'], 'requested_by' => $data['requested_by'] ? $data['requested_by'] : new Zend_Db_Expr("NULL"), 'modified_by' => $current_user, 'modified_date' => new Zend_Db_Expr("NOW()"));
     if (ProNav_Auth::hasPerm(ProNav_Auth::PERM_PROJECTS_OVERVIEW_EDIT) && isset($data['done_for_corporation'])) {
         $project['done_for_corporation'] = $data['done_for_corporation'];
         $project['done_for_workgroup'] = $data['done_for_workgroup'];
         $project['done_at_location'] = $data['done_at_location'];
         $project['done_by_workgroup'] = $data['done_by_workgroup'];
     }
     if ($orig->done_for_corporation != $data['done_for_corporation']) {
         //Done for corporaton changed. Update Billing Info.
         $billing_info = Application_Model_Corporations::getBillingInfo($data['done_for_corporation']);
         $project['acct_billing_address1'] = $billing_info['billing_address1'];
         $project['acct_billing_address2'] = $billing_info['billing_address2'];
         $project['acct_billing_city'] = $billing_info['billing_city'];
         $project['acct_billing_state'] = $billing_info['billing_state'];
         $project['acct_billing_zip'] = $billing_info['billing_zip'];
         $project['acct_billing_phone'] = $billing_info['billing_phone'];
         $project['acct_billing_contact'] = $billing_info['billing_contact'];
         $project['acct_billing_notes'] = $billing_info['billing_notes'];
     }
     $db->update('projects', $project, $db->quoteInto('project_id = ?', $project_id));
     //if this is the first time you are going into the open stage, then set the status percent to 'started' per the requirements.
     if ($data['stage_id'] == ProNav_Utils::STAGE_OPEN && !Application_Model_Projects::hasBeenInStage($project_id, ProNav_Utils::STAGE_OPEN)) {
         $overall = Application_Model_ProjectTask::get_overall_task($project_id);
         $overall->add_new_status(Application_Model_ProgressOption::STATUS_TASK_STARTED);
     }
     //stage audit
     if ($orig->stage_id != $data['stage_id']) {
         $stage = array('project_id' => $project_id, 'stage_id' => $data['stage_id'], 'comment' => $data['stage_comment'], 'entered_by' => $current_user, 'entered_date' => new Zend_Db_Expr("NOW()"));
         $db->insert('project_stage_audit', $stage);
         if ($orig->stage_id == ProNav_Utils::STAGE_POTENTIAL) {
             if ($data['stage_id'] != ProNav_Utils::STAGE_CANCELLED) {
                 ProNav_Utils::registerEvent($project_id, 1, $data['stage_id'], $current_user, new Zend_Db_Expr('Now()'));
             }
         } else {
             ProNav_Utils::registerEvent($project_id, 2, $data['stage_id'], $current_user, new Zend_Db_Expr('Now()'));
         }
     }
 }
 private function getLocationsForCorp($corporation_id)
 {
     $locations = Application_Model_Locations::getCorporationLocations($corporation_id);
     return ProNav_Utils::getSelectOptions($locations, 'location_id', 'name');
 }