<?
/**
 * VoiceOne Settings/Extensions/import
 *
 * @package voiceone
 * @subpackage  contacts
 */
  include ("../../../admin/config/cfg.php");
  global $cwlang,$cwUserInfo,$cwUserId;
  //================== POST ====================
  
  //================ PAGE LOGIC ================

  //================ MAIN CONTENTS ================
  ob_start();
  ?>
  <div class="SectionHeader">
    <div id="loading" style="float: right;"></div>
    <h1><?=T_("Export Contacts")?></h1>
    <h3><a href="../" class="admin" ><?=T_("Return to contact list")?></a></h3>
  </div>
  <div id="alert"><?=$alert?></div>
  <div id="basic_form">
    <form id="mainform" action="stream.php" method="post">
      <h2><?=T_("Download CSV file")?></h2>
      <p><?=T_("Select type of contacts to export.")?>
      <div class="block" style="background:#FFF;margin:10px 0 6px 0;">
        <input type="hidden" name="user" value="<?=$cwUserId?>"/>
        <dl>
        	<dt class="required" style="height:60px;"><label for="file"><?=T_("Export Filter")?>:</label></dt>
          <dd>
            <div style="margin-bottom:5px;"><input style="margin-left:10px;" type="radio" name="type" value="1" checked="checked"/> <span class="help"><?=T_("All user's contacts")?></span></div>
            <div style="margin-bottom:5px;"><input style="margin-left:10px;" type="radio" name="type" value="2"/> <span class="help"><?=T_("Only user's private contacts")?></span></div>
            <div style="margin-bottom:5px;"><input style="margin-left:10px;" type="radio" name="type" value="3"/> <span class="help"><?=T_("Only user's public contacts")?></span></div>
            <div style="margin-bottom:5px;"><input style="margin-left:10px;" type="radio" name="type" value="0"/> <span class="help"><?=T_("All contacts, included contacts shared by other users")?></span></div>
          </dd>
        </dl>
      </div>
      <p>
        <?=T_("The export procedure generates a CSV file which has one entry per line and line fields are separated by semicolon.")?>
        <?=T_("Every line has the following structure: ")?><br/>
      </p>
      <table style="margin: 5px 0;color:#666;" cellpadding="0" cellspacing="0">
        <tr><td style="text-align:right;vertical-align:top;" width="1%">&lt;name&gt;:</td><td style="text-align:left;"><?=T_("Name of the contact")?></td></tr>
        <tr><td style="text-align:right;vertical-align:top;" width="1%">&lt;surname&gt;:</td><td style="text-align:left"><?=T_("Surname of the contact")?></td></tr>
        <tr><td style="text-align:right;vertical-align:top;" width="1%">&lt;company&gt;:</td><td style="text-align:left"><?=T_("Company name of the contact")?></td></tr>
        <tr><td style="text-align:right;vertical-align:top;" width="1%">&lt;order_by&gt;:</td><td style="text-align:left"><?=T_("Contacts order field (accepted values: name|surname|company)")?></td></tr>
        <tr><td style="text-align:right;vertical-align:top;" width="1%">&lt;read&gt;:</td><td style="text-align:left"><?=T_("Read permission on the contact. If 1 every user can see this contact (accepted values: 1|0)")?></td></tr>
        <tr><td style="text-align:right;vertical-align:top;" width="1%">&lt;write&gt;:</td><td style="text-align:left"><?=T_("Write permission on the contact. If 1 every user can modify this contact. To be on the contact must be readable. (accepted values: 1|0)")?></td></tr>
        <tr><td style="text-align:right;vertical-align:top;" width="1%">&lt;phonenumber&gt;:</td><td style="text-align:left"><?=T_("Contact's phonenumber. Empty for no phonenumber")?></td></tr>
        <tr><td style="text-align:right;vertical-align:top;" width="1%">&lt;phonenumber_on_cid&gt;:</td><td style="text-align:left"><?=T_("If 1 show caller informations on phones when an incoming call comes from this phonenumber. To be on the contact must be readable and phonenumber must be not null. (accepted values: 1|0)")?></td></tr>
        <tr><td style="text-align:right;vertical-align:top;" width="1%">&lt;mobile&gt;:</td><td style="text-align:left"><?=T_("Contact's mobile number. Empty for no mobile number")?></td></tr>
        <tr><td style="text-align:right;vertical-align:top;" width="1%">&lt;mobile_on_cid&gt;:</td><td style="text-align:left"><?=T_("If 1 show caller informations on phones when an incoming call comes from this mobile number. To be on the contact must be readable and mobile number must be not null. (accepted values: 1|0)")?></td></tr>
        <tr><td style="text-align:right;vertical-align:top;" width="1%">&lt;fax&gt;:</td><td style="text-align:left"><?=T_("Contact's fax number. Empty for no fax number")?></td></tr>
        <tr><td style="text-align:right;vertical-align:top;" width="1%">&lt;fax_on_cid&gt;:</td><td style="text-align:left"><?=T_("If 1 show caller informations on phones when an incoming call comes from this fax number. To be on the contact must be readable and fax number must be not null. (accepted values: 1|0)")?></td></tr>
      </table>
      <p style="margin-bottom:15px;">
        <?=T_("For example an entry could be:")?>&nbsp;&nbsp;Joe;Doe;Matrix Ltd;surname;1;0;555898965;1;;0;55587475;0
      </p>
      <!-- Buttons -->
      <div class="action">
        <a href=""><img src="<?=$relBasePath?>/public/img/<?=$cwLanguage?>/b-cancel.gif" alt="Cancel" onclick="history.back(); return false;"/></a>
        <a href=""><img src="<?=$relBasePath?>/public/img/<?=$cwLanguage?>/b-save.gif" alt="Save" onclick=" document.getElementById('alert').innerHTML=''; document.getElementById('mainform').submit(); return false;"/></a>
      </div>
    </form>
  </div>

  <?
  $contents=ob_get_contents();
  ob_end_clean();

  //================ SIDEBAR ================
  ob_start();
  ?>
    <div class="Sidebar">
      <?$sel="list";include("../../sidebar.php");?>
      <h1><?=T_("Informations")?></h1>
      <p><?=T_("This page allows you to export contacts to a CSV file. To export contacts you have to select which contacts you want export and to press save button on the end of the page.")?></p>
      <div style="text-align: center"><img src="<?=$relBasePath?>public/img/book.jpg" align="center"/></div>
    </div>
  <?
  $sidebar=ob_get_contents();
  ob_end_clean();

  //================ SETTINGS ================
  $smarty->assign("section", "contacts");
  $smarty->assign("subsection", "");
  $smarty->assign("contents", $contents);
  $smarty->assign("sidebar", $sidebar);
  $smarty->display('main.tpl');
?>
