Example #1
0
/**
 * 	Return linked objects
 *
 * 	@param	object		$object			Object
 * 	@param	Translate	$outputlangs	Object lang for output
 * 	@return	array   Linked objects
 */
function pdf_getLinkedObjects($object, $outputlangs)
{
    global $hookmanager;
    $linkedobjects = array();
    $object->fetchObjectLinked();
    foreach ($object->linkedObjects as $objecttype => $objects) {
        if ($objecttype == 'propal') {
            $outputlangs->load('propal');
            foreach ($objects as $elementobject) {
                $linkedobjects[$objecttype]['ref_title'] = $outputlangs->transnoentities("RefProposal");
                $linkedobjects[$objecttype]['ref_value'] = $outputlangs->transnoentities($elementobject->ref);
                $linkedobjects[$objecttype]['date_title'] = $outputlangs->transnoentities("DatePropal");
                $linkedobjects[$objecttype]['date_value'] = dol_print_date($elementobject->date, 'day', '', $outputlangs);
            }
        } else {
            if ($objecttype == 'commande') {
                $outputlangs->load('orders');
                foreach ($objects as $elementobject) {
                    $linkedobjects[$objecttype]['ref_title'] = $outputlangs->transnoentities("RefOrder");
                    $linkedobjects[$objecttype]['ref_value'] = $outputlangs->transnoentities($elementobject->ref) . ($elementobject->ref_client ? ' (' . $elementobject->ref_client . ')' : '');
                    $linkedobjects[$objecttype]['date_title'] = $outputlangs->transnoentities("OrderDate");
                    $linkedobjects[$objecttype]['date_value'] = dol_print_date($elementobject->date, 'day', '', $outputlangs);
                }
            } else {
                if ($objecttype == 'contrat') {
                    $outputlangs->load('contracts');
                    foreach ($objects as $elementobject) {
                        $linkedobjects[$objecttype]['ref_title'] = $outputlangs->transnoentities("RefContract");
                        $linkedobjects[$objecttype]['ref_value'] = $outputlangs->transnoentities($elementobject->ref);
                        $linkedobjects[$objecttype]['date_title'] = $outputlangs->transnoentities("DateContract");
                        $linkedobjects[$objecttype]['date_value'] = dol_print_date($elementobject->date_contrat, 'day', '', $outputlangs);
                    }
                } else {
                    if ($objecttype == 'shipping') {
                        $outputlangs->load('orders');
                        $outputlangs->load('sendings');
                        foreach ($objects as $elementobject) {
                            $elementobject->fetchObjectLinked();
                            $order = $elementobject->linkedObjects['commande'][0];
                            if (!empty($object->linkedObjects['commande'])) {
                                $linkedobjects[$objecttype]['ref_title'] = $outputlangs->transnoentities("RefSending");
                                $linkedobjects[$objecttype]['ref_value'] .= $outputlangs->transnoentities($elementobject->ref);
                                $linkedobjects[$objecttype]['date_title'] = $outputlangs->transnoentities("DateSending");
                                $linkedobjects[$objecttype]['date_value'] .= dol_print_date($elementobject->date_delivery, 'day', '', $outputlangs);
                            } else {
                                $linkedobjects[$objecttype]['ref_title'] = $outputlangs->transnoentities("RefOrder") . ' / ' . $outputlangs->transnoentities("RefSending");
                                $linkedobjects[$objecttype]['ref_value'] = $outputlangs->convToOutputCharset($order->ref) . ($order->ref_client ? ' (' . $order->ref_client . ')' : '');
                                $linkedobjects[$objecttype]['ref_value'] .= ' / ' . $outputlangs->transnoentities($elementobject->ref);
                                $linkedobjects[$objecttype]['date_title'] = $outputlangs->transnoentities("OrderDate") . ' / ' . $outputlangs->transnoentities("DateSending");
                                $linkedobjects[$objecttype]['date_value'] = dol_print_date($order->date, 'day', '', $outputlangs);
                                $linkedobjects[$objecttype]['date_value'] .= ' / ' . dol_print_date($elementobject->date_delivery, 'day', '', $outputlangs);
                            }
                        }
                    }
                }
            }
        }
    }
    // For add external linked objects
    if (is_object($hookmanager)) {
        $parameters = array('linkedobjects' => $linkedobjects, 'outputlangs' => $outputlangs);
        $action = '';
        $hookmanager->executeHooks('pdf_getLinkedObjects', $parameters, $object, $action);
        // Note that $action and $object may have been modified by some hooks
        if (!empty($hookmanager->resArray)) {
            $linkedobjects = $hookmanager->resArray;
        }
    }
    return $linkedobjects;
}
Example #2
0
/**
 * 	Return linked objects
 *
 * 	@param	object		$object			Object
 * 	@param	Translate	$outputlangs	Object lang for output
 *	@param	HookManager	$hookmanager	Hook manager instance
 * 	@return	void
 */
function pdf_getLinkedObjects($object, $outputlangs, $hookmanager = false)
{
    $linkedobjects = array();
    $object->fetchObjectLinked();
    foreach ($object->linkedObjects as $objecttype => $objects) {
        if ($objecttype == 'propal') {
            $outputlangs->load('propal');
            $num = count($objects);
            for ($i = 0; $i < $num; $i++) {
                $linkedobjects[$objecttype]['ref_title'] = $outputlangs->transnoentities("RefProposal");
                $linkedobjects[$objecttype]['ref_value'] = $outputlangs->transnoentities($objects[$i]->ref);
                $linkedobjects[$objecttype]['date_title'] = $outputlangs->transnoentities("DatePropal");
                $linkedobjects[$objecttype]['date_value'] = dol_print_date($objects[$i]->date, 'day', '', $outputlangs);
            }
        } else {
            if ($objecttype == 'commande') {
                $outputlangs->load('orders');
                $num = count($objects);
                for ($i = 0; $i < $num; $i++) {
                    $linkedobjects[$objecttype]['ref_title'] = $outputlangs->transnoentities("RefOrder");
                    $linkedobjects[$objecttype]['ref_value'] = $outputlangs->transnoentities($objects[$i]->ref) . ($objects[$i]->ref_client ? ' (' . $objects[$i]->ref_client . ')' : '');
                    $linkedobjects[$objecttype]['date_title'] = $outputlangs->transnoentities("OrderDate");
                    $linkedobjects[$objecttype]['date_value'] = dol_print_date($objects[$i]->date, 'day', '', $outputlangs);
                }
            } else {
                if ($objecttype == 'contrat') {
                    $outputlangs->load('contracts');
                    $num = count($objects);
                    for ($i = 0; $i < $num; $i++) {
                        $linkedobjects[$objecttype]['ref_title'] = $outputlangs->transnoentities("RefContract");
                        $linkedobjects[$objecttype]['ref_value'] = $outputlangs->transnoentities($objects[$i]->ref);
                        $linkedobjects[$objecttype]['date_title'] = $outputlangs->transnoentities("DateContract");
                        $linkedobjects[$objecttype]['date_value'] = dol_print_date($objects[$i]->date_contrat, 'day', '', $outputlangs);
                    }
                }
            }
        }
    }
    // For add external linked objects
    if (is_object($hookmanager)) {
        $parameters = array('linkedobjects' => $linkedobjects, 'outputlangs' => $outputlangs);
        $action = '';
        $hookmanager->executeHooks('pdf_getLinkedObjects', $parameters, $object, $action);
        // Note that $action and $object may have been modified by some hooks
        if (!empty($hookmanager->resArray)) {
            $linkedobjects = $hookmanager->resArray;
        }
    }
    return $linkedobjects;
}