Example #1
0
 public function getResult()
 {
     $ip = getenv('HTTP_X_FORWARDED_FOR');
     $array_ip = explode(",", $ip);
     $country_code = getCountry($array_ip[0]);
     $storeCode = Mage::app()->getStore()->getCode();
     if (strtolower($country_code) != strtolower($storeCode)) {
         return $country_code;
     } else {
         return false;
     }
 }
 /**
  * Show users table
  */
 public function index()
 {
     $clang = Yii::app()->lang;
     if (!Permission::model()->hasGlobalPermission('Regions', 'create')) {
         Yii::app()->setFlashMessage($clang->gT("You do not have sufficient rights to access this page."), 'error');
         $this->getController()->redirect(array("admin/index"));
     }
     App()->getClientScript()->registerCssFile(Yii::app()->getConfig('styleurl') . "jquery.dataTables.css");
     App()->getClientScript()->registerScriptFile(Yii::app()->getConfig('adminscripts') . 'jquery.dataTables.min.js');
     $userlist = getCountry();
     $aData['row'] = 0;
     $aData['usr_arr'] = $userlist;
     $aData['imageurl'] = Yii::app()->getConfig("adminimageurl");
     $this->_renderWrappedTemplate('region/country', 'view_addcountry', $aData);
 }
function showCompetitionInfos () {
#----------------------------------------------------------------------
  global $chosenCompetitionId;

  #--- Get the competition infos from the database.
  $competition = getFullCompetitionInfos( $chosenCompetitionId );
  extract( $competition );
  $delegates = getCompetitionDelegates( $chosenCompetitionId );
  $wcaDelegate = joinUsers( $delegates, true );
  $organizers = getCompetitionOrganizers( $chosenCompetitionId );
  // Only show organizer emails if there is no contact info given.
  $organizer = joinUsers( $organizers, !$contact );

  #--- Show the infos.
  echo "<h1>$name</h1>\n";

  #--- Start the table.
  echo "<div class='table-responsive'>\n";
  echo "<table width='100%' id='competitionDetails'><tr valign='top'>\n";

  #--- Left part.
  echo "<td style='width:70%'><table>";
  $country = getCountry($countryId);
  showItem( 'key', "Date",         array( competitionDate( $competition ), $year ));
  showItem( 'key', "City",         array( $cityName, $country['name'] ));
  showItem( 'key', "Venue",        array( $venue ));
  showItem( 'sub', "Address",      array( $venueAddress ));
  showItem( 'sub', "Details",      array( $venueDetails ));
  showItem( 'key', "Website",      array( $website ));
  showItem( 'key', "Organizer",    array( $organizer ));
  showItem( 'key', "WCA Delegate", array( $wcaDelegate ));
  showItem( 'key', "Contact",      array( $contact ));
  echo "</table></td>";

  #--- Right part.
  echo "<td style='width:30%'><table>";
  showItem( 'key', "Information",  array( $information ));
  showListItemNew( 'View results for', computeCompetitionEvents( $eventSpecs ));
  showListItemNew( 'Reports', computeMedia( 'report' ));
  showListItemNew( 'Articles', computeMedia( 'article' ));
  showListItemNew( 'Multimedia', computeMedia( 'multimedia' ));
  echo "</table></td>";

  #--- End table.
  echo "</tr></table></div>";
}
Example #4
0
function list_country($c, $lang = '')
{
    //Create the country list menu for forms with the given value selected
    //$c = selected value
    if (empty($c)) {
        $c = strtoupper($GLOBALS['phpwcms']['default_lang']);
    }
    $country_list = '';
    $country = getCountry($lang);
    foreach ($country as $key => $value) {
        $country_list .= '	<option value="' . html($key) . '"';
        if ($key == $c) {
            $country_list .= ' selected="selected"';
        }
        $country_list .= '>' . html($value) . '</option>' . LF;
    }
    return $country_list;
}
										<td style="vertical-align: middle;"><span style="font-size: 30px;"><?php 
    echo mysql_result($querymodal, 0, 'flightnumber');
    ?>
</span><br/><span style="font-size: 10px;"><?php 
    echo airlinename(mysql_result($querymodal, 0, 'flightnumber'));
    ?>
</span></td>
										<td style="vertical-align: middle;"><span style="font-size: 30px; margin-top: 10px;"><?php 
    echo getCountry(mysql_result($querymodal, 0, 'origin'), "alt") . " " . mysql_result($querymodal, 0, 'origin');
    ?>
</span><br/><span style="font-size: 10px;"><?php 
    echo mysql_result($queryorig, 0, 'Name');
    ?>
</span>
										<td style="vertical-align: middle;"><span style="font-size: 30px; margin-top: 10px;"><?php 
    echo getCountry(mysql_result($querymodal, 0, 'destination'), "alt") . " " . mysql_result($querymodal, 0, 'destination');
    ?>
</span><br/><span style="font-size: 10px;"><?php 
    echo mysql_result($querydest, 0, 'Name');
    ?>
</span>
									</tr>
									<tr style="border-bottom: 1px solid #444">
										<td><b>Aircraft</b> <a href="http://www.airliners.net/search/photo.search?q=<?php 
    echo str_ireplace(" ", "+", aircraftname(mysql_result($querymodal, 0, 'acft')));
    ?>
+<?php 
    echo str_ireplace(" ", "+", airlinename(mysql_result($querymodal, 0, 'flightnumber'), "name"));
    ?>
" target="_blank" style="color: #333;" onMouseOver="this.style.color='#F00'" onMouseOut="this.style.color='#333'"><i class="icon-camera" title="Click here to see pictures of this aircraft"></i></a></td>
										<td><b>Departure Time</b></td>
?>
</td>
                                                                    <td align="center"><?php 
echo getDateFormate(getDispatchNumber("DespatchDate", "rec_id", $row['DispatchNumberId']), 1);
?>
</td>
                                                                    <td align="center"><?php 
echo getBuyer('BuyerName', 'rec_id', getDispatchNumber("BuyerId", "rec_id", $row['DispatchNumberId']));
?>
</td>
                                                                    <td align="center"><?php 
echo $row['Port'];
?>
</td>
                                                                    <td align="center"><?php 
echo getCountry(getBuyer('CountryId', 'rec_id', $row['BuyerId']));
?>
</td>
                                                                    <td align="center"><?php 
echo getProduct("ProductName", "rec_id", $row['ProductId']);
?>
</td>
                                                                    <td align="center"><?php 
echo $row['Quantity'];
?>
</td>
                                                                    <td align="center"><?php 
echo $row['Price'];
?>
</td>
                                                                   	<?
Example #7
0
// Country
print '<tr><td width="25%">'.$langs->trans('Country').'</td><td>';
$pays_id=GETPOST('pays_id');
if (! $pays_id && ! empty($conf->global->MEMBER_NEWFORM_FORCECOUNTRYCODE)) $pays_id=getCountry($conf->global->MEMBER_NEWFORM_FORCECOUNTRYCODE,2,$db,$langs);
if (! $pays_id && ! empty($conf->geoipmaxmind->enabled))
{
    $pays_code=dol_user_country();
    //print $pays_code;
    if ($pays_code)
    {
        $new_pays_id=getCountry($pays_code,3,$db,$langs);
        //print 'xxx'.$pays_code.' - '.$new_pays_id;
        if ($new_pays_id) $pays_id=$new_pays_id;
    }
}
$pays_code=getCountry($pays_id,2,$db,$langs);
print $html->select_country($pays_id,'pays_id');
print '</td></tr>';
// State
if (empty($conf->global->SOCIETE_DISABLE_STATE))
{
    print '<tr><td>'.$langs->trans('State').'</td><td>';
    if ($pays_code) print $formcompany->select_state(GETPOST("departement_id"),$pays_code);
    else print '';
    print '</td></tr>';
}
// EMail
print '<tr><td>'.$langs->trans("Email").' <FONT COLOR="red">*</FONT></td><td><input type="text" name="email" size="40" value="'.dol_escape_htmltag(GETPOST('email')).'"></td></tr>'."\n";
// Login
if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED))
{
/**
 * Update a product or service
 *
 * @param	array		$authentication		Array of authentication information
 * @param	Product		$product			Product
 * @return	array							Array result
 */
function updateProductOrService($authentication, $product)
{
    global $db, $conf, $langs;
    $now = dol_now();
    dol_syslog("Function: updateProductOrService login="******"You must choose between price or price_net to provide price.";
    }
    if ($product['barcode'] && !$product['barcode_type']) {
        $errror++;
        $errorcode = 'KO';
        $errorlabel = "You must set a barcode type when setting a barcode.";
    }
    if (!$error) {
        include_once DOL_DOCUMENT_ROOT . '/core/lib/company.lib.php';
        $newobject = new Product($db);
        $newobject->fetch($product['id']);
        if (isset($product['ref'])) {
            $newobject->ref = $product['ref'];
        }
        if (isset($product['ref_ext'])) {
            $newobject->ref_ext = $product['ref_ext'];
        }
        $newobject->type = $product['type'];
        $newobject->libelle = $product['label'];
        // TODO deprecated
        $newobject->label = $product['label'];
        $newobject->description = $product['description'];
        $newobject->note = $product['note'];
        $newobject->status = $product['status_tosell'];
        $newobject->status_buy = $product['status_tobuy'];
        $newobject->price = $product['price_net'];
        $newobject->price_ttc = $product['price'];
        $newobject->tva_tx = $product['vat_rate'];
        $newobject->price_base_type = $product['price_base_type'];
        $newobject->date_creation = $now;
        if ($product['barcode']) {
            $newobject->barcode = $product['barcode'];
            $newobject->barcode_type = $product['barcode_type'];
        }
        $newobject->stock_reel = $product['stock_real'];
        $newobject->pmp = $product['pmp'];
        $newobject->seuil_stock_alert = $product['stock_alert'];
        $newobject->country_id = $product['country_id'];
        if ($product['country_code']) {
            $newobject->country_id = getCountry($product['country_code'], 3);
        }
        $newobject->customcode = $product['customcode'];
        $newobject->canvas = $product['canvas'];
        /*foreach($product['lines'] as $line)
          {
              $newline=new FactureLigne($db);
              $newline->type=$line['type'];
              $newline->desc=$line['desc'];
              $newline->fk_product=$line['fk_product'];
              $newline->total_ht=$line['total_net'];
              $newline->total_vat=$line['total_vat'];
              $newline->total_ttc=$line['total'];
              $newline->vat=$line['vat_rate'];
              $newline->qty=$line['qty'];
              $newline->fk_product=$line['product_id'];
          }*/
        //var_dump($product['ref_ext']);
        //var_dump($product['lines'][0]['type']);
        $extrafields = new ExtraFields($db);
        $extralabels = $extrafields->fetch_name_optionals_label('product', true);
        foreach ($extrafields->attribute_label as $key => $label) {
            $key = 'options_' . $key;
            $newobject->array_options[$key] = $product[$key];
        }
        $db->begin();
        $result = $newobject->update($newobject->id, $fuser);
        if ($result <= 0) {
            $error++;
        }
        if (!$error) {
            $db->commit();
            $objectresp = array('result' => array('result_code' => 'OK', 'result_label' => ''), 'id' => $newobject->id, 'ref' => $newobject->ref);
        } else {
            $db->rollback();
            $error++;
            $errorcode = 'KO';
            $errorlabel = $newobject->error;
        }
    }
    if ($error) {
        $objectresp = array('result' => array('result_code' => $errorcode, 'result_label' => $errorlabel));
    }
    return $objectresp;
}
Example #9
0
/**
 * Update a contact
 *
 * @param	array		$authentication		Array of authentication information
 * @param	Contact		$contact		    Contact
 * @return	array							Array result
 */
function updateContact($authentication, $contact)
{
    global $db, $conf, $langs;
    $now = dol_now();
    dol_syslog("Function: updateContact login="******"Contact id is mandatory.";
    }
    if (!$error) {
        $objectfound = false;
        include_once DOL_DOCUMENT_ROOT . '/core/lib/company.lib.php';
        $object = new Contact($db);
        $result = $object->fetch($contact['id']);
        if (!empty($object->id)) {
            $objectfound = true;
            $object->firstname = $contact['firstname'];
            $object->lastname = $contact['lastname'];
            $object->address = $contact['address'];
            $object->zip = $contact['zip'];
            $object->town = $contact['town'];
            $object->country_id = $contact['country_id'];
            if ($contact['country_code']) {
                $object->country_id = getCountry($contact['country_code'], 3);
            }
            $object->province_id = $contact['province_id'];
            $object->phone_pro = $contact['phone_pro'];
            $object->phone_perso = $contact['phone_perso'];
            $object->phone_mobile = $contact['phone_mobile'];
            $object->fax = $contact['fax'];
            $object->email = $contact['email'];
            $object->civility_id = $contact['civility_id'];
            $object->poste = $contact['poste'];
            $object->statut = $contact['statut'];
            //Retreive all extrafield for contact
            // fetch optionals attributes and labels
            $extrafields = new ExtraFields($db);
            $extralabels = $extrafields->fetch_name_optionals_label('socpeople', true);
            foreach ($extrafields->attribute_label as $key => $label) {
                $key = 'options_' . $key;
                $object->array_options[$key] = $contact[$key];
            }
            $db->begin();
            $result = $object->update($contact['id'], $fuser);
            if ($result <= 0) {
                $error++;
            }
        }
        if (!$error && $objectfound) {
            $db->commit();
            $objectresp = array('result' => array('result_code' => 'OK', 'result_label' => ''), 'id' => $object->id);
        } elseif ($objectfound) {
            $db->rollback();
            $error++;
            $errorcode = 'KO';
            $errorlabel = $object->error;
        } else {
            $error++;
            $errorcode = 'NOT_FOUND';
            $errorlabel = 'Contact id=' . $contact['id'] . ' cannot be found';
        }
    }
    if ($error) {
        $objectresp = array('result' => array('result_code' => $errorcode, 'result_label' => $errorlabel));
    }
    return $objectresp;
}
Example #10
0
	/**
	 * 	Return full address of third party
	 *
	 * 	@param		int			$withcountry		1=Add country into address string
	 *  @param		string		$sep				Separator to use to build string
	 * 	@return		string							Full address string
	 */
	function getFullAddress($withcountry = 0, $sep = "\n") {
		$ret = '';
		if ($withcountry && $this->values->country_id && (empty($this->values->country_id) || empty($this->values->country))) {
			require_once(DOL_DOCUMENT_ROOT . "/core/lib/company.lib.php");
			$tmparray = getCountry($this->values->country_id, 'all');
			$this->values->country = $tmparray['label'];
		}

		if (in_array($this->values->country_code, array('US'))) {
			$ret.=($this->values->address ? $this->values->address . $sep : '');
			$ret.=trim($this->values->zip . ' ' . $this->values->town);
			if ($withcountry)
				$ret.=($this->values->country ? $sep . $this->values->country : '');
		}
		else {
			$ret.=($this->values->address ? $this->values->address . $sep : '');
			$ret.=trim($this->values->zip . ' ' . $this->values->town);
			if ($withcountry)
				$ret.=($this->values->country ? $sep . $this->values->country : '');
		}
		return trim($ret);
	}
    echo aircraftname(mysql_result($query, $i, 'acft'));
    ?>
</td>
					<td style="vertical-align:middle;text-align:center;"><?php 
    if (mysql_result($query, $i, 'deptime') == "----") {
        echo "FROM";
    } else {
        echo "TO";
    }
    ?>
</td>
					<td style="vertical-align:middle"><?php 
    if (mysql_result($query, $i, 'deptime') == "----") {
        echo getCountry(mysql_result($query, $i, 'origin'), "alt", "24") . " " . mysql_result($query, $i, 'origin') . " - " . mysql_result($queryorig, 0, 'Name');
    } else {
        echo getCountry(mysql_result($query, $i, 'destination'), "alt", "24") . " " . mysql_result($query, $i, 'destination') . " - " . mysql_result($querydest, 0, 'Name');
    }
    ?>
</td>
					<td style="vertical-align:middle"><?php 
    echo mysql_result($query, $i, 'opstime');
    ?>
Z</td>
					<td style="vertical-align:middle"><?php 
    echo mysql_result($query, $i, 'gate');
    ?>
</td>
					<td><?php 
    echo mysql_result($query, $i, 'name') . ' (<a href="http://www.ivao.aero/members/person/details.asp?ID=' . mysql_result($query, $i, 'vid') . '">' . mysql_result($query, $i, 'vid') . '</a>)';
    ?>
</td>
Example #12
0
function record_new_connection($config, $json)
{
    if (!(isset($_SERVER["REMOTE_ADDR"]) || isset($_SERVER["REMOTE_HOST"]))) {
        return false;
    }
    $ip = $_SERVER['REMOTE_ADDR'];
    $sql = "INSERT INTO connections (appid,ip,country,custom,`timestamp`) VALUES (:appid,:ip,:country,:custom,:timestamp)";
    $db = getDb($config);
    $custom = json_encode($json['customField']);
    if ($custom === false) {
        $custom = null;
    }
    $ar = [':appid' => intval($json["appid"]), ':ip' => $ip, ':country' => strval(getCountry($ip)), ':timestamp' => intval($json["time"]), ':custom' => $custom];
    $s = $db->prepare($sql);
    return $s->execute($ar);
}
Example #13
0
 // Account supplier code
 if (!empty($arrayfields['s.code_compta_fournisseur']['checked'])) {
     print '<td>' . $obj->code_compta_fournisseur . '</td>';
 }
 // Town
 if (!empty($arrayfields['s.town']['checked'])) {
     print "<td>" . $obj->town . "</td>\n";
 }
 // Zip
 if (!empty($arrayfields['s.zip']['checked'])) {
     print "<td>" . $obj->zip . "</td>\n";
 }
 // Country
 if (!empty($arrayfields['country.code_iso']['checked'])) {
     print '<td align="center">';
     $tmparray = getCountry($obj->fk_pays, 'all');
     print $tmparray['label'];
     print '</td>';
 }
 // Type ent
 if (!empty($arrayfields['typent.code']['checked'])) {
     print '<td align="center">';
     if (count($typenArray) == 0) {
         $typenArray = $formcompany->typent_array(1);
     }
     print $typenArray[$obj->typent_code];
     print '</td>';
 }
 if (!empty($arrayfields['s.siren']['checked'])) {
     print "<td>" . $obj->idprof1 . "</td>\n";
 }
Example #14
0
                                                    ?>
                                                                <tr <? if ($sno%2==1) { ?> bgcolor="#F5F2F1" <? } ?>>
                                                                    <td align="center"><?php 
echo $sno;
?>
</td>
                                                                    <td align="center"><?php 
echo $row['BuyerName'];
?>
</td>
                                                                    <td align="center"><?php 
echo $row['Address'];
?>
</td>
                                                                    <td align="center"><?php 
echo getCountry($row['CountryId']);
?>
</td>
                                                                    <td align="center"><? if($row['State']!=0){echo getState($row['State']);} else { echo $row['OtherState'];}?></td>
                                                                    <td align="center"><? if($row['City']!=0){ echo getCity($row['City']);} else{ echo $row['OtherCity'];}?></td>
                                                                    <td align="center"><?php 
echo $row['Email'];
?>
</td>
                                                                    <td align="center"><?php 
echo $row['ContactNumber'];
?>
</td>
                                                                    <td align="center"><a href="javascript:;" onClick="return hs.htmlExpand(this)">
                                                                    	<img src="images/Find-icon.png" border="0" width="24" height="24" /></a>
                                                                        <div class="highslide-maincontent">
include "func_weather.php";
// EXTERNAL VARIABLES
$aptICAO = $_REQUEST["icao"];
// GLOBAL VARIABLES
global $navdatabase, $rfedatabase, $sqlconn;
// Get Information of the Departure and Arrival airports from the Database
change_db($sqlconn, $navdatabase);
$queryapt = "SELECT Name,Latitude,Longtitude,Elevation FROM airports WHERE ICAO='" . $aptICAO . "'";
$queryapt = mysqlexec($sqlconn, $queryapt);
change_db($sqlconn, $rfedatabase);
?>

	<div class="modal-header">
		<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
		<h3 style="font-weight: 300"><?php 
echo getCountry($aptICAO);
?>
 <?php 
echo $aptICAO;
?>
 - <?php 
echo mysql_result($queryapt, 0, 'name');
?>
</h3>
	</div>
	<div id="modalbody" class="modal-body">

		<div class="accordion" id="detailsaccordion">
			<div class="accordion-group">
				<div class="accordion-heading">
					<a class="accordion-toggle" data-toggle="collapse" data-parent="#detailsaccordion" href="#collapsedetails">
Example #16
0
 if ($res && $res['blocked']) {
     echo "<ipblocked>true</ipblocked>";
     echo "</result>";
     mysql_close($conn);
     exit(0);
 }
 $result = mysql_query("SELECT (IF(DATE_SUB(NOW(), INTERVAL {$BAN_TIMEOUT} MINUTE)>ban_time, false, " . "true)) banned, ({$BAN_TIMEOUT}-MINUTE(TIMEDIFF(NOW(), ban_time))) ban_time_left FROM bans WHERE ip='" . "{$_SERVER['REMOTE_ADDR']}' LIMIT 1");
 $res = mysql_fetch_array($result);
 if ($res && $res['banned']) {
     echo "<banned banTime=\"{$res['ban_time_left']}\">true</banned>";
 } else {
     if (preg_match('/^register$/', $task)) {
         clean();
         $id = $_GET['id'];
         $result = mysql_query("INSERT INTO sessions (id, ip, created_at, marked, type) " . "VALUES('{$id}', '{$_SERVER['REMOTE_ADDR']}', DEFAULT, 0, 0)");
         $country = getCountry($_SERVER['REMOTE_ADDR']);
         $countryCode = $country ? strtolower($country['code']) : false;
         $country = $country ? $country['country'] : false;
         if ($result) {
             $q = "INSERT INTO user_settings (id, sett_name, sett_value) VALUES ";
             $haveSettings = $countryCode ? true : false;
             if ($haveSettings) {
                 $q .= "('{$id}', 'ccode', '{$countryCode}'),";
             }
             if (isset($_GET['settings'])) {
                 $settings = preg_replace('/^\\s+|\\s+$/', '', $_GET['settings']);
                 $settArr = explode(',', $settings);
                 if (count($settArr) > 1) {
                     $haveSettings = true;
                     for ($i = 0; $i < count($settArr); $i += 2) {
                         $q .= "('{$id}', '{$settArr[$i]}', '{$settArr[$i + 1]}'),";
Example #17
0
    $output=getGraphData($layer_tablename, $X, $Y);
    print $output;
    break;

  // /*start*/ These requests are specific to UAP (category structure)
  case 'getCity':
    require_once("MultiLayerSearch.php");
    $cid=$_REQUEST['cityName'];
    $result=getCity($cid);
    print $result;
    break;

  case 'getCountry':
    require_once("MultiLayerSearch.php");
    $cName=$_REQUEST['continentName'];
    $result=getCountry($cName);
    print $result;
    break;

  case 'getCategory':
    require_once("MultiLayerSearch.php");
    print getCategory();
    break;

  case 'getContinent':
    require_once("MultiLayerSearch.php");
    print getContinent();
    break;

  case 'getTheme':
    require_once("MultiLayerSearch.php");
Example #18
0
 /**
  *	Load warehouse data
  *
  *	@param		int		$id     Warehouse id
  *	@param		string	$ref	Warehouse label
  *	@return		int				>0 if OK, <0 if KO
  */
 function fetch($id, $ref = '')
 {
     global $conf;
     $sql = "SELECT rowid, label, description, statut, lieu, address, zip, town, fk_pays as country_id";
     $sql .= " FROM " . MAIN_DB_PREFIX . "entrepot";
     if ($id) {
         $sql .= " WHERE rowid = '" . $id . "'";
     } else {
         $sql .= " WHERE entity = " . $conf->entity;
         if ($ref) {
             $sql .= " AND label = '" . $this->db->escape($ref) . "'";
         }
     }
     dol_syslog(get_class($this) . "::fetch", LOG_DEBUG);
     $result = $this->db->query($sql);
     if ($result) {
         if ($this->db->num_rows($result) > 0) {
             $obj = $this->db->fetch_object($result);
             $this->id = $obj->rowid;
             $this->ref = $obj->rowid;
             $this->libelle = $obj->label;
             $this->description = $obj->description;
             $this->statut = $obj->statut;
             $this->lieu = $obj->lieu;
             $this->address = $obj->address;
             $this->zip = $obj->zip;
             $this->town = $obj->town;
             $this->country_id = $obj->country_id;
             include_once DOL_DOCUMENT_ROOT . '/core/lib/company.lib.php';
             $tmp = getCountry($this->country_id, 'all');
             $this->country = $tmp['label'];
             $this->country_code = $tmp['code'];
             return 1;
         } else {
             return 0;
         }
     } else {
         $this->error = $this->db->error();
         return -1;
     }
 }
Example #19
0
/**
 * Update a thirdparty
 *
 * @param	array		$authentication		Array of authentication information
 * @param	Societe		$thirdparty		    Thirdparty
 * @return	array							Array result
 */
function updateThirdParty($authentication, $thirdparty)
{
    global $db, $conf, $langs;
    $now = dol_now();
    dol_syslog("Function: updateThirdParty login="******"Thirdparty id is mandatory.";
    }
    if (!$error) {
        $objectfound = false;
        include_once DOL_DOCUMENT_ROOT . '/core/lib/company.lib.php';
        $object = new Societe($db);
        $result = $object->fetch($thirdparty['id']);
        if (!empty($object->id)) {
            $objectfound = true;
            $object->ref = $thirdparty['ref'];
            $object->name = $thirdparty['ref'];
            $object->ref_ext = $thirdparty['ref_ext'];
            $object->status = $thirdparty['status'];
            $object->client = $thirdparty['client'];
            $object->fournisseur = $thirdparty['supplier'];
            $object->code_client = $thirdparty['customer_code'];
            $object->code_fournisseur = $thirdparty['supplier_code'];
            $object->code_compta = $thirdparty['customer_code_accountancy'];
            $object->code_compta_fournisseur = $thirdparty['supplier_code_accountancy'];
            $object->date_creation = $now;
            $object->note_private = $thirdparty['note_private'];
            $object->note_public = $thirdparty['note_public'];
            $object->address = $thirdparty['address'];
            $object->zip = $thirdparty['zip'];
            $object->town = $thirdparty['town'];
            $object->country_id = $thirdparty['country_id'];
            if ($thirdparty['country_code']) {
                $object->country_id = getCountry($thirdparty['country_code'], 3);
            }
            $object->province_id = $thirdparty['province_id'];
            //if ($thirdparty['province_code']) $newobject->province_code=getCountry($thirdparty['province_code'],3);
            $object->phone = $thirdparty['phone'];
            $object->fax = $thirdparty['fax'];
            $object->email = $thirdparty['email'];
            $object->url = $thirdparty['url'];
            $object->idprof1 = $thirdparty['profid1'];
            $object->idprof2 = $thirdparty['profid2'];
            $object->idprof3 = $thirdparty['profid3'];
            $object->idprof4 = $thirdparty['profid4'];
            $object->idprof5 = $thirdparty['profid5'];
            $object->idprof6 = $thirdparty['profid6'];
            $object->capital = $thirdparty['capital'];
            $object->barcode = $thirdparty['barcode'];
            $object->tva_assuj = $thirdparty['vat_used'];
            $object->tva_intra = $thirdparty['vat_number'];
            $object->canvas = $thirdparty['canvas'];
            //Retreive all extrafield for thirdsparty
            // fetch optionals attributes and labels
            $extrafields = new ExtraFields($db);
            $extralabels = $extrafields->fetch_name_optionals_label('societe', true);
            foreach ($extrafields->attribute_label as $key => $label) {
                $key = 'options_' . $key;
                $object->array_options[$key] = $thirdparty[$key];
            }
            $db->begin();
            $result = $object->update($thirdparty['id'], $fuser);
            if ($result <= 0) {
                $error++;
            }
        }
        if (!$error && $objectfound) {
            $db->commit();
            $objectresp = array('result' => array('result_code' => 'OK', 'result_label' => ''), 'id' => $object->id);
        } elseif ($objectfound) {
            $db->rollback();
            $error++;
            $errorcode = 'KO';
            $errorlabel = $object->error;
        } else {
            $error++;
            $errorcode = 'NOT_FOUND';
            $errorlabel = 'Thirdparty id=' . $thirdparty['id'] . ' cannot be found';
        }
    }
    if ($error) {
        $objectresp = array('result' => array('result_code' => $errorcode, 'result_label' => $errorlabel));
    }
    return $objectresp;
}
Example #20
0
 // Status
 print '<tr><td class="fieldrequired">' . $langs->trans("Status") . '</td>';
 print '<td colspan="3">';
 print $form->selectarray("clos", array(0 => $account->status[0], 1 => $account->status[1]), isset($_POST["clos"]) ? $_POST["clos"] : $account->clos);
 print '</td></tr>';
 // Country
 $account->country_id = $account->country_id ? $account->country_id : $mysoc->country_id;
 $selectedcode = $account->country_code;
 if (isset($_POST["account_country_id"])) {
     $selectedcode = $_POST["account_country_id"];
 } else {
     if (empty($selectedcode)) {
         $selectedcode = $mysoc->country_code;
     }
 }
 $account->country_code = getCountry($selectedcode, 2);
 // Force country code on account to have following field on bank fields matching country rules
 print '<tr><td class="fieldrequired">' . $langs->trans("Country") . '</td>';
 print '<td colspan="3">';
 print $form->select_country($selectedcode, 'account_country_id');
 if ($user->admin) {
     print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
 }
 print '</td></tr>';
 // State
 print '<tr><td>' . $langs->trans('State') . '</td><td colspan="3">';
 if ($selectedcode) {
     print $formcompany->select_state(isset($_POST["account_state_id"]) ? $_POST["account_state_id"] : $account->state_id, $selectedcode, 'account_state_id');
 } else {
     print $countrynotdefined;
 }
<?
include("inc/check_session.php");
include('inc/dbconnection.php');
include('inc/adm_function.php');
?>
<?
if(isset($_GET['id']))
{
	$sql = "select * from ".$mysql_adm_table_prefix."dispatch_number where rec_id = '".$_GET['id']."'";
	$result = mysql_query($sql) or die("Error in Query : ".$sql."<br/>".mysql_error()."<br/>".mysql_errno());
	$row = mysql_fetch_array($result);
	$rec_id = $row['rec_id'];
	$buyername = getBuyer('BuyerName','rec_id',$row['BuyerId']);
	$buyercountry = getCountry(getBuyer('CountryId','rec_id',$row['BuyerId']));
	$buyeraddress = getBuyer('Address','rec_id',$row['BuyerId']);
	$invoiceno = $row['DispatchNumber'];
	$invoicedate = getDateFormate($row['DespatchDate'],1);
	$freightcharges = $row['FreightCharges'];
	$port = $row['Port'];
	$container_no = $row['TransportNo'];
	$seal_no = $row['VechileNo'];
	//$lot_no = $row['LrNo'];
	$no_pkg = count(explode(",",$row['SrNo']));
	$agent_seal_no = $row['AgentSealNo'];
	$hs_code = $row['HSCode'];
	$pi_no = getPINumber('PiNumber','rec_id',getDispatchDetail('PiId','DispatchNumberId',$rec_id));
	$PiDate = getDateFormate(getPINumber('PiDate','rec_id',getDispatchDetail('PiId','DispatchNumberId',$rec_id)),1);
	$pi_detailid = getPiDetail('rec_id','PiId',getDispatchDetail('PiId','DispatchNumberId',$rec_id));
	
}	
?>	
 /**
  *  Assign POST values into object
  *
  *	@param		string		$action		Action string
  *  @return		string					HTML output
  */
 private function assign_post($action)
 {
     global $langs, $mysoc;
     $this->object->id = $_POST["socid"];
     $this->object->name = $_POST["nom"];
     $this->object->prefix_comm = $_POST["prefix_comm"];
     $this->object->client = $_POST["client"];
     $this->object->code_client = $_POST["code_client"];
     $this->object->fournisseur = $_POST["fournisseur"];
     $this->object->code_fournisseur = $_POST["code_fournisseur"];
     $this->object->address = $_POST["adresse"];
     $this->object->zip = $_POST["zipcode"];
     $this->object->town = $_POST["town"];
     $this->object->country_id = $_POST["country_id"] ? $_POST["country_id"] : $mysoc->country_id;
     $this->object->state_id = $_POST["state_id"];
     $this->object->phone = $_POST["tel"];
     $this->object->fax = $_POST["fax"];
     $this->object->email = $_POST["email"];
     $this->object->url = $_POST["url"];
     $this->object->capital = $_POST["capital"];
     $this->object->idprof1 = $_POST["idprof1"];
     $this->object->idprof2 = $_POST["idprof2"];
     $this->object->idprof3 = $_POST["idprof3"];
     $this->object->idprof4 = $_POST["idprof4"];
     $this->object->typent_id = $_POST["typent_id"];
     $this->object->effectif_id = $_POST["effectif_id"];
     $this->object->barcode = $_POST["barcode"];
     $this->object->forme_juridique_code = $_POST["forme_juridique_code"];
     $this->object->default_lang = $_POST["default_lang"];
     $this->object->commercial_id = $_POST["commercial_id"];
     $this->object->tva_assuj = $_POST["assujtva_value"] ? $_POST["assujtva_value"] : 1;
     $this->object->tva_intra = $_POST["tva_intra"];
     //Local Taxes
     $this->object->localtax1_assuj = $_POST["localtax1assuj_value"];
     $this->object->localtax2_assuj = $_POST["localtax2assuj_value"];
     // We set country_id, and country_code label of the chosen country
     if ($this->object->country_id) {
         $tmparray = getCountry($this->object->country_id, 'all', $this->db, $langs, 0);
         $this->object->country_code = $tmparray['code'];
         $this->object->country_label = $tmparray['label'];
     }
 }
Example #23
0
         $desc = !empty($prod->multilangs[$outputlangs->defaultlang]["description"]) ? $prod->multilangs[$outputlangs->defaultlang]["description"] : $prod->description;
     } else {
         $desc = $prod->description;
     }
     $desc = dol_concatdesc($desc, $product_desc);
     // Add custom code and origin country into description
     if (empty($conf->global->MAIN_PRODUCT_DISABLE_CUSTOMCOUNTRYCODE) && (!empty($prod->customcode) || !empty($prod->country_code))) {
         $tmptxt = '(';
         if (!empty($prod->customcode)) {
             $tmptxt .= $langs->transnoentitiesnoconv("CustomCode") . ': ' . $prod->customcode;
         }
         if (!empty($prod->customcode) && !empty($prod->country_code)) {
             $tmptxt .= ' - ';
         }
         if (!empty($prod->country_code)) {
             $tmptxt .= $langs->transnoentitiesnoconv("CountryOrigin") . ': ' . getCountry($prod->country_code, 0, $db, $langs, 0);
         }
         $tmptxt .= ')';
         $desc = dol_concatdesc($desc, $tmptxt);
     }
     $type = $prod->type;
     $fk_unit = $prod->fk_unit;
 } else {
     $pu_ht = price2num($price_ht, 'MU');
     $pu_ttc = price2num(GETPOST('price_ttc'), 'MU');
     $tva_npr = preg_match('/\\*/', $tva_tx) ? 1 : 0;
     $tva_tx = str_replace('*', '', $tva_tx);
     $label = GETPOST('product_label') ? GETPOST('product_label') : '';
     $desc = $product_desc;
     $type = GETPOST('type');
     $fk_unit = GETPOST('units', 'alpha');
Example #24
0
	/**
	 *  Load a product in memory from database
	 *  @param      id      Id of product/service to load
	 *  @param      ref     Ref of product/service to load
	 *  @return     int     <0 if KO, >0 if OK
	 */
	function fetch($id='',$ref='')
	{
	    include_once(DOL_DOCUMENT_ROOT.'/lib/company.lib.php');

		global $langs;
		global $conf;

		dol_syslog("Product::fetch id=$id ref=$ref");

		// Check parameters
		if (! $id && ! $ref)
		{
			$this->error=$langs->trans('ErrorWrongParameters');
			dol_print_error("Product::fetch ".$this->error, LOG_ERR);
			return -1;
		}

		$sql = "SELECT rowid, ref, label, description, note, customcode, fk_country, price, price_ttc,";
		$sql.= " price_min, price_min_ttc, price_base_type, tva_tx, recuperableonly as tva_npr, localtax1_tx, localtax2_tx, tosell,";
		$sql.= " tobuy, fk_product_type, duration, seuil_stock_alerte, canvas,";
		$sql.= " weight, weight_units, length, length_units, surface, surface_units, volume, volume_units, barcode, fk_barcode_type, finished, hidden,";
		$sql.= " accountancy_code_buy, accountancy_code_sell, stock, pmp,";
		$sql.= " import_key";
		$sql.= " FROM ".MAIN_DB_PREFIX."product";
		if ($id) $sql.= " WHERE rowid = '".$id."'";
		else if ($ref) $sql.= " WHERE ref = '".$this->db->escape($ref)."'";

		dol_syslog("Product::fetch sql=".$sql);
		$resql = $this->db->query($sql);
		if ( $resql )
		{
			if ($this->db->num_rows($resql) > 0)
			{
				$object = $this->db->fetch_object($resql);

				$this->id					= $object->rowid;
				$this->ref					= $object->ref;
				$this->libelle				= $object->label;		// TODO deprecated
				$this->label				= $object->label;
				$this->description			= $object->description;
				$this->note					= $object->note;
	            $this->customcode			= $object->customcode;
	            $this->country_id			= $object->fk_country;
	            $this->country_code			= getCountry($this->country_id,2,$this->db);
	            $this->price				= $object->price;
				$this->price_ttc			= $object->price_ttc;
				$this->price_min			= $object->price_min;
				$this->price_min_ttc		= $object->price_min_ttc;
				$this->price_base_type		= $object->price_base_type;
				$this->tva_tx				= $object->tva_tx;
				//! French VAT NPR
				$this->tva_npr				= $object->tva_npr;
				//! Spanish local taxes
				$this->localtax1_tx			= $object->localtax1_tx;
				$this->localtax2_tx			= $object->localtax2_tx;

				$this->type					= $object->fk_product_type;
				$this->status				= $object->tosell;
				$this->status_buy			= $object->tobuy;
				$this->finished				= $object->finished;
				$this->hidden				= $object->hidden;
				$this->duration				= $object->duration;
				$this->duration_value		= substr($object->duration,0,dol_strlen($object->duration)-1);
				$this->duration_unit		= substr($object->duration,-1);
				$this->seuil_stock_alerte	= $object->seuil_stock_alerte;
				$this->canvas				= $object->canvas;
				$this->weight				= $object->weight;
				$this->weight_units			= $object->weight_units;
				$this->length				= $object->length;
				$this->length_units			= $object->length_units;
				$this->surface				= $object->surface;
				$this->surface_units		= $object->surface_units;
				$this->volume				= $object->volume;
				$this->volume_units			= $object->volume_units;
				$this->barcode				= $object->barcode;
				$this->barcode_type			= $object->fk_barcode_type;

				$this->accountancy_code_buy = $object->accountancy_code_buy;
				$this->accountancy_code_sell= $object->accountancy_code_sell;

				$this->stock_reel         = $object->stock;
				$this->pmp                = $object->pmp;

				$this->import_key         = $object->import_key;

				$this->db->free($resql);

				// multilangs
				if ($conf->global->MAIN_MULTILANGS) $this->getMultiLangs();

				// Barcode
				if ($conf->global->MAIN_MODULE_BARCODE)
				{
					if ($this->barcode_type == 0)
					{
						$this->barcode_type = $conf->global->PRODUIT_DEFAULT_BARCODE_TYPE;
					}

					if ($this->barcode_type > 0)
					{
						$sql = "SELECT code, libelle, coder";
						$sql.= " FROM ".MAIN_DB_PREFIX."c_barcode_type";
						$sql.= " WHERE rowid = ".$this->barcode_type;
						$resql = $this->db->query($sql);
						if ($resql)
						{
							$result = $this->db->fetch_array($resql);
							$this->barcode_type_code = $result["code"];
							$this->barcode_type_label = $result["libelle"];
							$this->barcode_type_coder = $result["coder"];
						}
						else
						{
							dol_print_error($this->db);
							return -1;
						}
					}
				}

				// Load multiprices array
				if ($conf->global->PRODUIT_MULTIPRICES)
				{
					for ($i=1; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i++)
					{
						$sql = "SELECT price, price_ttc, price_min, price_min_ttc,";
						$sql.= " price_base_type, tva_tx, tosell";
						$sql.= " FROM ".MAIN_DB_PREFIX."product_price";
						$sql.= " where price_level=".$i." and";
						$sql.= " fk_product = '".$this->id."'";
						$sql.= " ORDER BY date_price DESC";
						$sql.= " LIMIT 1";
						$resql = $this->db->query($sql) ;
						if ($resql)
						{
							$result = $this->db->fetch_array($resql);

							$this->multiprices[$i]=$result["price"];
							$this->multiprices_ttc[$i]=$result["price_ttc"];
							$this->multiprices_min[$i]=$result["price_min"];
							$this->multiprices_min_ttc[$i]=$result["price_min_ttc"];
							$this->multiprices_base_type[$i]=$result["price_base_type"];
							$this->multiprices_tva_tx[$i]=$result["tva_tx"];
						}
						else
						{
							dol_print_error($this->db);
							return -1;
						}
					}
				}

				$res=$this->load_stock();

				return $res;
			}
			else
			{
				return 0;
			}
		}
		else
		{
			dol_print_error($this->db);
			return -1;
		}
	}
$country_id = GETPOST('country_id');
if (!$country_id && !empty($conf->global->MEMBER_NEWFORM_FORCECOUNTRYCODE)) {
    $country_id = getCountry($conf->global->MEMBER_NEWFORM_FORCECOUNTRYCODE, 2, $db, $langs);
}
if (!$country_id && !empty($conf->geoipmaxmind->enabled)) {
    $country_code = dol_user_country();
    //print $country_code;
    if ($country_code) {
        $new_country_id = getCountry($country_code, 3, $db, $langs);
        //print 'xxx'.$country_code.' - '.$new_country_id;
        if ($new_country_id) {
            $country_id = $new_country_id;
        }
    }
}
$country_code = getCountry($country_id, 2, $db, $langs);
print $form->select_country($country_id, 'country_id');
print '</td></tr>';
// State
if (empty($conf->global->SOCIETE_DISABLE_STATE)) {
    print '<tr><td>' . $langs->trans('State') . '</td><td>';
    if ($country_code) {
        print $formcompany->select_state(GETPOST("state_id"), $country_code);
    } else {
        print '';
    }
    print '</td></tr>';
}
// EMail
print '<tr><td>' . $langs->trans("Email") . ' <FONT COLOR="red">*</FONT></td><td><input type="text" name="email" size="40" value="' . dol_escape_htmltag(GETPOST('email')) . '"></td></tr>' . "\n";
// Login
Example #26
0
	/**
	 *  Load a product in memory from database
	 *
	 *  @param	int		$id      	Id of product/service to load
	 *  @param  string	$ref     	Ref of product/service to load
	 *  @param	string	$ref_ext	Ref ext of product/service to load
	 *  @return int     			<0 if KO, >0 if OK
	 */
	function fetch($id='',$ref='',$ref_ext='')
	{
	    include_once(DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php');

		global $langs, $conf;

		dol_syslog(get_class($this)."::fetch id=".$id." ref=".$ref." ref_ext=".$ref_ext);

		// Check parameters
		if (! $id && ! $ref && ! $ref_ext)
		{
			$this->error='ErrorWrongParameters';
			dol_print_error(get_class($this)."::fetch ".$this->error, LOG_ERR);
			return -1;
		}

		$sql = "SELECT rowid, ref, label, description, note, customcode, fk_country, price, price_ttc,";
		$sql.= " price_min, price_min_ttc, price_base_type, tva_tx, recuperableonly as tva_npr, localtax1_tx, localtax2_tx, tosell, ecotax, ecotax_ttc,";
		$sql.= " tobuy, fk_product_type, duration, seuil_stock_alerte, canvas,";
		$sql.= " weight, weight_units, length, length_units, surface, surface_units, volume, volume_units, barcode, fk_barcode_type, finished,";
		$sql.= " accountancy_code_buy, accountancy_code_sell, stock, pmp,";
		$sql.= " datec, tms, import_key, entity";
		$sql.= " FROM ".MAIN_DB_PREFIX."product";
		if ($id) $sql.= " WHERE rowid = '".$id."'";
		else
		{
			$sql.= " WHERE entity IN (".getEntity($this->element, 1).")";
			if ($ref) $sql.= " AND ref = '".$this->db->escape($ref)."'";
			else if ($ref_ext) $sql.= " AND ref_ext = '".$this->db->escape($ref_ext)."'";
		}

		dol_syslog(get_class($this)."::fetch sql=".$sql);
		$resql = $this->db->query($sql);
		if ( $resql )
		{
			if ($this->db->num_rows($resql) > 0)
			{
				$obj = $this->db->fetch_object($resql);

				$this->id						= $obj->rowid;
				$this->ref						= $obj->ref;
				$this->libelle					= $obj->label;		// TODO deprecated
				$this->label					= $obj->label;
				$this->description				= $obj->description;
				$this->note						= $obj->note;

				$this->type						= $obj->fk_product_type;
				$this->status					= $obj->tosell;
				$this->status_buy				= $obj->tobuy;

	            $this->customcode				= $obj->customcode;
	            $this->country_id				= $obj->fk_country;
	            $this->country_code				= getCountry($this->country_id,2,$this->db);
	            $this->price					= $obj->price;
				$this->price_ttc				= $obj->price_ttc;
				$this->price_min				= $obj->price_min;
				//! ecotaxe
                $this->ecotax					= $obj->ecotax;
                $this->ecotax_ttc				= $obj->ecotax_ttc;
				$this->price_min_ttc			= $obj->price_min_ttc;
				$this->price_base_type			= $obj->price_base_type;
				$this->tva_tx					= $obj->tva_tx;
				//! French VAT NPR
				$this->tva_npr					= $obj->tva_npr;
				//! Spanish local taxes
				$this->localtax1_tx				= $obj->localtax1_tx;
				$this->localtax2_tx				= $obj->localtax2_tx;

				$this->finished					= $obj->finished;
				$this->duration					= $obj->duration;
				$this->duration_value			= substr($obj->duration,0,dol_strlen($obj->duration)-1);
				$this->duration_unit			= substr($obj->duration,-1);
				$this->canvas					= $obj->canvas;
				$this->weight					= $obj->weight;
				$this->weight_units				= $obj->weight_units;
				$this->length					= $obj->length;
				$this->length_units				= $obj->length_units;
				$this->surface					= $obj->surface;
				$this->surface_units			= $obj->surface_units;
				$this->volume					= $obj->volume;
				$this->volume_units				= $obj->volume_units;
				$this->barcode					= $obj->barcode;
				$this->barcode_type				= $obj->fk_barcode_type;

				$this->accountancy_code_buy		= $obj->accountancy_code_buy;
				$this->accountancy_code_sell	= $obj->accountancy_code_sell;

				$this->seuil_stock_alerte		= $obj->seuil_stock_alerte;
				$this->stock_reel				= $obj->stock;
				$this->pmp						= $obj->pmp;

				$this->date_creation			= $obj->datec;
				$this->date_modification		= $obj->tms;
				$this->import_key				= $obj->import_key;
				$this->entity					= $obj->entity;

				$this->db->free($resql);

				// multilangs
				if (! empty($conf->global->MAIN_MULTILANGS)) $this->getMultiLangs();

				// Load multiprices array
				if (! empty($conf->global->PRODUIT_MULTIPRICES))
				{
					for ($i=1; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i++)
					{
						$sql = "SELECT price, price_ttc, price_min, price_min_ttc,";
						$sql.= " price_base_type, tva_tx, tosell";
						$sql.= " FROM ".MAIN_DB_PREFIX."product_price";
						$sql.= " WHERE price_level=".$i;
						$sql.= " AND fk_product = '".$this->id."'";
						$sql.= " ORDER BY date_price DESC";
						$sql.= " LIMIT 1";
						$resql = $this->db->query($sql);
						if ($resql)
						{
							$result = $this->db->fetch_array($resql);

							$this->multiprices[$i]=$result["price"];
							$this->multiprices_ttc[$i]=$result["price_ttc"];
							$this->multiprices_min[$i]=$result["price_min"];
							$this->multiprices_min_ttc[$i]=$result["price_min_ttc"];
							$this->multiprices_base_type[$i]=$result["price_base_type"];
							$this->multiprices_tva_tx[$i]=$result["tva_tx"];
						}
						else
						{
							dol_print_error($this->db);
							return -1;
						}
					}
				}

				$res=$this->load_stock();

				return $res;
			}
			else
			{
				return 0;
			}
		}
		else
		{
			dol_print_error($this->db);
			return -1;
		}
	}
Example #27
0
                        // Used on logon for example
                        $imgThumbSmall = vignette($newfile, $maxwidthsmall, $maxheightsmall, '_small', $quality);

                        // Create mini thumbs for company (Ratio is near 16/9)
                        // Used on menu or for setup page for example
                        $imgThumbMini = vignette($newfile, $maxwidthmini, $maxheightmini, '_mini', $quality);
                    }
                }
            }
        }

        // We set country_id, country_code and country for the selected country
        $object->country_id=$_POST["country_id"]?$_POST["country_id"]:$mysoc->country_id;
        if ($object->country_id)
        {
            $tmparray=getCountry($object->country_id,'all');
            $object->country_code=$tmparray['code'];
            $object->country=$tmparray['label'];
        }
        $object->forme_juridique_code=$_POST['forme_juridique_code'];
        /* Show create form */

        print_fiche_titre($langs->trans("NewThirdParty"));

        if ($conf->use_javascript_ajax)
        {
            print "\n".'<script type="text/javascript">';
            print '$(document).ready(function () {
						id_te_private=8;
                        id_ef15=1;
                        is_private='.(GETPOST("private")?GETPOST("private"):0).';
 /**
  *  Load a product in memory from database
  *
  *  @param	int		$id      			Id of product/service to load
  *  @param  string	$ref     			Ref of product/service to load
  *  @param	string	$ref_ext			Ref ext of product/service to load
  *  @param	int		$ignore_expression  Ignores the math expression for calculating price and uses the db value instead
  *  @return int     					<0 if KO, 0 if not found, >0 if OK
  */
 function fetch($id = '', $ref = '', $ref_ext = '', $ignore_expression = 0)
 {
     include_once DOL_DOCUMENT_ROOT . '/core/lib/company.lib.php';
     global $langs, $conf;
     dol_syslog(get_class($this) . "::fetch id=" . $id . " ref=" . $ref . " ref_ext=" . $ref_ext);
     // Check parameters
     if (!$id && !$ref && !$ref_ext) {
         $this->error = 'ErrorWrongParameters';
         dol_print_error(get_class($this) . "::fetch " . $this->error);
         return -1;
     }
     $sql = "SELECT rowid, ref, ref_ext, label, description, url, note, customcode, fk_country, price, price_ttc,";
     $sql .= " price_min, price_min_ttc, price_base_type, tva_tx, recuperableonly as tva_npr, localtax1_tx, localtax2_tx, tosell,";
     $sql .= " tobuy, fk_product_type, duration, seuil_stock_alerte, canvas,";
     $sql .= " weight, weight_units, length, length_units, surface, surface_units, volume, volume_units, barcode, fk_barcode_type, finished,";
     $sql .= " accountancy_code_buy, accountancy_code_sell, stock, pmp,";
     $sql .= " datec, tms, import_key, entity, desiredstock, tobatch, fk_unit";
     $sql .= " , fk_price_expression";
     $sql .= " FROM " . MAIN_DB_PREFIX . "product";
     if ($id) {
         $sql .= " WHERE rowid = " . $this->db->escape($id);
     } else {
         $sql .= " WHERE entity IN (" . getEntity($this->element, 1) . ")";
         if ($ref) {
             $sql .= " AND ref = '" . $this->db->escape($ref) . "'";
         } else {
             if ($ref_ext) {
                 $sql .= " AND ref_ext = '" . $this->db->escape($ref_ext) . "'";
             }
         }
     }
     $resql = $this->db->query($sql);
     if ($resql) {
         if ($this->db->num_rows($resql) > 0) {
             $obj = $this->db->fetch_object($resql);
             $this->id = $obj->rowid;
             $this->ref = $obj->ref;
             $this->ref_ext = $obj->ref_ext;
             $this->label = $obj->label;
             $this->description = $obj->description;
             $this->url = $obj->url;
             $this->note = $obj->note;
             $this->type = $obj->fk_product_type;
             $this->status = $obj->tosell;
             $this->status_buy = $obj->tobuy;
             $this->status_batch = $obj->tobatch;
             $this->customcode = $obj->customcode;
             $this->country_id = $obj->fk_country;
             $this->country_code = getCountry($this->country_id, 2, $this->db);
             $this->price = $obj->price;
             $this->price_ttc = $obj->price_ttc;
             $this->price_min = $obj->price_min;
             $this->price_min_ttc = $obj->price_min_ttc;
             $this->price_base_type = $obj->price_base_type;
             $this->tva_tx = $obj->tva_tx;
             //! French VAT NPR
             $this->tva_npr = $obj->tva_npr;
             //! Spanish local taxes
             $this->localtax1_tx = $obj->localtax1_tx;
             $this->localtax2_tx = $obj->localtax2_tx;
             $this->finished = $obj->finished;
             $this->duration = $obj->duration;
             $this->duration_value = substr($obj->duration, 0, dol_strlen($obj->duration) - 1);
             $this->duration_unit = substr($obj->duration, -1);
             $this->canvas = $obj->canvas;
             $this->weight = $obj->weight;
             $this->weight_units = $obj->weight_units;
             $this->length = $obj->length;
             $this->length_units = $obj->length_units;
             $this->surface = $obj->surface;
             $this->surface_units = $obj->surface_units;
             $this->volume = $obj->volume;
             $this->volume_units = $obj->volume_units;
             $this->barcode = $obj->barcode;
             $this->barcode_type = $obj->fk_barcode_type;
             $this->accountancy_code_buy = $obj->accountancy_code_buy;
             $this->accountancy_code_sell = $obj->accountancy_code_sell;
             $this->seuil_stock_alerte = $obj->seuil_stock_alerte;
             $this->desiredstock = $obj->desiredstock;
             $this->stock_reel = $obj->stock;
             $this->pmp = $obj->pmp;
             $this->date_creation = $obj->datec;
             $this->date_modification = $obj->tms;
             $this->import_key = $obj->import_key;
             $this->entity = $obj->entity;
             $this->ref_ext = $obj->ref_ext;
             $this->fk_price_expression = $obj->fk_price_expression;
             $this->fk_unit = $obj->fk_unit;
             $this->db->free($resql);
             // Retreive all extrafield for current object
             // fetch optionals attributes and labels
             require_once DOL_DOCUMENT_ROOT . '/core/class/extrafields.class.php';
             $extrafields = new ExtraFields($this->db);
             $extralabels = $extrafields->fetch_name_optionals_label($this->table_element, true);
             $this->fetch_optionals($this->id, $extralabels);
             // multilangs
             if (!empty($conf->global->MAIN_MULTILANGS)) {
                 $this->getMultiLangs();
             }
             // Load multiprices array
             if (!empty($conf->global->PRODUIT_MULTIPRICES)) {
                 for ($i = 1; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i++) {
                     $sql = "SELECT price, price_ttc, price_min, price_min_ttc,";
                     $sql .= " price_base_type, tva_tx, tosell, price_by_qty, rowid, recuperableonly";
                     $sql .= " FROM " . MAIN_DB_PREFIX . "product_price";
                     $sql .= " WHERE entity IN (" . getEntity('productprice', 1) . ")";
                     $sql .= " AND price_level=" . $i;
                     $sql .= " AND fk_product = '" . $this->id . "'";
                     $sql .= " ORDER BY date_price DESC";
                     $sql .= " LIMIT 1";
                     $resql = $this->db->query($sql);
                     if ($resql) {
                         $result = $this->db->fetch_array($resql);
                         $this->multiprices[$i] = $result["price"];
                         $this->multiprices_ttc[$i] = $result["price_ttc"];
                         $this->multiprices_min[$i] = $result["price_min"];
                         $this->multiprices_min_ttc[$i] = $result["price_min_ttc"];
                         $this->multiprices_base_type[$i] = $result["price_base_type"];
                         $this->multiprices_tva_tx[$i] = $result["tva_tx"];
                         $this->multiprices_recuperableonly[$i] = $result["recuperableonly"];
                         // Price by quantity
                         $this->prices_by_qty[$i] = $result["price_by_qty"];
                         $this->prices_by_qty_id[$i] = $result["rowid"];
                         // Récuperation de la liste des prix selon qty si flag positionné
                         if ($this->prices_by_qty[$i] == 1) {
                             $sql = "SELECT rowid,price, unitprice, quantity, remise_percent, remise";
                             $sql .= " FROM " . MAIN_DB_PREFIX . "product_price_by_qty";
                             $sql .= " WHERE fk_product_price = '" . $this->prices_by_qty_id[$i] . "'";
                             $sql .= " ORDER BY quantity ASC";
                             $resultat = array();
                             $resql = $this->db->query($sql);
                             if ($resql) {
                                 $ii = 0;
                                 while ($result = $this->db->fetch_array($resql)) {
                                     $resultat[$ii] = array();
                                     $resultat[$ii]["rowid"] = $result["rowid"];
                                     $resultat[$ii]["price"] = $result["price"];
                                     $resultat[$ii]["unitprice"] = $result["unitprice"];
                                     $resultat[$ii]["quantity"] = $result["quantity"];
                                     $resultat[$ii]["remise_percent"] = $result["remise_percent"];
                                     $resultat[$ii]["remise"] = $result["remise"];
                                     $ii++;
                                 }
                                 $this->prices_by_qty_list[$i] = $resultat;
                             } else {
                                 dol_print_error($this->db);
                                 return -1;
                             }
                         }
                     } else {
                         dol_print_error($this->db);
                         return -1;
                     }
                 }
             } else {
                 if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY)) {
                     $sql = "SELECT price, price_ttc, price_min, price_min_ttc,";
                     $sql .= " price_base_type, tva_tx, tosell, price_by_qty, rowid";
                     $sql .= " FROM " . MAIN_DB_PREFIX . "product_price";
                     $sql .= " WHERE fk_product = '" . $this->id . "'";
                     $sql .= " ORDER BY date_price DESC";
                     $sql .= " LIMIT 1";
                     $resql = $this->db->query($sql);
                     if ($resql) {
                         $result = $this->db->fetch_array($resql);
                         // Price by quantity
                         $this->prices_by_qty[0] = $result["price_by_qty"];
                         $this->prices_by_qty_id[0] = $result["rowid"];
                         // Récuperation de la liste des prix selon qty si flag positionné
                         if ($this->prices_by_qty[0] == 1) {
                             $sql = "SELECT rowid,price, unitprice, quantity, remise_percent, remise";
                             $sql .= " FROM " . MAIN_DB_PREFIX . "product_price_by_qty";
                             $sql .= " WHERE fk_product_price = '" . $this->prices_by_qty_id[0] . "'";
                             $sql .= " ORDER BY quantity ASC";
                             $resultat = array();
                             $resql = $this->db->query($sql);
                             if ($resql) {
                                 $ii = 0;
                                 while ($result = $this->db->fetch_array($resql)) {
                                     $resultat[$ii] = array();
                                     $resultat[$ii]["rowid"] = $result["rowid"];
                                     $resultat[$ii]["price"] = $result["price"];
                                     $resultat[$ii]["unitprice"] = $result["unitprice"];
                                     $resultat[$ii]["quantity"] = $result["quantity"];
                                     $resultat[$ii]["remise_percent"] = $result["remise_percent"];
                                     $resultat[$ii]["remise"] = $result["remise"];
                                     $ii++;
                                 }
                                 $this->prices_by_qty_list[0] = $resultat;
                             } else {
                                 dol_print_error($this->db);
                                 return -1;
                             }
                         }
                     } else {
                         dol_print_error($this->db);
                         return -1;
                     }
                 }
             }
             if (!empty($this->fk_price_expression) && empty($ignore_expression)) {
                 require_once DOL_DOCUMENT_ROOT . '/product/dynamic_price/class/price_parser.class.php';
                 $priceparser = new PriceParser($this->db);
                 $price_result = $priceparser->parseProduct($this);
                 if ($price_result >= 0) {
                     $this->price = $price_result;
                     //Calculate the VAT
                     $this->price_ttc = price2num($this->price) * (1 + $this->tva_tx / 100);
                     $this->price_ttc = price2num($this->price_ttc, 'MU');
                 }
             }
             // We should not load stock at each fetch. If someone need stock, he must call load_stock after fetch.
             //$res=$this->load_stock();
             // instead we just init the stock_warehouse array
             $this->stock_warehouse = array();
             return 1;
         } else {
             return 0;
         }
     } else {
         dol_print_error($this->db);
         return -1;
     }
 }
Example #29
0
     print "</td></tr>\n";
 }
 // Unit
 if (!empty($conf->global->PRODUCT_USE_UNITS)) {
     $unit = $object->getLabelOfUnit();
     print '<tr><td>' . $langs->trans('DefaultUnitToShow') . '</td><td>';
     if ($unit !== '') {
         print $langs->trans($unit);
     }
     print '</td></tr>';
 }
 // Custom code
 if (empty($conf->global->PRODUCT_DISABLE_CUSTOM_INFO)) {
     print '<tr><td>' . $langs->trans("CustomCode") . '</td><td colspan="2">' . $object->customcode . '</td>';
     // Origin country code
     print '<tr><td>' . $langs->trans("CountryOrigin") . '</td><td colspan="2">' . getCountry($object->country_id, 0, $db) . '</td>';
 }
 // Other attributes
 $parameters = array('colspan' => ' colspan="' . (2 + ($showphoto || $showbarcode ? 1 : 0)) . '"');
 $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action);
 // Note that $action and $object may have been modified by hook
 if (empty($reshook) && !empty($extrafields->attribute_label)) {
     print $object->showOptionals($extrafields);
 }
 // Categories
 if ($conf->categorie->enabled) {
     print '<tr><td valign="middle">' . $langs->trans("Categories") . '</td><td colspan="3">';
     print $form->showCategories($object->id, 'product', 1);
     print "</td></tr>";
 }
 // Note
$font_rgb = hex_to_rgb($font_color_1);
$font_color_1 = ImageColorAllocate($image, $font_rgb['red'], $font_rgb['green'], $font_rgb['blue']);
// Transparent Background
/*imagealphablending($image, false);
$transparency = imagecolorallocatealpha($image, 0, 0, 0, 127);
imagefill($image, 0, 0, $transparency);
imagesavealpha($image, true);*/
//============================================================
// DRAWING: BACKGROUND
//============================================================
ImageFill($image, 0, 0, $black);
ImageFilledRectangle($image, 1, 1, $image_width - 2, $image_height - 2, $bg_white);
//============================================================
// DRAWING: FLAG
//============================================================
$flag = "../" . getCountry($icao, "norm", 48);
$flag = imagecreatefrompng($flag);
$insert_x = imagesx($flag);
$insert_y = imagesy($flag);
imagecopy($image, $flag, 0, -7, 0, 0, $insert_x, $insert_y);
//============================================================
// DRAWING: TITLE - ICAO CODE AND AIRPORT NAME
//============================================================
$name = $icao . " - " . mysql_result($query, 0, 'Name');
$y_finalpos = 24;
$box_width = $image_width;
$box = @ImageTTFBBox(15, 0, $font_file_1, $name);
$text_width = abs($box[2] - $box[0]);
$text_height = abs($box[5] - $box[3]);
$difference = $box_width - $text_width;
$put_text_x = $difference / 2;