function buildResume($format)
 {
     // Turn off WSDL caching
     ini_set('soap.wsdl_cache_enabled', 0);
     // Define credentials for LD
     define('USERNAME', 'rsimha01');
     define('PASSWORD', 'prannu35');
     // SOAP WSDL endpoint
     define('ENDPOINT', 'https://api.livedocx.com/1.2/mailmerge.asmx?WSDL');
     // Define timezone
     date_default_timezone_set('Europe/Berlin');
     // -----------------------------------------------------------------------------
     //
     // SAMPLE #1 - License Agreement
     //
     // Instantiate SOAP object and log into LiveDocx
     $soap = new SoapClient(ENDPOINT);
     $soap->LogIn(array('username' => USERNAME, 'password' => PASSWORD));
     // Upload template
     $data = file_get_contents('template.docx');
     $soap->SetLocalTemplate(array('template' => base64_encode($data), 'format' => 'docx'));
     // Assign data to template
     $fieldValues = array('first_name' => $this->firstname, 'last_name' => $this->lastname, 'street_name' => $this->address, 'city' => $this->city, 'state' => $this->state, 'zip' => $this->zip, 'phone_no' => $this->phone, 'email' => $this->email, 'company_name' => $this->company['company_name'], 'years' => $this->company['years'], 'job_title' => $this->company['job_title'], 'job_description' => $this->company['job_description'], 'degree' => $this->school['degree'], 'school' => $this->school['school'], 'school_dates' => $this->school['dates'], 'skills' => $this->skills[0]);
     $soap->SetFieldValues(array('fieldValues' => $this->assocArrayToArrayOfArrayOfString($fieldValues)));
     // Build the document
     $soap->CreateDocument();
     // Get document as PDF
     $result = $soap->RetrieveDocument(array('format' => $format));
     $data = $result->RetrieveDocumentResult;
     file_put_contents('resume.' . $format . '', base64_decode($data));
     return "resume." . $format;
     $soap->LogOut();
     unset($soap);
     print 'DONE.' . PHP_EOL;
 }
function convertToDocx($filepath, $format)
{
    // Turn up error reporting
    error_reporting(E_ERROR | E_PARSE);
    // Turn off WSDL caching
    ini_set('soap.wsdl_cache_enabled', 0);
    //// Define credentials for LD
    //define ('USERNAME', 'yourUsername');
    //define ('PASSWORD', 'yourPassword');
    // SOAP WSDL endpoint
    define('ENDPOINT', 'https://api.livedocx.com/1.2/mailmerge.asmx?WSDL');
    // Define timezone
    date_default_timezone_set('Europe/Berlin');
    // -----------------------------------------------------------------------------
    //
    // SAMPLE #1 - License Agreement
    //
    // Instantiate SOAP object and log into LiveDocx
    $soap = new SoapClient(ENDPOINT);
    $soap->LogIn(array('username' => rsimha01, 'password' => prannu35));
    // Upload template
    $data = file_get_contents($filepath);
    $soap->SetLocalTemplate(array('template' => base64_encode($data), 'format' => $format));
    // Build the document
    $soap->CreateDocument();
    // Get document as docx
    $result = $soap->RetrieveDocument(array('format' => 'docx'));
    $data = $result->RetrieveDocumentResult;
    file_put_contents('files/resume.zip', base64_decode($data));
}
 public function export()
 {
     require_once 'libs/nusoap/nusoap.php';
     if ($this->Input->get('key') != 'pdf') {
         return '';
     }
     $thisID = $this->Input->get('id');
     // Turn off WSDL caching
     ini_set('soap.wsdl_cache_enabled', 0);
     // SOAP WSDL endpoint
     define('ENDPOINT', 'https://api.livedocx.com/1.2/mailmerge.asmx?wsdl');
     // Define timezone
     date_default_timezone_set('Europe/Berlin');
     // Instantiate nuSOAP Client
     $soap = new SoapClient(ENDPOINT);
     // Set charset encoding for outgoing messages
     //	$soap ->soap_defencoding = 'UTF-8';
     $soap->LogIn(array('username' => $GLOBALS['TL_CONFIG']['livedocx_username'], 'password' => $GLOBALS['TL_CONFIG']['livedocx_password']));
     // Upload template
     $data = file_get_contents('templates/invoice-template.docx', FILE_USE_INCLUDE_PATH);
     // Assign field values data to template
     $soap->SetLocalTemplate(array('template' => base64_encode($data), 'format' => 'docx'));
     /* 	//debug
          $fieldNames = $soap->getFieldNames();
          print_r($fieldNames);
          exit;
         */
     $event = $this->Database->prepare("SELECT * FROM tl_pic_invoices WHERE id=?")->limit(1)->execute($thisID);
     if (!$event->numRows) {
         $this->log('Event not found', 'export_to_pdf()', TL_ERROR);
         header('Location: ?do=Invoices');
         return;
     }
     $name = $this->Database->prepare("SELECT * FROM tl_pic_customer_company WHERE id=?")->limit(1)->execute($event->customer_company_id);
     $address = $this->Database->prepare("SELECT * FROM tl_pic_customer_addresses WHERE pid=?")->limit(1)->execute($event->customer_company_id);
     $objInvoice = $this->Database->prepare("SELECT services FROM tl_pic_invoices WHERE id=?")->limit(1)->execute($thisID);
     $services = unserialize($objInvoice->services);
     $invoice_date = $event->invoice_date;
     $this->invoice_label = $_invoice_label;
     $format = 'd/m/Y';
     $this->invoice_date = gmdate($format, $invoice_date);
     $event->invoice_date = gmdate($format, $invoice_date);
     $fieldValues = array('logo' => $GLOBALS['TL_CONFIG']['logo'], 'company_name' => $GLOBALS['TL_CONFIG']['company_name'], 'address1' => $GLOBALS['TL_CONFIG']['company_address1'], 'address2' => $GLOBALS['TL_CONFIG']['company_address2'], 'city' => $GLOBALS['TL_CONFIG']['company_city'], 'postcode' => $GLOBALS['TL_CONFIG']['company_postcode'], 'phone' => $GLOBALS['TL_CONFIG']['company_phone'], 'num' => $GLOBALS['TL_CONFIG']['company_number'], 'taxnum' => $GLOBALS['TL_CONFIG']['company_taxnumber'], 'invoice_label' => $event->invoice_label, 'invoice_date' => $event->invoice_date, 'customer_company_name' => $name->customer_company_name, 'street' => $address->street, 'city' => $address->city, 'postal' => $address->postal, 'id' => $event->id, 'invoice_purchase_order' => $event->invoice_purchase_order, 'invoice_remaining_days' => $GLOBALS['TL_CONFIG']['invoice_remaining_days'], 'company_bankname' => $GLOBALS['TL_CONFIG']['company_bankname'], 'company_bankcode' => $GLOBALS['TL_CONFIG']['company_bankcode'], 'company_bankaccountnumber' => $GLOBALS['TL_CONFIG']['company_bankaccountnumber'], 'company_name' => $GLOBALS['TL_CONFIG']['company_name'], 'contact_firstname' => $GLOBALS['TL_CONFIG']['contact_firstname'], 'contact_lastname' => $GLOBALS['TL_CONFIG']['contact_lastname'], 'contact_phone' => $GLOBALS['TL_CONFIG']['contact_phone'], 'contact_email' => $GLOBALS['TL_CONFIG']['contact_email'], 'tax_applied' => $GLOBALS['TL_CONFIG']['tax_applied']);
     $sum = 0;
     $array_size = sizeof($services);
     for ($i = 0; $i < $array_size; $i++) {
         $sum = $sum + $services[$i]['cost'] * $services[$i]['quantity'];
         $fieldValues = $fieldValues + array('service_' . $i => $services[$i]['title'], 'price_' . $i => $GLOBALS['TL_CONFIG']['company_defaultCurrency'] . $services[$i]['cost'], 'qty_' . $i => $services[$i]['quantity'], 'amount_' . $i => $GLOBALS['TL_CONFIG']['company_defaultCurrency'] . $services[$i]['cost'] * $services[$i]['quantity']);
     }
     $fieldValues = $fieldValues + array('sum' => $GLOBALS['TL_CONFIG']['company_defaultCurrency'] . $sum, 'vat' => $GLOBALS['TL_CONFIG']['company_defaultCurrency'] . ($vat = $sum * $GLOBALS['TL_CONFIG']['tax_applied'] / 100), 'sumvat' => $GLOBALS['TL_CONFIG']['company_defaultCurrency'] . ($sum + $vat));
     $result = $soap->SetFieldValues(array('fieldValues' => $this->nuSoap_assocArrayToArrayOfArrayOfString($fieldValues)));
     // Build the document
     $soap->CreateDocument();
     // Get document as PDF
     $result = $soap->RetrieveDocument(array('format' => 'pdf'));
     $data = $result->RetrieveDocumentResult;
     $soap->LogOut();
     unset($soap);
     $invoice_name = $GLOBALS['TL_CONFIG']['invoice_title'] . $event->invoice_date . "-" . $event->invoice_number;
     $GLOBALS['TL_CONFIG']['invoice_startnum']++;
     header('Content-Type: application/x-download');
     header('Content-Disposition: attachment; filename="' . $invoice_name . '.pdf"');
     header('Cache-Control: private, max-age=0, must-revalidate');
     //$soap->Output($invoice_name . '.pdf', $GLOBALS['TL_CONFIG']['invoice_path']);
     header('Pragma: public');
     echo base64_decode($data);
     return;
 }
Exemple #4
0
         $result = $client->GetRest(array('Good' => $_POST['xml']));
     } else {
         $error = "101. Нет входящих данных.";
     }
     break;
 case "102":
     if (!empty($_POST['xml'])) {
         $result = $client->GetPrice(array('Good' => $_POST['xml']));
     } else {
         $error = "102. Нет входящих данных.";
     }
     break;
 case "103":
     //103 ОформлениеЗаказаПокупателя
     if (!empty($_POST['xml'])) {
         $result = $client->CreateDocument(array('Good' => $_POST['xml']));
         //                    file_put_contents($_SERVER['DOCUMENT_ROOT']."/t.txt",$result->return);
         //                    file_put_contents($_SERVER['DOCUMENT_ROOT']."/t.txt",$_POST['xml']);
     } else {
         $error = "103. Нет входящих данных.";
     }
     break;
 case "104":
     //104 ЗапросСтатусаЗаказаПокупателя
     if (!empty($_POST['xml'])) {
         $result = $client->GetStatus(array('Good' => $_POST['xml']));
     } else {
         $error = "104. Нет входящих данных.";
     }
     break;
 case "105":
 public function export()
 {
     if ($GLOBALS['TL_CONFIG']['generator_type'] == 'LivedocX') {
         require_once 'libs/nusoap/nusoap.php';
         if ($this->Input->get('key') != 'pdf') {
             return '';
         }
         $thisID = $this->Input->get('id');
         // Turn off WSDL caching
         ini_set('soap.wsdl_cache_enabled', 0);
         // SOAP WSDL endpoint
         define('ENDPOINT', 'https://api.livedocx.com/1.2/mailmerge.asmx?wsdl');
         // Define timezone
         date_default_timezone_set('Europe/Berlin');
         // Instantiate nuSOAP Client
         $soap = new SoapClient(ENDPOINT);
         // Set charset encoding for outgoing messages
         //	$soap ->soap_defencoding = 'UTF-8';
         $soap->LogIn(array('username' => $GLOBALS['TL_CONFIG']['livedocx_username'], 'password' => $GLOBALS['TL_CONFIG']['livedocx_password']));
         // Upload template
         $data = file_get_contents('templates/proposal-template.docx', FILE_USE_INCLUDE_PATH);
         // Assign field values data to template
         $soap->SetLocalTemplate(array('template' => base64_encode($data), 'format' => 'docx'));
         $event = $this->Database->prepare("SELECT * FROM tl_pic_proposal WHERE id=?")->limit(1)->execute($thisID);
         if (!$event->numRows) {
             $this->log('Event not found', 'export_proposal_to_pdf()', TL_ERROR);
             header('Location: ?do=Proposals');
             return;
         }
         $name = $this->Database->prepare("SELECT * FROM tl_pic_customer_company WHERE id=?")->limit(1)->execute($event->customer_company_id);
         $format = 'd/m/Y';
         $proposal_date = $event->proposal_date;
         $proposal_startdate = $event->proposal_startdate;
         $proposal_enddate = $event->proposal_enddate;
         $this->proposal_date = gmdate($format, $proposal_date);
         $event->proposal_date = gmdate($format, $proposal_date);
         $event->proposal_startdate = gmdate($format, $proposal_startdate);
         $event->proposal_enddate = gmdate($format, $proposal_enddate);
         $objProposal = $this->Database->prepare("SELECT * FROM tl_pic_proposal WHERE id=?")->limit(1)->execute($thisID);
         $services = unserialize($objProposal->services);
         $fieldValues = array('company_name' => $GLOBALS['TL_CONFIG']['company_name'], 'address1' => $GLOBALS['TL_CONFIG']['company_address1'], 'address2' => $GLOBALS['TL_CONFIG']['company_address2'], 'city' => $GLOBALS['TL_CONFIG']['company_city'], 'postcode' => $GLOBALS['TL_CONFIG']['company_postcode'], 'phone' => $GLOBALS['TL_CONFIG']['company_phone'], 'firstname' => $GLOBALS['TL_CONFIG']['contact_firstname'], 'lastname' => $GLOBALS['TL_CONFIG']['contact_lastname'], 'phone' => $GLOBALS['TL_CONFIG']['contact_phone'], 'email' => $GLOBALS['TL_CONFIG']['contact_email'], 'website' => $GLOBALS['TL_CONFIG']['company_website'], 'curr' => $GLOBALS['TL_CONFIG']['company_defaultCurrency'], 'proposal_label' => $event->proposal_label, 'customer_company_name' => $name->customer_company_name, 'proposal_version' => $event->proposal_version, 'proposal_date' => $event->proposal_date, 'proposal_startdate' => $event->proposal_startdate, 'proposal_enddate' => $event->proposal_enddate, 'introduction_headline' => $event->introduction_headline, 'introduction' => $event->introduction, 'endtext_headline' => $event->endtext_headline, 'endtext' => $event->endtext);
         $array_size = sizeof($services);
         $sum_days = 0;
         $sum = 0;
         $blockFieldValues = array();
         $i = 0;
         while ($i < $array_size) {
             $current_service = $this->Database->prepare("SELECT * FROM tl_pic_services WHERE id=?")->limit(1)->execute($services[$i]['service']);
             $sum_days = $sum_days + $services[$i]['days_spent'];
             $sum = $sum + $services[$i]['price'];
             if ($i >= 0 && $i <= 5) {
                 $page = 5;
             }
             if ($i >= 6 && $i <= 10) {
                 $page = 6;
             }
             if ($i >= 11 && $i <= 15) {
                 $page = 7;
             }
             $id = (string) $i + 1;
             $blockFieldValues[$i]['service_name_' . (string) $i] = $current_service->service_name;
             $blockFieldValues[$i]['service_description_' . (string) $i] = $current_service->service_description;
             $blockFieldValues[$i]['days_spent_' . (string) $i] = $services[$i]['days_spent'];
             $blockFieldValues[$i]['price_' . (string) $i] = $GLOBALS['TL_CONFIG']['company_defaultCurrency'] . $services[$i]['price'];
             $blockFieldValues[$i]['id_' . (string) $i] = "2." . $id . " ";
             $blockFieldValues[$i]['p_' . (string) $i] = $page;
             $i++;
         }
         $array_size = sizeof($services);
         $sum_days = 0;
         $sum = 0;
         $blockFieldValues2 = array();
         $i = 0;
         while ($i < $array_size) {
             $current_service = $this->Database->prepare("SELECT * FROM tl_pic_services WHERE id=?")->limit(1)->execute($services[$i]['service']);
             $sum_days = $sum_days + $services[$i]['days_spent'];
             $sum = $sum + $services[$i]['price'];
             if ($i >= 0 && $i <= 5) {
                 $page = 5;
             }
             if ($i >= 6 && $i <= 10) {
                 $page = 6;
             }
             if ($i >= 11 && $i <= 15) {
                 $page = 7;
             }
             $id = (string) $i + 1;
             $blockFieldValues2[$i]['service_name_' . (string) $i] = $current_service->service_name;
             $blockFieldValues2[$i]['service_description_' . (string) $i] = $current_service->service_description;
             $blockFieldValues2[$i]['days_spent_' . (string) $i] = $services[$i]['days_spent'];
             $blockFieldValues2[$i]['price_' . (string) $i] = $GLOBALS['TL_CONFIG']['company_defaultCurrency'] . $services[$i]['price'];
             $blockFieldValues2[$i]['id_' . (string) $i] = "2." . $id . " ";
             $blockFieldValues2[$i]['p_' . (string) $i] = $page;
             $i++;
         }
         $array_size = sizeof($services);
         $sum_days = 0;
         $sum = 0;
         $blockFieldValues3 = array();
         $i = 0;
         while ($i < $array_size) {
             $current_service = $this->Database->prepare("SELECT * FROM tl_pic_services WHERE id=?")->limit(1)->execute($services[$i]['service']);
             $sum_days = $sum_days + $services[$i]['days_spent'];
             $sum = $sum + $services[$i]['price'];
             if ($i >= 0 && $i <= 5) {
                 $page = 5;
             }
             if ($i >= 6 && $i <= 10) {
                 $page = 6;
             }
             if ($i >= 11 && $i <= 15) {
                 $page = 7;
             }
             $id = (string) $i + 1;
             $blockFieldValues3[$i]['service_name_' . (string) $i] = $current_service->service_name;
             $blockFieldValues3[$i]['service_description_' . (string) $i] = $current_service->service_description;
             $blockFieldValues3[$i]['days_spent_' . (string) $i] = $services[$i]['days_spent'];
             $blockFieldValues3[$i]['price_' . (string) $i] = $GLOBALS['TL_CONFIG']['company_defaultCurrency'] . $services[$i]['price'];
             $blockFieldValues3[$i]['id_' . (string) $i] = "2." . $id . " ";
             $blockFieldValues3[$i]['p_' . (string) $i] = $page;
             $i++;
         }
         $avp = 6;
         $last = 7;
         if ($array_size > 6) {
             $avp = 7;
             $last = 8;
         }
         if ($array_size > 11) {
             $avp = 8;
             $last = 9;
         }
         $custom_fields = unserialize($objProposal->custom_fields);
         $custom_fields_size = sizeof($custom_fields);
         for ($i = 0; $i < $custom_fields_size; $i++) {
             $fieldValues = $fieldValues + array($custom_fields[$i]['field_name'] => $custom_fields[$i]['value']);
         }
         $fieldValues = $fieldValues + array('sum' => $sum, 'sum_days' => $sum_days, 'avp' => $avp, 'last' => $last);
         $result = $soap->SetFieldValues(array('fieldValues' => $this->nuSoap_assocArrayToArrayOfArrayOfString($fieldValues)));
         $soap->SetBlockFieldValues(array('blockName' => 'content', 'blockFieldValues' => $this->nuSoap_multiAssocArrayToArrayOfArrayOfString($blockFieldValues)));
         $soap->SetBlockFieldValues(array('blockName' => 'content_menu', 'blockFieldValues' => $this->nuSoap_multiAssocArrayToArrayOfArrayOfString($blockFieldValues2)));
         $soap->SetBlockFieldValues(array('blockName' => 'content_array', 'blockFieldValues' => $this->nuSoap_multiAssocArrayToArrayOfArrayOfString($blockFieldValues3)));
         // Build the document
         $soap->CreateDocument();
         // Get document as PDF
         $result = $soap->RetrieveDocument(array('format' => 'pdf'));
         $data = $result->RetrieveDocumentResult;
         $soap->LogOut();
         unset($soap);
         header('Content-Type: application/x-download');
         header('Content-Disposition: attachment; filename="' . $event->proposal_label . '.pdf"');
         header('Cache-Control: private, max-age=0, must-revalidate');
         header('Pragma: public');
         echo base64_decode($data);
         return;
     } else {
         echo 'LivedocX only is available at the moment !';
     }
 }
function resman_livedocx_create_documents()
{
    global $wpdb;
    $fieldValues = array();
    $username = get_option('resman_livedocx_username');
    $password = get_option('resman_livedocx_password');
    $dateformat = get_option('resman_date_format');
    if ($dateformat == '') {
        $dateformat = 'Y-m-d';
    }
    $ldx = new SoapClient(LIVEDOCX_URL, array('user_agent' => 'Wordpress-Resume-Manager/' . RESMAN_VERSION . ' http://pento.net/projects/wordpress-resume-mananger-plugin/'));
    $ldx->LogIn(array('username' => $username, 'password' => $password));
    $template = file_get_contents(WP_PLUGIN_DIR . '/' . RESMAN_FOLDER . '/template/classic.docx');
    $ldx->SetLocalTemplate(array('template' => base64_encode($template), 'format' => 'docx'));
    // PERSONAL
    $sql = 'SELECT d.value AS value, f.name AS name FROM ' . $wpdb->prefix . 'resman_data AS d LEFT JOIN ' . $wpdb->prefix . 'resman_fields AS f on f.id = d.fieldid WHERE f.section="personal";';
    $data = $wpdb->get_results($sql, ARRAY_A);
    $nationality = array();
    $fieldValues['personal-count'] = 0;
    foreach ($data as $item) {
        switch ($item['name']) {
            case 'nationality':
                $nationality[] = $item['value'];
                break;
            default:
                $fieldValues['personal-' . $item['name']] = $item['value'];
        }
        $fieldValues['personal-count']++;
    }
    if (count($nationality)) {
        $fieldValues['personal-nationality'] = implode(', ', $nationality);
    }
    // GENERAL
    $sql = 'SELECT d.value AS value, f.name AS name FROM ' . $wpdb->prefix . 'resman_data AS d LEFT JOIN ' . $wpdb->prefix . 'resman_fields AS f on f.id = d.fieldid WHERE f.section="general";';
    $data = $wpdb->get_results($sql, ARRAY_A);
    $fieldValues['general-count'] = 0;
    foreach ($data as $item) {
        $fieldValues['general-' . $item['name']] = $item['value'];
        $fieldValues['general-count']++;
    }
    // EXPERIENCE
    $sql = 'SELECT d.value AS value, f.name AS name, d.repeatgroup_count AS repeatgroup FROM ' . $wpdb->prefix . 'resman_data AS d LEFT JOIN ' . $wpdb->prefix . 'resman_fields AS f on f.id = d.fieldid WHERE f.section="experience" ORDER BY d.repeatgroup_count;';
    $data = $wpdb->get_results($sql, ARRAY_A);
    $experience = array();
    $fieldValues['experience-count'] = 0;
    foreach ($data as $item) {
        switch ($item['name']) {
            case 'start':
            case 'end':
                $experience[$item['repeatgroup'] - 1]['experience-' . $item['name']] = date($dateformat, strtotime($item['value']));
                break;
            case 'abstract':
                $experience[$item['repeatgroup'] - 1]['experience-' . $item['name']] = resman_livedocx_format_abstract($item['value']);
                break;
            default:
                $experience[$item['repeatgroup'] - 1]['experience-' . $item['name']] = $item['value'];
        }
    }
    $fields = array('start', 'end', 'title', 'abstract', 'name', 'address', 'sector');
    $expBlock = array();
    foreach ($experience as $key => $exp) {
        if (!isset($experience[$key]['experience-start'])) {
            $experience[$key]['experience-start'] = __('Present', 'resman');
        }
        if (!isset($experience[$key]['experience-end'])) {
            $experience[$key]['experience-end'] = __('Present', 'resman');
        }
        foreach ($fields as $field) {
            if (!isset($experience[$key]['experience-' . $field])) {
                $experience[$key]['experience-' . $field] = '';
            }
            $expBlock[$fieldValues['experience-count']]['experience-' . $field] = $experience[$key]['experience-' . $field];
        }
        $fieldValues['experience-count']++;
    }
    $ldx->SetBlockFieldValues(array('blockName' => 'experience', 'blockFieldValues' => resman_multiAssocArrayToArrayOfArrayOfString($expBlock)));
    // EDUCATION
    $sql = 'SELECT d.value AS value, f.name AS name, d.repeatgroup_count AS repeatgroup FROM ' . $wpdb->prefix . 'resman_data AS d LEFT JOIN ' . $wpdb->prefix . 'resman_fields AS f on f.id = d.fieldid WHERE f.section="education" ORDER BY d.repeatgroup_count;';
    $data = $wpdb->get_results($sql, ARRAY_A);
    $education = array();
    $fieldValues['education-count'] = 0;
    foreach ($data as $item) {
        switch ($item['name']) {
            case 'start':
            case 'end':
                $education[$item['repeatgroup'] - 1]['education-' . $item['name']] = date($dateformat, strtotime($item['value']));
                break;
            case 'abstract':
                $education[$item['repeatgroup'] - 1]['education-' . $item['name']] = resman_livedocx_format_abstract($item['value']);
                break;
            default:
                $education[$item['repeatgroup'] - 1]['education-' . $item['name']] = $item['value'];
        }
    }
    $fields = array('start', 'end', 'title', 'abstract', 'name', 'address', 'field');
    $eduBlock = array();
    foreach ($education as $key => $exp) {
        if (!isset($education[$key]['education-start'])) {
            $education[$key]['education-start'] = __('Present', 'resman');
        }
        if (!isset($education[$key]['education-end'])) {
            $education[$key]['education-end'] = __('Present', 'resman');
        }
        foreach ($fields as $field) {
            if (!isset($education[$key]['education-' . $field])) {
                $education[$key]['education-' . $field] = '';
            }
            $eduBlock[$fieldValues['education-count']]['education-' . $field] = $education[$key]['education-' . $field];
        }
        $fieldValues['education-count']++;
    }
    $ldx->SetBlockFieldValues(array('blockName' => 'education', 'blockFieldValues' => resman_multiAssocArrayToArrayOfArrayOfString($eduBlock)));
    // SKILLS
    $sql = 'SELECT d.value AS value, f.name AS name FROM ' . $wpdb->prefix . 'resman_data AS d LEFT JOIN ' . $wpdb->prefix . 'resman_fields AS f on f.id = d.fieldid WHERE f.section="skills";';
    $data = $wpdb->get_results($sql, ARRAY_A);
    $fieldValues['skills-count'] = 0;
    foreach ($data as $item) {
        $fieldValues['skills-' . $item['name']] = resman_livedocx_format_abstract($item['value']);
        $fieldValues['skills-count']++;
    }
    $ldx->SetFieldValues(array('fieldValues' => resman_assocArrayToArrayOfArrayOfString($fieldValues)));
    $ldx->CreateDocument();
    resman_livedocx_write_document($ldx, 'html');
    $doctypes = array('txt', 'pdf', 'doc', 'docx', 'rtf');
    foreach ($doctypes as $doc) {
        if (get_option('resman_output_' . $doc)) {
            resman_livedocx_write_document($ldx, $doc);
        }
    }
    $ldx->LogOut();
    unset($ldx);
}