Пример #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()'));
         }
     }
 }
Пример #2
0
 private function getEligibleBillingFieldsForCorpUpdate($user_data, $projectinfo_orig, $projectinfo)
 {
     $fields = array(array('acct_billing_address1', 'billing_address1', 'Billing Address Line 1'), array('acct_billing_address2', 'billing_address2', 'Billing Address Line 2'), array('acct_billing_city', 'billing_city', 'Billing City'), array('acct_billing_state', 'billing_state', 'Billing State'), array('acct_billing_zip', 'billing_zip', 'Billing Zip'), array('acct_billing_contact', 'billing_contact', 'A/P Contact'), array('acct_billing_phone', 'billing_phone', 'A/P Phone'));
     $corp_billing = Application_Model_Corporations::getBillingInfo($projectinfo->done_for_corporation);
     $fields_to_update = array();
     //Will be a list of eligible billing fields to update on the corp.
     foreach ($fields as $f) {
         $pf = $f[0];
         $cf = $f[1];
         if (isset($user_data[$pf]) && $projectinfo->{$pf} != $projectinfo_orig->{$pf} && $projectinfo->{$pf} != $corp_billing[$cf]) {
             $fields_to_update[] = $f;
         }
     }
     return $fields_to_update;
 }