getProperties ());exit; class EcmFkVat extends SugarBean { /* // var $id; // var $ecmfkvat_name; // var $description; // var $category_id; // var $subcategory_id; // var $status_id; // var $status; // var $created_by; // var $date_entered; // var $date_modified; // var $modified_user_id; // var $active_date; // var $exp_date; // var $ecmfkvat_revision_id; // var $filename; // var $img_name; // var $img_name_bare; // var $related_doc_id; // var $related_doc_name; // var $related_doc_rev_id; // var $related_doc_rev_number; // var $is_template; // var $template_type; //additional fields. // var $revision; // var $last_rev_create_date; // var $last_rev_created_by; // var $last_rev_created_name; // var $file_url; // var $file_url_noimage; // var $user_preferences; // var $encodeFields = array(); // This is used to retrieve related fields from form posts. // var $new_schema = true; // var $save_file; */ /** * Table name. * * @var stiring */ var $table_name = "ecmfkvats"; /** * Object name. * * @var stiring */ var $object_name = "EcmFkVat"; /** * Additional column fields. * * @var stiring */ var $additional_column_fields = array(); /** * Module directory. * * @var stiring */ var $module_dir = 'EcmFkVats'; /** * Relationship fields. * * @var stiring */ var $relationship_fields = array(); function EcmFkVat() { parent::SugarBean(); $this->setupCustomFields('EcmFkVats'); } function save($check_notify = false) { if (empty($this->id) || $this->new_with_id) { if (false) { //!empty($this->uploadfile)) $this->filename = $this->uploadfile; if (empty($this->id)) { $this->id = create_guid(); $this->new_with_id = true; } $Revision = new EcmFkVatRevision(); //save revision. $Revision->change_log = translate('DEF_CREATE_LOG', 'EcmFkVats'); $Revision->revision = $this->revision; $Revision->ecmfkvat_id = $this->id; $Revision->filename = $this->filename; $Revision->file_ext = $this->file_ext; $Revision->file_mime_type = $this->file_mime_type; $Revision->save(); //Move file saved during populatefrompost to match the revision id rather than ecmfkvat id rename(UploadFile :: get_url($this->filename, $this->id), UploadFile :: get_url($this->filename, $Revision->id)); //update ecmfkvat with latest revision id $this->process_save_dates = false; //make sure that conversion does not happen again. $this->ecmfkvat_revision_id = $Revision->id; } //set relationship field values if contract_id is passed (via subpanel create) if (!empty($_POST['contract_id'])) { $save_revision['ecmfkvat_revision_id'] = $this->document_revision_id; $this->load_relationship('contracts'); $this->contracts->add($_POST['contract_id'], $save_revision); } if ((isset($_POST['load_signed_id']) and !empty($_POST['load_signed_id']))) { $query = "update linked_ecmfkvats set deleted=1 where id='" . $_POST['load_signed_id'] . "'"; $this->db->query($query); } } return parent :: save($check_notify); } function DrawMainPDF($pdf, $type) { global $mod_strings; // echo $this->template->getTemplateFile('subheader_' . $type . '.php'); // exit; // dump(get_class($pdf));exit; // $pdf->SetAutoPageBreak(false); $pdf->SetAutoPageBreak(true, $this->bMargin + $this->tMarign + 25); switch (strtolower($type)) { default: include($this->template->getTemplateFile('subheader_d.php')); include($this->template->getTemplateFile('subfooter_d.php')); break; case 'ac': case 'r': case 'd': case 'pk1': case 'pk2': case 'pk3': case 's_symbol1': case 's_symbol2': case 's_identifier1': case 's_identifier2': include($this->template->getTemplateFile('subheader_' . $type . '.php')); include($this->template->getTemplateFile('subfooter_' . $type . '.php')); break; } return; } /** * Pdf getter. * * Retrieve pdf stream. */ function getPDF($id = null, $method = 'I', $name = null, $type = null) { global $sugar_config; // if ($id != null) { // $this->retrieve($id); // if ($this->id == '') // return; // } global $mod_strings; require_once('modules/EcmTexts/EcmText.php'); //echo '
' . var_export($this->ecmlanguage, true) . '';exit; // if (isset($this->ecmlanguage) && $this->ecmlanguage != '') { // $data = EcmText::LoadText(null, null, "EcmServices", $this->ecmlanguage); // if (isset($data[0]) && isset($data[0]['data']) && isset($data[0]['data']['labels'])) { // $data = $data[0]['data']['labels']; // foreach ($data as $key => $value) { // $mod_strings[$value['label']] = $value['translation']; // } // } // } $this->format_all_fields(); // dump(__LINE__); // exit; $this->setTemplate(); $type = $type ? : @$_REQUEST['type']; // if (isset($this->template->id) && $this->template->id != '') { // dump($this->template_id); // exit; // dump($this->template_id); // exit; switch (strtolower($type)) { default: case 'ac': case 'd': $this->template->setPDF($this->template_id, array('L')); break; case 'r': case 'pk1': case 'pk2': case 'pk3': $this->template->setPDF($this->template_id, array('P')); break; } // dump(__LINE__); // exit; // dump($this->template); // exit; // $this->template->pdf->SetAutoPageBreak(true, 40); $this->DrawMainPDF($this->template->pdf, $type); $this->template->outputPDF(1, $method); // } } function setTemplate() { // if (!isset($this->template_id) || $this->template_id == '') // return null; // if (isset($this->template)) // return $this->template; require_once('modules/EcmDocumentTemplates/EcmDocumentTemplate.php'); $this->template = new EcmDocumentTemplate(); $this->template_id = "ef0c4dea-ddf3-de51-9d08-512257d4b675"; //$this->template->retrieve($this->template_id); $this->template->retrieve($this->template_id, true, false); if (isset($this->template->id) && $this->template->id != '') { $this->template->format_all_fields(); } else $this->template = null; // dump($this->template); // exit; return $this->template; } function get_summary_text() { return "$this->ecmfkvat_name"; } function is_authenticated() { return $this->authenticated; } function fill_in_additional_list_fields() { $this->fill_in_additional_detail_fields(); } function fill_in_additional_detail_fields() { // $vatYear = DateTime::createFromFormat('Y-m-d', $this->date_document); // $this->vat_year = $bookYear ? $bookYear->format('Y') : false; goto jump; global $theme; global $current_language; global $timedate; global $locale; parent::fill_in_additional_detail_fields(); $mod_strings = return_module_language($current_language, 'EcmFkVats'); $query = "SELECT filename,revision,file_ext FROM ecmfkvat_revisions WHERE id='$this->document_revision_id'"; $result = $this->db->query($query); $row = $this->db->fetchByAssoc($result); //popuplate filename if (isset($row['filename'])) $this->filename = $row['filename']; //$this->latest_revision = $row['revision']; if (isset($row['revision'])) $this->revision = $row['revision']; //populate the file url. //image is selected based on the extension name
' . var_export($this->field_defs, true) . ''; // echo '
' . var_export($ecmfkvat_fields, true) . ''; // exit; return $ecmfkvat_fields; } function mark_drelationships_deleted($id) { //do nothing, this call is here to avoid default delete processing since //delete.php handles deletion of ecmfkvat revisions. } function bean_implements($interface) { switch ($interface) { case 'ACL' : return true; } return false; } //static function. function get_ecmfkvat_name($doc_id) { if (empty($doc_id)) return null; $db = DBManagerFactory::getInstance(); $query = "select ecmfkvat_name from documents where id='$doc_id'"; $result = $db->query($query); if (!empty($result)) { $row = $db->fetchByAssoc($result); if (!empty($row)) { return $row['ecmfkvat_name']; } } return null; } }