Esempio n. 1
0
$donation_static=new Don($db);


/*
 * Actions
 */




/*
 * View
 */

$donstatic=new Don($db);

$help_url='EN:Module_Donations|FR:Module_Dons|ES:Módulo_Subvenciones';
llxHeader('',$langs->trans("Donations"),$help_url);

$sql = "SELECT count(d.rowid) as nb, sum(d.amount) as somme , d.fk_statut";
$sql.= " FROM ".MAIN_DB_PREFIX."don as d";
$sql.= " GROUP BY d.fk_statut";
$sql.= " ORDER BY d.fk_statut";

$result = $db->query($sql);

if ($result)
{
    $num = $db->num_rows($result);
    $i = 0;
Esempio n. 2
0
$langs->load("admin");
$langs->load("donations");
$langs->load("accountancy");
$langs->load('other');
if (!$user->admin) {
    accessforbidden();
}
$typeconst = array('yesno', 'texte', 'chaine');
$action = GETPOST('action', 'alpha');
$type = 'donation';
/*
 * Action
 */
if ($action == 'specimen') {
    $modele = GETPOST('module', 'alpha');
    $don = new Don($db);
    $don->initAsSpecimen();
    // Search template files
    $dir = DOL_DOCUMENT_ROOT . "/core/modules/dons/";
    $file = $modele . ".modules.php";
    if (file_exists($dir . $file)) {
        $classname = $modele;
        require_once $dir . $file;
        $obj = new $classname($db);
        if ($obj->write_file($don, $langs) > 0) {
            header("Location: " . DOL_URL_ROOT . "/document.php?modulepart=donation&file=SPECIMEN.html");
            return;
        } else {
            setEventMessage($obj->error, 'errors');
            dol_syslog($obj->error, LOG_ERR);
        }
 /**
  *  Write the object to document file to disk
  *
  *	@param	Don			$don	        Donation object
  *  @param  Translate	$outputlangs    Lang object for output language
  *	@return	int             			>0 if OK, <0 if KO
  */
 function write_file($don, $outputlangs)
 {
     global $user, $conf, $langs, $mysoc;
     $now = dol_now();
     $id = !is_object($don) ? $don : '';
     if (!is_object($outputlangs)) {
         $outputlangs = $langs;
     }
     $outputlangs->load("main");
     $outputlangs->load("dict");
     $outputlangs->load("companies");
     $outputlangs->load("bills");
     $outputlangs->load("products");
     $outputlangs->load("donations");
     if (!empty($conf->don->dir_output)) {
         // Definition de l'objet $don (pour compatibilite ascendante)
         if (!is_object($don)) {
             $don = new Don($this->db);
             $ret = $don->fetch($id);
             $id = $don->id;
         }
         // Definition de $dir et $file
         if (!empty($don->specimen)) {
             $dir = $conf->don->dir_output;
             $file = $dir . "/SPECIMEN.html";
         } else {
             $donref = dol_sanitizeFileName($don->ref);
             $dir = $conf->don->dir_output . "/" . get_exdir($donref, 2);
             $file = $dir . "/" . $donref . ".html";
         }
         if (!file_exists($dir)) {
             if (dol_mkdir($dir) < 0) {
                 $this->error = $langs->trans("ErrorCanNotCreateDir", $dir);
                 return -1;
             }
         }
         if (file_exists($dir)) {
             $formclass = new Form($this->db);
             //This is not the proper way to do it but $formclass->form_modes_reglement
             //prints the translation instead of returning it
             if ($don->modepaiementid) {
                 $formclass->load_cache_types_paiements();
                 $paymentmode = $formclass->cache_types_paiements[$don->modepaiementid]['label'];
             } else {
                 $paymentmode = '';
             }
             // Defini contenu
             $donmodel = DOL_DOCUMENT_ROOT . "/core/modules/dons/html_cerfafr.html";
             $form = implode('', file($donmodel));
             $form = str_replace('__REF__', $don->id, $form);
             $form = str_replace('__DATE__', dol_print_date($don->date, 'day', false, $outputlangs), $form);
             //$form = str_replace('__IP__',$user->ip,$form); // TODO $user->ip not exist
             $form = str_replace('__AMOUNT__', $don->amount, $form);
             $form = str_replace('__CURRENCY__', $outputlangs->transnoentitiesnoconv("Currency" . $conf->currency), $form);
             $form = str_replace('__CURRENCYCODE__', $conf->currency, $form);
             $form = str_replace('__MAIN_INFO_SOCIETE_NOM__', $mysoc->name, $form);
             $form = str_replace('__MAIN_INFO_SOCIETE_ADDRESS__', $mysoc->address, $form);
             $form = str_replace('__MAIN_INFO_SOCIETE_ZIP__', $mysoc->zip, $form);
             $form = str_replace('__MAIN_INFO_SOCIETE_TOWN__', $mysoc->town, $form);
             $form = str_replace('__DONATOR_FIRSTNAME__', $don->firstname, $form);
             $form = str_replace('__DONATOR_LASTNAME__', $don->lastname, $form);
             $form = str_replace('__DONATOR_ADDRESS__', $don->address, $form);
             $form = str_replace('__DONATOR_ZIP__', $don->zip, $form);
             $form = str_replace('__DONATOR_TOWN__', $don->town, $form);
             $form = str_replace('__PAYMENTMODE_LIB__ ', $paymentmode, $form);
             $form = str_replace('__NOW__', dol_print_date($now, '', false, $outputlangs), $form);
             $form = str_replace('__DonationRef__', $outputlangs->trans("DonationRef"), $form);
             $form = str_replace('__DonationReceipt__', $outputlangs->trans("DonationReceipt"), $form);
             $form = str_replace('__DonationRecipient__', $outputlangs->trans("DonationRecipient"), $form);
             $form = str_replace('__DatePayment__', $outputlangs->trans("DatePayment"), $form);
             $form = str_replace('__PaymentMode__', $outputlangs->trans("PaymentMode"), $form);
             $form = str_replace('__Name__', $outputlangs->trans("Name"), $form);
             $form = str_replace('__Address__', $outputlangs->trans("Address"), $form);
             $form = str_replace('__Zip__', $outputlangs->trans("Zip"), $form);
             $form = str_replace('__Town__', $outputlangs->trans("Town"), $form);
             $form = str_replace('__Donor__', $outputlangs->trans("Donor"), $form);
             $form = str_replace('__Date__', $outputlangs->trans("Date"), $form);
             $form = str_replace('__Signature__', $outputlangs->trans("Signature"), $form);
             $form = str_replace('__ThankYou__', $outputlangs->trans("ThankYou"), $form);
             $form = str_replace('__IConfirmDonationReception__', $outputlangs->trans("IConfirmDonationReception"), $form);
             $frencharticle = '';
             if (preg_match('/fr/i', $outputlangs->defaultlang)) {
                 $frencharticle = '<font size="+1"><b>(Article 200-5 du Code Général des Impôts)</b></font><br>+ article 238 bis';
             }
             $form = str_replace('__FrenchArticle__', $frencharticle, $form);
             // Sauve fichier sur disque
             dol_syslog("html_cerfafr::write_file {$file}");
             $handle = fopen($file, "w");
             fwrite($handle, $form);
             fclose($handle);
             if (!empty($conf->global->MAIN_UMASK)) {
                 @chmod($file, octdec($conf->global->MAIN_UMASK));
             }
             return 1;
         } else {
             $this->error = $langs->trans("ErrorCanNotCreateDir", $dir);
             return 0;
         }
     } else {
         $this->error = $langs->trans("ErrorConstantNotDefined", "DON_OUTPUTDIR");
         return 0;
     }
     $this->error = $langs->trans("ErrorUnknown");
     return 0;
     // Erreur par defaut
 }
Esempio n. 4
0
		Header("Location: type.php?rowid=".$_POST["rowid"]);
		exit;
	}
}

if ($user->rights->adherent->configurer && $_GET["action"] == 'delete')
{
	$adht = new AdherentType($db);
	$adht->delete($rowid);
	Header("Location: ".$_SERVER["PHP_SELF"]);
	exit;
}

if ($user->rights->adherent->configurer && $_GET["action"] == 'commentaire')
{
	$don = new Don($db);
	$don->fetch($rowid);
	$don->update_note($_POST["commentaire"]);
}


/*
 * View
 */

llxHeader('',$langs->trans("MembersTypeSetup"),'EN:Module_Foundations|FR:Module_Adh&eacute;rents|ES:M&oacute;dulo_Miembros');

$form=new Form($db);


// Liste of members type
Esempio n. 5
0
 /**
  *  Write the object to document file to disk
  *
  *	@param	Don			$don	        Donation object
  *  @param  Translate	$outputlangs    Lang object for output language
  *	@return	int             			>0 if OK, <0 if KO
  */
 function write_file($don, $outputlangs)
 {
     global $user, $conf, $langs, $mysoc;
     $now = dol_now();
     $id = !is_object($don) ? $don : '';
     if (!is_object($outputlangs)) {
         $outputlangs = $langs;
     }
     $outputlangs->load("main");
     $outputlangs->load("dict");
     $outputlangs->load("companies");
     $outputlangs->load("bills");
     $outputlangs->load("products");
     $outputlangs->load("donations");
     if (!empty($conf->don->dir_output)) {
         // Definition of the object don (for upward compatibility)
         if (!is_object($don)) {
             $don = new Don($this->db);
             $ret = $don->fetch($id);
             $id = $don->id;
         }
         // Definition of $dir and $file
         if (!empty($don->specimen)) {
             $dir = $conf->don->dir_output;
             $file = $dir . "/SPECIMEN.html";
         } else {
             $donref = dol_sanitizeFileName($don->ref);
             $dir = $conf->don->dir_output . "/" . get_exdir($donref, 2);
             $file = $dir . "/" . $donref . ".html";
         }
         if (!file_exists($dir)) {
             if (dol_mkdir($dir) < 0) {
                 $this->error = $langs->trans("ErrorCanNotCreateDir", $dir);
                 return -1;
             }
         }
         if (file_exists($dir)) {
             $formclass = new Form($this->db);
             // This is not the proper way to do it but $formclass->form_modes_reglement
             // prints the translation instead of returning it
             if ($don->modepaiementid) {
                 $formclass->load_cache_types_paiements();
                 $paymentmode = $formclass->cache_types_paiements[$don->modepaiementid]['label'];
             } else {
                 $paymentmode = '';
             }
             // Define contents
             $donmodel = DOL_DOCUMENT_ROOT . "/core/modules/dons/html_cerfafr.html";
             $form = implode('', file($donmodel));
             $form = str_replace('__REF__', $don->id, $form);
             $form = str_replace('__DATE__', dol_print_date($don->date, 'day', false, $outputlangs), $form);
             //$form = str_replace('__IP__',$user->ip,$form); // TODO $user->ip not exist
             $form = str_replace('__AMOUNT__', $don->amount, $form);
             $form = str_replace('__CURRENCY__', $outputlangs->transnoentitiesnoconv("Currency" . $conf->currency), $form);
             $form = str_replace('__CURRENCYCODE__', $conf->currency, $form);
             $form = str_replace('__MAIN_INFO_SOCIETE_NOM__', $mysoc->name, $form);
             $form = str_replace('__MAIN_INFO_SOCIETE_ADDRESS__', $mysoc->address, $form);
             $form = str_replace('__MAIN_INFO_SOCIETE_ZIP__', $mysoc->zip, $form);
             $form = str_replace('__MAIN_INFO_SOCIETE_TOWN__', $mysoc->town, $form);
             $form = str_replace('__DONATOR_FIRSTNAME__', $don->firstname, $form);
             $form = str_replace('__DONATOR_LASTNAME__', $don->lastname, $form);
             $form = str_replace('__DONATOR_ADDRESS__', $don->address, $form);
             $form = str_replace('__DONATOR_ZIP__', $don->zip, $form);
             $form = str_replace('__DONATOR_TOWN__', $don->town, $form);
             $form = str_replace('__PAYMENTMODE_LIB__ ', $paymentmode, $form);
             $form = str_replace('__NOW__', dol_print_date($now, 'day', false, $outputlangs), $form);
             $form = str_replace('__DonationRef__', $outputlangs->trans("DonationRef"), $form);
             $form = str_replace('__DonationTitle__', $outputlangs->trans("DonationTitle"), $form);
             $form = str_replace('__DonationReceipt__', $outputlangs->trans("DonationReceipt"), $form);
             $form = str_replace('__DonationRecipient__', $outputlangs->trans("DonationRecipient"), $form);
             $form = str_replace('__DonationDatePayment__', $outputlangs->trans("DonationDatePayment"), $form);
             $form = str_replace('__PaymentMode__', $outputlangs->trans("PaymentMode"), $form);
             $form = str_replace('__Name__', $outputlangs->trans("Name"), $form);
             $form = str_replace('__Address__', $outputlangs->trans("Address"), $form);
             $form = str_replace('__Zip__', $outputlangs->trans("Zip"), $form);
             $form = str_replace('__Town__', $outputlangs->trans("Town"), $form);
             $form = str_replace('__Object__', $outputlangs->trans("Object"), $form);
             $form = str_replace('__Donor__', $outputlangs->trans("Donor"), $form);
             $form = str_replace('__Date__', $outputlangs->trans("Date"), $form);
             $form = str_replace('__Signature__', $outputlangs->trans("Signature"), $form);
             $form = str_replace('__Message__', $outputlangs->trans("Message"), $form);
             $form = str_replace('__IConfirmDonationReception__', $outputlangs->trans("IConfirmDonationReception"), $form);
             $form = str_replace('__DonationMessage__', $conf->global->DONATION_MESSAGE, $form);
             $frencharticle = '';
             if (preg_match('/fr/i', $outputlangs->defaultlang)) {
                 $frencharticle = '<font size="+1">Article 200, 238 bis et 885-0 V bis A du code général des impôts (CGI)</font>';
             }
             $form = str_replace('__FrenchArticle__', $frencharticle, $form);
             $frencheligibility = '';
             if (preg_match('/fr/i', $outputlangs->defaultlang)) {
                 $frencheligibility = 'Le bénéficiaire certifie sur l\'honneur que les dons et versements qu\'il reçoit ouvrent droit à la réduction d\'impôt prévue à l\'article :';
             }
             $form = str_replace('__FrenchEligibility__', $frencheligibility, $form);
             $art200 = '';
             if (preg_match('/fr/i', $outputlangs->defaultlang)) {
                 if ($conf->global->DONATION_ART200 >= 1) {
                     $art200 = '<input type="checkbox" checked="checked">200 du CGI';
                 } else {
                     $art200 = '<input type="checkbox">200 du CGI';
                 }
             }
             $form = str_replace('__ARTICLE200__', $art200, $form);
             $art238 = '';
             if (preg_match('/fr/i', $outputlangs->defaultlang)) {
                 if ($conf->global->DONATION_ART238 >= 1) {
                     $art238 = '<input type="checkbox" checked="checked">238 bis du CGI';
                 } else {
                     $art238 = '<input type="checkbox">238 bis du CGI';
                 }
             }
             $form = str_replace('__ARTICLE238__', $art238, $form);
             $art885 = '';
             if (preg_match('/fr/i', $outputlangs->defaultlang)) {
                 if ($conf->global->DONATION_ART885 >= 1) {
                     $art885 = '<input type="checkbox" checked="checked">885-0 V bis du CGI';
                 } else {
                     $art885 = '<input type="checkbox">885-0 V bis du CGI';
                 }
             }
             $form = str_replace('__ARTICLE885__', $art885, $form);
             // Save file on disk
             dol_syslog("html_cerfafr::write_file {$file}");
             $handle = fopen($file, "w");
             fwrite($handle, $form);
             fclose($handle);
             if (!empty($conf->global->MAIN_UMASK)) {
                 @chmod($file, octdec($conf->global->MAIN_UMASK));
             }
             return 1;
         } else {
             $this->error = $langs->trans("ErrorCanNotCreateDir", $dir);
             return 0;
         }
     } else {
         $this->error = $langs->trans("ErrorConstantNotDefined", "DON_OUTPUTDIR");
         return 0;
     }
     $this->error = $langs->trans("ErrorUnknown");
     return 0;
     // Error by default
 }
Esempio n. 6
0
/**
 \brief       Supprime l'image de pr�visualitation, pour le cas de r�g�n�ration de facture
 \param	    db  		Objet base de donn�e
 \param	    donid		Id du don
 */
function don_delete_preview($db, $donid)
{
    global $langs,$conf;

    $don = new Don($db);
    $don->id=$donid;
    $don->fetch($donid);
}
            $colspan = 5;
            if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) {
                $colspan++;
            }
            print '<tr ' . $bc[$var] . '><td colspan="' . $colspan . '">' . $langs->trans("NoInvoice") . '</td></tr>';
        }
        print '</table><br>';
    } else {
        dol_print_error($db);
    }
}
// Last donations
if (!empty($conf->don->enabled) && $user->rights->societe->lire) {
    include_once DOL_DOCUMENT_ROOT . '/compta/dons/class/don.class.php';
    $langs->load("boxes");
    $donationstatic = new Don($db);
    $sql = "SELECT d.rowid, d.lastname, d.firstname, d.societe, d.datedon as date, d.tms as dm, d.amount, d.fk_statut";
    $sql .= " FROM " . MAIN_DB_PREFIX . "don as d";
    $sql .= " WHERE d.entity = " . $conf->entity;
    $sql .= $db->order("d.tms", "DESC");
    $sql .= $db->plimit($max, 0);
    $result = $db->query($sql);
    if ($result) {
        $var = false;
        $num = $db->num_rows($result);
        $i = 0;
        print '<table class="noborder" width="100%">';
        print '<tr class="liste_titre"><td>' . $langs->trans("BoxTitleLastModifiedDonations", $max) . '</td>';
        print '<td class="liste_titre" align="right">' . $langs->trans("AmountTTC") . '</td>';
        print '<td class="liste_titre" align="right">' . $langs->trans("DateModificationShort") . '</td>';
        print '<td class="liste_titre" width="16">&nbsp;</td>';
Esempio n. 8
0
        if ($ret < 0) {
            $error++;
        }
        $adht->update($user);
        header("Location: " . $_SERVER["PHP_SELF"] . "?rowid=" . $_POST["rowid"]);
        exit;
    }
}
if ($action == 'delete' && $user->rights->adherent->configurer) {
    $adht = new AdherentType($db);
    $adht->delete($rowid);
    header("Location: " . $_SERVER["PHP_SELF"]);
    exit;
}
if ($action == 'commentaire' && $user->rights->adherent->configurer) {
    $don = new Don($db);
    $don->fetch($rowid);
    $don->update_note(dol_html_entity_decode(GETPOST('commentaire'), ENT_QUOTES));
}
/*
 * View
 */
llxHeader('', $langs->trans("MembersTypeSetup"), 'EN:Module_Foundations|FR:Module_Adh&eacute;rents|ES:M&oacute;dulo_Miembros');
$form = new Form($db);
// Liste of members type
if (!$rowid && $action != 'create' && $action != 'edit') {
    print_fiche_titre($langs->trans("MembersTypes"));
    $sql = "SELECT d.rowid, d.libelle, d.cotisation, d.vote";
    $sql .= " FROM " . MAIN_DB_PREFIX . "adherent_type as d";
    $sql .= " WHERE d.entity IN (" . getEntity() . ")";
    $result = $db->query($sql);
Esempio n. 9
0
$sortfield = GETPOST('sortfield', 'alpha');
$sortorder = GETPOST('sortorder', 'alpha');
$page = GETPOST('page', 'int');
if ($page == -1) {
    $page = 0;
}
$offset = $conf->liste_limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;
if (!$sortorder) {
    $sortorder = "ASC";
}
if (!$sortfield) {
    $sortfield = "name";
}
$object = new Don($db);
$object->fetch($id, $ref);
$upload_dir = $conf->don->dir_output . '/' . get_exdir($filename, 2, 0, 1, $object, 'donation') . '/' . dol_sanitizeFileName($object->ref);
$modulepart = 'don';
/*
 * Actions
 */
include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_pre_headers.tpl.php';
/*
 * View
 */
$form = new Form($db);
llxHeader("", "", $langs->trans("Donations"));
if ($object->id) {
    $object->fetch_thirdparty();
    $head = donation_prepare_head($object);
Esempio n. 10
0
            if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
                $fac->generateDocument($fac->modelpdf, $outputlangs);
            }
        }
        header('Location: card.php?id=' . $payment->id);
        exit;
    } else {
        setEventMessages($payment->error, $payment->errors, 'errors');
        $db->rollback();
    }
}
/*
 * View
 */
llxHeader();
$don = new Don($db);
$form = new Form($db);
$h = 0;
$head[$h][0] = DOL_URL_ROOT . '/don/payment/card.php?id=' . $id;
$head[$h][1] = $langs->trans("Card");
$hselected = $h;
$h++;
dol_fiche_head($head, $hselected, $langs->trans("DonationPayment"), 0, 'payment');
/*
 * Confirm deleting of the payment
 */
if ($action == 'delete') {
    print $form->formconfirm('card.php?id=' . $payment->id, $langs->trans("DeletePayment"), $langs->trans("ConfirmDeletePayment"), 'confirm_delete', '', 0, 2);
}
/*
 * Confirm validation of the payment
Esempio n. 11
0
/**
 *	Cree un don sur disque en fonction du modele de DON_ADDON_PDF
 *
 *	@param	DoliDB		$db  			Databse handler
 *	@param	int			$id				Id donation
 *	@param	string		$message		Message
 *	@param	string		$modele			Force le modele a utiliser ('' par defaut)
 *	@param	Translate	$outputlangs	Object langs
 *	@return int         				0 if KO, 1 if OK
 */
function don_create($db, $id, $message, $modele, $outputlangs)
{
    global $conf, $langs;
    $langs->load("bills");
    $dir = DOL_DOCUMENT_ROOT . "/core/modules/dons/";
    // Set template to use
    if (!dol_strlen($modele)) {
        if ($conf->global->DON_ADDON_MODEL) {
            $modele = $conf->global->DON_ADDON_MODEL;
        } else {
            print $langs->trans("Error") . " " . $langs->trans("Error_DON_ADDON_MODEL_NotDefined");
            return 0;
        }
    }
    // Charge le modele
    $file = $modele . ".modules.php";
    if (file_exists($dir . $file)) {
        $object = new Don($db);
        $object->fetch($id);
        require_once $dir . $file;
        $classname = $modele;
        $module = new $classname($db);
        // We save charset_output to restore it because write_file can change it if needed for
        // output format that does not support UTF8.
        $sav_charset_output = $outputlangs->charset_output;
        if ($module->write_file($object, $outputlangs) > 0) {
            $outputlangs->charset_output = $sav_charset_output;
            // we delete preview files
            require_once DOL_DOCUMENT_ROOT . "/core/lib/files.lib.php";
            dol_delete_preview($object);
            return 1;
        } else {
            $outputlangs->charset_output = $sav_charset_output;
            dol_syslog("Erreur dans don_create");
            dol_print_error($db, $module->error);
            return 0;
        }
    } else {
        print $langs->trans("Error") . " " . $langs->trans("ErrorFileDoesNotExists", $dir . $file);
        return 0;
    }
}
Esempio n. 12
0
        $upload_dir = $conf->don->dir_output;
        $file = $upload_dir . '/' . GETPOST('file');
        $ret = dol_delete_file($file, 0, 0, 0, $object);
        if ($ret) {
            setEventMessages($langs->trans("FileWasRemoved", GETPOST('urlfile')), null, 'mesgs');
        } else {
            setEventMessages($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), null, 'errors');
        }
        $action = '';
    }
}
/*
 * Build doc
 */
if ($action == 'builddoc') {
    $object = new Don($db);
    $result = $object->fetch($id);
    // Save last template used to generate document
    if (GETPOST('model')) {
        $object->setDocModel($user, GETPOST('model', 'alpha'));
    }
    // Define output language
    $outputlangs = $langs;
    $newlang = '';
    if ($conf->global->MAIN_MULTILANGS && empty($newlang) && !empty($_REQUEST['lang_id'])) {
        $newlang = $_REQUEST['lang_id'];
    }
    if ($conf->global->MAIN_MULTILANGS && empty($newlang)) {
        $newlang = $object->client->default_lang;
    }
    if (!empty($newlang)) {
Esempio n. 13
0
                exit;
            } else {
                $db->rollback();
            }
        }
    }
    $_GET["action"] = 'create';
}
/*
 * View
 */
llxHeader();
$form = new Form($db);
// Form to create donation payment
if (GETPOST("action") == 'create') {
    $don = new Don($db);
    $don->fetch($chid);
    $total = $don->amount;
    print_fiche_titre($langs->trans("DoPayment"));
    if ($mesg) {
        print "<div class=\"error\">{$mesg}</div>";
    }
    print '<form name="add_payment" action="' . $_SERVER['PHP_SELF'] . '" method="post">';
    print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
    print '<input type="hidden" name="rowid" value="' . $chid . '">';
    print '<input type="hidden" name="chid" value="' . $chid . '">';
    print '<input type="hidden" name="action" value="add_payment">';
    dol_fiche_head();
    print '<table cellspacing="0" class="border" width="100%" cellpadding="2">';
    print '<tr class="liste_titre"><td colspan="3">' . $langs->trans("Donation") . '</td>';
    print '<tr><td>' . $langs->trans("Ref") . '</td><td colspan="2"><a href="' . DOL_URL_ROOT . '/don/card.php?rowid=' . $chid . '">' . $chid . '</a></td></tr>';
Esempio n. 14
0
        $mesg = $don->error;
    }
}
if ($action == 'set_encaisse') {
    if ($don->set_encaisse($id) >= 0) {
        Header("Location: " . $_SERVER['PHP_SELF'] . "?id=" . $id);
        exit;
    } else {
        $mesg = $don->error;
    }
}
/*
 * Build doc
 */
if ($action == 'builddoc') {
    $donation = new Don($db);
    $donation->fetch($id);
    if ($_REQUEST['model']) {
        $donation->setDocModel($user, $_REQUEST['model']);
    }
    // Define output language
    $outputlangs = $langs;
    $newlang = '';
    if ($conf->global->MAIN_MULTILANGS && empty($newlang) && !empty($_REQUEST['lang_id'])) {
        $newlang = $_REQUEST['lang_id'];
    }
    if ($conf->global->MAIN_MULTILANGS && empty($newlang)) {
        $newlang = $donation->client->default_lang;
    }
    if (!empty($newlang)) {
        $outputlangs = new Translate("", $conf);
Esempio n. 15
0
        $mesg = $don->error;
    }
}
if ($action == 'set_encaisse') {
    if ($don->set_encaisse($id) >= 0) {
        header("Location: " . $_SERVER['PHP_SELF'] . "?id=" . $id);
        exit;
    } else {
        $mesg = $don->error;
    }
}
/*
 * Build doc
 */
if ($action == 'builddoc') {
    $object = new Don($db);
    $object->fetch($id);
    // Save last template used to generate document
    if (GETPOST('model')) {
        $object->setDocModel($user, GETPOST('model', 'alpha'));
    }
    // Define output language
    $outputlangs = $langs;
    $newlang = '';
    if ($conf->global->MAIN_MULTILANGS && empty($newlang) && !empty($_REQUEST['lang_id'])) {
        $newlang = $_REQUEST['lang_id'];
    }
    if ($conf->global->MAIN_MULTILANGS && empty($newlang)) {
        $newlang = $object->client->default_lang;
    }
    if (!empty($newlang)) {
Esempio n. 16
0
    /**
     *  Write the object to document file to disk
     *	@param	    don	            Donation object
     *  @param      outputlangs     Lang object for output language
     *	@return	    int             >0 if OK, <0 if KO
     */
    function write_file($don,$outputlangs)
    {
		global $user,$conf,$langs,$mysoc;

		$now=gmmktime();

		if (! is_object($outputlangs)) $outputlangs=$langs;

		$outputlangs->load("main");
		$outputlangs->load("dict");
		$outputlangs->load("companies");
		$outputlangs->load("bills");
		$outputlangs->load("products");

        if ($conf->don->dir_output)
        {
			// Definition de l'objet $don (pour compatibilite ascendante)
        	if (! is_object($don))
        	{
	            $id = $don;
	            $don = new Don($this->db);
	            $ret=$don->fetch($id);
			}

			// Definition de $dir et $file
			if ($don->specimen)
			{
				$dir = $conf->don->dir_output;
				$file = $dir . "/SPECIMEN.html";
			}
			else
			{
				$donref = dol_sanitizeFileName($don->ref);
				$dir = $conf->don->dir_output . "/" . get_exdir($donref,2);
				$file = $dir . "/" . $donref . ".html";
			}

	        if (! file_exists($dir))
	        {
	            if (create_exdir($dir) < 0)
	            {
	                $this->error=$langs->trans("ErrorCanNotCreateDir",$dir);
	                return -1;
	            }
	        }

            if (file_exists($dir))
            {
		        // Defini contenu
		        $donmodel=DOL_DOCUMENT_ROOT ."/includes/modules/dons/html_cerfafr.html";
		        $html = implode('', file($donmodel));
		        $html = str_replace('__REF__',$id,$html);
		        $html = str_replace('__DATE__',dol_print_date($don->date,'day',false,$outputlangs),$html);
		        $html = str_replace('__IP__',$user->ip,$html);
		        $html = str_replace('__AMOUNT__',$don->amount,$html);
		        $html = str_replace('__CURRENCY__',$outputlangs->transnoentitiesnoconv("Currency".$conf->monnaie),$html);
		        $html = str_replace('__CURRENCYCODE__',$conf->monnaie,$html);
		        $html = str_replace('__MAIN_INFO_SOCIETE_NOM__',$mysoc->name,$html);
		        $html = str_replace('__MAIN_INFO_SOCIETE_ADRESSE__',$mysoc->address,$html);
		        $html = str_replace('__MAIN_INFO_SOCIETE_CP__',$mysoc->zip,$html);
		        $html = str_replace('__MAIN_INFO_SOCIETE_VILLE__',$mysoc->town,$html);
		        $html = str_replace('__DONATOR_NAME__',$don->nom,$html);
		        $html = str_replace('__DONATOR_ADDRESS__',$don->adresse,$html);
		        $html = str_replace('__DONATOR_ZIP__',$don->cp,$html);
		        $html = str_replace('__DONATOR_TOWN__',$don->ville,$html);
		        $html = str_replace('__PAYMENTMODE_LIB__ ',$don->modepaiement,$html);
		        $html = str_replace('__NOW__',dol_print_date($now,'',false,$outputlangs),$html);

		        // Sauve fichier sur disque
		        dol_syslog("html_cerfafr::write_file $file");
		        $handle=fopen($file,"w");
		        fwrite($handle,$html);
		        fclose($handle);
				if (! empty($conf->global->MAIN_UMASK))
					@chmod($file, octdec($conf->global->MAIN_UMASK));

		        return 1;
            }
            else
            {
                $this->error=$langs->trans("ErrorCanNotCreateDir",$dir);
                return 0;
            }
	    }
        else
        {
            $this->error=$langs->trans("ErrorConstantNotDefined","DON_OUTPUTDIR");
            return 0;
		}
        $this->error=$langs->trans("ErrorUnknown");
        return 0;   // Erreur par defaut

    }
Esempio n. 17
0
    accessforbidden();
}
if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) {
    $search_ref = "";
    $search_company = "";
    $search_name = "";
    $search_amount = "";
}
/*
 * View
 */
if (!empty($conf->projet->enabled)) {
    $projectstatic = new Project($db);
}
llxHeader('', $langs->trans("Donations"), 'EN:Module_Donations|FR:Module_Dons|ES:M&oacute;dulo_Donaciones');
$donationstatic = new Don($db);
// Genere requete de liste des dons
$sql = "SELECT d.rowid, d.datedon, d.firstname, d.lastname, d.societe,";
$sql .= " d.amount, d.fk_statut as statut, ";
$sql .= " p.rowid as pid, p.ref, p.title, p.public";
$sql .= " FROM " . MAIN_DB_PREFIX . "don as d LEFT JOIN " . MAIN_DB_PREFIX . "projet AS p";
$sql .= " ON p.rowid = d.fk_projet WHERE 1 = 1";
if ($statut >= 0) {
    $sql .= " AND d.fk_statut = " . $statut;
}
if (trim($search_ref) != '') {
    $sql .= ' AND d.rowid LIKE \'%' . $db->escape(trim($search_ref)) . '%\'';
}
if (trim($search_company) != '') {
    $sql .= natural_search('d.societe', $search_company);
}
/**
 *	Cree un don sur disque en fonction du modele de DON_ADDON_PDF
 *
 *	@param	DoliDB		$db  			Databse handler
 *	@param	int			$id				Id donation
 *	@param	string		$message		Message
 *	@param	string		$modele			Force le modele a utiliser ('' par defaut)
 *	@param	Translate	$outputlangs	Object langs
 *  @param  int			$hidedetails    Hide details of lines
 *  @param  int			$hidedesc       Hide description
 *  @param  int			$hideref        Hide ref
 *	@return int         				0 if KO, 1 if OK
 */
function don_create($db, $id, $message, $modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0)
{
    global $conf, $langs;
    $langs->load("bills");
    $eror = 0;
    // Increase limit for PDF build
    $err = error_reporting();
    error_reporting(0);
    @set_time_limit(120);
    error_reporting($err);
    $srctemplatepath = '';
    // Set template to use
    if (!dol_strlen($modele)) {
        if (!empty($conf->global->DON_ADDON_MODEL)) {
            $modele = $conf->global->DON_ADDON_MODEL;
        } else {
            print $langs->trans("Error") . " " . $langs->trans("Error_DON_ADDON_MODEL_NotDefined");
            return 0;
        }
    }
    // If selected modele is a filename template (then $modele="modelname:filename")
    $tmp = explode(':', $modele, 2);
    if (!empty($tmp[1])) {
        $modele = $tmp[0];
        $srctemplatepath = $tmp[1];
    }
    // Search template files
    $file = '';
    $classname = '';
    $filefound = 0;
    $dirmodels = array('/');
    if (is_array($conf->modules_parts['models'])) {
        $dirmodels = array_merge($dirmodels, $conf->modules_parts['models']);
    }
    foreach ($dirmodels as $reldir) {
        foreach (array('html', 'doc', 'pdf') as $prefix) {
            $file = $prefix . "_" . preg_replace('/^html_/', '', $modele) . ".modules.php";
            // On verifie l'emplacement du modele
            $file = dol_buildpath($reldir . "core/modules/dons/" . $file, 0);
            if (file_exists($file)) {
                $filefound = 1;
                $classname = $prefix . '_' . $modele;
                break;
            }
        }
        if ($filefound) {
            break;
        }
    }
    // Charge le modele
    if ($filefound) {
        require_once $file;
        $object = new Don($db);
        $object->fetch($id);
        $classname = $modele;
        $obj = new $classname($db);
        // We save charset_output to restore it because write_file can change it if needed for
        // output format that does not support UTF8.
        $sav_charset_output = $outputlangs->charset_output;
        if ($obj->write_file($object, $outputlangs, $srctemplatepath, $hidedetails, $hidedesc, $hideref) > 0) {
            $outputlangs->charset_output = $sav_charset_output;
            // we delete preview files
            require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php';
            dol_delete_preview($object);
            return 1;
        } else {
            $outputlangs->charset_output = $sav_charset_output;
            dol_syslog("Erreur dans don_create");
            dol_print_error($db, $obj->error);
            return 0;
        }
    } else {
        print $langs->trans("Error") . " " . $langs->trans("ErrorFileDoesNotExists", $file);
        return 0;
    }
}
Esempio n. 19
0
 * You should have received a copy of the GNU General Public License
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 */
/**
 *	    \file       htdocs/public/donations/therm.php
 *      \ingroup    donation
 *		\brief      Screen with thermometer
 */
define("NOLOGIN", 1);
// This means this output page does not require to be logged.
define("NOCSRFCHECK", 1);
// We accept to go on this page from external web site.
require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/images.lib.php';
require_once DOL_DOCUMENT_ROOT . '/compta/dons/class/don.class.php';
// Security check
if (empty($conf->don->enabled)) {
    accessforbidden('', 1, 1, 1);
}
/*
 * 	View (output an image)
 */
$dontherm = new Don($db);
$intentValue = $dontherm->sum_donations(1);
$pendingValue = $dontherm->sum_donations(2);
$actualValue = $dontherm->sum_donations(3);
$db->close();
/*
 * Graph thermometer
 */
print moneyMeter($actualValue, $pendingValue, $intentValue);
Esempio n. 20
0
 *		\brief      Home page of donation module
 */
require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT . '/compta/dons/class/don.class.php';
$langs->load("donations");
// Security check
$result = restrictedArea($user, 'don');
$donation_static = new Don($db);
/*
 * Actions
 */
// None
/*
 * View
 */
$donstatic = new Don($db);
$help_url = 'EN:Module_Donations|FR:Module_Dons|ES:M&oacute;dulo_Donaciones';
llxHeader('', $langs->trans("Donations"), $help_url);
$nb = array();
$somme = array();
$sql = "SELECT count(d.rowid) as nb, sum(d.amount) as somme , d.fk_statut";
$sql .= " FROM " . MAIN_DB_PREFIX . "don as d";
$sql .= " GROUP BY d.fk_statut";
$sql .= " ORDER BY d.fk_statut";
$result = $db->query($sql);
if ($result) {
    $i = 0;
    $num = $db->num_rows($result);
    while ($i < $num) {
        $objp = $db->fetch_object($result);
        $somme[$objp->fk_statut] = $objp->somme;
Esempio n. 21
0
 * 	\ingroup    donations
 * 	\brief      Page to show a donation information
 */
require '../main.inc.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/donation.lib.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/functions2.lib.php';
require_once DOL_DOCUMENT_ROOT . '/don/class/don.class.php';
$langs->load("donations");
// Security check
$id = GETPOST('id', 'int');
if ($user->societe_id) {
    $socid = $user->societe_id;
}
$result = restrictedArea($user, 'don', $id, '');
/*
 * View
 */
llxHeader();
if ($id) {
    $object = new Don($db);
    $object->fetch($id);
    $object->info($id);
    $head = donation_prepare_head($object);
    dol_fiche_head($head, 'info', $langs->trans("Donation"), 0, 'generic');
    print '<table width="100%"><tr><td>';
    dol_print_object_info($object);
    print '</td></tr></table>';
    print '</div>';
}
$db->close();
llxFooter();
Esempio n. 22
0
if ($_GET["action"] == 'set_encaisse')
{
	if ($don->set_encaisse($_GET["rowid"]) >= 0)
	{
        Header("Location: fiche.php?rowid=".$_GET["rowid"]);
		exit;
	}
    else $mesg=$don->error;
}

/*
 * Build doc
 */
if ($_REQUEST['action'] == 'builddoc')
{
	$donation = new Don($db);
	$donation->fetch($_GET['rowid']);

	if ($_REQUEST['model'])
	{
		$donation->setDocModel($user, $_REQUEST['model']);
	}

	// Define output language
	$outputlangs = $langs;
	$newlang='';
	if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) $newlang=$_REQUEST['lang_id'];
	if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$donation->client->default_lang;
	if (! empty($newlang))
	{
		$outputlangs = new Translate("",$conf);