Example #1
0
 /**
  * Get models list
  *
  * @return PdfModel[]
  */
 public function getList()
 {
     try {
         $select = $this->zdb->select(PdfModel::TABLE, 'a');
         $select->order(PdfModel::PK);
         $models = array();
         $results = $this->zdb->execute($select);
         foreach ($results as $row) {
             $class = PdfModel::getTypeClass($row->model_type);
             $models[] = new $class($this->zdb, $this->preferences, $row);
         }
         return $models;
     } catch (\Exception $e) {
         Analog::log('Cannot list pdf models | ' . $e->getMessage(), Analog::WARNING);
     }
 }
Example #2
0
 /**
  * Main constructor
  *
  * @param Contribution $contrib Contribution
  * @param Db           $zdb     Database instance
  * @param Preferences  $prefs   Preferences instance
  */
 public function __construct(Contribution $contrib, $zdb, $prefs)
 {
     $this->_contrib = $contrib;
     $class = PdfModel::getTypeClass($this->_contrib->model);
     $this->_model = new $class($zdb, $prefs, $this->_contrib->model);
     $member = new Adherent($this->_contrib->member);
     $this->_model->setPatterns(array('adh_name' => '/{NAME_ADH}/', 'adh_address' => '/{ADDRESS_ADH}/', 'adh_zip' => '/{ZIP_ADH}/', 'adh_town' => '/{TOWN_ADH}/', 'adh_main_group' => '/{GROUP_ADH}/', 'adh_groups' => '/{GROUPS_ADH}/', 'adh_company' => '/{COMPANY_ADH}/', 'contrib_label' => '/{CONTRIBUTION_LABEL}/', 'contrib_amount' => '/{CONTRIBUTION_AMOUNT}/', 'contrib_date' => '/{CONTRIBUTION_DATE}/', 'contrib_year' => '/{CONTRIBUTION_YEAR}/', 'contrib_comment' => '/{CONTRIBUTION_COMMENT}/', 'contrib_bdate' => '/{CONTRIBUTION_BEGIN_DATE}/', 'contrib_edate' => '/{CONTRIBUTION_END_DATE}/', 'contrib_id' => '/{CONTRIBUTION_ID}/', 'contrib_payment' => '/{CONTRIBUTION_PAYMENT_TYPE}/'));
     $address = $member->address;
     if ($member->address_continuation != '') {
         $address .= '<br/>' . $member->address_continuation;
     }
     $member_groups = $member->groups;
     $main_group = _T("None");
     $group_list = _T("None");
     if (count($member_groups) > 0) {
         $main_group = $member_groups[0]->getName();
         $group_list = '<ul>';
         foreach ($member_groups as $group) {
             $group_list .= '<li>' . $group->getName() . '</li>';
         }
         $group_list .= '</ul>';
     }
     $this->_model->setReplacements(array('adh_name' => $member->sfullname, 'adh_address' => $address, 'adh_zip' => $member->zipcode, 'adh_town' => $member->town, 'adh_main_group' => $main_group, 'adh_groups' => $group_list, 'adh_company' => $member->company_name, 'contrib_label' => $this->_contrib->type->libelle, 'contrib_amount' => $this->_contrib->amount, 'contrib_date' => $this->_contrib->date, 'contrib_year' => $this->_contrib->raw_date->format('Y'), 'contrib_comment' => $this->_contrib->info, 'contrib_bdate' => $this->_contrib->begin_date, 'contrib_edate' => $this->_contrib->end_date, 'contrib_id' => $this->_contrib->id, 'contrib_payment' => $this->_contrib->spayment_type));
     $this->_filename = _T("contribution");
     $this->_filename .= '_' . $this->_contrib->id . '_';
     if ($this->_model->type === PdfModel::RECEIPT_MODEL) {
         $this->_filename .= _T("receipt");
     } else {
         $this->_filename .= _T("invoice");
     }
     $this->_filename .= '.pdf';
     $this->_pdf = new Pdf($prefs, $this->_model);
     $this->_pdf->Open();
     $this->_pdf->AddPage();
     $this->_pdf->PageHeader();
     $this->_pdf->PageBody();
 }
Example #3
0
    $id = (int) $_GET['id'];
} else {
    if (isset($_POST[PdfModel::PK])) {
        $id = (int) $_POST[PdfModel::PK];
    }
}
$model = null;
if (isset($_POST['store']) && $_POST['store'] == 'true') {
    $type = null;
    if (isset($_POST['model_type'])) {
        $type = (int) $_POST['model_type'];
    }
    if ($type === null) {
        $error_detected[] = _T("Missing PDF model type!");
    } else {
        $class = PdfModel::getTypeClass($type);
        if (isset($_POST[PdfModel::PK])) {
            $model = new $class($zdb, $preferences, (int) $_POST[PdfModel::PK]);
        } else {
            $model = new $class($zdb, $preferences);
        }
        try {
            $model->header = $_POST['model_header'];
            $model->footer = $_POST['model_footer'];
            $model->type = $type;
            if (isset($_POST['model_body'])) {
                $model->body = $_POST['model_body'];
            }
            if (isset($_POST['model_title'])) {
                $model->title = $_POST['model_title'];
            }
Example #4
0
 /**
  * Main constructor
  *
  * @param Db          $zdb         Database instance
  * @param Preferences $preferences Galette preferences
  * @param mixed       $args        Arguments
  */
 public function __construct($zdb, $preferences, $args = null)
 {
     parent::__construct($zdb, $preferences, self::INVOICE_MODEL, $args);
 }