/**
	 * Return all leads grouped by status
	 *
	 * @param  int             $limit Limit results
	 * @return array|int       Array with value or -1 if error
	 * @throws Exception
	 */
	function getAllProjectByStatus($limit = 5)
	{
		global $conf, $user, $langs;

		$datay = array ();

		$sql = "SELECT";
		$sql .= " SUM(t.opp_amount), t.fk_opp_status, cls.code, cls.label";
		$sql .= " FROM " . MAIN_DB_PREFIX . "projet as t, ".MAIN_DB_PREFIX."c_lead_status as cls";
		$sql .= $this->buildWhere();
		$sql .= " AND t.fk_opp_status = cls.rowid";
		$sql .= " AND t.fk_statut <> 0";     // We want historic also, so all projects
		$sql .= " GROUP BY t.fk_opp_status, cls.code, cls.label";

		$result = array ();
		$res = array ();

		dol_syslog(get_class($this) . '::' . __METHOD__ . "", LOG_DEBUG);
		$resql = $this->db->query($sql);
		if ($resql) {
			$num = $this->db->num_rows($resql);
			$i = 0;
			$other = 0;
			while ( $i < $num ) {
				$row = $this->db->fetch_row($resql);
				if ($i < $limit || $num == $limit)
				{
				    $label = (($langs->trans("OppStatus".$row[2]) != "OppStatus".$row[2]) ? $langs->trans("OppStatus".$row[2]) : $row[2]);
					$result[$i] = array(
						$label. ' (' . price(price2num($row[0], 'MT'), 1, $langs, 1, -1, -1, $conf->currency) . ')',
						$row[0]
					);
				}
				else
					$other += $row[1];
				$i++;
			}
			if ($num > $limit)
				$result[$i] = array (
						$langs->transnoentitiesnoconv("Other"),
						$other
				);
			$this->db->free($resql);
		} else {
			$this->error = "Error " . $this->db->lasterror();
			dol_syslog(get_class($this) . '::' . __METHOD__ . ' ' . $this->error, LOG_ERR);
			return -1;
		}

		return $result;
	}
function _updateLine($objectid, $objectelement, $lineid, $column, $value)
{
    global $db, $conf, $langs;
    ${$column} = price2num($value);
    $Tab = array();
    $o = new $objectelement($db);
    $o->fetch($objectid);
    $find = false;
    foreach ($o->lines as &$line) {
        if ($line->id == $lineid || $line->rowid == $lineid) {
            $find = true;
            break;
        }
    }
    if ($find) {
        if (is_null($qty)) {
            $qty = $line->qty;
        }
        if (is_null($price)) {
            $price = $line->subprice;
        }
        if (is_null($remise_percent)) {
            $remise_percent = $line->remise_percent;
        }
        if ($objectelement == 'facture') {
            $res = $o->updateline($lineid, $line->desc, $price, $qty, $remise_percent, $line->date_start, $line->date_end, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, 'HT', $line->info_bits, $line->product_type, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->situation_percent, $line->fk_unit);
            $total_ht = $o->line->total_ht;
            $uttc = $o->line->subprice + $o->line->subprice * $o->line->tva_tx / 100;
        } else {
            if ($objectelement == 'commande') {
                $res = $o->updateline($lineid, $line->desc, $price, $qty, $remise_percent, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, 'HT', $line->info_bits, $line->date_start, $line->date_end, $line->product_type, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->fk_unit);
                $total_ht = $o->line->total_ht;
                $uttc = $o->line->subprice + $o->line->subprice * $o->line->tva_tx / 100;
            } else {
                $res = $o->updateline($lineid, $price, $qty, $remise_percent, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, $line->desc, 'HT', $line->info_bits, $line->special_code, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->product_type, $line->date_start, $line->date_end, $line->array_options, $line->fk_unit);
                $total_ht = $o->line->total_ht;
                $uttc = $o->line->subprice + $o->line->subprice * $o->line->tva_tx / 100;
            }
        }
        if ($res > 0) {
            $Tab = array('total_ht' => price($total_ht), 'qty' => $qty, 'price' => price($price), 'remise_percent' => $remise_percent, 'uttc' => $uttc);
        } else {
            $Tab = array('error' => 'updateFailed', 'msg' => $o->error);
        }
    } else {
        $Tab = array('error' => 'noline');
    }
    return $Tab;
}
Esempio n. 3
0
        }
        print '<td align="right">' . price(price2num($subtot_paye_total_ht, 'MT')) . '</td>';
        print '<td class="nowrap" align="right">' . price(price2num($subtot_paye_vat, 'MT')) . '</td>';
        print '</tr>';
    }
    if (count($x_paye) == 0) {
        print '<tr class="liste_total">';
        print '<td>&nbsp;</td>';
        print '<td align="right">' . $langs->trans("Total") . ':</td>';
        if ($modetax == 0) {
            print '<td class="nowrap" align="right">&nbsp;</td>';
            print '<td align="right">&nbsp;</td>';
        }
        print '<td align="right">' . price(price2num(0, 'MT')) . '</td>';
        print '<td class="nowrap" align="right">' . price(price2num(0, 'MT')) . '</td>';
        print '</tr>';
    }
    print '</table>';
    // Total to pay
    print '<br><br>';
    print '<table class="noborder" width="100%">';
    $diff = $x_coll_sum - $x_paye_sum;
    print '<tr class="liste_total">';
    print '<td class="liste_total" colspan="' . $span . '">' . $langs->trans("TotalToPay") . ($q ? ', ' . $langs->trans("Quadri") . ' ' . $q : '') . '</td>';
    print '<td class="liste_total nowrap" align="right"><b>' . price(price2num($diff, 'MT')) . "</b></td>\n";
    print "</tr>\n";
    $i++;
}
echo '</table>';
llxFooter();
$db->close();
Esempio n. 4
0
print '<td>' . $langs->trans("Subscriptions") . '</td>';
print '<td align="right">' . $langs->trans("Number") . '</td>';
print '<td align="right">' . $langs->trans("AmountTotal") . '</td>';
print '<td align="right">' . $langs->trans("AmountAverage") . '</td>';
print "</tr>\n";
$var = true;
krsort($Total);
foreach ($Total as $key => $value) {
    $var = !$var;
    print "<tr {$bc[$var]}>";
    print "<td><a href=\"adherent/cotisations.php?date_select={$key}\">{$key}</a></td>";
    print "<td align=\"right\">" . $Number[$key] . "</td>";
    print "<td align=\"right\">" . price($value) . "</td>";
    print "<td align=\"right\">" . price(price2num($value / $Number[$key], 'MT')) . "</td>";
    $numb += $Number[$key];
    $tot += $value;
    print "</tr>\n";
}
// Total
print '<tr class="liste_total">';
print '<td>' . $langs->trans("Total") . '</td>';
print "<td align=\"right\">" . $numb . "</td>";
print '<td align="right">' . price($tot) . "</td>";
print "<td align=\"right\">" . price(price2num($numb > 0 ? $tot / $numb : 0, 'MT')) . "</td>";
print "</tr>\n";
print "</table><br>\n";
print '</td></tr>';
print '</table>';
print dol_fiche_end();
llxFooter();
$db->close();
    // Delete price by customer
    $prodcustprice->id = GETPOST('lineid');
    $result = $prodcustprice->delete($user);
    if ($result < 0) {
        setEventMessage($prodcustprice->error, 'mesgs');
    } else {
        setEventMessage($langs->trans('Delete'), 'errors');
    }
    $action = '';
}
if ($action == 'update_customer_price_confirm' && !$_POST["cancel"] && ($user->rights->produit->creer || $user->rights->service->creer)) {
    $prodcustprice->fetch(GETPOST('lineid', 'int'));
    $update_child_soc = GETPOST('updatechildprice');
    // update price by customer
    $prodcustprice->price = price2num(GETPOST("price"), 'MU');
    $prodcustprice->price_min = price2num(GETPOST("price_min"), 'MU');
    $prodcustprice->price_base_type = GETPOST("price_base_type", 'alpha');
    $prodcustprice->tva_tx = str_replace('*', '', GETPOST("tva_tx"));
    $prodcustprice->recuperableonly = preg_match('/\\*/', GETPOST("tva_tx")) ? 1 : 0;
    $result = $prodcustprice->update($user, 0, $update_child_soc);
    if ($result < 0) {
        setEventMessage($prodcustprice->error, 'errors');
    } else {
        setEventMessage($langs->trans('Save'), 'mesgs');
    }
    $action = '';
}
/*
 * View
 */
$form = new Form($db);
 /**
  * Update object into database
  *
  * @param User $user that modifies
  * @param int $notrigger triggers after, 1=disable triggers
  * @param int $forceupdateaffiliate update price on each soc child
  * @return int <0 if KO, >0 if OK
  */
 function update($user = 0, $notrigger = 0, $forceupdateaffiliate = 0)
 {
     global $conf, $langs;
     $error = 0;
     // Clean parameters
     if (isset($this->entity)) {
         $this->entity = trim($this->entity);
     }
     if (isset($this->fk_product)) {
         $this->fk_product = trim($this->fk_product);
     }
     if (isset($this->fk_soc)) {
         $this->fk_soc = trim($this->fk_soc);
     }
     if (isset($this->price)) {
         $this->price = trim($this->price);
     }
     if (isset($this->price_ttc)) {
         $this->price_ttc = trim($this->price_ttc);
     }
     if (isset($this->price_min)) {
         $this->price_min = trim($this->price_min);
     }
     if (isset($this->price_min_ttc)) {
         $this->price_min_ttc = trim($this->price_min_ttc);
     }
     if (isset($this->price_base_type)) {
         $this->price_base_type = trim($this->price_base_type);
     }
     if (isset($this->tva_tx)) {
         $this->tva_tx = trim($this->tva_tx);
     }
     if (isset($this->recuperableonly)) {
         $this->recuperableonly = trim($this->recuperableonly);
     }
     if (isset($this->localtax1_tx)) {
         $this->localtax1_tx = trim($this->localtax1_tx);
     }
     if (isset($this->localtax2_tx)) {
         $this->localtax2_tx = trim($this->localtax2_tx);
     }
     if (isset($this->fk_user)) {
         $this->fk_user = trim($this->fk_user);
     }
     if (isset($this->import_key)) {
         $this->import_key = trim($this->import_key);
     }
     // Check parameters
     // Put here code to add a control on parameters values
     if ($this->price != '' || $this->price == 0) {
         if ($this->price_base_type == 'TTC') {
             $this->price_ttc = price2num($this->price, 'MU');
             $this->price = price2num($this->price) / (1 + $this->tva_tx / 100);
             $this->price = price2num($this->price, 'MU');
             if ($this->price_min != '' || $this->price_min == 0) {
                 $this->price_min_ttc = price2num($this->price_min, 'MU');
                 $this->price_min = price2num($this->price_min) / (1 + $this->tva_tx / 100);
                 $this->price_min = price2num($this->price_min, 'MU');
             } else {
                 $this->price_min = 0;
                 $this->price_min_ttc = 0;
             }
         } else {
             $this->price = price2num($this->price, 'MU');
             $this->price_ttc = $this->recuperableonly != 1 ? price2num($this->price) * (1 + $this->tva_tx / 100) : $this->price;
             $this->price_ttc = price2num($this->price_ttc, 'MU');
             if ($this->price_min != '' || $this->price_min == 0) {
                 $this->price_min = price2num($this->price_min, 'MU');
                 $this->price_min_ttc = price2num($this->price_min) * (1 + $this->tva_tx / 100);
                 $this->price_min_ttc = price2num($this->price_min_ttc, 'MU');
                 // print 'X'.$newminprice.'-'.$price_min;
             } else {
                 $this->price_min = 0;
                 $this->price_min_ttc = 0;
             }
         }
     }
     // Do a copy of current record into log table
     // Insert request
     $sql = "INSERT INTO " . MAIN_DB_PREFIX . "product_customer_price_log(";
     $sql .= "entity,";
     $sql .= "datec,";
     $sql .= "fk_product,";
     $sql .= "fk_soc,";
     $sql .= "price,";
     $sql .= "price_ttc,";
     $sql .= "price_min,";
     $sql .= "price_min_ttc,";
     $sql .= "price_base_type,";
     $sql .= "tva_tx,";
     $sql .= "recuperableonly,";
     $sql .= "localtax1_tx,";
     $sql .= "localtax2_tx,";
     $sql .= "fk_user,";
     $sql .= "import_key";
     $sql .= ") \t\t";
     $sql .= "SELECT";
     $sql .= " t.entity,";
     $sql .= " t.datec,";
     $sql .= " t.fk_product,";
     $sql .= " t.fk_soc,";
     $sql .= " t.price,";
     $sql .= " t.price_ttc,";
     $sql .= " t.price_min,";
     $sql .= " t.price_min_ttc,";
     $sql .= " t.price_base_type,";
     $sql .= " t.tva_tx,";
     $sql .= " t.recuperableonly,";
     $sql .= " t.localtax1_tx,";
     $sql .= " t.localtax2_tx,";
     $sql .= " t.fk_user,";
     $sql .= " t.import_key";
     $sql .= " FROM " . MAIN_DB_PREFIX . "product_customer_price as t";
     $sql .= " WHERE t.rowid = " . $this->id;
     $this->db->begin();
     dol_syslog(get_class($this) . "::update", LOG_DEBUG);
     $resql = $this->db->query($sql);
     if (!$resql) {
         $error++;
         $this->errors[] = "Error " . $this->db->lasterror();
     }
     // Update request
     $sql = "UPDATE " . MAIN_DB_PREFIX . "product_customer_price SET";
     $sql .= " entity=" . $conf->entity . ",";
     $sql .= " datec='" . $this->db->idate(dol_now()) . "',";
     $sql .= " tms=" . (dol_strlen($this->tms) != 0 ? "'" . $this->db->idate($this->tms) . "'" : 'null') . ",";
     $sql .= " fk_product=" . (isset($this->fk_product) ? $this->fk_product : "null") . ",";
     $sql .= " fk_soc=" . (isset($this->fk_soc) ? $this->fk_soc : "null") . ",";
     $sql .= " price=" . (isset($this->price) ? $this->price : "null") . ",";
     $sql .= " price_ttc=" . (isset($this->price_ttc) ? $this->price_ttc : "null") . ",";
     $sql .= " price_min=" . (isset($this->price_min) ? $this->price_min : "null") . ",";
     $sql .= " price_min_ttc=" . (isset($this->price_min_ttc) ? $this->price_min_ttc : "null") . ",";
     $sql .= " price_base_type=" . (isset($this->price_base_type) ? "'" . $this->db->escape($this->price_base_type) . "'" : "null") . ",";
     $sql .= " tva_tx=" . (isset($this->tva_tx) ? $this->tva_tx : "null") . ",";
     $sql .= " recuperableonly=" . (isset($this->recuperableonly) ? $this->recuperableonly : "null") . ",";
     $sql .= " localtax1_tx=" . (isset($this->localtax1_tx) ? $this->localtax1_tx : "null") . ",";
     $sql .= " localtax2_tx=" . (isset($this->localtax2_tx) ? $this->localtax2_tx : "null") . ",";
     $sql .= " fk_user="******",";
     $sql .= " import_key=" . (isset($this->import_key) ? "'" . $this->db->escape($this->import_key) . "'" : "null") . "";
     $sql .= " WHERE rowid=" . $this->id;
     dol_syslog(get_class($this) . "::update", LOG_DEBUG);
     $resql = $this->db->query($sql);
     if (!$resql) {
         $error++;
         $this->errors[] = "Error " . $this->db->lasterror();
     }
     if (!$error) {
         if (!$notrigger) {
             // Uncomment this and change MYOBJECT to your own tag if you
             // want this action calls a trigger.
             // // Call triggers
             // include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
             // $interface=new Interfaces($this->db);
             // $result=$interface->run_triggers('MYOBJECT_MODIFY',$this,$user,$langs,$conf);
             // if ($result < 0) { $error++; $this->errors=$interface->errors; }
             // // End call triggers
         }
     }
     if (!$error) {
         $result = $this->setPriceOnAffiliateThirdparty($user, $forceupdateaffiliate);
         if ($result < 0) {
             $error++;
         }
     }
     // Commit or rollback
     if ($error) {
         foreach ($this->errors as $errmsg) {
             dol_syslog(get_class($this) . "::update " . $errmsg, LOG_ERR);
             $this->error .= $this->error ? ', ' . $errmsg : $errmsg;
         }
         $this->db->rollback();
         return -1 * $error;
     } else {
         $this->db->commit();
         return 1;
     }
 }
Esempio n. 7
0
    $resql = $db->query($sql);
    if ($resql) {
        print '<table class="noborder" width="100%">';
        $tag = !$tag;
        print '<tr class="liste_titre">';
        print '<td width="160">' . $langs->trans("Date") . '</td>';
        print '<td width="160" align="center">' . $langs->trans("CustomerRelativeDiscountShort") . '</td>';
        print '<td align="left">' . $langs->trans("NoteReason") . '</td>';
        print '<td align="center">' . $langs->trans("User") . '</td>';
        print '</tr>';
        $i = 0;
        $num = $db->num_rows($resql);
        while ($i < $num) {
            $obj = $db->fetch_object($resql);
            $tag = !$tag;
            print '<tr ' . $bc[$tag] . '>';
            print '<td>' . dol_print_date($db->jdate($obj->dc), "dayhour") . '</td>';
            print '<td align="center">' . price2num($obj->remise_percent) . '%</td>';
            print '<td align="left">' . $obj->note . '</td>';
            print '<td align="center"><a href="' . DOL_URL_ROOT . '/user/card.php?id=' . $obj->user_id . '">' . img_object($langs->trans("ShowUser"), 'user') . ' ' . $obj->login . '</a></td>';
            print '</tr>';
            $i++;
        }
        $db->free($resql);
        print "</table>";
    } else {
        dol_print_error($db);
    }
}
$db->close();
llxFooter();
Esempio n. 8
0
 $result = $db->query($sql);
 if ($result) {
     $now = dol_now();
     $nows = dol_print_date($now, '%Y%m%d');
     //$form->load_cache_types_paiements();
     //$form->cache_types_paiements
     $var = true;
     $num = $db->num_rows($result);
     $i = 0;
     $total = 0;
     $sep = -1;
     $total_deb = 0;
     $total_cred = 0;
     while ($i < $num) {
         $objp = $db->fetch_object($result);
         $total = price2num($total + $objp->amount, 'MT');
         if ($i >= $viewline * ($totalPages - $page - 1)) {
             $var = !$var;
             // Is it a transaction in future ?
             $dos = dol_print_date($db->jdate($objp->do), '%Y%m%d');
             //print "dos=".$dos." nows=".$nows;
             if ($dos < $nows) {
                 $sep = 0;
             }
             // 0 means there was at least one line before current date
             if ($dos > $nows && !$sep) {
                 $sep = 1;
                 print '<tr class="liste_total"><td colspan="8">';
                 print $langs->trans("CurrentBalance");
                 print '</td>';
                 print '<td align="right" class="nowrap"><b>' . price($total - $objp->amount) . '</b></td>';
Esempio n. 9
0
    $year = $val['year'];
    while ($year && $oldyear > $year + 1) {
        // If we have empty year
        $oldyear--;
        print '<tr height="24">';
        print '<td align="center"><a href="' . $_SERVER["PHP_SELF"] . '?year=' . $oldyear . '&amp;mode=' . $mode . '">' . $oldyear . '</a></td>';
        print '<td align="right">0</td>';
        print '<td align="right">0</td>';
        print '<td align="right">0</td>';
        print '</tr>';
    }
    print '<tr height="24">';
    print '<td align="center"><a href="' . $_SERVER["PHP_SELF"] . '?year=' . $year . '&amp;mode=' . $mode . '">' . $year . '</a></td>';
    print '<td align="right">' . $val['nb'] . '</td>';
    print '<td align="right">' . price(price2num($val['total'], 'MT'), 1) . '</td>';
    print '<td align="right">' . price(price2num($val['avg'], 'MT'), 1) . '</td>';
    print '</tr>';
    $oldyear = $year;
}
print '</table>';
print '</div><div class="fichetwothirdright"><div class="ficheaddleft">';
// Show graphs
print '<table class="border" width="100%"><tr valign="top"><td align="center">';
if ($mesg) {
    print $mesg;
} else {
    print $px1->show();
    print "<br>\n";
    print $px2->show();
    print "<br>\n";
    print $px3->show();
Esempio n. 10
0
    exit;
}
if ($action == 'add' && $_POST["cancel"] != $langs->trans("Cancel")) {
    $error = 0;
    $datep = dol_mktime(12, 0, 0, $_POST["datepmonth"], $_POST["datepday"], $_POST["datepyear"]);
    $datev = dol_mktime(12, 0, 0, $_POST["datevmonth"], $_POST["datevday"], $_POST["datevyear"]);
    $datesp = dol_mktime(12, 0, 0, $_POST["datespmonth"], $_POST["datespday"], $_POST["datespyear"]);
    $dateep = dol_mktime(12, 0, 0, $_POST["dateepmonth"], $_POST["dateepday"], $_POST["dateepyear"]);
    if (empty($datev)) {
        $datev = $datep;
    }
    $object->accountid = GETPOST("accountid", "int");
    $object->fk_user = GETPOST("fk_user", "int");
    $object->datev = $datev;
    $object->datep = $datep;
    $object->amount = price2num(GETPOST("amount"));
    $object->label = GETPOST("label");
    $object->datesp = $datesp;
    $object->dateep = $dateep;
    $object->note = GETPOST("note");
    $object->type_payment = GETPOST("paymenttype");
    $object->num_payment = GETPOST("num_payment");
    $object->fk_user_creat = $user->id;
    // Set user current salary as ref salaray for the payment
    $fuser = new User($db);
    $fuser->fetch(GETPOST("fk_user", "int"));
    $object->salary = $fuser->salary;
    if (empty($datep) || empty($datev) || empty($datesp) || empty($dateep)) {
        setEventMessage($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Date")), 'errors');
        $error++;
    }
Esempio n. 11
0
    /**
     *    	Add a discount for third party
     *    	@param      remise      Montant de la remise
     *    	@param      user        Utilisateur qui accorde la remise
     *    	@param      desc		Motif de l'avoir
     *      @param      tva_tx      VAT rate
     *		@return		int			<0 if KO, id or record if OK
     */
    function set_remise_except($remise, $user, $desc, $tva_tx=0)
    {
        global $langs;

        // Nettoyage des parametres
        $remise = price2num($remise);
        $desc = trim($desc);

        // Check parameters
        if (! $remise > 0)
        {
            $this->error=$langs->trans("ErrorWrongValueForParameter","1");
            return -1;
        }
        if (! $desc)
        {
            $this->error=$langs->trans("ErrorWrongValueForParameter","3");
            return -2;
        }

        if ($this->id)
        {
            require_once(DOL_DOCUMENT_ROOT.'/core/class/discount.class.php');

            $discount = new DiscountAbsolute($this->db);
            $discount->fk_soc=$this->id;
            $discount->amount_ht=price2num($remise,'MT');
            $discount->amount_tva=price2num($remise*$tva_tx/100,'MT');
            $discount->amount_ttc=price2num($discount->amount_ht+$discount->amount_tva,'MT');
            $discount->tva_tx=price2num($tva_tx,'MT');
            $discount->description=$desc;
            $result=$discount->create($user);
            if ($result > 0)
            {
                return $result;
            }
            else
            {
                $this->error=$discount->error;
                return -3;
            }
        }
        else return 0;
    }
Esempio n. 12
0
 /**
  * Update object into database
  *
  * @param User $user that modifies
  * @param int $notrigger triggers after, 1=disable triggers
  * @return int <0 if KO, >0 if OK
  */
 function update($user = null, $notrigger = 0)
 {
     global $conf, $langs;
     $error = 0;
     // Clean parameters
     if (isset($this->ref)) {
         $this->ref = trim($this->ref);
     }
     if (isset($this->ref_ext)) {
         $this->ref_ext = trim($this->ref_ext);
     }
     if (isset($this->ref_int)) {
         $this->ref_int = trim($this->ref_int);
     }
     if (isset($this->fk_c_status)) {
         $this->fk_c_status = trim($this->fk_c_status);
     }
     if (isset($this->fk_c_type)) {
         $this->fk_c_type = trim($this->fk_c_type);
     }
     if (isset($this->amount_prosp)) {
         $this->amount_prosp = trim($this->amount_prosp);
     }
     if (isset($this->fk_user_resp)) {
         $this->fk_user_resp = trim($this->fk_user_resp);
     }
     if (isset($this->description)) {
         $this->description = trim($this->description);
     }
     if (isset($this->fk_user_author)) {
         $this->fk_user_author = trim($this->fk_user_author);
     }
     if (isset($this->fk_user_mod)) {
         $this->fk_user_mod = trim($this->fk_user_mod);
     }
     if (isset($this->fk_soc)) {
         $this->fk_soc = trim($this->fk_soc);
     }
     if (isset($this->note_private)) {
         $this->note_private = trim($this->note_private);
     }
     if (isset($this->note_public)) {
         $this->note_public = trim($this->note_public);
     }
     // Check parameters
     // Put here code to add a control on parameters values
     if (!empty($conf->global->LEAD_FORCE_USE_THIRDPARTY)) {
         if (empty($this->fk_soc)) {
             $error++;
             $this->errors[] = $langs->trans('ErrorFieldRequired', $langs->transnoentities('Customer'));
         }
     }
     if (empty($this->ref_int)) {
         $error++;
         $this->errors[] = $langs->trans('ErrorFieldRequired', $langs->transnoentities('LeadRefInt'));
     }
     if (empty($this->fk_user_resp)) {
         $error++;
         $this->errors[] = $langs->trans('ErrorFieldRequired', $langs->transnoentities('LeadCommercial'));
     }
     if (empty($this->fk_c_status)) {
         $error++;
         $this->errors[] = $langs->trans('ErrorFieldRequired', $langs->transnoentities('LeadStatus'));
     }
     if (empty($this->fk_c_type)) {
         $error++;
         $this->errors[] = $langs->trans('ErrorFieldRequired', $langs->transnoentities('LeadType'));
     }
     if (!isset($this->amount_prosp)) {
         $error++;
         $this->errors[] = $langs->trans('ErrorFieldRequired', $langs->transnoentities('LeadAmountGuess'));
     }
     if (dol_strlen($this->date_closure) == 0) {
         $error++;
         $this->errors[] = $langs->trans('ErrorFieldRequired', $langs->transnoentities('LeadDeadLine'));
     }
     if (!$error) {
         // Update request
         $sql = "UPDATE " . MAIN_DB_PREFIX . "lead SET";
         $sql .= " ref=" . (isset($this->ref) ? "'" . $this->db->escape($this->ref) . "'" : "null") . ",";
         $sql .= " ref_ext=" . (isset($this->ref_ext) ? "'" . $this->db->escape($this->ref_ext) . "'" : "null") . ",";
         $sql .= " ref_int=" . (isset($this->ref_int) ? "'" . $this->db->escape($this->ref_int) . "'" : "null") . ",";
         $sql .= " fk_c_status=" . (isset($this->fk_c_status) ? $this->fk_c_status : "null") . ",";
         $sql .= " fk_c_type=" . (isset($this->fk_c_type) ? $this->fk_c_type : "null") . ",";
         $sql .= " fk_soc=" . (isset($this->fk_soc) ? $this->fk_soc : "null") . ",";
         $sql .= " date_closure=" . (dol_strlen($this->date_closure) != 0 ? "'" . $this->db->idate($this->date_closure) . "'" : 'null') . ",";
         $sql .= " amount_prosp=" . (isset($this->amount_prosp) ? "'" . price2num($this->amount_prosp) . "'" : "null") . ",";
         $sql .= " fk_user_resp=" . (isset($this->fk_user_resp) ? $this->fk_user_resp : "null") . ",";
         $sql .= " description=" . (!empty($this->description) ? "'" . $this->db->escape($this->description) . "'" : "null") . ",";
         $sql .= " note_private=" . (!empty($this->note_private) ? "'" . $this->db->escape($this->note_private) . "'" : "null") . ",";
         $sql .= " note_public=" . (!empty($this->note_public) ? "'" . $this->db->escape($this->note_public) . "'" : "null") . ",";
         $sql .= " fk_user_mod=" . $user->id . ",";
         $sql .= " tms='" . $this->db->idate(dol_now()) . "'";
         $sql .= " WHERE rowid=" . $this->id;
         $this->db->begin();
         dol_syslog(get_class($this) . "::update sql=" . $sql, LOG_DEBUG);
         $resql = $this->db->query($sql);
         if (!$resql) {
             $error++;
             $this->errors[] = "Error " . $this->db->lasterror();
         }
     }
     if (!$error) {
         if (!$notrigger) {
             // Uncomment this and change MYOBJECT to your own tag if you
             // want this action calls a trigger.
             // // Call triggers
             // include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
             // $interface=new Interfaces($this->db);
             // $result=$interface->run_triggers('MYOBJECT_MODIFY',$this,$user,$langs,$conf);
             // if ($result < 0) { $error++; $this->errors=$interface->errors; }
             // // End call triggers
         }
     }
     if (!$error) {
         if ($this->fk_c_status == 7) {
             $result = $this->closeAllProposal($user);
             if ($result < 0) {
                 $this->errors[] = $this->error;
                 $error++;
             }
         }
     }
     if (!$error) {
         if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) {
             $result = $this->insertExtraFields();
             if ($result < 0) {
                 $error++;
             }
         }
     }
     // Commit or rollback
     if ($error) {
         foreach ($this->errors as $errmsg) {
             dol_syslog(get_class($this) . "::update " . $errmsg, LOG_ERR);
             $this->error .= $this->error ? ', ' . $errmsg : $errmsg;
         }
         $this->db->rollback();
         return -1 * $error;
     } else {
         $this->db->commit();
         return 1;
     }
 }
$sql .= " ORDER BY c.label";
$result = $db->query($sql);
if ($result) {
    $num = $db->num_rows($result);
    $i = 0;
    $total = 0;
    $totalnb = 0;
    $var = true;
    while ($i < $num) {
        $objp = $db->fetch_object($result);
        $var = !$var;
        print "<tr " . $bc[$var] . ">";
        print "<td><a href=\"" . DOL_URL_ROOT . "/compta/bank/search.php?bid={$objp->rowid}\">{$objp->label}</a></td>";
        print '<td align="right">' . $objp->nombre . '</td>';
        print '<td align="right">' . price(abs($objp->somme)) . "</td>";
        print '<td align="right">' . price(abs(price2num($objp->somme / $objp->nombre, 'MT'))) . "</td>";
        print "</tr>";
        $i++;
        $total += abs($objp->somme);
        $totalnb += $objp->nombre;
    }
    $db->free($result);
    print '<tr class="liste_total"><td colspan="2">' . $langs->trans("Total") . '</td>';
    print '<td align="right" class="liste_total">' . price($total) . '</td>';
    print '<td align="right" colspan="2" class="liste_total">' . price($totalnb ? price2num($total / $totalnb, 'MT') : 0) . '</td></tr>';
} else {
    dol_print_error($db);
}
print "</table>";
$db->close();
llxFooter();
Esempio n. 14
0
     $object->oldcopy = dol_clone($object);
     $old_start_date = $object->date_start;
     $object->ref = GETPOST('ref', 'alpha');
     $object->title = GETPOST('title');
     // Do not use 'alpha' here, we want field as it is
     $object->socid = GETPOST('socid', 'int');
     $object->description = GETPOST('description');
     // Do not use 'alpha' here, we want field as it is
     $object->public = GETPOST('public', 'alpha');
     $object->date_start = empty($_POST["projectstart"]) ? '' : $date_start;
     $object->date_end = empty($_POST["projectend"]) ? '' : $date_end;
     if (isset($_POST['opp_amount'])) {
         $object->opp_amount = price2num(GETPOST('opp_amount'));
     }
     if (isset($_POST['budget_amount'])) {
         $object->budget_amount = price2num(GETPOST('budget_amount'));
     }
     if (isset($_POST['opp_status'])) {
         $object->opp_status = $opp_status;
     }
     // Fill array 'array_options' with data from add form
     $ret = $extrafields->setOptionalsFromPost($extralabels, $object);
     if ($ret < 0) {
         $error++;
     }
 }
 if ($object->opp_amount && $object->opp_status <= 0) {
     $error++;
     setEventMessage($langs->trans("ErrorOppStatusRequiredIfAmount"), 'errors');
 }
 if (!$error) {
Esempio n. 15
0
            if (empty($conf->global->PRODUIT_MULTIPRICES)) print price(price2num($objp->sellvalue,'MT'));
            else print $langs->trans("Variable");
            print '</td>';
            // Status
            print '<td align="right">'.$entrepot->LibStatut($objp->statut,5).'</td>';
            print "</tr>\n";
            $total += price2num($objp->estimatedvalue,'MU');
            $totalsell += price2num($objp->sellvalue,'MU');
            $var=!$var;
            $i++;
        }

        print '<tr class="liste_total">';
        print '<td colspan="2" align="right">'.$langs->trans("Total").'</td>';
        print '<td align="right">'.price(price2num($total,'MT')).' '.$langs->trans('Currency'.$conf->currency).'</td>';
        print '<td align="right">'.price(price2num($totalsell,'MT')).' '.$langs->trans('Currency'.$conf->currency).'</td>';
        print '<td align="right">&nbsp;</td>';
        print "</tr>\n";

    }
    $db->free($result);
    print "</table>";

    print '<br>';

    $file='entrepot-'.$year.'.png';
    if (file_exists(DOL_DATA_ROOT.'/entrepot/temp/'.$file))
    {
        $url=DOL_URL_ROOT.'/viewimage.php?modulepart=graph_stock&amp;file='.$file;
        print '<img src="'.$url.'">';
    }
Esempio n. 16
0
     $resteapayer = 0;
 }
 $resteapayeraffiche = $resteapayer;
 if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
     $filterabsolutediscount = "fk_facture_source IS NULL";
     // If we want deposit to be substracted to payments only and not to total of final invoice
     $filtercreditnote = "fk_facture_source IS NOT NULL";
     // If we want deposit to be substracted to payments only and not to total of final invoice
 } else {
     $filterabsolutediscount = "fk_facture_source IS NULL OR (fk_facture_source IS NOT NULL AND description='(DEPOSIT)')";
     $filtercreditnote = "fk_facture_source IS NOT NULL AND description <> '(DEPOSIT)'";
 }
 $absolute_discount = $soc->getAvailableDiscounts('', $filterabsolutediscount);
 $absolute_creditnote = $soc->getAvailableDiscounts('', $filtercreditnote);
 $absolute_discount = price2num($absolute_discount, 'MT');
 $absolute_creditnote = price2num($absolute_creditnote, 'MT');
 $author = new User($db);
 if ($object->user_author) {
     $author->fetch($object->user_author);
 }
 $objectidnext = $object->getIdReplacingInvoice();
 $head = facture_prepare_head($object);
 dol_fiche_head($head, 'compta', $langs->trans('InvoiceCustomer'), 0, 'bill');
 $formconfirm = '';
 // Confirmation de la conversion de l'avoir en reduc
 if ($action == 'converttoreduc') {
     $text = $langs->trans('ConfirmConvertToReduc');
     $formconfirm = $form->formconfirm($_SERVER['PHP_SELF'] . '?facid=' . $object->id, $langs->trans('ConvertToReduc'), $text, 'confirm_converttoreduc', '', "yes", 2);
 }
 // Confirmation to delete invoice
 if ($action == 'delete') {
Esempio n. 17
0
             $i++;
         }
         if ($i > 1) {
             // Print total
             print '<tr class="liste_total">';
             print '<td colspan="2" align="left">' . $langs->trans('TotalTTC') . '</td>';
             print '<td align="right"><b>' . price($total_ttc) . '</b></td>';
             print '<td align="right"><b>' . price($totalrecu);
             if ($totalrecucreditnote) {
                 print '+' . price($totalrecucreditnote);
             }
             if ($totalrecudeposits) {
                 print '+' . price($totalrecudeposits);
             }
             print '</b></td>';
             print '<td align="right"><b>' . price(price2num($total_ttc - $totalrecu - $totalrecucreditnote - $totalrecudeposits, 'MT')) . '</b></td>';
             print '<td align="right" id="result" style="font-weight:bold;"></td>';
             print '<td align="center">&nbsp;</td>';
             print "</tr>\n";
         }
         print "</table>";
         //print "</td></tr>\n";
     }
     $db->free($resql);
 } else {
     dol_print_error($db);
 }
 // Bouton Enregistrer
 if ($action != 'add_paiement') {
     //			print '<tr><td colspan="3" align="center">';
     print '<center><br><input type="checkbox" checked="checked" name="closepaidinvoices"> ' . $langs->trans("ClosePaidInvoicesAutomatically");
Esempio n. 18
0
 if ($tabrowid[$id]) {
     $rowidcol = $tabrowid[$id];
 } else {
     $rowidcol = "rowid";
 }
 // Modify entry
 $sql = "UPDATE " . $tabname[$id] . " SET ";
 // Modifie valeur des champs
 if ($tabrowid[$id] && !in_array($tabrowid[$id], $listfieldmodify)) {
     $sql .= $tabrowid[$id] . "=";
     $sql .= "'" . $db->escape($rowid) . "', ";
 }
 $i = 0;
 foreach ($listfieldmodify as $field) {
     if ($field == 'price' || preg_match('/^amount/i', $field) || preg_match('/^localtax/i', $field) || $field == 'taux') {
         $_POST[$listfieldvalue[$i]] = price2num($_POST[$listfieldvalue[$i]], 'MU');
     } else {
         if ($field == 'entity') {
             $_POST[$listfieldvalue[$i]] = $conf->entity;
         }
     }
     if ($i) {
         $sql .= ",";
     }
     $sql .= $field . "=";
     if ($_POST[$listfieldvalue[$i]] == '') {
         $sql .= "null";
     } else {
         $sql .= "'" . $db->escape($_POST[$listfieldvalue[$i]]) . "'";
     }
     $i++;
Esempio n. 19
0
         } else {
             print $langs->trans("Variable");
         }
         print '</td>';
         // Status
         print '<td align="right">' . $entrepot->LibStatut($objp->statut, 5) . '</td>';
         print "</tr>\n";
         $total += price2num($objp->estimatedvalue, 'MU');
         $totalsell += price2num($objp->sellvalue, 'MU');
         $var = !$var;
         $i++;
     }
     print '<tr class="liste_total">';
     print '<td colspan="2" align="right">' . $langs->trans("Total") . '</td>';
     print '<td align="right">' . price(price2num($total, 'MT'), 1, $langs, 0, 0, -1, $conf->currency) . '</td>';
     print '<td align="right">' . price(price2num($totalsell, 'MT'), 1, $langs, 0, 0, -1, $conf->currency) . '</td>';
     print '<td align="right">&nbsp;</td>';
     print "</tr>\n";
 }
 $db->free($result);
 print "</table>";
 print '<br>';
 $file = 'entrepot-' . $year . '.png';
 if (file_exists($conf->stock->dir_temp . '/' . $file)) {
     $url = DOL_URL_ROOT . '/viewimage.php?modulepart=graph_stock&amp;file=' . $file;
     print '<img src="' . $url . '">';
 }
 $file = 'entrepot-' . ($year - 1) . '.png';
 if (file_exists($conf->stock->dir_temp . '/' . $file)) {
     $url = DOL_URL_ROOT . '/viewimage.php?modulepart=graph_stock&amp;file=' . $file;
     print '<br><img src="' . $url . '">';
Esempio n. 20
0
                 setEventMessages($object->error, $object->errors, 'errors');
                 $action = 'create';
             }
         } else {
             $action = 'create';
         }
     } else {
         header("Location: index.php");
         exit;
     }
 } else {
     if ($action == 'update' && $user->rights->deplacement->creer) {
         if (!GETPOST('cancel', 'alpha')) {
             $result = $object->fetch($id);
             $object->date = dol_mktime(12, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int'));
             $object->km = price2num(GETPOST('km', 'alpha'), 'MU');
             // Not 'int', it may be a formated amount
             $object->type = GETPOST('type', 'alpha');
             $object->socid = GETPOST('socid', 'int');
             $object->fk_user = GETPOST('fk_user', 'int');
             $object->note_private = GETPOST('note_private', 'alpha');
             $object->note_public = GETPOST('note_public', 'alpha');
             $result = $object->update($user);
             if ($result > 0) {
                 header("Location: " . $_SERVER["PHP_SELF"] . "?id=" . $id);
                 exit;
             } else {
                 setEventMessages($object->error, $object->errors, 'errors');
             }
         } else {
             header("Location: " . $_SERVER["PHP_SELF"] . "?id=" . $id);
 // By default, electronic transfert from bank to bank
 $typefrom = 'PRE';
 $typeto = 'VIR';
 if ($accountto->courant == 2 || $accountfrom->courant == 2) {
     // This is transfert of change
     $typefrom = 'LIQ';
     $typeto = 'LIQ';
 }
 if (!$error) {
     $bank_line_id_from = $accountfrom->addline($dateo, $typefrom, $label, -1 * price2num($amount), '', '', $user);
 }
 if (!($bank_line_id_from > 0)) {
     $error++;
 }
 if (!$error) {
     $bank_line_id_to = $accountto->addline($dateo, $typeto, $label, price2num($amount), '', '', $user);
 }
 if (!($bank_line_id_to > 0)) {
     $error++;
 }
 if (!$error) {
     $result = $accountfrom->add_url_line($bank_line_id_from, $bank_line_id_to, DOL_URL_ROOT . '/compta/bank/ligne.php?rowid=', '(banktransfert)', 'banktransfert');
 }
 if (!($result > 0)) {
     $error++;
 }
 if (!$error) {
     $result = $accountto->add_url_line($bank_line_id_to, $bank_line_id_from, DOL_URL_ROOT . '/compta/bank/ligne.php?rowid=', '(banktransfert)', 'banktransfert');
 }
 if (!($result > 0)) {
     $error++;
Esempio n. 22
0
 if (empty($donation_date)) {
     $mesgs[] = $langs->trans("ErrorFieldRequired", $langs->trans("Date"));
     $action = "create";
     $error++;
 }
 if (empty($amount)) {
     $mesgs[] = $langs->trans("ErrorFieldRequired", $langs->trans("Amount"));
     $action = "create";
     $error++;
 }
 if (!$error) {
     $don->firstname = $_POST["firstname"];
     $don->lastname = $_POST["lastname"];
     $don->societe = $_POST["societe"];
     $don->address = $_POST["address"];
     $don->amount = price2num($_POST["amount"]);
     $don->town = $_POST["town"];
     $don->zip = $_POST["zipcode"];
     $don->town = $_POST["town"];
     $don->country = $_POST["country"];
     $don->email = $_POST["email"];
     $don->date = $donation_date;
     $don->note_private = GETPOST("note_private");
     $don->note_public = GETPOST("note_public");
     $don->public = $_POST["public"];
     $don->fk_project = $_POST["projectid"];
     $don->modepaiementid = $_POST["modepaiement"];
     if ($don->create($user) > 0) {
         header("Location: index.php");
         exit;
     }
Esempio n. 23
0
	/**
	 *      Mise a jour en base des champs total_xxx de ligne
	 *		Used by migration process
	 *		@return		int		<0 if KO, >0 if OK
	 */
	function update_total()
	{
		$this->db->begin();

		// Mise a jour ligne en base
		$sql = "UPDATE ".MAIN_DB_PREFIX."contratdet SET";
		$sql.= " total_ht=".price2num($this->total_ht,'MT')."";
		$sql.= ",total_tva=".price2num($this->total_tva,'MT')."";
		$sql.= ",total_localtax1=".price2num($this->total_localtax1,'MT')."";
		$sql.= ",total_localtax2=".price2num($this->total_localtax2,'MT')."";
		$sql.= ",total_ttc=".price2num($this->total_ttc,'MT')."";
		$sql.= " WHERE rowid = ".$this->rowid;

		dol_syslog("ContratLigne::update_total sql=".$sql);

		$resql=$this->db->query($sql);
		if ($resql)
		{
			$this->db->commit();
			return 1;
		}
		else
		{
			$this->error=$this->db->error();
			dol_syslog("ContratLigne::update_total Error ".$this->error, LOG_ERR);
			$this->db->rollback();
			return -2;
		}
	}
Esempio n. 24
0
 if ($conf->global->MEMBER_NEWFORM_PAYONLINE == 'paybox') {
     $urlback = DOL_MAIN_URL_ROOT . '/public/paybox/newpayment.php?from=membernewform&source=membersubscription&ref=' . $adh->ref;
     if (price2num(GETPOST('amount'))) {
         $urlback .= '&amount=' . price2num(GETPOST('amount'));
     }
     if (GETPOST('email')) {
         $urlback .= '&email=' . urlencode(GETPOST('email'));
     }
     if (!empty($entity)) {
         $urlback .= '&entity=' . $entity;
     }
 } else {
     if ($conf->global->MEMBER_NEWFORM_PAYONLINE == 'paypal') {
         $urlback = DOL_MAIN_URL_ROOT . '/public/paypal/newpayment.php?from=membernewform&source=membersubscription&ref=' . $adh->ref;
         if (price2num(GETPOST('amount'))) {
             $urlback .= '&amount=' . price2num(GETPOST('amount'));
         }
         if (GETPOST('email')) {
             $urlback .= '&email=' . urlencode(GETPOST('email'));
         }
         if (!empty($conf->global->PAYPAL_SECURITY_TOKEN) && !empty($conf->global->PAYPAL_SECURITY_TOKEN_UNIQUE)) {
             $urlback .= '&securekey=' . dol_hash($conf->global->PAYPAL_SECURITY_TOKEN . 'membersubscription' . $adh->ref, 2);
         }
         if (!empty($entity)) {
             $urlback .= '&entity=' . $entity;
         }
     } else {
         dol_print_error('', "Autosubscribe form is setup to ask an online payment for a not managed online payment");
         exit;
     }
 }
 /**
  *	Show total to pay
  *
  *	@param	PDF			$pdf           Object PDF
  *	@param  Facture		$object         Object invoice
  *	@param  int			$deja_regle     Montant deja regle
  *	@param	int			$posy			Position depart
  *	@param	Translate	$outputlangs	Objet langs
  *	@return int							Position pour suite
  */
 function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs)
 {
     global $conf, $mysoc;
     $sign = 1;
     if ($object->type == 2 && !empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) {
         $sign = -1;
     }
     $default_font_size = pdf_getPDFFontSize($outputlangs);
     $tab2_top = $posy;
     $tab2_hl = 4;
     $pdf->SetFont('', '', $default_font_size - 1);
     // Tableau total
     $col1x = 120;
     $col2x = 170;
     if ($this->page_largeur < 210) {
         $col2x -= 20;
     }
     $largcol2 = $this->page_largeur - $this->marge_droite - $col2x;
     $useborder = 0;
     $index = 0;
     // Total HT
     $pdf->SetFillColor(255, 255, 255);
     $pdf->SetXY($col1x, $tab2_top + 0);
     $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT"), 0, 'L', 1);
     $total_ht = $conf->multicurrency->enabled && $object->mylticurrency_tx != 1 ? $object->multicurrency_total_ht : $object->total_ht;
     $pdf->SetXY($col2x, $tab2_top + 0);
     $pdf->MultiCell($largcol2, $tab2_hl, price($sign * ($total_ht + (!empty($object->remise) ? $object->remise : 0)), 0, $outputlangs), 0, 'R', 1);
     // Show VAT by rates and total
     $pdf->SetFillColor(248, 248, 248);
     $this->atleastoneratenotnull = 0;
     if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) {
         $tvaisnull = !empty($this->tva) && count($this->tva) == 1 && isset($this->tva['0.000']) && is_float($this->tva['0.000']) ? true : false;
         if (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_ISNULL) && $tvaisnull) {
             // Nothing to do
         } else {
             //Local tax 1 before VAT
             //if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on')
             //{
             foreach ($this->localtax1 as $localtax_type => $localtax_rate) {
                 if (in_array((string) $localtax_type, array('1', '3', '5'))) {
                     continue;
                 }
                 foreach ($localtax_rate as $tvakey => $tvaval) {
                     if ($tvakey != 0) {
                         //$this->atleastoneratenotnull++;
                         $index++;
                         $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
                         $tvacompl = '';
                         if (preg_match('/\\*/', $tvakey)) {
                             $tvakey = str_replace('*', '', $tvakey);
                             $tvacompl = " (" . $outputlangs->transnoentities("NonPercuRecuperable") . ")";
                         }
                         $totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code) . ' ';
                         $totalvat .= vatrate(abs($tvakey), 1) . $tvacompl;
                         $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
                         $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
                         $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
                     }
                 }
             }
             //}
             //Local tax 2 before VAT
             //if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on')
             //{
             foreach ($this->localtax2 as $localtax_type => $localtax_rate) {
                 if (in_array((string) $localtax_type, array('1', '3', '5'))) {
                     continue;
                 }
                 foreach ($localtax_rate as $tvakey => $tvaval) {
                     if ($tvakey != 0) {
                         //$this->atleastoneratenotnull++;
                         $index++;
                         $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
                         $tvacompl = '';
                         if (preg_match('/\\*/', $tvakey)) {
                             $tvakey = str_replace('*', '', $tvakey);
                             $tvacompl = " (" . $outputlangs->transnoentities("NonPercuRecuperable") . ")";
                         }
                         $totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code) . ' ';
                         $totalvat .= vatrate(abs($tvakey), 1) . $tvacompl;
                         $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
                         $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
                         $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
                     }
                 }
             }
             //}
             // VAT
             foreach ($this->tva as $tvakey => $tvaval) {
                 if ($tvakey > 0) {
                     $this->atleastoneratenotnull++;
                     $index++;
                     $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
                     $tvacompl = '';
                     if (preg_match('/\\*/', $tvakey)) {
                         $tvakey = str_replace('*', '', $tvakey);
                         $tvacompl = " (" . $outputlangs->transnoentities("NonPercuRecuperable") . ")";
                     }
                     $totalvat = $outputlangs->transnoentities("TotalVAT") . ' ';
                     $totalvat .= vatrate($tvakey, 1) . $tvacompl;
                     $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
                     $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
                     $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
                 }
             }
             //Local tax 1 after VAT
             //if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on')
             //{
             foreach ($this->localtax1 as $localtax_type => $localtax_rate) {
                 if (in_array((string) $localtax_type, array('2', '4', '6'))) {
                     continue;
                 }
                 foreach ($localtax_rate as $tvakey => $tvaval) {
                     if ($tvakey != 0) {
                         //$this->atleastoneratenotnull++;
                         $index++;
                         $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
                         $tvacompl = '';
                         if (preg_match('/\\*/', $tvakey)) {
                             $tvakey = str_replace('*', '', $tvakey);
                             $tvacompl = " (" . $outputlangs->transnoentities("NonPercuRecuperable") . ")";
                         }
                         $totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code) . ' ';
                         $totalvat .= vatrate(abs($tvakey), 1) . $tvacompl;
                         $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
                         $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
                         $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
                     }
                 }
             }
             //}
             //Local tax 2 after VAT
             //if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on')
             //{
             foreach ($this->localtax2 as $localtax_type => $localtax_rate) {
                 if (in_array((string) $localtax_type, array('2', '4', '6'))) {
                     continue;
                 }
                 foreach ($localtax_rate as $tvakey => $tvaval) {
                     // retrieve global local tax
                     if ($tvakey != 0) {
                         //$this->atleastoneratenotnull++;
                         $index++;
                         $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
                         $tvacompl = '';
                         if (preg_match('/\\*/', $tvakey)) {
                             $tvakey = str_replace('*', '', $tvakey);
                             $tvacompl = " (" . $outputlangs->transnoentities("NonPercuRecuperable") . ")";
                         }
                         $totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code) . ' ';
                         $totalvat .= vatrate(abs($tvakey), 1) . $tvacompl;
                         $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
                         $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
                         $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
                     }
                 }
                 //}
             }
             // Revenue stamp
             if (price2num($object->revenuestamp) != 0) {
                 $index++;
                 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
                 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("RevenueStamp"), $useborder, 'L', 1);
                 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
                 $pdf->MultiCell($largcol2, $tab2_hl, price($sign * $object->revenuestamp), $useborder, 'R', 1);
             }
             // Total TTC
             $index++;
             $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
             $pdf->SetTextColor(0, 0, 60);
             $pdf->SetFillColor(224, 224, 224);
             $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC"), $useborder, 'L', 1);
             $total_ttc = $conf->multicurrency->enabled && $object->multiccurency_tx != 1 ? $object->multicurrency_total_ttc : $object->total_ttc;
             $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
             $pdf->MultiCell($largcol2, $tab2_hl, price($sign * $total_ttc, 0, $outputlangs), $useborder, 'R', 1);
         }
     }
     $pdf->SetTextColor(0, 0, 0);
     $creditnoteamount = $object->getSumCreditNotesUsed();
     $depositsamount = $object->getSumDepositsUsed();
     //print "x".$creditnoteamount."-".$depositsamount;exit;
     $resteapayer = price2num($object->total_ttc - $deja_regle - $creditnoteamount - $depositsamount, 'MT');
     if ($object->paye) {
         $resteapayer = 0;
     }
     if ($deja_regle > 0 || $creditnoteamount > 0 || $depositsamount > 0) {
         // Already paid + Deposits
         $index++;
         $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
         $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("Paid"), 0, 'L', 0);
         $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
         $pdf->MultiCell($largcol2, $tab2_hl, price($deja_regle + $depositsamount, 0, $outputlangs), 0, 'R', 0);
         // Credit note
         if ($creditnoteamount) {
             $index++;
             $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
             $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("CreditNotes"), 0, 'L', 0);
             $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
             $pdf->MultiCell($largcol2, $tab2_hl, price($creditnoteamount, 0, $outputlangs), 0, 'R', 0);
         }
         // Escompte
         if ($object->close_code == Facture::CLOSECODE_DISCOUNTVAT) {
             $index++;
             $pdf->SetFillColor(255, 255, 255);
             $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
             $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("EscompteOfferedShort"), $useborder, 'L', 1);
             $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
             $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_ttc - $deja_regle - $creditnoteamount - $depositsamount, 0, $outputlangs), $useborder, 'R', 1);
             $resteapayer = 0;
         }
         $index++;
         $pdf->SetTextColor(0, 0, 60);
         $pdf->SetFillColor(224, 224, 224);
         $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
         $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("RemainderToPay"), $useborder, 'L', 1);
         $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
         $pdf->MultiCell($largcol2, $tab2_hl, price($resteapayer, 0, $outputlangs), $useborder, 'R', 1);
         $pdf->SetFont('', '', $default_font_size - 1);
         $pdf->SetTextColor(0, 0, 0);
     }
     $index++;
     return $tab2_top + $tab2_hl * $index;
 }
 /**
  *	Met a jour en base la cotisation
  *
  *	@param	User	$user			Objet user qui met a jour
  *	@param 	int		$notrigger		0=Desactive les triggers
  *	@return	int						<0 if KO, >0 if OK
  */
 function update($user, $notrigger = 0)
 {
     $this->db->begin();
     $sql = "UPDATE " . MAIN_DB_PREFIX . "cotisation SET ";
     $sql .= " fk_adherent = " . $this->fk_adherent . ",";
     $sql .= " note=" . ($this->note ? "'" . $this->db->escape($this->note) . "'" : 'null') . ",";
     $sql .= " cotisation = '" . price2num($this->amount) . "',";
     $sql .= " dateadh='" . $this->db->idate($this->dateh) . "',";
     $sql .= " datef='" . $this->db->idate($this->datef) . "',";
     $sql .= " datec='" . $this->db->idate($this->datec) . "',";
     $sql .= " fk_bank = " . ($this->fk_bank ? $this->fk_bank : 'null');
     $sql .= " WHERE rowid = " . $this->id;
     dol_syslog(get_class($this) . "::update sql=" . $sql);
     $resql = $this->db->query($sql);
     if ($resql) {
         $member = new Adherent($this->db);
         $result = $member->fetch($this->fk_adherent);
         $result = $member->update_end_date($user);
         $this->db->commit();
         return 1;
     } else {
         $this->db->rollback();
         $this->error = $this->db->error();
         dol_syslog(get_class($this) . "::update " . $this->error, LOG_ERR);
         return -1;
     }
 }
Esempio n. 27
0
 /**
  * return array_options array for object by extrafields value (using for data send by forms)
  *
  * @param  array   $extralabels    $array of extrafields
  * @param  string  $keyprefix      Prefix string to add into name and id of field (can be used to avoid duplicate names)
  * @param  string  $keysuffix      Suffix string to add into name and id of field (can be used to avoid duplicate names)
  * @return int                     1 if array_options set / 0 if no value
  */
 function getOptionalsFromPost($extralabels, $keyprefix = '', $keysuffix = '')
 {
     global $_POST;
     $array_options = array();
     if (is_array($extralabels)) {
         // Get extra fields
         foreach ($extralabels as $key => $value) {
             $key_type = $this->attribute_type[$key];
             if (in_array($key_type, array('date', 'datetime'))) {
                 // Clean parameters
                 $value_key = dol_mktime($_POST[$keysuffix . "options_" . $key . $keyprefix . "hour"], $_POST[$keysuffix . "options_" . $key . $keyprefix . "min"], 0, $_POST[$keysuffix . "options_" . $key . $keyprefix . "month"], $_POST[$keysuffix . "options_" . $key . $keyprefix . "day"], $_POST[$keysuffix . "options_" . $key . $keyprefix . "year"]);
             } else {
                 if (in_array($key_type, array('checkbox'))) {
                     $value_arr = GETPOST($keysuffix . "options_" . $key . $keyprefix);
                     // Make sure we get an array even if there's only one checkbox
                     $value_arr = (array) $value_arr;
                     $value_key = implode(',', $value_arr);
                 } else {
                     if (in_array($key_type, array('price', 'double'))) {
                         $value_arr = GETPOST($keysuffix . "options_" . $key . $keyprefix);
                         $value_key = price2num($value_arr);
                     } else {
                         $value_key = GETPOST($keysuffix . "options_" . $key . $keyprefix);
                     }
                 }
             }
             $array_options[$keysuffix . "options_" . $key] = $value_key;
             // No keyprefix here. keyprefix is used only for read.
         }
         return $array_options;
     } else {
         return 0;
     }
 }
Esempio n. 28
0
$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);
}
if (trim($search_name) != '') {
    $sql .= natural_search(array('d.lastname', 'd.firstname'), $search_name);
}
if ($search_amount) {
    $sql .= " AND d.amount='" . $db->escape(price2num(trim($search_amount))) . "'";
}
$sql .= $db->order($sortfield, $sortorder);
$sql .= $db->plimit($limit + 1, $offset);
$resql = $db->query($sql);
if ($resql) {
    $num = $db->num_rows($resql);
    $i = 0;
    $param = "&statut={$statut}&sortorder={$sortorder}&sortfield={$sortfield}";
    if ($statut >= 0) {
        $donationstatic->statut = $statut;
        $label = $donationstatic->getLibStatut(0);
        print_barre_liste($label, $page, $_SERVER["PHP_SELF"], $param, '', '', '', $num);
    } else {
        print_barre_liste($langs->trans("Donations"), $page, $_SERVER["PHP_SELF"], $param, '', '', '', $num);
    }
Esempio n. 29
0
             if ($user->rights->stock->creer) {
                 print '<td align="center"><a href="' . DOL_URL_ROOT . '/product/stock/product.php?dwid=' . $object->id . '&amp;id=' . $objp->rowid . '&amp;action=correction">';
                 print $langs->trans("StockCorrection");
                 print "</a></td>";
             }
             print "</tr>";
             $i++;
         }
         $db->free($resql);
         print '<tr class="liste_total"><td class="liste_total" colspan="2">' . $langs->trans("Total") . '</td>';
         print '<td class="liste_total" align="right">' . $totalunit . '</td>';
         print '<td class="liste_total">&nbsp;</td>';
         print '<td class="liste_total" align="right">' . price(price2num($totalvalue, 'MT')) . '</td>';
         if (empty($conf->global->PRODUIT_MULTIPRICES)) {
             print '<td class="liste_total">&nbsp;</td>';
             print '<td class="liste_total" align="right">' . price(price2num($totalvaluesell, 'MT')) . '</td>';
         }
         print '<td class="liste_total">&nbsp;</td>';
         print '<td class="liste_total">&nbsp;</td>';
         print '</tr>';
     } else {
         dol_print_error($db);
     }
     print "</table>\n";
 }
 /*
  * Edition fiche
  */
 if (($action == 'edit' || $action == 're-edit') && 1) {
     print_fiche_titre($langs->trans("WarehouseEdit"), $mesg);
     print '<form action="fiche.php" method="POST">';
 $db->free($resql);
 print '<table class="noborder nohover" width="100%">';
 print '<tr class="liste_titre"><td colspan="2">' . $langs->trans("Statistics") . ' - ' . $langs->trans("OpportunitiesStatusForOpenedProjects") . '</td></tr>' . "\n";
 $var = true;
 $listofstatus = array_keys($listofoppstatus);
 foreach ($listofstatus as $status) {
     $labelstatus = '';
     $code = dol_getIdFromCode($db, $status, 'c_lead_status', 'rowid', 'code');
     if ($code) {
         $labelstatus = $langs->trans("OppStatus" . $code);
     }
     if (empty($labelstatus)) {
         $labelstatus = $listofopplabel[$status];
     }
     //$labelstatus .= ' ('.$langs->trans("Coeff").': '.price2num($listofoppstatus[$status]).')';
     $labelstatus .= ' - ' . price2num($listofoppstatus[$status]) . '%';
     $dataseries[] = array('label' => $labelstatus, 'data' => isset($valsamount[$status]) ? (double) $valsamount[$status] : 0);
     if (!$conf->use_javascript_ajax) {
         $var = !$var;
         print "<tr " . $bc[$var] . ">";
         print '<td>' . $labelstatus . '</td>';
         print '<td align="right"><a href="list.php?statut=' . $status . '">' . price(isset($valsamount[$status]) ? (double) $valsamount[$status] : 0, 0, '', 1, -1, -1, $conf->currency) . '</a></td>';
         print "</tr>\n";
     }
 }
 if ($conf->use_javascript_ajax) {
     print '<tr class="impair"><td align="center" colspan="2">';
     $data = array('series' => $dataseries);
     dol_print_graph('stats', 400, 180, $data, 1, 'pie', 0, '', 0);
     print '</td></tr>';
 }