示例#1
0
 /**
  *  Load data into info_box_contents array to show array later.
  *
  *  @param	int		$max        Maximum number of records to load
  *  @return	void
  */
 function loadBox($max = 5)
 {
     global $user, $langs, $db, $conf;
     $langs->load("boxes");
     $this->max = $max;
     include_once DOL_DOCUMENT_ROOT . "/adherents/class/adherent.class.php";
     $memberstatic = new Adherent($db);
     $this->info_box_head = array('text' => $langs->trans("BoxTitleLastModifiedMembers", $max));
     if ($user->rights->societe->lire) {
         $sql = "SELECT a.rowid, a.nom as lastname, a.prenom as firstname, a.datec, a.tms, a.statut as status, a.datefin as date_end_subscription,";
         $sql .= " t.cotisation";
         $sql .= " FROM " . MAIN_DB_PREFIX . "adherent as a, " . MAIN_DB_PREFIX . "adherent_type as t";
         $sql .= " WHERE a.entity = " . $conf->entity;
         $sql .= " AND a.fk_adherent_type = t.rowid";
         $sql .= " ORDER BY a.tms DESC";
         $sql .= $db->plimit($max, 0);
         $result = $db->query($sql);
         if ($result) {
             $num = $db->num_rows($result);
             $i = 0;
             while ($i < $num) {
                 $objp = $db->fetch_object($result);
                 $datec = $db->jdate($objp->datec);
                 $datem = $db->jdate($objp->tms);
                 $memberstatic->lastname = $objp->lastname;
                 $memberstatic->firstname = $objp->firstname;
                 $this->info_box_contents[$i][0] = array('td' => 'align="left" width="16"', 'logo' => $this->boximg, 'url' => DOL_URL_ROOT . "/adherents/fiche.php?rowid=" . $objp->rowid);
                 $this->info_box_contents[$i][1] = array('td' => 'align="left"', 'text' => $memberstatic->getFullName($langs), 'url' => DOL_URL_ROOT . "/adherents/fiche.php?rowid=" . $objp->rowid);
                 $this->info_box_contents[$i][2] = array('td' => 'align="right"', 'text' => dol_print_date($datem, "day"));
                 $this->info_box_contents[$i][3] = array('td' => 'align="right" width="18"', 'text' => $memberstatic->LibStatut($objp->status, $objp->cotisation, $db->jdate($objp->date_end_subscription), 3));
                 $i++;
             }
             if ($num == 0) {
                 $this->info_box_contents[$i][0] = array('td' => 'align="center"', 'text' => $langs->trans("NoRecordedCustomers"));
             }
         } else {
             $this->info_box_contents[0][0] = array('td' => 'align="left"', 'maxlength' => 500, 'text' => $db->error() . ' sql=' . $sql);
         }
     } else {
         $this->info_box_contents[0][0] = array('align' => 'left', 'text' => $langs->trans("ReadPermissionNotAllowed"));
     }
 }
示例#2
0
	$result=$member->fetch('',GETPOST("ref"));
	if ($result < 0)
	{
		$mesg=$member->error;
		$error++;
	}
	else
	{
		$subscription=new Cotisation($db);
	}

	$amount=$subscription->total_ttc;
    if (GETPOST("amount",'int')) $amount=GETPOST("amount",'int');
    $amount=price2num($amount);

	$fulltag='MID='.$member->id.'.M='.strtr($member->getFullName($langs),"-"," ");
	if (! empty($_REQUEST["tag"])) { $tag=$_REQUEST["tag"]; $fulltag.='.TAG='.$_REQUEST["tag"]; }
	$fulltag=dol_string_unaccent($fulltag);

	// Creditor
	$var=!$var;
	print '<tr><td class="CTableRow'.($var?'1':'2').'">'.$langs->trans("Creditor");
    print '</td><td class="CTableRow'.($var?'1':'2').'"><b>'.$creditor.'</b>';
    print '<input type="hidden" name="creditor" value="'.$creditor.'">';
    print '</td></tr>'."\n";

	// Debitor
	$var=!$var;
	print '<tr><td class="CTableRow'.($var?'1':'2').'">'.$langs->trans("Member");
	print '</td><td class="CTableRow'.($var?'1':'2').'"><b>'.$member->getFullName($langs).'</b>';
示例#3
0
 }
 $fulltag = dol_string_unaccent($fulltag);
 // Creditor
 $var = !$var;
 print '<tr class="CTableRow' . ($var ? '1' : '2') . '"><td class="CTableRow' . ($var ? '1' : '2') . '">' . $langs->trans("Creditor");
 print '</td><td class="CTableRow' . ($var ? '1' : '2') . '"><b>' . $creditor . '</b>';
 print '<input type="hidden" name="creditor" value="' . $creditor . '">';
 print '</td></tr>' . "\n";
 // Debitor
 $var = !$var;
 print '<tr class="CTableRow' . ($var ? '1' : '2') . '"><td class="CTableRow' . ($var ? '1' : '2') . '">' . $langs->trans("Member");
 print '</td><td class="CTableRow' . ($var ? '1' : '2') . '"><b>';
 if ($member->morphy == 'mor' && !empty($member->societe)) {
     print $member->societe;
 } else {
     print $member->getFullName($langs);
 }
 print '</b>';
 // Object
 $var = !$var;
 $text = '<b>' . $langs->trans("PaymentSubscription") . '</b>';
 print '<tr class="CTableRow' . ($var ? '1' : '2') . '"><td class="CTableRow' . ($var ? '1' : '2') . '">' . $langs->trans("Designation");
 print '</td><td class="CTableRow' . ($var ? '1' : '2') . '">' . $text;
 print '<input type="hidden" name="source" value="' . GETPOST("source", 'alpha') . '">';
 print '<input type="hidden" name="ref" value="' . $member->ref . '">';
 print '</td></tr>' . "\n";
 if ($member->last_subscription_date || $member->last_subscription_amount) {
     // Last subscription date
     $var = !$var;
     print '<tr class="CTableRow' . ($var ? '1' : '2') . '"><td class="CTableRow' . ($var ? '1' : '2') . '">' . $langs->trans("LastSubscriptionDate");
     print '</td><td class="CTableRow' . ($var ? '1' : '2') . '">' . dol_print_date($member->last_subscription_date, 'day');
示例#4
0
 print '<input type="image" class="liste_titre" src="' . DOL_URL_ROOT . '/theme/' . $conf->theme . '/img/searchclear.png" name="button_removefilter" value="' . dol_escape_htmltag($langs->trans("RemoveFilter")) . '" title="' . dol_escape_htmltag($langs->trans("RemoveFilter")) . '">';
 print '</td>';
 print "</tr>\n";
 print '</form>';
 $var = True;
 while ($i < $num && $i < $conf->liste_limit) {
     $objp = $db->fetch_object($resql);
     $datefin = $db->jdate($objp->datefin);
     $adh = new Adherent($db);
     $adh->lastname = $objp->lastname;
     $adh->firstname = $objp->firstname;
     // Lastname
     $var = !$var;
     print '<tr ' . $bc[$var] . '>';
     if ($objp->societe != '') {
         print '<td><a href="card.php?rowid=' . $objp->rowid . '">' . img_object($langs->trans("ShowMember"), "user") . ' ' . $adh->getFullName($langs, 0, -1, 20) . ' / ' . dol_trunc($objp->societe, 12) . '</a></td>' . "\n";
     } else {
         print '<td><a href="card.php?rowid=' . $objp->rowid . '">' . img_object($langs->trans("ShowMember"), "user") . ' ' . $adh->getFullName($langs, 0, -1, 32) . '</a></td>' . "\n";
     }
     // Login
     print "<td>" . $objp->login . "</td>\n";
     // Type
     /*print '<td class="nowrap">';
             $membertypestatic->id=$objp->type_id;
             $membertypestatic->libelle=$objp->type;
             print $membertypestatic->getNomUrl(1,12);
             print '</td>';
     		*/
     // Moral/Physique
     print "<td>" . $adh->getmorphylib($objp->morphy) . "</td>\n";
     // EMail
示例#5
0
if ($action == 'setsocid') {
    $error = 0;
    if (!$error) {
        if (GETPOST('socid', 'int') != $object->fk_soc) {
            $sql = "SELECT rowid FROM " . MAIN_DB_PREFIX . "adherent";
            $sql .= " WHERE fk_soc = '" . GETPOST('socid', 'int') . "'";
            $resql = $db->query($sql);
            if ($resql) {
                $obj = $db->fetch_object($resql);
                if ($obj && $obj->rowid > 0) {
                    $othermember = new Adherent($db);
                    $othermember->fetch($obj->rowid);
                    $thirdparty = new Societe($db);
                    $thirdparty->fetch(GETPOST('socid', 'int'));
                    $error++;
                    setEventMessages($langs->trans("ErrorMemberIsAlreadyLinkedToThisThirdParty", $othermember->getFullName($langs), $othermember->login, $thirdparty->name), null, 'errors');
                }
            }
            if (!$error) {
                $result = $object->setThirdPartyId(GETPOST('socid', 'int'));
                if ($result < 0) {
                    dol_print_error('', $object->error);
                }
                $_POST['action'] = '';
                $action = '';
            }
        }
    }
}
if ($user->rights->adherent->cotisation->creer && $action == 'cotisation' && !$_POST["cancel"]) {
    $error = 0;
示例#6
0
 $objp = $db->fetch_object($resql);
 $datefin = $db->jdate($objp->datefin);
 $memberstatic->id = $objp->rowid;
 $memberstatic->ref = $objp->rowid;
 $memberstatic->lastname = $objp->lastname;
 $memberstatic->firstname = $objp->firstname;
 $companyname = $objp->company;
 $var = !$var;
 print "<tr " . $bc[$var] . ">";
 // Ref
 print "<td>";
 print $memberstatic->getNomUrl(1);
 print "</td>\n";
 // Lastname
 print "<td><a href=\"card.php?rowid={$objp->rowid}\">";
 print !empty($objp->lastname) || !empty($objp->firstname) ? dol_trunc($memberstatic->getFullName($langs)) : '';
 print (!empty($objp->lastname) || !empty($objp->firstname)) && !empty($companyname) ? ' / ' : '';
 print !empty($companyname) ? dol_trunc($companyname, 32) : '';
 print "</a></td>\n";
 // Login
 print "<td>" . $objp->login . "</td>\n";
 // Type
 $membertypestatic->id = $objp->type_id;
 $membertypestatic->libelle = $objp->type;
 print '<td class="nowrap">';
 print $membertypestatic->getNomUrl(1, 32);
 print '</td>';
 // Moral/Physique
 print "<td>" . $memberstatic->getmorphylib($objp->morphy) . "</td>\n";
 // EMail
 print "<td>" . dol_print_email($objp->email, 0, 0, 1) . "</td>\n";
示例#7
0
print '</tr>';
print '</thead>';
print '<tfoot>';
print '</tfoot>';
print '<tbody>';
$var = true;
$total = 0;
if (count($result->rows) > 0) {
    foreach ($result->rows as $aRow) {
        $objp = $aRow->value;
        $total += $objp->amount;
        $cotisation->ref = $objp->crowid;
        $cotisation->id = $objp->crowid;
        $adherent->Lastname = $objp->Lastname;
        $adherent->Firstname = $objp->Firstname;
        $adherent->ref = $adherent->getFullName($langs);
        $adherent->id = $objp->_id;
        $adherent->login = $objp->login;
        print "<tr>";
        print '<td>' . $objp->_id . '</td>';
        // Login
        print '<td>' . $objp->login . '</td>';
        print '<td>' . $objp->Firstname . '</td>';
        print '<td>' . $objp->Lastname . '</td>';
        // Libelle
        print '<td>';
        print dol_trunc($objp->note, 32);
        print '</td>';
        // Banque
        if ($conf->banque->enabled) {
            if ($objp->fk_account) {
示例#8
0
 }
 $fulltag = dol_string_unaccent($fulltag);
 // Creditor
 $var = !$var;
 print '<tr class="CTableRow' . ($var ? '1' : '2') . '"><td class="CTableRow' . ($var ? '1' : '2') . '">' . $langs->trans("Creditor");
 print '</td><td class="CTableRow' . ($var ? '1' : '2') . '"><b>' . $creditor . '</b>';
 print '<input type="hidden" name="creditor" value="' . $creditor . '">';
 print '</td></tr>' . "\n";
 // Debitor
 $var = !$var;
 print '<tr class="CTableRow' . ($var ? '1' : '2') . '"><td class="CTableRow' . ($var ? '1' : '2') . '">' . $langs->trans("Member");
 print '</td><td class="CTableRow' . ($var ? '1' : '2') . '"><b>';
 if ($member->morphy == 'mor' && !empty($member->societe)) {
     print $member->societe;
 } else {
     print $member->getFullName($langs);
 }
 print '</b>';
 // Object
 $var = !$var;
 $text = '<b>' . $langs->trans("PaymentSubscription") . '</b>';
 print '<tr class="CTableRow' . ($var ? '1' : '2') . '"><td class="CTableRow' . ($var ? '1' : '2') . '">' . $langs->trans("Designation");
 print '</td><td class="CTableRow' . ($var ? '1' : '2') . '">' . $text;
 print '<input type="hidden" name="source" value="' . GETPOST("source", 'alpha') . '">';
 print '<input type="hidden" name="ref" value="' . $member->ref . '">';
 print '</td></tr>' . "\n";
 if ($member->last_subscription_date || $member->last_subscription_amount) {
     // Last subscription date
     $var = !$var;
     print '<tr class="CTableRow' . ($var ? '1' : '2') . '"><td class="CTableRow' . ($var ? '1' : '2') . '">' . $langs->trans("LastSubscriptionDate");
     print '</td><td class="CTableRow' . ($var ? '1' : '2') . '">' . dol_print_date($member->last_subscription_date, 'day');
示例#9
0
 $fulltag = 'MEM=' . $member->id . '.DAT=' . dol_print_date(dol_now(), '%Y%m%d%H%M');
 if (!empty($TAG)) {
     $tag = $TAG;
     $fulltag .= '.TAG=' . $TAG;
 }
 $fulltag = dol_string_unaccent($fulltag);
 // Creditor
 $var = !$var;
 print '<tr><td class="CTableRow' . ($var ? '1' : '2') . '">' . $langs->trans("Creditor");
 print '</td><td class="CTableRow' . ($var ? '1' : '2') . '"><b>' . $creditor . '</b>';
 print '<input type="hidden" name="creditor" value="' . $creditor . '">';
 print '</td></tr>' . "\n";
 // Debitor
 $var = !$var;
 print '<tr><td class="CTableRow' . ($var ? '1' : '2') . '">' . $langs->trans("Member");
 print '</td><td class="CTableRow' . ($var ? '1' : '2') . '"><b>' . $member->getFullName($langs) . '</b>';
 // Object
 $var = !$var;
 $text = '<b>' . $langs->trans("PaymentSubscription") . '</b>';
 print '<tr><td class="CTableRow' . ($var ? '1' : '2') . '">' . $langs->trans("Designation");
 print '</td><td class="CTableRow' . ($var ? '1' : '2') . '">' . $text;
 print '<input type="hidden" name="source" value="' . GETPOST("source", 'alpha') . '">';
 print '<input type="hidden" name="ref" value="' . $member->ref . '">';
 print '</td></tr>' . "\n";
 if ($member->last_subscription_date || $member->last_subscription_amount) {
     // Last subscription date
     $var = !$var;
     print '<tr><td class="CTableRow' . ($var ? '1' : '2') . '">' . $langs->trans("LastSubscriptionDate");
     print '</td><td class="CTableRow' . ($var ? '1' : '2') . '">' . dol_print_date($member->last_subscription_date, 'day');
     print '</td></tr>' . "\n";
     // Last subscription amount
 $ldap->connect_bind();
 while ($i < $num) {
     $ldap->error = "";
     $obj = $db->fetch_object($resql);
     $member = new Adherent($db);
     $result = $member->fetch($obj->rowid);
     if ($result < 0) {
         dol_print_error($db, $member->error);
         exit(-1);
     }
     $result = $member->fetch_subscriptions();
     if ($result < 0) {
         dol_print_error($db, $member->error);
         exit(-1);
     }
     print $langs->transnoentities("UpdateMember") . " rowid=" . $member->id . " " . $member->getFullName($langs);
     $oldobject = $member;
     $oldinfo = $oldobject->_load_ldap_info();
     $olddn = $oldobject->_load_ldap_dn($oldinfo);
     $info = $member->_load_ldap_info();
     $dn = $member->_load_ldap_dn($info);
     $result = $ldap->add($dn, $info, $user);
     // Wil fail if already exists
     $result = $ldap->update($dn, $info, $user, $olddn);
     if ($result > 0) {
         print " - " . $langs->transnoentities("OK");
     } else {
         $error++;
         print " - " . $langs->transnoentities("KO") . ' - ' . $ldap->error;
     }
     print "\n";
示例#11
0
        $var = True;
        while ($i < $num) {
            $var = !$var;
            $obj = $db->fetch_object($resql);
            print "<tr " . $bc[$var] . ">";
            $staticmember->id = $obj->rowid;
            $staticmember->lastname = $obj->lastname;
            $staticmember->firstname = $obj->firstname;
            if (!empty($obj->fk_soc)) {
                $staticmember->fk_soc = $obj->fk_soc;
                $staticmember->fetch_thirdparty();
                $staticmember->name = $staticmember->thirdparty->name;
            } else {
                $staticmember->name = $obj->company;
            }
            $staticmember->ref = $staticmember->getFullName($langs);
            $statictype->id = $obj->typeid;
            $statictype->libelle = $obj->libelle;
            print '<td>' . $staticmember->getNomUrl(1, 32) . '</td>';
            print '<td>' . $statictype->getNomUrl(1, 32) . '</td>';
            print '<td>' . dol_print_date($db->jdate($obj->datem), 'dayhour') . '</td>';
            print '<td align="right">' . $staticmember->LibStatut($obj->statut, $obj->cotisation == 'yes' ? 1 : 0, $db->jdate($obj->date_end_subscription), 5) . '</td>';
            print '</tr>';
            $i++;
        }
    }
    print "</table><br>";
} else {
    dol_print_error($db);
}
/*
示例#12
0
    /**
     *  Create a third party into database from a member object
     *
     *  @param	Adherent	$member		Object member
     * 	@param	string	$socname	Name of third party to force
     *  @return int					<0 if KO, id of created account if OK
     */
    function create_from_member(Adherent $member,$socname='')
    {
        global $user,$langs;

        $name = $socname?$socname:$member->societe;
        if (empty($name)) $name=$member->getFullName($langs);

        // Positionne parametres
        $this->nom=$name;				// TODO deprecated
        $this->name=$name;
        $this->address=$member->address;
        $this->zip=$member->zip;
        $this->town=$member->town;
        $this->country_code=$member->country_code;
        $this->country_id=$member->country_id;
        $this->phone=$member->phone;       // Prof phone
        $this->email=$member->email;
        $this->skype=$member->skype;

        $this->client = 1;				// A member is a customer by default
        $this->code_client = -1;
        $this->code_fournisseur = -1;

        $this->db->begin();

        // Cree et positionne $this->id
        $result=$this->create($user);
        if ($result >= 0)
        {
            $sql = "UPDATE ".MAIN_DB_PREFIX."adherent";
            $sql.= " SET fk_soc=".$this->id;
            $sql.= " WHERE rowid=".$member->id;

            dol_syslog(get_class($this)."::create_from_member", LOG_DEBUG);
            $resql=$this->db->query($sql);
            if ($resql)
            {
                $this->db->commit();
                return $this->id;
            }
            else
            {
                $this->error=$this->db->error();

                $this->db->rollback();
                return -1;
            }
        }
        else
        {
            // $this->error deja positionne
            dol_syslog(get_class($this)."::create_from_member - 2 - ".$this->error." - ".join(',',$this->errors), LOG_ERR);

            $this->db->rollback();
            return $result;
        }
    }
 /**
  * \brief Fonction generant le document sur le disque
  * \param agf		Objet document a generer (ou id si ancienne methode)
  * outputlangs	Lang object for output language
  * file		Name of file to generate
  * \return int 1=ok, 0=ko
  */
 function write_file($loyer, $outputlangs, $file, $socid, $courrier)
 {
     global $user, $langs, $conf, $mysoc;
     $default_font_size = pdf_getPDFFontSize($outputlangs);
     if (!is_object($outputlangs)) {
         $outputlangs = $langs;
     }
     if (!is_object($loyer)) {
         $id = $loyer;
         $loyer = new Loyer($this->db);
         $ret = $loyer->fetch($id);
     }
     // dol_syslog ( "pdf_quittance::debug loyer=" . var_export ( $loyer, true ) );
     // Definition of $dir and $file
     $dir = $conf->immobilier->dir_output;
     $file = $dir . '/' . $file;
     if (!file_exists($dir)) {
         if (create_exdir($dir) < 0) {
             $this->error = $langs->trans("ErrorCanNotCreateDir", $dir);
             return 0;
         }
     }
     if (file_exists($dir)) {
         $pdf = pdf_getInstance($this->format, $this->unit, $this->orientation);
         if (class_exists('TCPDF')) {
             $pdf->setPrintHeader(false);
             $pdf->setPrintFooter(false);
         }
         $pdf->Open();
         $pagenb = 0;
         $pdf->SetTitle($outputlangs->convToOutputCharset($loyer->nom));
         $pdf->SetSubject($outputlangs->transnoentities("Quitance"));
         $pdf->SetCreator("Dolibarr " . DOL_VERSION . ' (Immobilier module)');
         $pdf->SetAuthor($outputlangs->convToOutputCharset($user->fullname));
         $pdf->SetKeyWords($outputlangs->convToOutputCharset($loyer->nom) . " " . $outputlangs->transnoentities("Document"));
         if ($conf->global->MAIN_DISABLE_PDF_COMPRESSION) {
             $pdf->SetCompression(false);
         }
         $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);
         // Left, Top, Right
         $pdf->SetAutoPageBreak(1, 0);
         // On recupere les infos societe
         $locataire = new Locataire($this->db);
         $result = $locataire->fetch($loyer->locataire_id);
         $proprio = new Adherent($this->db);
         $result = $proprio->fetch($loyer->proprietaire_id);
         $local = new Local($this->db);
         $result = $local->fetch($loyer->local_id);
         $paiement = new Paie($this->db);
         $result = $paiement->fetch_by_loyer($loyer->id);
         if (!empty($loyer->id)) {
             // New page
             $pdf->AddPage();
             $pagenb++;
             $this->_pagehead($pdf, $agf, 1, $outputlangs);
             $pdf->SetFont(pdf_getPDFFont($outputlangs), '', 9);
             $pdf->MultiCell(0, 3, '', 0, 'J');
             $pdf->SetTextColor(0, 0, 0);
             $posY = $this->marge_haute;
             $posX = $this->marge_gauche;
             // Bloc Owner
             $pdf->SetFont(pdf_getPDFFont($outputlangs), '', 15);
             $pdf->SetXY($posX, $posY + 3);
             $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset('Bailleur'), 1, 'C');
             $posY = $pdf->getY();
             $pdf->SetXY($posX, $posY);
             $pdf->SetFont(pdf_getPDFFont($outputlangs), '', 13);
             $this->str = $proprio->getFullName($outputlangs) . "\n";
             $this->str .= $proprio->address . "\n";
             $this->str .= $proprio->zip . ' ' . $proprio->town;
             $this->str .= ' - ' . $proprio->country . "\n\n";
             if ($proprio->phone) {
                 $this->str .= $outputlangs->transnoentities('Téléphone') . ' ' . $proprio->phone . "\n";
             }
             if ($proprio->fax) {
                 $this->str .= $outputlangs->transnoentities('Fax') . ' ' . $proprio->fax . "\n";
             }
             if ($proprio->email) {
                 $this->str .= $outputlangs->transnoentities('EMail') . ' ' . $proprio->email . "\n";
             }
             if ($proprio->url) {
                 $this->str .= $outputlangs->transnoentities('Url') . ' ' . $proprio->url . "\n";
             }
             $pdf->MultiCell(100, 20, $outputlangs->convToOutputCharset($this->str), 1, 'L');
             // Bloc Locataire
             $posX = $this->page_largeur - $this->marge_droite - 100;
             $posY = $pdf->getY() + 10;
             $pdf->SetFont(pdf_getPDFFont($outputlangs), '', 15);
             $pdf->SetXY($posX, $posY);
             $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset('Locataire Destinataire'), 1, 'C');
             $posY = $pdf->getY();
             $pdf->SetXY($posX, $posY);
             $pdf->SetFont(pdf_getPDFFont($outputlangs), '', 13);
             $this->str = $locataire->nom . "\n";
             $this->str .= $local->nom . "\n";
             if (!empty($locataire->adresse)) {
                 $this->str .= $locataire->adresse . "\n";
             } else {
                 $this->str .= $local->adresse . "\n";
             }
             $pdf->MultiCell(100, 20, $outputlangs->convToOutputCharset($this->str), 1, 'L');
             // Bloc Quittance de loyer
             $posX = $this->marge_gauche;
             $posY = $pdf->getY() + 10;
             $widthbox = $this->page_largeur - $this->marge_gauche - $this->marge_droite;
             $pdf->SetFont(pdf_getPDFFont($outputlangs), 'B', 15);
             $pdf->SetXY($posX, $posY);
             $pdf->MultiCell($widthbox, 3, $outputlangs->convToOutputCharset('Quittance de loyer'), 1, 'C');
             $pdf->SetFont(pdf_getPDFFont($outputlangs), '', 13);
             $posY = $pdf->getY();
             $pdf->SetXY($posX, $posY);
             $period = 'Loyer ' . dol_print_date($loyer->periode_du, '%b %Y');
             $pdf->MultiCell($widthbox, 3, $outputlangs->convToOutputCharset($period), 1, 'C');
             $pdf->SetFont(pdf_getPDFFont($outputlangs), '', 13);
             $posY = $pdf->getY();
             $pdf->SetXY($posX, $posY);
             $numquitance = 'Quittance n°:' . 'ILQ' . $loyer->id;
             $pdf->MultiCell($widthbox, 3, $outputlangs->convToOutputCharset($numquitance), 1, 'R');
             // Sous Bloc Quittance de loyer Gauche
             $posX = $this->marge_gauche;
             $posY = $pdf->getY();
             $widthbox = ($this->page_largeur - $this->marge_gauche - $this->marge_droite) / 2;
             $pdf->SetFont(pdf_getPDFFont($outputlangs), '', 12);
             $pdf->SetXY($posX, $posY);
             $text = ' Reçu de :' . $locataire->nom . "\n";
             $text .= "\n";
             $montantpay = 0;
             if (!empty($loyer->paiepartiel)) {
                 $montantpay = $loyer->paiepartiel;
             }
             $text .= ' la somme de :' . $montantpay . '€' . "\n";
             $text .= "\n";
             $dtpaiement = $paiement->date_paiement;
             if (empty($dtpaiement)) {
                 $dtpaiement = $loyer->echeance;
             }
             $text .= ' le :' . dol_print_date($dtpaiement, 'daytext') . "\n";
             $text .= "\n";
             $text .= ' pour loyer et accessoires des locaux sis à :' . "\n";
             $text .= $local->adresse . "\n";
             $text .= "\n";
             $text .= 'en paiement du terme du ' . dol_print_date($loyer->periode_du, 'daytext') . "\n";
             $text .= 'au ' . dol_print_date($loyer->periode_au, 'daytext') . "\n";
             $text .= "\n";
             $text .= 'Fait à ' . $proprio->town . "\n";
             $text .= 'le ' . dol_print_date(dol_now(), 'daytext') . "\n";
             $text .= "\n";
             $pdf->MultiCell($widthbox, 0, $outputlangs->convToOutputCharset($text), 1, 'L');
             $newpoy = $pdf->getY();
             // Sous Bloc Quittance de loyer Droite
             $posX = $widthbox + $this->marge_gauche;
             $widthbox = ($this->page_largeur - $this->marge_gauche - $this->marge_droite) / 2;
             $pdf->SetFont(pdf_getPDFFont($outputlangs), '', 12);
             $pdf->SetXY($posX, $posY);
             $text = '<table>';
             $text .= '<tr>';
             $text .= '<td colspan="2">';
             $text .= 'Détail :' . "<BR>";
             $text .= ' - Loyer nu :' . $loyer->loy . '€' . "<BR>";
             $text .= ' - Charges / Provisions de Charges :' . $loyer->charges . '€' . "<BR>";
             $text .= "<BR>";
             $text .= 'Montant total du terme :' . $loyer->montant_tot . '€' . "<BR>";
             $text .= '</td>';
             $text .= '</tr>';
             $sql = "SELECT p.rowid, p.loyer_id, date_paiement as dp, p.montant, p.commentaire as type, il.montant_tot as amount";
             $sql .= " FROM " . MAIN_DB_PREFIX . "immo_paie as p";
             $sql .= ", " . MAIN_DB_PREFIX . "immo_loyer as il ";
             $sql .= " WHERE p.loyer_id = " . $loyer->id;
             $sql .= " AND p.loyer_id = il.rowid";
             $sql .= " ORDER BY dp DESC";
             // print $sql;
             dol_syslog(get_class($this) . ':: Paiement sql=' . $sql, LOG_DEBUG);
             $resql = $this->db->query($sql);
             if ($resql) {
                 $num = $this->db->num_rows($resql);
                 $i = 0;
                 $total = 0;
                 $text .= '<tr>';
                 $text .= '<td align="left">' . $langs->trans("Date") . '</td>';
                 $text .= '<td align="right">' . $langs->trans("Amount") . '</td>';
                 $text .= '</tr><br>';
                 $var = True;
                 while ($i < $num) {
                     $objp = $this->db->fetch_object($resql);
                     $text .= '<tr>';
                     $text .= '<td>' . dol_print_date($this->db->jdate($objp->dp), 'day') . "</td>";
                     $text .= '<td align="right">' . price($objp->montant) . ' ' . $langs->trans("Currency" . $conf->currency) . "</td>";
                     $text .= "</tr>";
                     $totalpaye += $objp->montant;
                     $i++;
                 }
                 if ($loyer->paye == 0) {
                     $text .= "<br><tr><td align=\"left\">" . $langs->trans("AlreadyPaid") . " :</td><td align=\"right\">" . price($totalpaye) . " " . $langs->trans("Currency" . $conf->currency) . "</td></tr>";
                     $text .= "<tr><td align=\"left\">" . $langs->trans("AmountExpected") . " :</td><td align=\"right\">" . price($loyer->montant_tot) . " " . $langs->trans("Currency" . $conf->currency) . "</td></tr>";
                     $resteapayer = $loyer->montant_tot - $totalpaye;
                     $text .= "<tr><td align=\"left\">" . $langs->trans("RemainderToPay") . " :</td>";
                     $text .= "<td align=\"right\">" . price($resteapayer, 2) . " " . $langs->trans("Currency" . $conf->currency) . "</td></tr>";
                 }
                 $this->db->free($resql);
             }
             $text .= "</table>";
             $pdf->writeHTMLCell($widthbox, $newpoy - $posY, $posX, $posY, dol_htmlentitiesbr($text), 1);
             // Tableau Loyer et solde
             $sql = "SELECT il.nom, il.solde";
             $sql .= " FROM " . MAIN_DB_PREFIX . "immo_loyer as il ";
             $sql .= " WHERE il.solde<>0 AND paye=0 AND periode_du<'" . $this->db->idate($loyer->periode_du) . "'";
             $sql .= " AND local_id=" . $loyer->local_id . " AND locataire_id=" . $loyer->locataire_id;
             $sql .= " ORDER BY echeance ASC";
             dol_syslog(get_class($this) . ':: loyerAntierieur sql=' . $sql, LOG_DEBUG);
             $resql = $this->db->query($sql);
             if ($resql) {
                 $num = $this->db->num_rows($resql);
                 if ($num > 0) {
                     // Bloc Solde Anterieur
                     $posX = $this->marge_gauche;
                     $posY = $pdf->getY() + ($newpoy - $posY) + 5;
                     $widthbox = $this->page_largeur - $this->marge_gauche - $this->marge_droite;
                     $pdf->SetFont(pdf_getPDFFont($outputlangs), 'B', 15);
                     $pdf->SetXY($posX, $posY);
                     $pdf->MultiCell($widthbox, 3, $outputlangs->convToOutputCharset('Solde Anterieur'), 1, 'C');
                     $text = '<table>';
                     // print $sql;
                     dol_syslog(get_class($this) . ':: loyerAntierieur sql=' . $sql, LOG_DEBUG);
                     $resql = $this->db->query($sql);
                     $i = 0;
                     $total = 0;
                     $var = True;
                     while ($i < $num) {
                         $objp = $this->db->fetch_object($resql);
                         $text .= '<tr>';
                         $text .= '<td>' . $objp->nom . "</td>";
                         $text .= "<td align=\"right\">" . $objp->solde . ' ' . $langs->trans("Currency" . $conf->currency) . "</td>";
                         $text .= "</tr>";
                         $i++;
                     }
                     $this->db->free($resql);
                     $text .= "</table>";
                     $posY = $pdf->getY();
                     $pdf->SetFont(pdf_getPDFFont($outputlangs), '', 13);
                     $pdf->writeHTMLCell($widthbox, 0, $posX, $posY, dol_htmlentitiesbr($text), 1, 1);
                 }
             }
             // Bloc total somme due
             // Tableau total somme due
             $sql = "SELECT SUM(il.solde) as total";
             $sql .= " FROM " . MAIN_DB_PREFIX . "immo_loyer as il ";
             $sql .= " WHERE il.solde<>0 AND paye=0 AND periode_du<='" . $this->db->idate($loyer->periode_du) . "'";
             $sql .= " AND local_id=" . $loyer->local_id . " AND locataire_id=" . $loyer->locataire_id;
             $sql .= " GROUP BY local_id,locataire_id";
             // print $sql;
             dol_syslog(get_class($this) . ':: loyerAntierieur sql=' . $sql, LOG_DEBUG);
             $resql = $this->db->query($sql);
             if ($resql) {
                 $num = $this->db->num_rows($resql);
                 if ($num > 0) {
                     $objp = $this->db->fetch_object($resql);
                     $posX = $this->marge_gauche;
                     $posY = $pdf->getY() + 5;
                     $widthbox = $this->page_largeur - $this->marge_gauche - $this->marge_droite;
                     $pdf->SetFont(pdf_getPDFFont($outputlangs), 'B', 15);
                     $pdf->SetXY($posX, $posY);
                     if ($objp->total > 0) {
                         $title = 'Total somme due';
                     } else {
                         $title = 'Total somme à rembouser';
                     }
                     $pdf->MultiCell($widthbox, 3, $outputlangs->convToOutputCharset($title), 1, 'C');
                     $text = '<table>';
                     $i = 0;
                     $total = 0;
                     $text .= '<tr>';
                     $text .= "<td align=\"right\">" . $objp->total . ' ' . $langs->trans("Currency" . $conf->currency) . "</td></tr>";
                     $this->db->free($resql);
                     $text .= "</table>";
                     $posY = $pdf->getY();
                     $pdf->SetFont(pdf_getPDFFont($outputlangs), '', 13);
                     $pdf->writeHTMLCell($widthbox, 0, $posX, $posY, dol_htmlentitiesbr($text), 1);
                 }
             }
         }
         $pdf->Close();
         $pdf->Output($file, 'F');
         if (!empty($conf->global->MAIN_UMASK)) {
             @chmod($file, octdec($conf->global->MAIN_UMASK));
         }
         return 1;
         // Pas d'erreur
     } else {
         $this->error = $langs->trans("ErrorConstantNotDefined", "AGF_OUTPUTDIR");
         return 0;
     }
     $this->error = $langs->trans("ErrorUnknown");
     return 0;
     // Erreur par defaut
 }
    /**
     *    Assign custom values for canvas (for example into this->tpl to be used by templates)
     *
     *    @param	string	$action    Type of action
     *    @param	string	$id			Id of object
     *    @param	string	$ref		Ref of object
     *    @return	void
     */
    function assign_values(&$action, $id = 0, $ref = '')
    {
        global $conf, $langs, $user, $mysoc, $canvas;
        global $form, $formadmin, $formcompany;
        if ($action == 'add' || $action == 'update') {
            $this->assign_post($action);
        }
        if ($_GET["type"] == 'f') {
            $this->object->fournisseur = 1;
        }
        if ($_GET["type"] == 'c') {
            $this->object->client = 1;
        }
        if ($_GET["type"] == 'p') {
            $this->object->client = 2;
        }
        if ($_GET["type"] == 'cp') {
            $this->object->client = 3;
        }
        if ($_REQUEST["private"] == 1) {
            $this->object->particulier = 1;
        }
        foreach ($this->object as $key => $value) {
            $this->tpl[$key] = $value;
        }
        $this->tpl['error'] = get_htmloutput_errors($this->object->error, $this->object->errors);
        if (is_array($GLOBALS['errors'])) {
            $this->tpl['error'] = get_htmloutput_mesg('', $GLOBALS['errors'], 'error');
        }
        if ($action == 'create') {
            if ($conf->use_javascript_ajax) {
                $this->tpl['ajax_selecttype'] = "\n" . '<script type="text/javascript" language="javascript">
				$(document).ready(function () {
		              $("#radiocompany").click(function() {
                            document.formsoc.action.value="create";
                            document.formsoc.canvas.value="company";
                            document.formsoc.private.value=0;
                            document.formsoc.submit();
		              });
		               $("#radioprivate").click(function() {
                            document.formsoc.action.value="create";
                            document.formsoc.canvas.value="individual";
                            document.formsoc.private.value=1;
                            document.formsoc.submit();
                      });
		          });
                </script>' . "\n";
            }
        }
        if ($action == 'create' || $action == 'edit') {
            if ($conf->use_javascript_ajax) {
                $this->tpl['ajax_selectcountry'] = "\n" . '<script type="text/javascript" language="javascript">
				$(document).ready(function () {
						$("#selectcountry_id").change(function() {
							document.formsoc.action.value="' . $action . '";
							document.formsoc.canvas.value="' . $canvas . '";
							document.formsoc.submit();
						});
					})
				</script>' . "\n";
            }
            // Load object modCodeClient
            $module = !empty($conf->global->SOCIETE_CODECLIENT_ADDON) ? $conf->global->SOCIETE_CODECLIENT_ADDON : 'mod_codeclient_leopard';
            if (substr($module, 0, 15) == 'mod_codeclient_' && substr($module, -3) == 'php') {
                $module = substr($module, 0, dol_strlen($module) - 4);
            }
            $dirsociete = array_merge(array('/core/modules/societe/'), $conf->modules_parts['societe']);
            foreach ($dirsociete as $dirroot) {
                $res = dol_include_once($dirroot . $module . '.php');
                if ($res) {
                    break;
                }
            }
            $modCodeClient = new $module($db);
            $this->tpl['auto_customercode'] = $modCodeClient->code_auto;
            // We verified if the tag prefix is used
            if ($modCodeClient->code_auto) {
                $this->tpl['prefix_customercode'] = $modCodeClient->verif_prefixIsUsed();
            }
            // TODO create a function
            $this->tpl['select_customertype'] = '<select class="flat" name="client">';
            $this->tpl['select_customertype'] .= '<option value="2"' . ($this->object->client == 2 ? ' selected="selected"' : '') . '>' . $langs->trans('Prospect') . '</option>';
            $this->tpl['select_customertype'] .= '<option value="3"' . ($this->object->client == 3 ? ' selected="selected"' : '') . '>' . $langs->trans('ProspectCustomer') . '</option>';
            $this->tpl['select_customertype'] .= '<option value="1"' . ($this->object->client == 1 ? ' selected="selected"' : '') . '>' . $langs->trans('Customer') . '</option>';
            $this->tpl['select_customertype'] .= '<option value="0"' . ($this->object->client == 0 ? ' selected="selected"' : '') . '>' . $langs->trans('NorProspectNorCustomer') . '</option>';
            $this->tpl['select_customertype'] .= '</select>';
            // Customer
            $this->tpl['customercode'] = $this->object->code_client;
            if ((!$this->object->code_client || $this->object->code_client == -1) && $modCodeClient->code_auto) {
                $this->tpl['customercode'] = $modCodeClient->getNextValue($this->object, 0);
            }
            $this->tpl['ismodifiable_customercode'] = $this->object->codeclient_modifiable();
            $s = $modCodeClient->getToolTip($langs, $this->object, 0);
            $this->tpl['help_customercode'] = $form->textwithpicto('', $s, 1);
            if (!empty($conf->fournisseur->enabled)) {
                $this->tpl['supplier_enabled'] = 1;
                // Load object modCodeFournisseur
                $module = $conf->global->SOCIETE_CODECLIENT_ADDON;
                if (substr($module, 0, 15) == 'mod_codeclient_' && substr($module, -3) == 'php') {
                    $module = substr($module, 0, dol_strlen($module) - 4);
                }
                $dirsociete = array_merge(array('/core/modules/societe/'), $conf->modules_parts['societe']);
                foreach ($dirsociete as $dirroot) {
                    $res = dol_include_once($dirroot . $module . '.php');
                    if ($res) {
                        break;
                    }
                }
                $modCodeFournisseur = new $module();
                $this->tpl['auto_suppliercode'] = $modCodeFournisseur->code_auto;
                // We verified if the tag prefix is used
                if ($modCodeFournisseur->code_auto) {
                    $this->tpl['prefix_suppliercode'] = $modCodeFournisseur->verif_prefixIsUsed();
                }
                // Supplier
                $this->tpl['yn_supplier'] = $form->selectyesno("fournisseur", $this->object->fournisseur, 1);
                $this->tpl['suppliercode'] = $this->object->code_fournisseur;
                if ((!$this->object->code_fournisseur || $this->object->code_fournisseur == -1) && $modCodeFournisseur->code_auto) {
                    $this->tpl['suppliercode'] = $modCodeFournisseur->getNextValue($this->object, 1);
                }
                $this->tpl['ismodifiable_suppliercode'] = $this->object->codefournisseur_modifiable();
                $s = $modCodeFournisseur->getToolTip($langs, $this->object, 1);
                $this->tpl['help_suppliercode'] = $form->textwithpicto('', $s, 1);
                $this->object->LoadSupplierCateg();
                $this->tpl['suppliercategory'] = $this->object->SupplierCategories;
            }
            // Zip
            $this->tpl['select_zip'] = $formcompany->select_ziptown($this->object->zip, 'zipcode', array('town', 'selectcountry_id', 'state_id'), 6);
            // Town
            $this->tpl['select_town'] = $formcompany->select_ziptown($this->object->town, 'town', array('zipcode', 'selectcountry_id', 'state_id'));
            // Country
            $this->object->country_id = $this->object->country_id ? $this->object->country_id : $mysoc->country_id;
            $this->object->country_code = $this->object->country_code ? $this->object->country_code : $mysoc->country_code;
            $this->tpl['select_country'] = $form->select_country($this->object->country_id, 'country_id');
            $countrynotdefined = $langs->trans("ErrorSetACountryFirst") . ' (' . $langs->trans("SeeAbove") . ')';
            if ($user->admin) {
                $this->tpl['info_admin'] = info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
            }
            // State
            if ($this->object->country_id) {
                $this->tpl['select_state'] = $formcompany->select_state($this->object->state_id, $this->object->country_code);
            } else {
                $this->tpl['select_state'] = $countrynotdefined;
            }
            // Language
            if (!empty($conf->global->MAIN_MULTILANGS)) {
                $this->tpl['select_lang'] = $formadmin->select_language($this->object->default_lang ? $this->object->default_lang : $conf->global->MAIN_LANG_DEFAULT, 'default_lang', 0, 0, 1);
            }
            // VAT
            $this->tpl['yn_assujtva'] = $form->selectyesno('assujtva_value', $this->tpl['tva_assuj'], 1);
            // Assujeti par defaut en creation
            // Select users
            $this->tpl['select_users'] = $form->select_dolusers($this->object->commercial_id, 'commercial_id', 1);
            // Local Tax
            // TODO mettre dans une classe propre au pays
            if ($mysoc->country_code == 'ES') {
                $this->tpl['localtax'] = '';
                if ($mysoc->localtax1_assuj == "1" && $mysoc->localtax2_assuj == "1") {
                    $this->tpl['localtax'] .= '<tr><td>' . $langs->trans("LocalTax1IsUsedES") . '</td><td>';
                    $this->tpl['localtax'] .= $form->selectyesno('localtax1assuj_value', $this->object->localtax1_assuj, 1);
                    $this->tpl['localtax'] .= '</td><td>' . $langs->trans("LocalTax2IsUsedES") . '</td><td>';
                    $this->tpl['localtax'] .= $form->selectyesno('localtax2assuj_value', $this->object->localtax1_assuj, 1);
                    $this->tpl['localtax'] .= '</td></tr>';
                } elseif ($mysoc->localtax1_assuj == "1") {
                    $this->tpl['localtax'] .= '<tr><td>' . $langs->trans("LocalTax1IsUsedES") . '</td><td colspan="3">';
                    $this->tpl['localtax'] .= $form->selectyesno('localtax1assuj_value', $this->object->localtax1_assuj, 1);
                    $this->tpl['localtax'] .= '</td><tr>';
                } elseif ($mysoc->localtax2_assuj == "1") {
                    $this->tpl['localtax'] .= '<tr><td>' . $langs->trans("LocalTax2IsUsedES") . '</td><td colspan="3">';
                    $this->tpl['localtax'] .= $form->selectyesno('localtax2assuj_value', $this->object->localtax1_assuj, 1);
                    $this->tpl['localtax'] .= '</td><tr>';
                }
            }
        } else {
            $head = societe_prepare_head($this->object);
            $this->tpl['showhead'] = dol_get_fiche_head($head, 'card', '', 0, 'company');
            $this->tpl['showend'] = dol_get_fiche_end();
            $this->tpl['showrefnav'] = $form->showrefnav($this->object, 'socid', '', $user->societe_id ? 0 : 1, 'rowid', 'nom');
            $this->tpl['checkcustomercode'] = $this->object->check_codeclient();
            $this->tpl['checksuppliercode'] = $this->object->check_codefournisseur();
            $this->tpl['address'] = dol_nl2br($this->object->address);
            $img = picto_from_langcode($this->object->country_code);
            if ($this->object->isInEEC()) {
                $this->tpl['country'] = $form->textwithpicto(($img ? $img . ' ' : '') . $this->object->country, $langs->trans("CountryIsInEEC"), 1, 0);
            }
            $this->tpl['country'] = ($img ? $img . ' ' : '') . $this->object->country;
            $this->tpl['phone'] = dol_print_phone($this->object->phone, $this->object->country_code, 0, $this->object->id, 'AC_TEL');
            $this->tpl['fax'] = dol_print_phone($this->object->fax, $this->object->country_code, 0, $this->object->id, 'AC_FAX');
            $this->tpl['email'] = dol_print_email($this->object->email, 0, $this->object->id, 'AC_EMAIL');
            $this->tpl['url'] = dol_print_url($this->object->url);
            $this->tpl['tva_assuj'] = yn($this->object->tva_assuj);
            // Third party type
            $arr = $formcompany->typent_array(1);
            $this->tpl['typent'] = $arr[$this->object->typent_code];
            if (!empty($conf->global->MAIN_MULTILANGS)) {
                require_once DOL_DOCUMENT_ROOT . '/core/lib/functions2.lib.php';
                //$s=picto_from_langcode($this->default_lang);
                //print ($s?$s.' ':'');
                $langs->load("languages");
                $this->tpl['default_lang'] = $this->default_lang ? $langs->trans('Language_' . $this->object->default_lang) : '';
            }
            $this->tpl['image_edit'] = img_edit();
            $this->tpl['display_rib'] = $this->object->display_rib();
            // Sales representatives
            $this->tpl['sales_representatives'] = '';
            $listsalesrepresentatives = $this->object->getSalesRepresentatives($user);
            $nbofsalesrepresentative = count($listsalesrepresentatives);
            if ($nbofsalesrepresentative > 3) {
                $this->tpl['sales_representatives'] .= '<a href="' . DOL_URL_ROOT . '/societe/commerciaux.php?socid=' . $this->object->id . '">';
                $this->tpl['sales_representatives'] .= $nbofsalesrepresentative;
                $this->tpl['sales_representatives'] .= '</a>';
            } else {
                if ($nbofsalesrepresentative > 0) {
                    $userstatic = new User($this->db);
                    $i = 0;
                    foreach ($listsalesrepresentatives as $val) {
                        $userstatic->id = $val['id'];
                        $userstatic->lastname = $val['name'];
                        $userstatic->firstname = $val['firstname'];
                        $this->tpl['sales_representatives'] .= $userstatic->getNomUrl(1);
                        $i++;
                        if ($i < $nbofsalesrepresentative) {
                            $this->tpl['sales_representatives'] .= ', ';
                        }
                    }
                } else {
                    $this->tpl['sales_representatives'] .= $langs->trans("NoSalesRepresentativeAffected");
                }
            }
            // Linked member
            if (!empty($conf->adherent->enabled)) {
                $langs->load("members");
                $adh = new Adherent($this->db);
                $result = $adh->fetch('', '', $this->object->id);
                if ($result > 0) {
                    $adh->ref = $adh->getFullName($langs);
                    $this->tpl['linked_member'] = $adh->getNomUrl(1);
                } else {
                    $this->tpl['linked_member'] = $langs->trans("ThirdpartyNotLinkedToMember");
                }
            }
            // Local Tax
            // TODO mettre dans une classe propre au pays
            if ($mysoc->country_code == 'ES') {
                $this->tpl['localtax'] = '';
                if ($mysoc->localtax1_assuj == "1" && $mysoc->localtax2_assuj == "1") {
                    $this->tpl['localtax'] .= '<tr><td>' . $langs->trans("LocalTax1IsUsedES") . '</td>';
                    $this->tpl['localtax'] .= '<td>' . yn($this->object->localtax1_assuj) . '</td>';
                    $this->tpl['localtax'] .= '<td>' . $langs->trans("LocalTax2IsUsedES") . '</td>';
                    $this->tpl['localtax'] .= '<td>' . yn($this->object->localtax2_assuj) . '</td></tr>';
                } elseif ($mysoc->localtax1_assuj == "1") {
                    $this->tpl['localtax'] .= '<tr><td>' . $langs->trans("LocalTax1IsUsedES") . '</td>';
                    $this->tpl['localtax'] .= '<td colspan="3">' . yn($this->object->localtax1_assuj) . '</td></tr>';
                } elseif ($mysoc->localtax2_assuj == "1") {
                    $this->tpl['localtax'] .= '<tr><td>' . $langs->trans("LocalTax2IsUsedES") . '</td>';
                    $this->tpl['localtax'] .= '<td colspan="3">' . yn($this->object->localtax2_assuj) . '</td></tr>';
                }
            }
        }
    }
 $member->morphy = 'phy';
 $member->photo = '';
 $member->public = 1;
 $member->birth = dol_stringtotime($ldapuser[$conf->global->LDAP_FIELD_BIRTHDATE]);
 $member->statut = -1;
 if (isset($ldapuser[$conf->global->LDAP_FIELD_MEMBER_STATUS])) {
     $member->datec = dol_stringtotime($ldapuser[$conf->global->LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_DATE]);
     $member->datevalid = dol_stringtotime($ldapuser[$conf->global->LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_DATE]);
     $member->statut = $ldapuser[$conf->global->LDAP_FIELD_MEMBER_STATUS];
 }
 //if ($member->statut > 1) $member->statut=1;
 //print_r($ldapuser);
 // Propriete type membre
 $member->typeid = $typeid;
 // Creation membre
 print $langs->transnoentities("MemberCreate") . ' # ' . $key . ': login='******', fullname=' . $member->getFullName($langs);
 print ', datec=' . $member->datec;
 $member_id = $member->create($user);
 if ($member_id > 0) {
     print ' --> Created member id=' . $member_id . ' login='******' --> ' . $member->error;
 }
 print "\n";
 //print_r($member);
 $datefirst = '';
 if ($conf->global->LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_DATE) {
     $datefirst = dol_stringtotime($ldapuser[$conf->global->LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_DATE]);
     $pricefirst = price2num($ldapuser[$conf->global->LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_AMOUNT]);
 }
示例#16
0
 }
 $sql .= " ORDER BY d.rowid ASC";
 dol_syslog("Search members", LOG_DEBUG);
 $result = $db->query($sql);
 if ($result) {
     $num = $db->num_rows($result);
     $i = 0;
     while ($i < $num) {
         $objp = $db->fetch_object($result);
         if ($objp->country == '-') {
             $objp->country = '';
         }
         $adherentstatic->lastname = $objp->lastname;
         $adherentstatic->firstname = $objp->firstname;
         // List of values to scan for a replacement
         $substitutionarray = array('%ID%' => $objp->rowid, '%LOGIN%' => $objp->login, '%FIRSTNAME%' => $objp->firstname, '%LASTNAME%' => $objp->lastname, '%FULLNAME%' => $adherentstatic->getFullName($langs), '%COMPANY%' => $objp->company, '%ADDRESS%' => $objp->address, '%ZIP%' => $objp->zip, '%TOWN%' => $objp->town, '%COUNTRY%' => $objp->country, '%COUNTRY_CODE%' => $objp->country_code, '%EMAIL%' => $objp->email, '%BIRTH%' => dol_print_date($objp->birth, 'day'), '%TYPE%' => $objp->type, '%YEAR%' => $year, '%MONTH%' => $month, '%DAY%' => $day, '%DOL_MAIN_URL_ROOT%' => DOL_MAIN_URL_ROOT, '%SERVER%' => "http://" . $_SERVER["SERVER_NAME"] . "/");
         complete_substitutions_array($substitutionarray, $langs);
         // For business cards
         if (empty($mode) || $mode == 'card' || $mode == 'cardlogin') {
             $textleft = make_substitutions($conf->global->ADHERENT_CARD_TEXT, $substitutionarray);
             $textheader = make_substitutions($conf->global->ADHERENT_CARD_HEADER_TEXT, $substitutionarray);
             $textfooter = make_substitutions($conf->global->ADHERENT_CARD_FOOTER_TEXT, $substitutionarray);
             $textright = make_substitutions($conf->global->ADHERENT_CARD_TEXT_RIGHT, $substitutionarray);
             if (is_numeric($foruserid) || $foruserlogin) {
                 for ($j = 0; $j < 100; $j++) {
                     $arrayofmembers[] = array('textleft' => $textleft, 'textheader' => $textheader, 'textfooter' => $textfooter, 'textright' => $textright, 'id' => $objp->rowid, 'photo' => $objp->photo);
                 }
             } else {
                 $arrayofmembers[] = array('textleft' => $textleft, 'textheader' => $textheader, 'textfooter' => $textfooter, 'textright' => $textright, 'id' => $objp->rowid, 'photo' => $objp->photo);
             }
         }
if ($action == 'setsocid') {
    $error = 0;
    if (!$error) {
        if (GETPOST('socid', 'int') != $object->fk_soc) {
            $sql = "SELECT rowid FROM " . MAIN_DB_PREFIX . "adherent";
            $sql .= " WHERE fk_soc = '" . GETPOST('socid', 'int') . "'";
            $resql = $db->query($sql);
            if ($resql) {
                $obj = $db->fetch_object($resql);
                if ($obj && $obj->rowid > 0) {
                    $othermember = new Adherent($db);
                    $othermember->fetch($obj->rowid);
                    $thirdparty = new Societe($db);
                    $thirdparty->fetch(GETPOST('socid', 'int'));
                    $error++;
                    $mesg = '<div class="error">' . $langs->trans("ErrorMemberIsAlreadyLinkedToThisThirdParty", $othermember->getFullName($langs), $othermember->login, $thirdparty->name) . '</div>';
                }
            }
            if (!$error) {
                $result = $object->setThirdPartyId(GETPOST('socid', 'int'));
                if ($result < 0) {
                    dol_print_error('', $object->error);
                }
                $_POST['action'] = '';
                $action = '';
            }
        }
    }
}
if ($user->rights->adherent->cotisation->creer && $action == 'cotisation' && !$_POST["cancel"]) {
    $error = 0;
示例#18
0
文件: soc.php 项目: nrjacker4/crm-php
        }

        // Sales representative
        include(DOL_DOCUMENT_ROOT.'/societe/tpl/linesalesrepresentative.tpl.php');

        // Module Adherent
        if ($conf->adherent->enabled)
        {
            $langs->load("members");
            print '<tr><td width="25%" valign="top">'.$langs->trans("LinkedToDolibarrMember").'</td>';
            print '<td colspan="3">';
            $adh=new Adherent($db);
            $result=$adh->fetch('','',$object->id);
            if ($result > 0)
            {
                $adh->ref=$adh->getFullName($langs);
                print $adh->getNomUrl(1);
            }
            else
            {
                print $langs->trans("UserNotLinkedToMember");
            }
            print '</td>';
            print "</tr>\n";
        }

        print '</table>';

        dol_fiche_end();

示例#19
0
文件: liste.php 项目: netors/dolibarr
 print '&nbsp; ';
 print '<input type="image" class="liste_titre" src="' . DOL_URL_ROOT . '/theme/' . $conf->theme . '/img/searchclear.png" name="button_removefilter" value="' . dol_escape_htmltag($langs->trans("RemoveFilter")) . '" title="' . dol_escape_htmltag($langs->trans("RemoveFilter")) . '">';
 print '</td>';
 print "</tr>\n";
 print '</form>';
 $var = True;
 while ($i < $num && $i < $conf->liste_limit) {
     $objp = $db->fetch_object($resql);
     $datefin = $db->jdate($objp->datefin);
     // Nom
     $var = !$var;
     print "<tr " . $bc[$var] . ">";
     $memberstatic->nom = $objp->nom;
     $memberstatic->prenom = $objp->prenom;
     if ($objp->societe != '') {
         print "<td><a href=\"fiche.php?rowid={$objp->rowid}\">" . img_object($langs->trans("ShowMember"), "user") . ' ' . dol_trunc($memberstatic->getFullName($langs)) . " / " . dol_trunc($objp->societe, 12) . "</a></td>\n";
     } else {
         print "<td><a href=\"fiche.php?rowid={$objp->rowid}\">" . img_object($langs->trans("ShowMember"), "user") . ' ' . dol_trunc($memberstatic->getFullName($langs)) . "</a></td>\n";
     }
     // Login
     print "<td>" . $objp->login . "</td>\n";
     // Type
     print '<td nowrap="nowrap">';
     $membertypestatic->id = $objp->type_id;
     $membertypestatic->libelle = $objp->type;
     print $membertypestatic->getNomUrl(1, 12);
     print '</td>';
     // Moral/Physique
     print "<td>" . $memberstatic->getmorphylib($objp->morphy) . "</td>\n";
     // EMail
     print "<td>" . dol_print_email($objp->email, 0, 0, 1) . "</td>\n";